07-23-2014 04:58 PM
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?
07-23-2014 05:40 PM
@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. 🙂
07-23-2014 07:20 PM
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.
07-23-2014 07:23 PM
@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"
07-23-2014 07:59 PM
@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.
07-23-2014 08:09 PM
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.
07-23-2014 08:29 PM
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?
07-24-2014 06:45 AM
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.
07-24-2014 11:37 AM
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?
07-24-2014 11:45 AM
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.