LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Method to handle events within events

Hi,
 
In my front panel i am having three buttons 'Run','Pause','Display'.I have to start executing test cases when the user presses the Run button.The user can press the 'Pause' button at any time in the middle of exection of test case.When the user press 'Pause' button i need to pause the execution of test cases until the user press it once again and need to enable the 'Display' button.On click of Display button i need to display the result of the test case.
 
Can u tell me how to continuously monitor the status of 'Pause' button??
 
Regards
Rajameenatchi
0 Kudos
Message 1 of 18
(3,321 Views)
You can do it with an event structure.. no need to handle events within events.
Also you can use an action engine (state machine).
Do a little search on the forum for those...
0 Kudos
Message 2 of 18
(3,308 Views)

Hi Rajameenatchi,

Are you using events in your code or not?  If all you need is a simple pause function and nothing else going on in your program when you hit pause, it would be easiest to use a state machine.  Just have your pause button as the input to a case structure.  In the case where pause is true, have a while loop with a 20ms wait and in that while loop, read the value of pause so that when it goes false, the while loop exits.  Then in the false case, you can perform the test cases.

Donovan
0 Kudos
Message 3 of 18
(3,271 Views)

I have a similar issue. I have an event that is fired when a play or pause button is pushed. I then have a case structure inside that event where the true (from play button) case is a state machine that performs testing based on selections in a list box control. The pause case is just a while loop with a wait and the stop is looking for the pause to become false. I am using properties to ensure that the play and pause aren't true at the same time.

 

I want to be able to pause the state machine and then when play is pressed I want to resume from where the state machine left off. I have a shift register in the state machine  while loop that writes to a local variable (list box control). This seems like an easy problem but I'm having difficulty. I'm wondering if it has to do with my lack of experience with event structures. I'll try to mock up a simple example to show. In the mean time does anyone see a glaring problem with my methodology?

 

kph

0 Kudos
Message 4 of 18
(2,993 Views)

If i understood correctly, you have a state machine and a while loop in an event case !

This is bad programming. An event should last, the less time possible.

Take a look at event patterns shipped with Labview.

 

0 Kudos
Message 5 of 18
(2,988 Views)

kphite wrote:

I have a similar issue. I have an event that is fired when a play or pause button is pushed. I then have a case structure inside that event where the true (from play button) case is a state machine that performs testing based on selections in a list box control. The pause case is just a while loop with a wait and the stop is looking for the pause to become false. I am using properties to ensure that the play and pause aren't true at the same time.

 

I want to be able to pause the state machine and then when play is pressed I want to resume from where the state machine left off. I have a shift register in the state machine  while loop that writes to a local variable (list box control). This seems like an easy problem but I'm having difficulty. I'm wondering if it has to do with my lack of experience with event structures. I'll try to mock up a simple example to show. In the mean time does anyone see a glaring problem with my methodology?

 

kph


 

You may be better off starting a new thread to get greater visability.

 

But off-hand it sounds like a Master/Slave architecture would meet your needs. The master would utilize an event structure to detect the user actions and then use queues to transfer the commands "Pasue Stop, etc" to the Slave loop which should monitor the queue for commands and changes states as indiciated. So loo for Master/Slave and State machine for ideas on how to structure your app.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 18
(2,983 Views)

Yeah, I've seen the event templates. They use queues to message the current state to the state machine. I probably haven't done enough research but I never saw anything that said that the event has to be short. My code is working well I just cant seem to feed back the current state even though I have an outer while loop with a shift register.

 

If it's bad programming then I guess I'm guilty. I'm not a programmer I'm an electrical engineer.

 

kph

0 Kudos
Message 7 of 18
(2,982 Views)

Hey Ben, thanks for the reply. I've read some of your responses here over the years and greatly respect your expertise.

 

I've seen the master/slave methodology but I'm wondering how that would work with a listbox control versus separate controls for states where the event strucutre would fire on those individual contols. I have a listbox with 24 distinct tests and I want to be able to select any combination of them.

 

kph

0 Kudos
Message 8 of 18
(2,980 Views)

kphite wrote:

Yeah, I've seen the event templates. They use queues to message the current state to the state machine. I probably haven't done enough research but I never saw anything that said that the event has to be short. My code is working well I just cant seem to feed back the current state even though I have an outer while loop with a shift register.

 

If it's bad programming then I guess I'm guilty. I'm not a programmer I'm an electrical engineer.

 

kph


Re: Short

When designing an app I ask myslef "How long COULD the operation take?" If the answer is more than one or two seconds ( the amount of time a user would wait before attempting to do a ctrl-alt-del) I will turn that operation into a command that is handled somewhere other than the loop with the event structure.

 

Re: EE

 Then you are already half way to becoming a LV developer before your drop your first operator. Kidding aside, I understand. LV (and softweare in general) unlike hardware design require we do all of the work with a single chip (the CPU) so scheduling and order are of importance, but you know that.

 

Just trying to help!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 18
(2,979 Views)

Maybe I should have mentioned that I have a table that shows the progress of testing. As each state (test) executes the user sees the appropriate display to tell them it's running. They also have an abort button that will fire to stop the inner and outer loop.

 

I've done quite a bit of easy labview programming but this is my first foray into the event driven world.

 

kph

0 Kudos
Message 10 of 18
(2,976 Views)