LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Structure: Transfer of Control

All

I have a test process and I accomplish it this way: User Login --> Test System door locked --> Start measurement

I have two while loops with event structures in each. The first while loop (A) is basically a login procedure. If the login is successful I use "value signalling" and activate the event in the second while loop (B).

While in the second while loop (B), the event starts the measurement process if the test system door is found to be locked. If the door is not locked, it keeps polling until the door is locked to start the measurement process.

I have an Abort button that I would like to use to cancel all events and go back to starting point. However, since the event in the second while loop keeps polling till the door is locked, I am not able to use the abort button. Is there a way I can mimic the APP_STOP functionalities for my abort button but not exit the software ?

Thanks

Kudos are the best way to say thanks 🙂
0 Kudos
Message 1 of 9
(3,602 Views)
I would add a third, dedicated loop to the emergency stop, or lock.

This way, when the user tries to start the second loop (by making the appropriate actions such that the code will take them there), the abort will always be available, since it will not be tied into an event.

Now, whenever an abort condition is reached, the third loop will catch it, and you can use queues or some other form of loop communication to ensure all code stops and reverts to the default state.

I would however, recommend against an event structure in your B loop, unless it is absolutely necessary.  Wouldn't it be easier to use a state machine?
0 Kudos
Message 2 of 9
(3,601 Views)
I will be using a state machine eventually. Since I am limited time-wise, I want a quick method to do the abort.

Let me try your suggestion and see how it works. Thanks

Kudos are the best way to say thanks 🙂
0 Kudos
Message 3 of 9
(3,592 Views)
1) Usually it is best to have just one event structure to handle all user events.

2) This sounds like a good application for a queued state machine. See the examples and templates that come with LV.

If the GUI loop handles the login, the Start button, and the Stop button by sending commands via queues to the other loop(s), then you avoid the lockout situation. The measurement loop waits for a command, checks the door status, and responds appropriately. If the door is unlocked, it could send a status message back to the GUI loop via another queue. If you save the "logged in" status in a shift regsiter, it could be reset when the Stop button is pressed, requiring a new log-in to start anothre message.

Lynn
Message 4 of 9
(3,592 Views)
Adding a third button would not work. The reason is when the door is open, I keep polling to see when the door would be locked. So the control is in the while loop. I am not able to access my abort button.

Kudos are the best way to say thanks 🙂
0 Kudos
Message 5 of 9
(3,587 Views)
Maybe I was not clear.

GUI loop: Contains event structure with cases for Log-in control, Start, and Stop buttons. Three cases, plus timeout if needed.

Process loop: Does not contain any event structure. Receives commands generated by button presses in GUI loop via queues. If, while polling the door status, a Stopp command arrives on the queue, the polling is stopped and the Stop function is executed. The maximum delay is that of one iteration of the polling.

What version of LV are you using? I will try to put together a simple example.

Lynn
Message 6 of 9
(3,582 Views)
I see what you saying. Makes sense. It would be nice to have an example though. I am currently using 8.2

Kudos are the best way to say thanks 🙂
0 Kudos
Message 7 of 9
(3,578 Views)
Here is a simple example (LV 8.0). I hope this clarifies my earlier suggestions.

Lynn
Message 8 of 9
(3,571 Views)
That totally helped. Thanks very much !!!!

Kudos are the best way to say thanks 🙂
0 Kudos
Message 9 of 9
(3,466 Views)