- #include
-
- int main(){
-
- //指令工厂初始化
-
- //控制外设工厂初始化
-
- //线程池
-
- return 0;
- }

- struct InputCmd{
- char cmdName[128];//指令名称
- char cmd[32];//指令
-
- int (*Init)(char *name,char *ipAdresschar *port);//初始化函数
- int (*getCmd)(char *cmd);//获取指令函数
- char *log[1024];//日志
-
- struct InputCmd *next;
- }
定义一个名为 `InputCmd` 的结构体,包含以下成员:
- struct Devices{
- char devicesName[128];//设备名称
- int status;//状态:开&关
-
- int (*open)();//打开设备
- int (*close)();//关闭设备
- int (*devicesInit)();//设备初始化
- int (*readStatus)();//读取设备状态
- int (*changeStatus)(int status);//改变设备状态
-
- struct Devices *next;
- }
定义一个名为 `Devices` 的结构体,包含以下成员:
以浴室灯模块为例
bathroomLight.c
- struct Devices BathroomLight{
- .name="bathroomLight",
- .open=bathroomLight_open,
- .close=bathroomLight_close,
- .devicesInit=bathroomLight_init,
- .changeStatus=bathroomLight_status
- }
-
- int bathroomLight_open(){
-
-
- }
-
- int bathroomLight_close(){
-
-
- }
-
- int bathroomLight_init(){
-
- }
-
- int bathroomLight_status(int status){
-
- }
- sturct Devices *addbathroomLightToDevicesLink(stuuct Devices *phead){
- if(phead==NULL){
- ruturn &bathroomLight;
- }else{
- bathroomLight.next=phead;
- phead=&bathroomLight;
- }
- }