This example runs four parallel instances of a synchronous state diagram generated by the Statechart Module. The diagrams execute on a cRIO 9074. The diagram triggers come from an XP HMI. The triggers originate from event-driven producer-consumer architecture. Triggers are sent to the cRIO using the Simple Messaging Reference Library (STM). There is an example of command-based communication that installs with STM. The STM messages are received on the cRIO and sent to one of four RT FIFOs. The RT FIFO Read pops the trigger and sends it to the diagram. Since we want each instance of the diagram to operate on different hardware resources, I use a reentrant VI as a resource LUT. I pull out the correct resource set by providing the diagram with an "instance" control.
Alternate hardware may be used. The cRIO must support Scan Engine. Four AO channels are wired to four AI channels.
In this reentrant VI, I define the hardware resources that will be unique to each instance of the reentrant statechart. I made the VI reentrant so none of the statechart instances would call into a shared resource. If you have other ideas of how to implement different resources in multiple instances of the same statechart, I'd like to hear them.
State Diagram Loops (x4)