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 on JKI State Machine (JKISM). It extends JKISM with keywords for inter-module communication, including Sync-Message, Async-Message, and Status Subscription/Unsubscription—essential features for building reusable code modules. For more information, visit the CSM Wiki: https://nevstop-lab.github.io/CSM-Wiki/

image

CSM API Palette

image

Template Description:
English | 中文

API Description:
English | 中文

Create Reusable Modules

A reusable module typically doesn't need to communicate with other modules—it only needs to provide an external interface and publish status changes. As long as these two aspects are clearly defined, the module can be called without understanding its internal implementation.

In CSM modules, all cases can be invoked as messages, but it's recommended to use API categories as the external interface. To send status updates, use Status or Interrupt Status to notify external entities of changes.

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

Use CSM as an Application Framework

In this scenario, inter-module communication relies on message string queue operations. You can generate message strings using the Build Message with Arguments++.vi function, or write them directly if you're familiar with the syntax.

#CSM State Syntax
    // Local Message
    DoSth: DoA >> Arguments

    // Sync Call
    API: xxxx >> Arguments -@ TargetModule

    // Async Call
    API: xxxx >> Arguments -> TargetModule

    // Async Call without Reply
    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 Comments
    // Use "//" to add comments - all text to the right will be ignored
    UI: Initialize // This initializes the UI
    // Another comment line

For more syntax information, visit: Syntax.md

See /Example/2. Caller is CSM Scenario for an example.

Reuse CSM Modules in Other Frameworks

In this scenario, inter-module communication relies on Post/Send Message APIs and module status change user events.

See /Example/3. Caller is Other Framework Scenario for an example.

CSM Parameter Support

JKISM only supports STRING parameters, but applications need to transmit various data types. The table below lists current parameter support options—some built-in, others requiring addon installation.

Parameter Type Description
SafeStr Built-in Special characters ("->| -> -@ & <- , ; []{}`") are replaced with %[HEXCODE]
HexStr Built-in Data is converted to variant and encoded as hex string
MassData Addon Data is stored in a circular buffer; StartPos with length is passed as parameter
API String Arguments Addon Supports plain string as CSM API parameter
INI Static Variable Addon Provides ${variable} support for CSM

About

LabVIEW Application Framework extended from JKI State Machine(JKISM)

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors

Languages