01-15-2015 12:53 AM
In the state machine, I have a Event Structure in the Idle state. I want to add a timeout in the idle state. For example, when the VI times out, it will jump to Update state.
01-15-2015 01:03 AM
Wire a constant on the top left corner of the event structure. By default it's -1 (never times out)
01-15-2015 01:54 AM
You can have the timeout event wired with the timeout duration you want to set.
But Event structure inside a state machine? You need to re-design your design pattern. You can take a look into the NI standard design patterns and check any of them helps you.
01-15-2015 05:22 AM
Particularly the Producer/Consumer (User Events) pattern. Go to "New... VI -> From Template -> Frameworks -> Design Patterns".
That's generally a better way of having user events communicating with a state machine.
01-15-2015 06:48 AM
P@Anand wrote:
[...] But Event structure inside a state machine? You need to re-design your design pattern.
But, I love the JKI State Machine.
01-15-2015 07:49 AM
P@Anand wrote:
But Event structure inside a state machine? You need to re-design your design pattern. You can take a look into the NI standard design patterns and check any of them helps you.
There is absolutely nothing wrong with having an event structure inside of your state machine. You just have to make sure you check it every so often and make sure it has a timeout when you still need to run other states. I do most of my programs with this setup.
01-15-2015 08:54 AM
P@Anand wrote:
You can have the timeout event wired with the timeout duration you want to set.
But Event structure inside a state machine? You need to re-design your design pattern. You can take a look into the NI standard design patterns and check any of them helps you.
I'd say it's a fairly common/standard design. I tried to find a template of it to say the correct name but couldn't find it right now, event driven state machine? Strangly enough they've removed the pure state machine template in 2014 ...
/Y
01-15-2015 11:48 AM
@Yamaeda wrote:
Strangly enough they've removed the pure state machine template in 2014 ...
I was sure you weren't looking in the right place until I tried. Why would they remove this? The basic state machine (and Queued Message Handler) are probably the most basic, and common templates used. Still a "Simple State Machine" template can be made which contains the while loop, case structure, and event structure. Apparently NI's definition of simple is not the same as mine.
To find this go to Project >> Create Project then pick "Simple State Machine" under the templates section.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
01-15-2015 10:20 PM
@crossrulz wrote:
P@Anand wrote:
But Event structure inside a state machine? You need to re-design your design pattern. You can take a look into the NI standard design patterns and check any of them helps you.
There is absolutely nothing wrong with having an event structure inside of your state machine. You just have to make sure you check it every so often and make sure it has a timeout when you still need to run other states. I do most of my programs with this setup.
I agree. But for a beginner without complete knowledge of the event structure may complicate things, so I would suggest following a standard design pattern.
01-15-2015 10:22 PM
@jcarmody wrote:
P@Anand wrote:
[...] But Event structure inside a state machine? You need to re-design your design pattern.
But, I love the
JKI State Machine.
What I mean is not only the design patterns given in NI (Needs update) but also the other design patterns which are proven.