12-13-2007 07:07 AM
12-13-2007 09:46 AM
12-14-2007 02:58 PM
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.
02-17-2009 07:11 AM
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
02-17-2009 07:25 AM
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.
02-17-2009 07:32 AM
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
02-17-2009 07:33 AM
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
02-17-2009 07:38 AM
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
02-17-2009 07:42 AM
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
02-17-2009 07:48 AM
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