Skip to content
Discussion options

You must be logged in to vote
Admin verified this answer by nevstop May 28, 2026

CSM Attribute 是 CSM 框架内置的 Addon 插件(属于插件系统中的 Addon 类型),它为模块提供了一种无需消息传递即可直接读写配置或共享数据的机制。

一句话结论:CSM Attribute 让你可以像操作全局变量一样读写模块内部的数据,但具有类型安全、按名称访问、支持动态定义等优点,适用于跨模块配置共享、Worker/Chain 模式节点间数据交换以及外部调试监控等场景。


核心功能与原理

CSM Attribute 本质上是每个 CSM 模块内部维护的一个键-值存储空间(Key-Value Store),键是字符串(属性名),值可以是任意 LabVIEW 数据类型。它的核心能力包括:

  • 外部直接读写:不需要向模块发送消息,外部代码(如主 VI、UI 线程、其他模块)通过模块名称 + 属性名称 + 数据类型即可直接读取或设置模块的属性值。
  • 内部节点共享:在 Worker 模式Chain 模式下,模块内的不同节点共享同一个 Attribute 空间,节点间可以通过读写 Attribute 来交换数据,无需显式传递消息。
  • 动态定义:可以在模块运行过程中动态定义新的属性(例如在 Macro:Initialize 之后添加 API: Define ABC Attribute 状态),无需预先在模块模板中声明。

使用方法

1. 在模块内部定义属性

在模块的状态机中,使用 API: Define <属性名> Attribute 状态来定义属性并赋初值。例如:

  • Macro:Initialize 之后添加一行状态字符串:API: Define ABC…

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer verified by Admin May 28, 2026
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants