08-09-2005 09:26 AM
08-09-2005 09:37 AM
08-09-2005 09:46 AM
hi there
in LabVIEW 7.1 you could replace each while lopp with a "Timed Loop". You can give each timed loop a name and then stop each loop with the "Abort timed Loop.vi".
But: the timing behaviour of your app will probably change because a Timed Loop will take at least 1 ms for one turn.
Another solution would be to pack your state machine in a vi and load that vi dynamically. then you could call the "Abort VI" method to kill the vi.
08-09-2005 10:15 AM - edited 08-09-2005 10:15 AM
Message Edited by altenbach on 08-09-2005 08:22 AM
08-09-2005 03:36 PM
11-29-2011 09:00 AM
@Altenbach
Sorry for referring to your reply 6 years ago lol. Power of database.
If I understand what you have proposed here, Having code placed in timeout case of an event structure inside a while loop and setting timeout to say 100 ms is equivalent to having a while loop with 100ms iteration time with the same code? I am trying to understand how that works?
Effectively, is the structure polling every 100ms for an event to occur vis'-a-vis' STOP, if not, the code executes?
THanks!
11-29-2011 09:23 AM
Basically what is happening is that each 'while loop' keeps each 'event structure' running until a True condition is passed to the While Loop condition element. After the 'Timeout period' (200ms or 500ms), the timeout case will execute. During the wait period of 200ms or 500ms, any other event can occur and the Event Structure will jump to that event. In the example provided, the only other event is the pressing of the Stop button. When the Stop button is pressed, the value is passed out to the stop condition of the While Loop and the Event structure no longer runs.
So the event structure is not polling every 200ms or 500ms for a Stop button event, it is ever ready for a Stop button event. The 200ms or 500ms timeout causes the 'Timeout' event to occur so every 200ms or 500ms the waveforms update (in the provided example ).
To better understand, try running the exmple with the Highlight on with larger timeout period.and press the Stop button at any time.
11-29-2011 10:29 AM
@VeeJay wrote:
Effectively, is the structure polling every 100ms for an event to occur vis'-a-vis' STOP, if not, the code executes?
This old example is somewhat unusual because both event structures have a timeout event to do something at regular intervals. This is often not needed. You can have an event structure with all real events and it will just be sitting there unless one of the events is triggered.
Typically only zero or one of all event structures has a timeout event. An event loop without a timeout will do nothing at all unless an associated event is triggered. There is no polling.
For example you could have a small event loop that only reacts when a cursor is moved in order to synchronize the cursor of another graph. An example can be found here. There could be a small event loop that monitors key presses. All these indepdendent event loops need to stop when the stop button in your main interactive loop is pressed. All they need is a stop event, they don't even need the terminal (or local variable) of the stop button.
11-29-2011 11:02 AM
From what I understand the loops are being terminated when some condition you programmed becomes "True", but you want to have the ablility to stop before. Just wire your condition and you stop to an "OR" then to the loop termination. Also set the mechanical action on the stop button to 'Latch'. Remeber to click it again once the program stops to return the button to its standard "F" state. If the Stop button determined the value for all the other stop variables it should work.
11-29-2011 11:08 AM - edited 11-29-2011 11:12 AM
@Adrian S. wrote:
From what I understand the loops are being terminated when some condition you programmed becomes "True", but you want to have the ablility to stop before. Just wire your condition and you stop to an "OR" then to the loop termination.
We are talking about loops with an event structure here. Each event can output any desired boolean to the conditional terminal. The tunnel is set to use default if unwired, so all events that don't specifically stop the loop with keep it running.
Of course in each event case you can use any boolean operations you want to come to the final stop decision but that's not the topic of this discussion. Here we are talking about stopping multiple parallel loops. It is probably not a good idea to selectively stop only some loops and there should be only one condition to stop all at once.