Skip to content

NEVSTOP-LAB/Communicable-State-Machine

Repository files navigation

Communicable State Machine (CSM)

English | 中文

Image Image GitHub all releases

Communicable State Machine (CSM) is a LabVIEW application framework built upon JKI State Machine (JKISM). It follows the JKISM design pattern while extending keywords to describe inter-module message communication mechanisms, including key concepts such as Sync-Message, Async-Message, and status Subscription/Unsubscription—all essential elements for creating reusable code modules. For more information, please visit the CSM Wiki: https://nevstop-lab.github.io/CSM-Wiki/

image

CSM API

image

Template Description: English | 中文

API Description: English | 中文

Create Reusable Modules

Creating a reusable module typically does not require message interaction with other modules; it only needs to provide an external interface and publish module status changes. Therefore, as long as these two aspects are clearly described, you 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 categories as external interfaces. When sending status updates, notify external entities of changes by sending either Status or Interrupt Status.

Refer to /Example/1. Create a reusable module to learn how to create a CSM module.

Use CSM as an 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 write message description strings.

#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  -><status>

    // Broadcast Interrupt status:
    Interrupt >> StatusArguments  -><interrupt>

    // Register Source Module's status to Handler Module
    Status@Source Module >> API@Handler Module -><register>

    // Unregister Source Module's status
    Status@Source Module >> API@Handler Module -><unregister>

#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

For more syntax information, please visit: Syntax.md

Refer to /Example/2. Caller is CSM Scenario for an example of 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 events.

Refer to /Example/3. Caller is Other Framework Scenario for an example of this scenario.

CSM Parameter Support

JKISM only supports the STRING TYPE as a parameter, but there is a wide variety of data that needs to be transmitted. Therefore, parameter support 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.

Parameter Type Description
Safe String Built-in "->| -> -@ & <- , ; []{}`" will be replaced with %[HEXCODE]
HexStr Built-in Data will be converted as variant and changed to Hex String as parameter
MassData Addons Data will be converted to memory and saved in a circle buffer. Pass the StartPos with length as parameter.
API String Arguments Addons Support plain string as CSM API parameter
INI Static Variable Support Addons Offering ${variable} support for CSM