Solution
In order to get a LabVIEW program to repeat the execution of a block depending on conditions that change during runtime, the state machine design pattern can be used. The state machine is composed by states that are represented by the code in each case of a
Case Structure in LabVIEW, and the result of the execution of each case can be used to define the next state to execute. A change in any condition of your interest can be evaluated during any state and it can be used to get the program to transition back to the case in which the code you want to execute again was placed.
To understand the general structure of this design pattern, refer to
Using a State Machine (Event Driven) Architecture. In LabVIEW, you can either generate the state machine code from scratch or use the template project. To create a project from the template:
- Go to File>>Create Project or click the Create Project option from the LabVIEW splash screen.
- In the Create Project window, click on Templates on the left and then choose Simple State Machine from the options on the right.
- Click Next and define a Project Name and the project location in the Project Root field.
- Click Finish and open the Main VI file.
- Proceed to replace the components in the Front Panel and Block Diagram as suggested in the template.