LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

about state machine

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.

a.png

0 Kudos
Message 1 of 11
(3,448 Views)

Wire a constant on the top left corner of the event structure. By default it's -1 (never times out)

0 Kudos
Message 2 of 11
(3,438 Views)

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.

-----

The best solution is the one you find it by yourself
Message 3 of 11
(3,416 Views)

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.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 11
(3,386 Views)

P@Anand wrote:

[...] But Event structure inside a state machine? You need to re-design your design pattern.


But, I love the Heart JKI State Machine. Heart

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 5 of 11
(3,374 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 11
(3,355 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 11
(3,340 Views)

@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.

0 Kudos
Message 8 of 11
(3,309 Views)

@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.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 9 of 11
(3,281 Views)

@jcarmody wrote:

P@Anand wrote:

[...] But Event structure inside a state machine? You need to re-design your design pattern.


But, I love the Heart JKI State Machine. Heart


What I mean is not only the design patterns given in NI (Needs update) but also the other design patterns which are proven.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 10 of 11
(3,279 Views)