graph control with edit box or button


Shan

Recommended Posts

Yes. First you have to name your graph: select the graph and right click and select "Component Name...". Lets say you call it MyGraph. Next, you need to put a trace on the graph for your initial channel. You'll need to name the trace. This is about half way down on the trace page. Now you can change the Y expression programmatically:

Component.MyGraph.MyTrace.strYExpression = "V.Motor5"

There are a variety of components: combo, radio, button, etc. that can be used to actually set this value.

Link to comment
Share on other sites

I'm not sure I understand your question. If you are using a button, you'd just go to the Action page, select Quick Sequence and type in the code like:

Component.MyGraph.MyTrace.strYExpression = "V.Motor5"

Create a different button for each possible trace, changing the code appropriately.

Link to comment
Share on other sites

  • 1 month later...

Sure, lets say your sequence is MySequence and you named your button MyButton. In the quick sequence action for the button put:

if (Sequence.MySequence.Running)
   if (System.MessageBox("Do you really want to stop?","YesNo") == "Yes")
	  endseq(MySequence)
	  Component.MyButton.BackColor = RGB(0,0,0)
   endif
else
   beginseq(MySequence)
   Component.MyButton.BackColor = RGB(0,255,0)
endif

Link to comment
Share on other sites

  • 2 weeks later...

I'm not sure I understand your question. If you are using a button, you'd just go to the Action page, select Quick Sequence and type in the code like:

Component.MyGraph.MyTrace.strYExpression = "V.Motor5"

Create a different button for each possible trace, changing the code appropriately.

How can I quit the graph with the same button. Otherwise I have to create another button with the code:

Component.MyGraph.MyTrace.strYExpression = " "

Link to comment
Share on other sites

Just use an if to see what the current expression is:

if (Component.MyGraph.MyTrace.strYExpression == "V.Motor5")
   Component.MyGraph.MyTrace.strYExpression = ""
else
   Component.MyGraph.MyTrace.strYExpression = "V.Motor5"
endif

This will toggle the graph display between V.Motor5 and nothing.

Link to comment
Share on other sites

Sure, lets say your sequence is MySequence and you named your button MyButton. In the quick sequence action for the button put:

if (Sequence.MySequence.Running)
   if (System.MessageBox("Do you really want to stop?","YesNo") == "Yes")
	  endseq(MySequence)
	  Component.MyButton.BackColor = RGB(0,0,0)
   endif
else
   beginseq(MySequence)
   Component.MyButton.BackColor = RGB(0,255,0)
endif

In this case I need a messagebox with Yes No for the ClearHistory function. After else I have problems how to end it without any actions.

if (System.MessageBox("Do you really want to stop?","YesNo") == "Yes")

Mychannel.ClearHistory()

else

...???

endif

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.