#if !defined(__INCLUDE_HEAD_ZEROT__) #define __INCLUDE_HEAD_ZEROT__ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 const int MAX_SENDSIZE = 1024; const int MAX_RECVSIZE = 1024; const int MAX_STATICID = 60; // 静态ID; const int MAX_FACTORY = 60; // 产家; const int MAX_DEVICE = 120; // 设备名称; const int MAX_MARKSIZE = 50; // 命令Mark特征码; const int MAX_PROTOCOL = 120; // 协议名称; const int MAX_TIPSIZE = 256; // 命令说明; const int MAX_CUSTOMNAME = 120; // 自定义设备名称; const int MAX_CLASS = 120; // 设备系列; const int MAX_DEVICETYPE = 90; // 设备类型; const int MAX_CHECKSIZE = 60; // 校验符号长度; enum CommandType { CT_SET, CT_READ }; // 是否应该包含地址? typedef struct _STSendCommand { //int iType; // 读写类型; == 0 读请求, == 1 写请求; //int iSNum; // 发送的顺序(默认 -1,大于0为特殊命令);这里最好是按发送优先级别插入,不然这个成员要判断才能知道哪个是最优先的; int iPort; // 成员port在某些地方才用到;有些地方可以进行忽略; int iAddr; bool bRecv; // 是否有返回数据(或是否保存); DWORD dwSID; // 记录该结构体的ID号(自增效果); int iSLen; // 命令实际长度; char szMark[MAX_MARKSIZE]; // 命令特征码; char szCheck[MAX_CHECKSIZE]; // 校验符号 ; BYTE bySend[MAX_SENDSIZE]; // 配置好的命令串; //_STSendCommand(){ delete []szMark;szMark = NULL; delete [](char*)bySend;bySend=NULL;} }STSendCommand, *pSTSendCommand; // 是否应该包含地址? #if 1 typedef struct _STRecvMessage { int iPort; // 串口; int iAddr; // 地址 ; DWORD dwSID; // 记录该结构体的ID号(自增效果); int iRLen; // 实际接收字节; char szMark[MAX_MARKSIZE]; // 命令特征码; char szCheck[MAX_CHECKSIZE]; // 校验符号 ; BYTE byRecv[MAX_RECVSIZE]; // 用于存放返回数据; //_STRecvMessage(){ delete []szMark;szMark =NULL; delete [](char*)byRecv;byRecv=NULL;} }STRecvMessage, *pSTRecvMessage; #else typedef struct _STSubRecvMessage { DWORD dwSID; // 记录接收对应的命令号; int iRLen; // 实际接收字节; char szMark[MAX_MARKSIZE]; // 对应的命令特征码; char szCheck[MAX_CHECKSIZE]; // 校验符号 ; BYTE byRecv[MAX_RECVSIZE]; // 用于存放返回数据; //_STSubRecvMessage(){ delete []szMark;szMark =NULL; delete [](char*)byRecv;byRecv=NULL;} }STSubRecvMessage, *pSTSubRecvMessage; typedef struct _STRecvMessage { int iPort; // 串口; int iAddr; // 地址 ; char szCheck[MAX_CHECKSIZE]; // 校验符号 ; vector vt_subrecvmessage; }STRecvMessage, *pSTRecvMessage; #endif /************************************************************************/ /* Depot元素制定 */ /************************************************************************/ // 物理特性; typedef struct _STDepotPhysical { int iRate; // 1.波特率; int iDBit; // 2.数据位; int iSBit; // 3.停止位; int iPaty; // 4.校验位; int iIntl; // 5.超时值; int iRsTm; // 5.响应时间; char szLineType[90]; // 6.接线类型;(RS232,RS485,RJ45) char szComType[90]; // 7.通信类型;(RS232电总,RS485电总,RTU,ASCII,SNMP) char szPinDef[90]; // 8.针脚定义;(RS232:235-325,RS485:23-32...) //_STDepotPhysical(){ delete []szLineType;szLineType =NULL; delete []szComType;szComType=NULL;delete []szPinDef;szPinDef=NULL;} }STDepotPhysical,*pSTDepotPhysical; // 文档记录; typedef struct _STDeviceDocument { char szFactory[MAX_FACTORY]; // 1.生产厂家; char szdeviceType[MAX_DEVICETYPE]; // 2.设备类型; char szdeviceClass[MAX_CLASS]; // 3.设备系列; char szdeviceName[MAX_DEVICE]; // 4.设备名称; char szUnitType[120]; // 5.单元类型; char szProtocol[MAX_PROTOCOL]; // 6.设备协议; }STDeviceDocument,*pSTDeviceDocument; // 命令格式; typedef struct _STCommandFormat { char szName[50]; // 1.关键字名称; char szLen[30]; // 2.长度; char szData[256]; // 3.内容; char szType[10]; // 4.类型; int nDatalen; // 5.记录实际串长度; }STCommandFormat,*pSTCommandFormat; // 命令元素; typedef struct _STCommandStyle { char szName[90]; char szData[1024]; int nDatalen; // 记录实际串长度; }STCommandStyle, *pSTCommandStyle; typedef struct _STCommandTable { BOOL bRecv; // 命令是否保存返回; char szMark[MAX_MARKSIZE]; char szTip[MAX_TIPSIZE]; vector vt_commandstyle; }STCommandTable, *pSTCommandTable; // 整个元素; typedef struct _STDepotObject { char szName[120]; // 0.设备名称; char szSID[MAX_STATICID]; // 1.静态ID号; STDepotPhysical st_depotphy; // 2.物理特性; STDeviceDocument st_depotdoc; // 3.文档记录; int ByteCount; // 4.格式串最大长度; vector vt_commandformat; // 5.命令格式; vector vt_commandtable; // 6.具体命令; }STDepotObject, *pSTDepotObject; /************************************************************************/ /* Depot元素制定 */ /************************************************************************/ /************************************************************************/ /* 静态ID号说明 : 静态ID号由4段组成: A:设备的属类;(eg.属哪大类,UPS或空调或电量仪....); B:设备产家;(eg:艾默生或梅兰或泓格....); C:设备系列:(eg:艾默生Nx系列) D:设备型号;(eg:具体到艾默生UL33-0620L); 静态ID号在另一文档里记录,与depotobject.xml里的所有设备映射; 而设备的命令Mark特征码,则由 <静态ID号+本身Mark+地址位> 所以,Mark特征码是6段; */ /************************************************************************/ /************************************************************************/ /* RunObject元素制定 */ /************************************************************************/ typedef struct _STRunCommand { BOOL bRecv; char szSCMD[255]; char szMark[MAX_MARKSIZE]; char szTip[256]; }STRunCommand, *pSTRunCommand; typedef struct _STRunDevice { int iPort; // 该串口号,不在xml上显示,只用于程序计算; int iAddr; char szUName[MAX_CUSTOMNAME]; char szCheck[MAX_CHECKSIZE]; // 校验符号 ; char szSID[MAX_STATICID]; vector vt_rundevice; }STRunDevice, *pSTRunDevice; typedef struct _STRunPhysical { int iRate; // 1.波特率; int iDBit; // 2.数据位; int iSBit; // 3.停止位; int iPaty; // 4.校验位; int iIntl; // 5.超时值; int iRsTm; // 5.响应时间; char szLineType[50]; // 6.接线类型;(RS232,RS485,RJ45) char szComType[50]; // 7.通信类型;(RS232电总,RS485电总,RTU,ASCII,SNMP) char szPinDef[50]; // 8.针脚定义;(RS232:235-325,RS485:23-32...) }STRunPhysical, *pSTRunPhysical; #if 0 // 运行时设备库元素; typedef struct _STRunObject { char szName[30]; // 1.设备名; char szSID[MAX_STATICID]; // 2.静态ID号; int iPort; // 3.串口号; STRunPhysical st_runphy; // 4.物理特性; STDeviceDocument st_rundoc; // 5.文档记录; STRunDevice st_rundevice; // 6.详细命令; }STRunObject, *pSTRunObject; #else // 新:运行时设备库元素; typedef struct _STRunObject { int iPort; // 1.串口号; int iCount; // 2.设备数; STRunPhysical st_runphy; // 3.串口属性; STRunDevice st_rundevice; // 4.设备; }STRunObject, *pSTRunObject; #endif typedef struct _STRunComInfo { int iPort; int iCount; STRunPhysical tRunPhysical; vector vtSendCommand; }STRunComInfo,*pSTRunComInfo; /************************************************************************/ /* RunObject元素制定 */ /************************************************************************/ #endif