From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State machine

Solved!
Go to solution

Whenever I make a state machine, I feel like there is some redundancy in the way I program the final "complete" state.

 

Attached is an image of the final two states in my state machine.  There is a user dialog that asks if you want it to keep going or if you are finished.  It then sends the string to go to the "complete" case.  My question is if the "complete" case ever actually runs, or if I can get rid of that case entirely.  (I feel it is kind of redundant because I pass the "complete" string out of the "complete" state, even though I am not running that case multiple times)

 

I ask because I am thinking about putting some general formatting code in that comlpete case if I can, but I can always just add in another state if I have to.

0 Kudos
Message 1 of 6
(2,671 Views)

I would keep it. Just in case you need to add some "completion code" some time

Rodéric L
Certified LabVIEW Architect
Message 2 of 6
(2,664 Views)

That is my question though, that "complete" case does run?  It is not skipped over when it registers that complete=complete in the beginning?

0 Kudos
Message 3 of 6
(2,660 Views)
Solution
Accepted by topic author LarsUlrich

Your complete case will execute. However, I would put the boolean for stopping the state machine inside your complete case itself. By doing this you could possibly use different cases to exit your state machine if your require different porcessing depending on what triggered the stop. It is also easier to maintain since you cold change the name of your exit state and not have to update the extra check outside the case.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 4 of 6
(2,656 Views)

As Mark was saying, do something like this.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 6
(2,630 Views)

JUst thought I would add your Exit state cound evolve into something like this...

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 6
(2,590 Views)