Page 1 of 1

Trendviewer History Control via Script

Posted: Wed Jul 03, 2013 9:15 am
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

Re: Trendviewer History Control via Script

Posted: Wed Jul 03, 2013 9:35 am
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.

Re: Trendviewer History Control via Script

Posted: Wed Jul 03, 2013 9:43 am
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.