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: 

can a state machine run multiple cases simultaneously?

So a basic state machine has a case structure with different cases (states) inside a while loop.

 

Suppose you have a case structure with 5 different cases that are independent of each other. Independent in the sense that inputs to one case do not depend on outputs from another case.

 

If I took this case structure and put it inside a while loop, does this mean that the cases will get executed simultaneously? Say my states are measure temperature, measure pressue, flag when some monitor output

gets above a certain value. Will these three states (assuming each resides in a different case of the case structure) will get executed at the same time?

 

Does using a case structure presumes that only one case can be executed at a time? Is there any fundamental relationship between the iterator i of the while loop and different cases of the case structure?

 

 

0 Kudos
Message 1 of 10
(3,343 Views)

@murchak wrote:

So a basic state machine has a case structure with different cases (states) inside a while loop.

 

Suppose you have a case structure with 5 different cases that are independent of each other. Independent in the sense that inputs to one case do not depend on outputs from another case.

 

If I took this case structure and put it inside a while loop, does this mean that the cases will get executed simultaneously? Say my states are measure temperature, measure pressue, flag when some monitor output

gets above a certain value. Will these three states (assuming each resides in a different case of the case structure) will get executed at the same time?

 

Does using a case structure presumes that only one case can be executed at a time? Is there any fundamental relationship between the iterator i of the while loop and different cases of the case structure?

 

 


Only one state will execute at a time regardless of what conditions are imposed on the states because the selector can only select one case at a time.

 

Please tell us what you are trying to accomplish so we can make some appropriate suggestions.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 10
(3,334 Views)

What I am trying to do is the following: We use LabVIEW to automate our test suite. That part is done and is maintained by someone else. I use LabVIEW to post process the data.

Below is how my code works at the moment:

 

1. Run the code which opens up File Dialog

2. Select data files 

3. Summarize the data into a table and format the table

4. Make over 30 different plots and format the curves (4 groups of plots)

5. Save the plots as images and export them to a PowerPoint 

6. Save analyzed data into a data base

7. Exit the program

 

Steps 3 and 4 are independent. Steps 5 and 6 clearly depend on the previous steps. I took my code and coverted into a state machine architecture for all the reasons that people promote here.

But it is forcing my code to execute one step at a time and made it slower. But the code looks less bulky. 

 

0 Kudos
Message 3 of 10
(3,312 Views)

@murchak wrote:

What I am trying to do is the following: We use LabVIEW to automate our test suite. That part is done and is maintained by someone else. I use LabVIEW to post process the data.

Below is how my code works at the moment:

 

1. Run the code which opens up File Dialog

2. Select data files 

3. Summarize the data into a table and format the table

4. Make over 30 different plots and format the curves (4 groups of plots)

5. Save the plots as images and export them to a PowerPoint 

6. Save analyzed data into a data base

7. Exit the program

 

Steps 3 and 4 are independent. Steps 5 and 6 clearly depend on the previous steps. I took my code and coverted into a state machine architecture for all the reasons that people promote here.

But it is forcing my code to execute one step at a time and made it slower. But the code looks less bulky. 

 


Make Step 3 "Format tables and plots" Smiley Very Happy


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 10
(3,309 Views)

@murchak wrote:

What I am trying to do is the following: We use LabVIEW to automate our test suite. That part is done and is maintained by someone else. I use LabVIEW to post process the data.

Below is how my code works at the moment:

 

1. Run the code which opens up File Dialog

2. Select data files 

3. Summarize the data into a table and format the table

4. Make over 30 different plots and format the curves (4 groups of plots)

5. Save the plots as images and export them to a PowerPoint 

6. Save analyzed data into a data base

7. Exit the program

 

Steps 3 and 4 are independent. Steps 5 and 6 clearly depend on the previous steps. I took my code and coverted into a state machine architecture for all the reasons that people promote here.

But it is forcing my code to execute one step at a time and made it slower. But the code looks less bulky. 

 


Uh-oh, then we completely misunderstood your requirements, because a state machine is the anti-parallel programming technique.

 

You want separate loops for each if you wanted them to run all at once.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 10
(3,294 Views)


murchak wrote:

What I am trying to do is the following: We use LabVIEW to automate our test suite. That part is done and is maintained by someone else. I use LabVIEW to post process the data.

Below is how my code works at the moment:

 

1. Run the code which opens up File Dialog

2. Select data files 

3. Summarize the data into a table and format the table

4. Make over 30 different plots and format the curves (4 groups of plots)

5. Save the plots as images and export them to a PowerPoint 

6. Save analyzed data into a data base

7. Exit the program

 

Steps 3 and 4 are independent. Steps 5 and 6 clearly depend on the previous steps. I took my code and coverted into a state machine architecture for all the reasons that people promote here.

But it is forcing my code to execute one step at a time and made it slower. But the code looks less bulky.


 

I dont see how this is really a terrible problem, Wouldn't it be possible to simply rearrange the state machine so that State 3 is simply:

 

3. Summarize the data into a table and format the table & Make over 30 different plots and format the curves (4 groups of plots)

 

This way everything that is dependent on earlier stages still runs and the two stages that are independent can run simultaneously.

0 Kudos
Message 6 of 10
(3,289 Views)

These are all fine ideas, except it is impossible to reduce the bulk from my code. A lot of the properties are read from the file names (such as plot labels and legends),

axes min and max values and so on. I have so many plots and for each I have to create a Ref and put them in an array to feed them in the property nodes.

 

Actually, does it make sense to leave the XYGraphs in the main VI and create little SubVIs that include the propertly nodes and feed references to these nodes in the SubVIs?

0 Kudos
Message 7 of 10
(3,278 Views)

I would make a subVI that just sets the properites of a graph.  And anything else that you might use elsewhere should also become a subVI.


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 8 of 10
(3,227 Views)

Thanks crossrulz.

 

So  it's okay to leave the actual XYGraph on the main VI, but update its properties in a SubVI where the SubVI is fed the reference to the XYGraph?

0 Kudos
Message 9 of 10
(3,195 Views)

murchak wrote:

So  it's okay to leave the actual XYGraph on the main VI, but update its properties in a SubVI where the SubVI is fed the reference to the XYGraph?


Sure.  Especially if that means that you can reuse this VI to set the properties of other graphs.


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 10 of 10
(3,190 Views)