<< 点击显示目录 >> 主页 exOS使用助手 > exOS Automation Help > Development > Programming > Data communication > Datamodel description > Application templates |
VsCode 插件exOS 组件生成器可以通过.typ 文件创建完整的模板--有关创建模板的更多信息,请参阅本章。
▪模板生成器只为结构中的第一层创建值(尽管exOS允许更深层次的访问),为此,它需要知道您是在订阅还是在发布一个值(或两者兼而有之)。您可以在.typ文件中使用PUB或SUB注释来说明这一点。请注意,只要注释中包含PUB或SUB,您就可以在注释中添加任何其他信息。现在,如果您不在注释中指定PUB或SUB,将不会为值添加订阅或出版商。需要注意的是,PUB/SUB方向是从AR角度来看的。
例如
TYPE
MyApplication : STRUCT
Run : BOOL; (*PUB*)
Counter : INT; (*SUB*)
Temperature : REAL; (*SUB*)
Buffer : ARRAY[0..999] OF USINT; (*SUB*)
Config : MyApplicationConfig; (*PUB SUB*)
Status : MyApplicationStatus; (*SUB*)
END_STRUCT;
MyApplicationStatus: STRUCT
Result : UINT;
ActualPressure : LREAL;
Message : STRING[80];
END_STRUCT;
MyApplicationConfig: STRUCT
MaxPressure : LREAL;
SleepTime : LREAL;
END_STRUCT;
END_TYPE
The VsCode plugin exOS Component Generator comes with the possibility to create complete templates out of .typ files - please have a look into this chapter for more on creating templates.
•The template generator only creates values for the first level within the structure (even though exOS allows for deeper levels of access), and for doing this, it needs to know if you are subscribing or publishing a value (or both). You specify this with a PUB or SUB comment in your .typ file. Note that you can have any other information in the comment as long as it contains PUB or SUB. Now, if you do not specify PUB or SUB in the comment, no subscription or publisher will be added for the value. Very important to note is that the PUB/SUB direction is seen from the AR perspective.
For example:
TYPE
MyApplication : STRUCT
Run : BOOL; (*PUB*)
Counter : INT; (*SUB*)
Temperature : REAL; (*SUB*)
Buffer : ARRAY[0..999] OF USINT; (*SUB*)
Config : MyApplicationConfig; (*PUB SUB*)
Status : MyApplicationStatus; (*SUB*)
END_STRUCT;
MyApplicationStatus: STRUCT
Result : UINT;
ActualPressure : LREAL;
Message : STRING[80];
END_STRUCT;
MyApplicationConfig: STRUCT
MaxPressure : LREAL;
SleepTime : LREAL;
END_STRUCT;
END_TYPE