Trendviewer History Control via Script

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
bennanio
Posts: 14
Joined: Thu Mar 01, 2012 11:48 am

Trendviewer History Control via Script

Post by bennanio »

Hi, wondering if anyone else has encountered issues with this because I can't explain it. For whatever reason, in order to turn on the history for a trendviewer via script I'm having to turn it "Off". Here's the code I've got on a start/stop button:

Code: Select all

void startButton_Click(System.Object sender, System.EventArgs e)
		{
			//TrendViewer1.ShowHistory("Toggle"); //this seriously doesn't work here but does on an separate button (other code snippet)
			if(start == true){
				chart.Start();
				Globals.trendLogger.Start();
				Globals.trendLogger.Log(); 
				TrendViewer1.ShowHistory("On"); //this is backwards but it works correctly. I can not explain it
				start = false;
				
			}else {
			TrendViewer1.ShowHistory("Off");
			Globals.trendLogger.Stop();
			chart.Stop();

			start = true;
		}
		
			}
In my testing to see if there was a difference between my hand coded script and that generated by the tool, this is the autogenerated code that works:

Code: Select all

        private void m_Button6_Action_Click(object sender, System.EventArgs e) {
            Neo.ApplicationFramework.Generated.Globals.AuditTrailService.LogAction("m_Button6", "Click", "Trend Viewer History", "TrendViewer1", "");
            TrendViewer1.ShowHistory("Toggle");
        }
Thanks

mark.monroe
Posts: 824
Joined: Tue Mar 13, 2012 9:53 am

Re: Trendviewer History Control via Script

Post by mark.monroe »

I tested the below code and it switched the trend viewer into history mode as expected. It does not display a dialog box, it only toggles the trend viewer. You can tell because when the trend viewer is in history mode it says "History" below the X axis.

Code: Select all

		void Button1_Click(System.Object sender, System.EventArgs e)
		{
			this.TrendViewer1.ShowHistory("Toggle"); //this seriously doesn't work here but does on an separate button (other code snippet)
		}
Are you sure you do not have an action on the same button that is toggling the history mode? Maybe some other code in your project is toggling the trend viewer history as well.
Best Regards,
Mark Monroe

Beijer Electronics, Inc. | Applications Engineer

bennanio
Posts: 14
Joined: Thu Mar 01, 2012 11:48 am

Re: Trendviewer History Control via Script

Post by bennanio »

I think I might know what happened. I thought the button I was working with only had actions setup in the script environment... turns out I had a "Toggle" setup through the ui so they were likely fighting each other.

Post Reply