Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5a3be95
init dev_2026Q2
Apr 16, 2026
afd0480
[update] #607 expose "Wait(5000ms)" input for changing wait time in C…
Apr 16, 2026
27f769a
[update] #606 add "Sync Response Only(F)" optional input for CSM - Ru…
Apr 17, 2026
e55325e
调试简化 testcase
Apr 20, 2026
4769692
fix https://github.com/NEVSTOP-LAB/Communicable-State-Machine/actions…
Apr 20, 2026
62f5ac9
trigger ci/cd
Apr 20, 2026
56928f9
移除 Check_Broken_VIs 工作流中的超时设置
Apr 20, 2026
d1e88e2
update testcase
Apr 20, 2026
a2659dc
update testcases
Apr 20, 2026
db0569d
update testcases
Apr 20, 2026
29e2943
fix https://github.com/NEVSTOP-LAB/Communicable-State-Machine/actions…
Apr 21, 2026
638eb8a
fix https://github.com/NEVSTOP-LAB/Communicable-State-Machine/actions…
Apr 21, 2026
1e5618a
[update] #611 Set Menu Entry VIs as "Run When Opened"
May 7, 2026
18c190c
[update] #611 Set Menu Entry VIs as "Run When Opened", hide FP when r…
May 7, 2026
821f8f3
[update] #612 Add csm version in csmlog file.
May 9, 2026
84f0602
[update] #613 Updated the icon of "CSMLS - Define Loop State(s).vi" t…
May 9, 2026
a08bfef
[fix] minor fix on module information page of Debug Console
May 9, 2026
5ff8f28
docs: add warning about reversed wiring in CSMLS - Define Loop State(…
Copilot May 10, 2026
877c364
docs: clarify chain mode routing semantics in zh/en API docs (#617)
Copilot Jun 2, 2026
6a4f703
修复类型错误的问题
Jun 3, 2026
cdf7754
更新文档
Jun 3, 2026
d4ba427
fix CSM_LAUNCH_INTERFACE_BROWSER loading
Jun 4, 2026
6f9c999
try to fix https://github.com/NEVSTOP-LAB/Communicable-State-Machine/…
Jun 8, 2026
d8ee490
update Interface Browser.vi
Jun 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/Check_Broken_VIs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ jobs:
Parameter2: NOPASSWORD
Parameter3: YES
Parameter4: -placeContent
timeout-minutes: 5
5 changes: 5 additions & 0 deletions Communicable State Machine(CSM).lvproj
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@
<Item Name="Global_Interface.ctl" Type="VI" URL="/&lt;resource&gt;/Framework/Providers/API/Global_Interface.ctl"/>
<Item Name="Item_Interface.ctl" Type="VI" URL="/&lt;resource&gt;/Framework/Providers/API/Item_Interface.ctl"/>
<Item Name="provcom_StringGlobals.vi" Type="VI" URL="/&lt;resource&gt;/Framework/Providers/Common/provcom_StringGlobals.vi"/>
<Item Name="InitCSMs.vi" Type="VI" URL="../testcases/CSM/InitCSMs.vi"/>
<Item Name="StartCSMs.vi" Type="VI" URL="../testcases/CSM/StartCSMs.vi"/>
<Item Name="GetPathByPrototypeName.vi" Type="VI" URL="../testcases/CSM/GetPathByPrototypeName.vi"/>
<Item Name="Prototypes.vi" Type="VI" URL="../testcases/CSM/Prototypes.vi"/>
<Item Name="Build CSM to PPL.vi" Type="VI" URL="../testcases/CSM/Build CSM to PPL.vi"/>
</Item>
<Item Name="Build Specifications" Type="Build">
<Item Name="Communicable State Machine.lvlibp" Type="Packed Library">
Expand Down
479 changes: 232 additions & 247 deletions Communicable State Machine(CSM).vipb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
> - CSM module name must be unique. Otherwise, CSM enters a `Critical Error` state.
> - If the input module name is an empty string (""), the system uses a UUID as the module name. Such a module is marked as standalone mode and does not appear in the module list.
> - Worker Mode Rule: If the input module name ends with `#`, a worker mode node will be instantiated. Multiple worker mode nodes can form a worker mode module.
> - Chain of Responsibility Mode Rule: If the input module name ends with `$` followed by a number, a chain of responsibility mode node will be instantiated. Multiple chain of responsibility mode nodes can form a chain of responsibility mode module.
> - Chain of Responsibility Mode Rule: If the input module name ends with `$` followed by a number, a chain of responsibility mode node will be instantiated. Multiple chain of responsibility mode nodes can form a chain of responsibility mode module. Smaller numbers mean higher priority, and messages are routed directly to the highest-priority node that can handle them.
> - System-Level Module Rule: If the input module name starts with `.`, the module is a system-level module. Under default settings, such modules are not listed by the CSM - List Modules VI and are suitable for instantiating modules that run in the background.
> - Submodule Rule: `.` is also allowed in a module name to separate the module name into multiple parts. CSM does not have strict rules for submodules. The `.` in the module name only marks the logical relationship between different modules. From an execution perspective, they are considered independent modules. The only difference is that you can obtain a list of logical submodules via the CSM - List Submodules VI.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
> - <b>Stand-alone</b>: Independent operation mode. If no module name is specified, a random ID is automatically generated to identify the module.
> - <b>CSM</b>: Normal CSM module.
> - <b>Action Worker</b>: Worker Mode. Append `#` to the module name to mark this module as a worker. This module shares the same message queue with other workers having the same name.
> - <b>Chain Node</b>: Chain node. Append `$` to the module name to mark this module as a chain node. Messages on the same chain will be passed sequentially until a node processes the message.
> - <b>Chain Node</b>: Chain node. Append `$` and a number to the module name to mark this module as a chain node. Within the same Chain, a smaller number means higher priority. Messages sent to the Chain module name are routed directly to the highest-priority node that can handle them.

> [!NOTE]
> <b>CSM Priority Queue Design</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,13 @@ API: Do Something Else -@ csm
-- <b>Controls</b> --
- <b>Current Module ("" to Generate an ID)</b>: Name of the current module. If empty, a temporary ID is generated for debugging purposes to identify the location.
- <b>CSM Scripts</b>: CSM commands to execute.
- <b>Sync Response Only (F)</b>: Whether <b>Response</b> should include only responses from synchronous messages. Disabled by default.
- <b>Continue If Error? (F)</b>: Whether to continue execution if an error occurs. The default is FALSE, which specifies to not continue.
- <b>Wait (5000 ms)</b>: Timeout duration for waiting module to be alive. The default is 5000 ms.
- <b>Response Timeout (-2 Using Global Settings)</b>: Timeout for synchronous calls. The default is -2, which uses the global setting. You can set the global timeout using the CSM - Set TMO of Sync-Reply VI.

-- <b>Indicators</b> --
- <b>Response</b>: Returned results from executing the script. Only synchronous messages carry returns. The corresponding column for other commands will be an empty string.
- <b>Response</b>: Results returned by the script. When <b>Sync Response Only (F)</b> is enabled, this output includes only responses from synchronous messages. Otherwise, each script line, including blank lines and comments, produces one result in order. Non-synchronous commands return an empty string.
- <b>Scripts Left</b>: Remaining unexecuted scripts.

## CSM - Broadcast Event.vi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ Marks a module as a Worker Mode module by adding `#` after the CSM name.
> [!NOTE]
> <b>CSM Chain of Responsibility Mode</b>
>
> Multiple CSM modules form a complete module via Chain of Responsibility Mode by appending `$` to the requested name to form a chain for processing transactions.
> Multiple CSM modules form a Chain module by appending `$` and a number to the requested name.
> - From an external call perspective, these instances collectively form a composite module named Chain.
> - Each instance is named a Chain Node.
>
> <b>Behavior</b>: External callers can consider the Chain as a single CSM module capable of message communication, state registration, and so on. Internally, nodes attempt to process the message sequentially according to their order. When a node has the capability to process the current message, the message is processed and is not passed further down the chain.
> <b>Behavior</b>: External callers can consider the Chain as a single CSM module capable of message communication, state registration, and so on. Internally, CSM uses the Chain registry to route a message directly to the highest-priority node that can handle it (smaller number = higher priority). A message is handled by only one node; it is not passed sequentially or downgraded across nodes.
>
> <b>Communication Restriction</b>: Messages must be sent to the Chain module name, not to a specific `ChainName$N` node.
>
> <b>Example</b>:
>
Expand All @@ -109,20 +111,17 @@ Marks a module as a Worker Mode module by adding `#` after the CSM name.
> // - `module$2`
> // - `module$3`
> // - `module$4`
> // The sequence of the composed Chain is `module$1(head) >> module$2 >> module$3 >> module$4(tail)`
> // Assume `module$3` and `module$4` can process "csm message"
> `csm message >> arguments -@ module`
> // This message will be processed by `module$3`. `module$4` will not respond.
> // CSM routes the message directly to the higher-priority `module$3`; `module$4` will not respond.
>
> <b>Application Scenarios</b>:
> - Permission approval process. Based on job hierarchy, personnel with specific functional permissions can approve directly without passing it further.
> - Function concatenation. Different modules implement different tasks, and different functional sets can be combined through concatenation.
> - Function overriding. Implementing overloading in OOP through overriding.
> - Worker Mode scenarios are usually not suitable for having UI operations.
> - Function composition: Different nodes handle different message types while exposing one Chain module externally.
> - Function overriding: When multiple nodes implement the same message type, the higher-priority node takes effect.

### CSM - Mark As Chain Module.vi

Concatenates the name of a Chain of Responsibility Mode module, using `$` as the separator. Note that the order does not need to be consecutive, but it must be unique. Nodes with smaller numbers are arranged at the front of the responsibility chain.
Concatenates a Chain of Responsibility Mode module name using `$` as the separator. The order does not need to be consecutive, but it must be unique. Smaller numbers mean higher priority. During routing, CSM chooses the highest-priority node that can handle the message.

<b>Reference Example</b>: `4. Advance Examples\2. Chain of Responsibility Example`.

Expand All @@ -131,7 +130,7 @@ Concatenates the name of a Chain of Responsibility Mode module, using `$` as the

-- <b>Controls</b> --
- <b>CSM Name</b>: CSM module name.
- <b>Order</b>: Sequence in Chain of Responsibility Mode. Nodes with smaller numbers are arranged at the front of the responsibility chain.
- <b>Order</b>: Priority number in Chain of Responsibility Mode. Smaller numbers mean higher priority, and the value must be unique within the same Chain.

-- <b>Indicators</b> --
- <b>CSM Name (Marked As Chain)</b>: CSM module name marked with `$`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ Starts the CSM Watchdog thread to monitor whether the main program has exited. I

> - Ref: CSM WatchDog Implementation Principle

-- <b>Controls</b> --
- <b>Wait(5000ms)</b>: The time the Watchdog thread waits for modules to process `Macro: Exit` and exit, in milliseconds (ms). The default value is 5000 ms.

### CSM Watchdog Thread.vi
The CSM Watchdog thread is used to ensure that all asynchronously started CSM modules can exit normally after the main program exits.

> - Ref: CSM WatchDog Implementation Principle

-- <b>Controls</b> --
- <b>Watchdog Queue</b>: Watchdog queue resource.
- <b>Wait(5000ms)</b>: The time the Watchdog thread waits for modules to process `Macro: Exit` and exit, in milliseconds (ms). The default value is 5000 ms.

## CSM File Logger Addon

Expand Down Expand Up @@ -111,6 +115,9 @@ The loop can be ended by removing `-><loop>`. You can use the following VIs to r
> [!WARNING]
> <b>Add to Front? (F)</b> is usually FALSE because once a loop state starts, it does not end immediately. Before insertion into the state queue, it is considered a sub-state of the current state. If the current state was called via a synchronous message, it would not return immediately. For example, if a set of continuous acquisition states is defined in `API: Start DAQ` and this message is sent synchronously from outside, the logic should be to start the loop and then return immediately. Only set <b>Add to Front? (F)</b> to TRUE if the logic is to wait for the loop to end before returning.

> [!WARNING]
> Be careful not to connect <b>State Queue</b> and <b>Loop States</b> in reverse. If reversed, it may cause synchronous messages sent externally to fail to return, and external messages can no longer be processed.

-- <b>Controls</b> --
- <b>States Queue</b>: Connect the entire state queue to this input.
- <b>Loop States</b>: Loop states.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
> System-level modules start with a `.` in their name. The target module for a CSM message includes the `.` in the name. For example, if the requested module name is `.System`, the target module for the CSM message is `.System`.
> In Worker Mode, the target module for a CSM message can only be the overall module name, not the node name. For example, if the requested module name is `Worker#`, the target module for the CSM message is `Worker`.
> In Chain of Responsibility Mode, the target module for a CSM message can only be the overall module name, not the node name. For example, if the requested module name is `Chain$1`, the target module for the CSM message is `Chain`.
> In Chain of Responsibility Mode, a message is routed directly based on handling capability and priority (smaller number = higher priority) and is not passed sequentially across nodes.

> [!NOTE]
> <b>Synchronous Message</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
> - CSM模块名称必须唯一,否则将导致CSM进入`Critical Error`状态。
> - 若输入为空字符串(""),系统将使用UUID作为模块名称。该模块会被标记为独立模式,不会包含在模块列表中。
> - 协作者模式规则:若输入以`#`结尾,则会实例化一个协作者模式节点,多个节点可共同组成一个协作者模式模块。
> - 责任链模式规则:若输入以`$`加数字结尾,则会实例化一个责任链模式节点,多个节点可共同组成一个责任链模式模块。
> - 责任链模式规则:若输入以`$`加数字结尾,则会实例化一个责任链模式节点,多个节点可共同组成一个责任链模式模块。数字越小优先级越高,消息会被直接路由到可处理该消息的最高优先级节点。
> - 系统级模块规则:若输入以`.`开头,则该模块为系统级模块。在默认参数下,此类模块不会被CSM - List Modules VI列出,适用于实例化后台运行的模块。
> - 子模块规则:`.`也允许出现在名称之中,将模块名称分为多个部分,每个部分之间用`.`分隔。CSM中并没有严格意义上的子模块,仅通过模块名称中的`.`来标记不同模块的逻辑关系,从实际运行角度来看认为是独立的模块。唯一区别在于可以通过CSM - List Submodules VI,获取逻辑上的子模块列表。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
> - <b>Stand-alone</b>: 独立工作模式。不输入模块名称,将自动生成一个随机ID,用于标识模块。
> - <b>CSM</b>: 普通CSM模块。
> - <b>Action Worker</b>: 协作者模式。在模块名称后添加`#`,以标记此模块为工作者,该模块与具有相同名称的其他工作者共享相同的消息队列。
> - <b>Chain Node</b>: 链式节点。在模块名称后添加`$`,以标记此模块为链式节点,同一个链上的消息将依次传递,直到某个节点处理消息
> - <b>Chain Node</b>: 链式节点。在模块名称后添加`$`和数字,以标记此模块为链式节点;同一Chain内数字越小优先级越高。发送到Chain模块名的消息,会被直接路由到可处理该消息的最高优先级节点

> [!NOTE]
> <b>CSM优先级队列设计</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ API: Do Something Else -@ csm
-- <b>输入控件(Controls)</b> --
- <b>Current Module ("" to Generate an ID)</b>: 当前模块名称,当没有输入时,生成一个临时ID,便于调试判断位置。
- <b>CSM Scripts</b>: 待运行的CSM指令。
- <b>Sync Response Only (F)</b>: <b>Response</b>中是否仅包含同步消息的响应,默认不启用。
- <b>Continue If Error? (F)</b>: 发生错误时是否继续执行, 默认不继续执行。
- <b>Wait (5000 ms)</b>: 等待超时时间,默认为5000 ms。
- <b>Response Timeout (-2 Using Global Settings)</b>: 同步调用的超时时间,默认为-2,使用全局设置。你可以通过CSM - Set TMO of Sync-Reply VI设置全局超时时间。

-- <b>输出控件(Indicators)</b> --
- <b>Response</b>: 执行脚本的返回结果。只有同步消息才会携带返回,其他的指令对应列为空字符串
- <b>Response</b>: 执行脚本的返回结果。<b>Sync Response Only (F)</b>启用时仅包含同步消息的响应,否则每一行指令,包括空行和注释,都对应了一个返回结果,按照顺序排列,非同步消息的响应为空字符串
- <b>Scripts Left</b>: 剩余未执行的脚本。

## CSM - Broadcast Event.vi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,20 @@
-- <b>输出控件(Indicators)</b> --
- <b>CSM Name (Marked As Worker)</b>: 添加`#`标记的CSM模块名称。

## 责任链模式 (Chain of Responsibility API) - 待完善
## 责任链模式 (Chain of Responsibility API)

> [!NOTE]
> <b>CSM责任链模式(Chain of Responsibility Mode)</b>
>
> 多个CSM模块,申请的名称后添加`$`,组成处理事务的一个链条,通过责任链模式形成一个完整的模块
> 多个CSM模块,申请的名称后添加`$`和数字,组成责任链模式模块
> - 从外部调用上看,这些实例一起组成了一个复合的模块,命名为Chain。
> - 每一个实例,命名为Chain Node。
>
> <b>行为</b>:
> 外部调用者可以认为Chain就是一个CSM模块,可以进行消息通讯、状态注册等操作。从内部看,nodes会根据排列顺序依次尝试处理消息,当node具有当前消息处理的能力时,消息被处理,不再向后传递。
> 外部调用者可以认为Chain就是一个CSM模块,可以进行消息通讯、状态注册等操作。从内部看,框架会根据Chain注册表,直接把消息路由给“能处理该消息且优先级最高”的节点(数字越小优先级越高)。消息只会由一个节点处理,不会在节点之间依次传递或降级。
>
> <b>通讯限制</b>:
> 必须向Chain模块名发送消息,不能直接向单个`ChainName$N`节点发送消息。
>
> <b>举例</b>:
>
Expand All @@ -115,20 +118,17 @@
> // - module$2
> // - module$3
> // - module$4
> // 组成的Chain顺序为module$1(head) >> module$2 >> module$3 >> module$4(tail)
> // 假设module$3 module$4能够处理"csm message"
> // 假设module$3和module$4都能够处理"csm message"
> csm message >> arguments -@ module
> // 这个消息将被module$3处理, module$4不会响应
> // 框架会直接把消息路由到优先级更高的module$3,module$4不会响应
>
> <b>应用场景</b>:
> - 权限审批过程,按照职位层级,具有某职能权限的人员,就可以直接审批,无需继续传递。
> - 功能拼接,不同模块实现不同的任务,通过拼接可以完成不同功能合集的组合。
> - 功能覆盖,通过覆盖实现OOP中的重载。
> - 工作者模式的场景,通常不适合具有界面操作。
> - 功能拼接:不同节点处理不同消息类型,对外统一为一个Chain模块。
> - 功能覆盖:多个节点实现相同消息类型时,由更高优先级节点生效。

### CSM - Mark As Chain Module.vi

拼接责任链模式模块的名称,使用`$`作为分隔符。注意Order不必连续,但是必须唯一,编号小的节点,将排列在责任链的前面
拼接责任链模式模块的名称,使用`$`作为分隔符。Order不必连续,但必须唯一;数字越小优先级越高。路由时,框架会选择能处理消息的最高优先级节点

<b>参考范例</b>: `4. Advance Examples\2. Chain of Responsibility Example`。

Expand All @@ -137,7 +137,7 @@

-- <b>输入控件(Controls)</b> --
- <b>CSM Name</b>: CSM模块名称。
- <b>Order</b>: 责任链模式下的顺序,编号小的节点,将排列在责任链的前面
- <b>Order</b>: 责任链模式下的优先级编号。数字越小优先级越高,且同一Chain内必须唯一

-- <b>输出控件(Indicators)</b> --
- <b>CSM Name (Marked As Chain)</b>: 添加`$`标记的CSM模块名称。
Expand Down
Loading
Loading