Communicable State Machine(CSM) is a LabVIEW Application Framework extended from JKI State Machine(JKISM). It follows the JKISM's pattern and extends the Key words to describe message communication between modules including the concepts of Sync-Message, Async-Message, Subscription/Unsubscription of status, which is essential elements for creating re-use code modules. More information, please visit wiki of CSM: https://nevstop-lab.github.io/CSM-Wiki/
- For instructions on JKI State Machine, visit: http://jki.net/state-machine/
- For information about NEVSTOP-LAB, visit: https://github.com/NEVSTOP-LAB
Examples: // Local Message Example DoSth: DoA >> Arguments
// Sync Call Example
API: xxxx >> Arguments -@ TargetModule
// Async Call Example
API: xxxx >> Arguments -> TargetModule
// Async Call without Reply Example
API: xxxx >> Arguments ->| TargetModule
// Broadcast Status:
Status >> StatusArguments -> <all>
To add a comment use "//" or "#" and all text to the right will be ignored
Commenting Example: UI: Initialize // This initializes the UI // Another comment line
If you won't post any state from other CSM, leave this control blank.
It means wait forever until new state is coming or user operation is detected in Event Structure
this is used to capture unhandled states and typos
Case for holding CSM Documentation
executes when the state queue is empty
This user event is used to break out CSM from waiting in the event structure, to process the next state from external. DO NOT place any code here unless you really need to.
Discard the event because we'll close the front panel ourselves in Macro: Exit
You can also output any states to clean-up after errors occur
If any error Occurred, "Error Occurred" status update will be broadcasted to system. Parameter is Error Cluster.
Usually, it's because this CSM register others' "Error Occurred" status with "Error Handler". If other CSM have any error, the error will be passed here for central handling.
When any un-recoverable error occurs, CSM goes into this case.
When Critical Error occurs, Stop the loop immediately. Do NOT change this unless you fully understand the impact.
When this CSM try to communicate with a Busy target, this CSM goes into this case.
When this CSM could not get the sync-call response in time, this CSM goes into this case.
When this CSM try to communicate with an un-existed CSM, this CSM goes into this case.
Handle Async-call Response ("Async Response" for ->)
Handle Sync-call Response ("Response" for -@)
After Message is executed, CSM goes to this state for receive the response. For Async Message(->), "Async Response" is used. This CSM will goes to "Async Message Posted" immediately and receive the "Async Response" after the callee finishes the message. For Sync Message(@), This CSM will wait until the message is done and immediately goes to "Response"
After Async Message is posted (-> or ->| ), CSM goes to this state for post-action. You can use Argument - State to tell which Async Message is called.
This is used to determine panel behavior on exit
Case for exiting the loop. No errors that occur here will be handled.
Do not put any code in this frame.
Initialize the shift-register data, here. (data names are defined by what you wire into the bundle function)
Cleanup any data and references, here. (this is called automatically, by the Macro: Exit)
Register user event. New Message Event is registered to break CSM waiting in event structure by default.
Register message event to break Waiting in Event structure.
Unregister user event.
Initialize the User Interface, here. (this is called automatically, by the Macro: Init)
Set and Unset Cursor Busy. (Usage: "UI: Cursor Set >> Busy|Idle")
Set Front Panel Open or Closed (Usage: "UI: Front Panel State >> Open|Close")
Initialization Macro (This is called once, when the VI starts)
Exit Macro (This is called once, when the VI exits)
Copy/Rename this case for your own API
If you need to tell who triggered this state , use this string. If it's this case itself, this string is "".
Deal with the parameter if any
Connect this to return the response of your API
(No-Event Template Only) Stop by posting "Macro: Exit" Message to lower CSM Module. Remove this code after dropping to your block diagram.
This category is used for holding internal states