05-15-2015 05:45 AM
Hi all.
i like to create a state machine using events methos .
i have 4 functions 1,2,3,4. (event based functios) (seperate sub vis)
1.i will trigger the 1 function.
then end of the first function should trigger the next function.
..
like state machine .
how to create this method in labview .. i tried value signaling its still not working . what i want.
Solved! Go to Solution.
05-15-2015 06:32 AM
Wouldn't it make sense to have the entire state machine within one event case? When you trigger the event case the state machine then executes like a normal state machine. Something like this:
05-15-2015 07:09 AM - edited 05-15-2015 07:35 AM
Hi JGar,
Wouldn't it make sense to have the entire state machine within one event case?
No, it doesn't make sense to put the statemachine into the event case!
- THINK DATAFLOW: your statemachine will block the event structure!
- Your UI becomes either unusable or you may click on buttons but those events will not get processed!
Use a queued state machine approach with two parallel running loops!
05-15-2015 07:19 AM
You can create one or more User Events that act like a "software interrupt". If you open LabVIEW Help, go to Contents, Event-driven Programming, Concepts, How-To, look at Creating User Events.
What I've done is to make the State, which I configure as an Enum, a User Event. When I want to signal a State Change, I wire the new State into Generate User Event, and the Event Structure "fires", returning the particular value that I wire to the usual Event Case Statement.
Bob Schor
05-15-2015 07:23 AM
One caveat (occasioned by GerdW's reply) is that if you have a single Event loop handling both Front Panel Events and User Events (your State Machine), you need to recognize that while processing any single Event (Front Panel or User), the system is "blocked" and cannot respond to another. If all of your States and Event processing is quick and nothing is time-critical, this single-loop architecture can be efficient (and is certainly "neat"). Otherwise, take advantage of LabVIEW's ability to handle parallel processing in parallel loops.
BS
05-15-2015 07:29 AM
@JGar wrote:
Wouldn't it make sense to have the entire state machine within one event case? When you trigger the event case the state machine then executes like a normal state machine.
DO NOT DO THAT!!!!!! Long parts of code do NOT belong inside of an event case.
The Event Structure should be in its own state and the state machine should to to that state every once in awhile to check for user events.
Alternatively, you could put just the state case structure inside of the Timeout event case. Something like this: http://www.notatamelion.com/2015/03/02/building-a-proper-labview-state-machine-design-pattern-pt-2/
05-16-2015 10:45 AM
i am expectin like this
05-16-2015 10:46 AM
But here the event alwasy calling (I confirmed with other threads , value signaling behaives same )
05-16-2015 11:13 AM
I'm not sure what you are trying to show with those images.
I don't see any state machine in your architecture.
Your combination of loops and event structures look like they would basically function just glancing at them. But it all seems rather contrived, and there it isn't clear what problem you are trying to solve by creating a VI that looks like that.
05-16-2015 11:33 AM