12-21-2008 12:24 PM
I would like to use an event handler in the VI containing an XControl to respond to a change to that XControl's state. Is there an easy way to do this without continually polling the XControl's state using a property read and a Create/Generate Event approach?
Thank you!
Brian
12-21-2008 12:48 PM
I would create a user event in the owning VI, sent it to the XControl with a custom property.
If you have an interesting state change you can sent the data via that user ref to the owning VI.
But my question is why?
State changes are ment for the XControl, and should be kept inside the XControl, the beauty of XControls is that everything is contained inside the XControl and is shielded from the owning VI.
Ton
12-21-2008 01:12 PM
Thanks Ton!
The answer to your question may be wrong-headed as this is my first attempt to use XControls. I am trying to use a customized numeric slider (with multiple sliders) as a sort of thermostat. One slider is the "TURN ON" point and the other is the current value. One of the states that I have created in the XControl is a Boolean that is set to true when the current value slider exceeds the TURN ON slider. In my main application, I would like to respond to that event. The actual response to that event will necessarily be different for each instance of the XControl and thus I do not want to encapsulate the response into the behaviour of the XControl.
Does that make sense?
Note, I have set three other states which correspond to three other sliders - "TOO LOW", "TOO HIGH", and "TURN OFF" which I would also like to handle in similar ways.
Thank you again!
Brian
12-21-2008 01:46 PM
Yes, that makes perfectly sense!
I think your question was stated wrong.
But the idea is still the same.
Add to you XControl's state a User event Ref with a string datatype.
Create the user event in the owning application and register a event structure to this user event.
With a custom property (set user event ref) you set the User event Ref in the Xcontrol's state.
If the alarm level is passed you generate a user event inside XControl and the owning VI will be triggered.
I you don't succeed please post an example as complete as can be.
Ton (I have done this several times)