modify apparch/kong.md
This commit is contained in:
parent
6e47485878
commit
5c82f4c501
|
@ -8,10 +8,10 @@ XiUOS应用程序框架中的“控”子框架从“控制需求”本身出发
|
|||
|
||||
```c
|
||||
struct xs_PlcAbility {
|
||||
const char name[XS_NAME_MAX]; /* name of the plc ability instance */
|
||||
const char name[XS_NAME_MAX]; /* name of the PLC ability instance */
|
||||
enum xs_PlcCtlType type; /* type of control the plcable to excute, such as HSC or PID control */
|
||||
char address[XS_PLC_ADDRESS_MAX]; /* The address for this function in the plc*/
|
||||
struct xs_PlcDevice *pdev;/* corresponding plc device */
|
||||
char address[XS_PLC_ADDRESS_MAX]; /* The address for this function in the PLC*/
|
||||
struct xs_PlcDevice *pdev;/* corresponding PLC device */
|
||||
struct XS_DOUBLE_LINKLIST_NODE link;/* link list node */
|
||||
};
|
||||
```
|
||||
|
@ -30,7 +30,7 @@ enum xs_PLcCtlType {
|
|||
};
|
||||
```
|
||||
|
||||
由于plc里控制指令执行都是向数据模块DB写数据,需要知道该函数功能对应的数据块地址,这个用address标识。
|
||||
由于 PLC 里控制指令执行都是向数据模块DB写数据,需要知道该函数功能对应的数据块地址,这个用address标识。
|
||||
|
||||
pdev成员表示该xs_PlcAbility所属的xs_PlcDevice结构,其具体定义在下文给出。
|
||||
|
||||
|
@ -39,9 +39,9 @@ pdev成员表示该xs_PlcAbility所属的xs_PlcDevice结构,其具体定义在
|
|||
```c
|
||||
struct xs_PlcDevice {
|
||||
const char name[XS_NAME_MAX]; /* name of the device */
|
||||
struct xs_PlcInfo info;/* Plc info, such as vendor name and model name */
|
||||
struct xs_PlcInfo info;/* PLC info, such as vendor name and model name */
|
||||
struct xs_PlcOps ops;/* filesystem-like APIs for data transferring */
|
||||
struct xs_PlcInterface interface;/* protocls used for transferring data from program to plc */
|
||||
struct xs_PlcInterface interface;/* protocls used for transferring data from program to PLC */
|
||||
structXS_DOUBLE_LINKLIST_NODE link;/* link list node */
|
||||
};
|
||||
```
|
||||
|
@ -119,7 +119,7 @@ xs_PlcProtocolCheck(struct xs_PlcDevice*);
|
|||
|
||||
最后,系统中所有注册过的 PLC 设备被组织成一个双链表,即link成员。
|
||||
|
||||
## 2.XiUOS Plc控制框架驱动开发
|
||||
## 2.XiUOS PLC 控制框架驱动开发
|
||||
|
||||
以HSC高速计数器为例。控制框架针对每个具体的控制类型将xs_PlcAbility进行扩充,采用类似面向对象的手段添加其他必要成员,如:
|
||||
|
||||
|
@ -143,7 +143,7 @@ structxs_PlcOpshsc_example_ops = {
|
|||
};
|
||||
```
|
||||
|
||||
实现xs_PlcAbilityHsc中的write和read接口,该接口用于向PLC的HSC模块发送控制参数和读取返回参数。在实现过程中可以使用xs_PlcOps中的接口与plc进行通信。
|
||||
实现xs_PlcAbilityHsc中的write和read接口,该接口用于向 PLC 的HSC模块发送控制参数和读取返回参数。在实现过程中可以使用xs_PlcOps中的接口与 PLC 进行通信。
|
||||
|
||||
其中param为一个void类型指针,由于要写入的命令参数和要读取的返回参数往往不止一个,可以根据不同的控制类型定义不同的数据读写结构体,最后使用结构体指针进行强制类型转换即可。例如对于HSC:
|
||||
定义数据写入结构体:
|
||||
|
@ -209,7 +209,7 @@ struct xs_PlcAbilityHsc hsc_example进行必要的初始化后,用强制类
|
|||
```c
|
||||
hsc_example ->write(&hsc_example,(struct hsc_write*)&write_example);
|
||||
```
|
||||
最后,将plc设备添加到plc框架。分别填充xs_PlcDevice与对应物理量的xs_PlcAbility结构(高速计数器即为xs_PlcAbilityHsc),并依次使用xs_PlcDeviceRegister和xs_PlcAbilityRegister函数将其注册到plc框架:
|
||||
最后,将 PLC 设备添加到 PLC 框架。分别填充xs_PlcDevice与对应物理量的xs_PlcAbility结构(高速计数器即为xs_PlcAbilityHsc),并依次使用xs_PlcDeviceRegister和xs_PlcAbilityRegister函数将其注册到 PLC 框架:
|
||||
|
||||
```c
|
||||
int xs_PlcDeviceRegister (struct xs_PlcDeviceRegister *pdev);
|
||||
|
@ -254,7 +254,7 @@ void register_example_plc()
|
|||
}
|
||||
```
|
||||
|
||||
## 3. XiUOS Plc控制框架的使用示例
|
||||
## 3. XiUOS PLC 控制框架的使用示例
|
||||
PLC 控制应用开发者使用 PLC 控制框架提供的API操作 PLC,PLC 的API可以分为通用API与控制类型特有API。通用API用于 PLC 的获取、打开与关闭,控制类型特有API用于不同种类 PLC 的不同控制指令。以具有HSC高速计时器功能的 PLC 为例:
|
||||
|
||||
```c
|
||||
|
|
Loading…
Reference in New Issue