# Communicable-State-Machine
**Repository Path**: NEVSTOP-LAB/Communicable-State-Machine
## Basic Information
- **Project Name**: Communicable-State-Machine
- **Description**: 可通信状态机(CSM)是一个基于JKI状态机(JKISM)的LabVIEW应用框架。它遵循 JKISM 的模式,扩展了关键词以描述模块之间的消息通信,包括同步消息、异步消息、状态订阅/取消订阅等概念
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 13
- **Forks**: 4
- **Created**: 2024-04-26
- **Last Updated**: 2025-08-05
## Categories & Tags
**Categories**: hardware
**Tags**: LabVIEW-CSM
## README
# Communicable State Machine(CSM)
[English](./README.md) | [中文](./README(zh-cn).md)
[](https://www.vipm.io/package/nevstop_lib_communicable_state_machine/)
[](https://www.vipm.io/package/nevstop_lib_communicable_state_machine/)
[](https://github.com/NEVSTOP-LAB/Communicable-State-Machine/releases)
Communicable State Machine(CSM) is a LabVIEW application framework that builds upon JKI State Machine(JKISM). It follows the pattern of JKISM and extends the keywords to describe message communication between modules, including concepts such as Sync-Message, Async-Message, Subscription/Unsubscription of status - essential elements for creating reusable code modules. For more information, please visit the CSM wiki:
- For instructions on JKI State Machine(JKISM), visit:
- For information on NEVSTOP-LAB, visit:

_**CSM API**_

Template Description:
[English](src/help/NEVSTOP/Communicable%20State%20Machine(CSM)/Template%20Description(EN).md) | [中文](src/help/NEVSTOP/Communicable%20State%20Machine(CSM)/Template%20Description(zh-cn).md)
API Description:
[English](src/help/NEVSTOP/Communicable%20State%20Machine(CSM)/VI%20Description(EN).md) | [中文](src/help/NEVSTOP/Communicable%20State%20Machine(CSM)/VI%20Description(zh-cn).md)
## Create Reuseable Modules
Creating a reusable module typically does not require message interaction with other modules; it only needs to provide an external interface and publish the state of the module. Therefore, as long as these two aspects are clearly described, one can call the reusable module without understanding its internal implementation details.
In CSM modules, all cases can be considered as messages for invocation, but it is recommended to use API category as external interfaces. When sending status updates, notify external entities of changes by sending either Status or Interrupt Status.
Go to _**/Example/1. Create a reusable module**_ to learn how to create a CSM module.
## Use CSM as application framework Scenario
In this scenario, inter-module communication solely relies on message string queue operations. You can generate a Message string using the "**Build Message with Arguments++.vi**" function. Alternatively, if you are familiar with the rules, you can directly utilize message description strings.
``` c++
#CSM State Syntax
// 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 normal status:
Status >> StatusArguments ->
// Broadcast Interrupt status:
Interrupt >> StatusArguments ->
// Register Source Module's status to Handler Module
Status@Source Module >> API@Handler Module ->
// Unregister Source Module's status
Status@Source Module >> API@Handler Module ->
#CSM Commenting
To add a comment use "//" and all text to the right will be ignored
UI: Initialize // This initializes the UI
// Another comment line
```
Please visit this link for more syntax information: [Syntax.md](https://github.com/NEVSTOP-LAB/Communicable-State-Machine/tree/main/.doc/Syntax.md)
Go to _**/Example/2. Caller is CSM Scenario**_ to find an example for this scenario.
## Reuse CSM Module in another Application Framework
In this scenario, inter-module communication solely relies on Post/Send Message API and module status change user event.
Go to _**/Example/3. Caller is Other Framework Scenario**_ to find an example for this scenario.
## CSM Arguments Support
JKISM only supports the STRING TYPE as a parameter, but there is a wide variety of data that needs to be transmitted. Therefore, support for parameters is crucial. The table below lists some of the current ways in which different data types are supported, with some being built-in within CSM and others requiring additional installation through addons.
| Arguments | Type | Description |
|---|---|---|
| Safe String | Build-in | "->\| -> -@ & <- , ; []{}`" wil be replaced with %[HEXCODE] |
| HexStr | Build-in | Data will be converted as variant and changed to Hex String as parameter |
|[MassData](https://github.com/NEVSTOP-LAB/CSM-MassData-Parameter-Support) |Addons|Data will be converted to memory and saved in a circle buffer. Pass the StartPos with length as parameter. |
|[API String Arguments](https://github.com/NEVSTOP-LAB/CSM-API-String-Arugments-Support) |Addons|Support plain string as CSM API parameter|
|[INI Static Variable Support](https://github.com/NEVSTOP-LAB/CSM-INI-Static-Variable-Support)|Addons|offering ${variable} support for CSM|