09-03-2009 10:59 AM - edited 09-03-2009 11:01 AM
Hi all,
I have an event structure, whose events are all "value change"s of buttons placed on the front panel (each of them toggles a light when clicked).
I need one of the events to be executed also in case a certain time elapses (in order to allow one of the lights to blink).
Is there a way to generate such an event?
I tought about creating a timed loop running in parallel, which generates a "fake" event at every iteration... but how can this fake event be generated? (it looks like all events that can be handled by an event structure are generated by human action, like pushing buttons, dragging mouse etc.)
Many thanks, regards
Solved! Go to Solution.
09-03-2009 11:02 AM
Using your already existing event structure, create a 'timeout' case.
If none of the other events occur before the specified time, the timeout case will run.
Just place the generated event within the timeout case.
09-03-2009 11:04 AM
Thanks for replying.
The default timeout event is already in use (for a different function), and have a different period.
09-03-2009 11:05 AM
Create a timeout event and place in a property node for button you wish to "fake"
Value (Signaling)
That will cause to event for the button to fire running it's code.
Omar
09-03-2009 11:16 AM
Isn't there a timeout event built into the event structure? The default value is "-1", meaning it never times out, but you can wire a different value to the hour glass icon in the upper right corner. Then put your blinking light indicator inside the timeout event case and change its state on each iteration. Hope this helps!
Zador
09-03-2009 11:18 AM
but how can this fake event be generated? (it looks like all events that can be handled by an event structure are generated by human action, like pushing buttons, dragging mouse etc.)
Try
Value (Signaling) Property
Short Name: Val(Sgnl)
Installed With: Base Package
Class: Control Properties
Sets the value of the control and generates a Value Change event.
This property updates the value of an object similar to the Value property. However, Value (Signaling) also causes LabVIEW to generate an event as if the user had interactively changed the value of the object. National Instruments recommends you use this property only when you rely on LabVIEW generating an event in response to the programmatic value change.
If this is a Boolean value configured with a latching mechanical action, this property always returns an error. Due to race conditions that can occur when you have a Boolean value with latching mechanical action, you cannot programmatically read Boolean values that are set with a latching mechanical action.
09-03-2009 11:34 AM
Often a better approach is to move the "task" to be performed after an "event" occurs outside the event structure, typically in a parallel loop. The event structure and anything else (such as the timeout) which wants to perform the "task" then sends a command to the task code via a queue. By separating the tasks from the conditions which call them, no complicated fake events are required.
For an example of how this can be done, look at the Produce/Consumer (Events) Design Pattern.
Lynn
09-03-2009 11:46 AM
It worked, but I had to use a parallel loop as suggested by johnsold.
Thanks to all!