Overview
A pattern for re-sequencing machine states on the fly. This version is synchronous.
Description
The "self-programming" aspect of this example is in the "review experiment" case on the wiring diagram. A fixed number of new "tasks" are created by casting the random number to a defined "state". That "state" is injected into the queue. The content of the queue is unraveled at a controlled rate determined by the millisecond wait timer. The whole program stops when the "I'm done" state is tripped.
When used in actual code, the wait timer will typically be omitted. Calls to sub-vis will cause it to pause until data flow requirements are met. At which time it will proceed to the next state.
In actual use, an operator input or a real-world input would replace the random number generator, and cause a decision to be made about what step(s) to execute next.
A real-world use-case is to enable an operator to--in a limited way--resequence an experimental process in one of multiple conventional ways. The decomposition of the experiment is done in a way that each state corresponds to a small enough experimental step (activity | task) to program easily and independently into a given state. The particular experiment is hinted at by the activity names used in the example.
Imagining silly things to do with it:
Steps to Implement or Execute Code
Requirements
Software
Hardware
Additional Images or Video
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.