07-08-2010 12:05 PM
So I am running about 10 different machines, about half at a givie time. Everything seems to be working great but one of the processes i would like to be able stop. I am using an event sequence to trigger different processes, i would like to be able to stop one of my events if lets say a certain condition is not met. But once the event starts and runs its stacked sequence I can not stop it. Is there anyway around this?
07-08-2010 12:10 PM
Generally speaking you have two options.
Code all of the frames in the Timed Sequence to check for a flag to control execution
OR
Re-code it as a state machine inside a Timed loop and struture the state machine to check for the work/no-work flag.
Ben
07-08-2010 12:16 PM
Now I am not using a Timed Loop or Time Sequence since the process i am running can take either and hour or four, so will this work an a stacked sequence
07-08-2010 12:19 PM
@jastel wrote:
But once the event starts and runs its stacked sequence I can not stop it.
This is exactly why stacked sequences or even flat sequences is frowned upon. You cannot stop it in the middle in case of errors or some other event. Ben has given the best advice, convert to a state machine. You can put error or event checking in each state to dictate what the next state will be. Sort of like this:
If error
NextState=exit
else
NextState=NormalNextState
07-08-2010 12:22 PM
@jastel wrote:
Now I am not using a Timed Loop or Time Sequence since the process i am running can take either and hour or four, so will this work an a stacked sequence
Yikes!
The same suggestion for the timed seq will apply to the stacked seq but the only difference between a stacked an un-stacked sequnce (aside from experienced LV developers knowing better than to use a stacked squence, Yeeesh!) is the flat version is easier to read.
Ben
07-08-2010 12:36 PM
This maybe a stupid question but how do you create a state machine
07-08-2010 12:36 PM
I would get away from the Stacked Sequence Structure. It gets nasty when using them.
As the name suggests, it's a sequence, which means that unless you use case statements around your code, you won't be able to control your code based on changes in events. As a matter of fact, unless done properly, you may not be able to control the code within a stacked sequence even if you do use case statements. I won't get into details.
07-08-2010 12:37 PM
@jastel wrote:
This maybe a stupid question but how do you create a state machine
Glad you asked.. That is the right question.. 😉
The easiest answer is to do a search on the topic. I think I have a tag where it is well described (I'll look for it).
07-08-2010 12:39 PM
Attached is a simple state machine example. It can be used as a start.
07-08-2010 12:41 PM
Try taking a look at the Application Design Patterns: State Machines.
Look at this thread : http://forums.ni.com/t5/LabVIEW/how-to-get-values-out-of-stacked-sequence/td-p/1160985