09-24-2008 08:10 PM
I'm working on moving an event structure into a sub VI. This means I have to register dynamic events.
The event structure is handling some button clicks. The state of the button (mechanical action = latch when released) resets itself automatically as long as the variable is placed within the value change case. Leaving the button in this case is not possible when the event structure is put in a sub VI and the variable is located in the parent VI. How do I make sure the button unlatches after clicking on it? I have attached an example where all the code is in one VI (the local variable must be moved outside the event structure in order for it to be moved into a sub VI). Any ideas?
If you open the VI and run it, you can click Start which will cause the counter to start incrementing. The button only unlatches as long as the variable is located in the value change case.
(Btw, how do you put images inline in a post?)
09-24-2008 08:21 PM - edited 09-24-2008 08:25 PM
The first thing that comes to mind is to just switch the control to "switch when released" and have the event structure set it to false via a control reference. You could also palce its indicator or a local in a loop that runs regularly in the main vi (how long it takes to unlatch would depend on when its value is read).
To attach images you edit the post, copy the url of the image's attachment. Then use that url with the insert image button.
09-24-2008 09:11 PM
09-24-2008 09:55 PM
Race conditions are the primary reason not to do that. But since your treating your variable as a latch, I doubt your using the value you read from it anywhere, and in that case it can't create a race condition. There's also the possibility that the control's reference could become invalid. But since this is a sub VI of the control's VI that can't happen (even if it could you can check the error out of the value property node to see when it happens and deal with it).
I'm not sure about the flickering, Since I can't seem to duplicate it with a simple test case on my machine. It might related to whatever else you're doing in the event apart from reseting the value to false.