123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- #if !defined(__INCLUDE_HEAD_ZEROT__)
- #define __INCLUDE_HEAD_ZEROT__
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- const int MAX_SENDSIZE = 32;
- const int MAX_RECVSIZE = 800;
- const int MAX_STATICID = 30; // 静态ID;
- const int MAX_FACTORY = 60; // 产家;
- const int MAX_DEVICE = 60; // 设备名称;
- const int MAX_MARKSIZE = 30; // 命令Mark特征码;
- const int MAX_PROTOCOL = 60; // 协议名称;
- const int MAX_TIPSIZE = 90; // 命令说明;
- const int MAX_CUSTOMNAME = 90; // 自定义设备名称;
- const int MAX_CLASS = 90; // 设备系列;
- const int MAX_DEVICETYPE = 20; // 设备类型;
- enum CommandType
- {
- CT_SET,
- CT_READ
- };
- // 是否应该包含地址?
- typedef struct _STSendCommand
- {
- //int iType; // 读写类型; == 0 读请求, == 1 写请求;
- int iSNum; // 发送的顺序(默认 -1,大于0为特殊命令);
- int iAddr;
- bool bRecv; // 是否有返回数据(或是否保存);
- DWORD dwSID; // 记录该结构体的ID号(自增效果);
- int iSLen; // 命令实际长度;
- char szMark[MAX_MARKSIZE]; // 命令特征码;
- 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]; // 命令特征码;
- 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]; // 对应的命令特征码;
- BYTE byRecv[MAX_RECVSIZE]; // 用于存放返回数据;
- //_STSubRecvMessage(){ delete []szMark;szMark =NULL; delete [](char*)byRecv;byRecv=NULL;}
- }STSubRecvMessage, *pSTSubRecvMessage;
- typedef struct _STRecvMessage
- {
- int iPort; // 串口;
- int iAddr; // 地址 ;
- vector <STSubRecvMessage> vt_subrecvmessage;
- }STRecvMessage, *pSTRecvMessage;
- #endif
- /************************************************************************/
- /* Depot元素制定 */
- /************************************************************************/
- // 物理特性;
- typedef struct _STDepotPhysical
- {
- int iRate; // 1.波特率;
- int iDBit; // 2.数据位;
- int iSBit; // 3.停止位;
- int iPaty; // 4.校验位;
- int iIntl; // 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...)
- //_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[80]; // 5.单元类型;
- char szProtocol[MAX_PROTOCOL]; // 6.设备协议;
- }STDeviceDocument,*pSTDeviceDocument;
- // 命令格式;
- typedef struct _STCommandFormat
- {
- char szName[50]; // 1.关键字名称;
- char szLen[10]; // 2.长度;
- char szData[256]; // 3.内容;
- char szType[2]; // 4.类型;
- int nDatalen; // 5.记录实际串长度;
- }STCommandFormat,*pSTCommandFormat;
- // 命令元素;
- typedef struct _STCommandStyle
- {
- char szName[50];
- char szData[256];
- int nDatalen; // 记录实际串长度;
- }STCommandStyle, *pSTCommandStyle;
- typedef struct _STCommandTable
- {
- vector <STCommandStyle> vt_commandstyle;
- char szMark[MAX_MARKSIZE];
- char szTip[MAX_TIPSIZE];
- }STCommandTable, *pSTCommandTable;
- // 整个元素;
- typedef struct _STDepotObject
- {
- char szName[60]; // 0.设备名称;
- char szSID[MAX_STATICID]; // 1.静态ID号;
- STDepotPhysical st_depotphy; // 2.物理特性;
- STDeviceDocument st_depotdoc; // 3.文档记录;
- int ByteCount; // 4.格式串最大长度;
- vector <STCommandFormat> vt_commandformat; // 5.命令格式;
- vector <STCommandTable> 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
- {
- char szSCMD[255];
- char szMark[MAX_MARKSIZE];
- char szTip[90];
- }STRunCommand, *pSTRunCommand;
- typedef struct _STRunDevice
- {
- int iAddr;
- char szUName[MAX_CUSTOMNAME];
- vector <STRunCommand> vt_rundevice;
- }STRunDevice, *pSTRunDevice;
- typedef struct _STRunPhysical
- {
- //int iPort; // 0.串口号;
- //STDepotPhysical st_depotphy;
- int iRate; // 1.波特率;
- int iDBit; // 2.数据位;
- int iSBit; // 3.停止位;
- int iPaty; // 4.校验位;
- int iIntl; // 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;
- // 运行的设备;
- 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;
- /************************************************************************/
- /* RunObject元素制定 */
- /************************************************************************/
- #endif
|