Struct_Def.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. #if !defined(__INCLUDE_HEAD_ZEROT__)
  2. #define __INCLUDE_HEAD_ZEROT__
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. const int MAX_SENDSIZE = 1024;
  7. const int MAX_RECVSIZE = 1024;
  8. const int MAX_STATICID = 60; // 静态ID;
  9. const int MAX_FACTORY = 60; // 产家;
  10. const int MAX_DEVICE = 120; // 设备名称;
  11. const int MAX_MARKSIZE = 50; // 命令Mark特征码;
  12. const int MAX_PROTOCOL = 120; // 协议名称;
  13. const int MAX_TIPSIZE = 256; // 命令说明;
  14. const int MAX_CUSTOMNAME = 120; // 自定义设备名称;
  15. const int MAX_CLASS = 120; // 设备系列;
  16. const int MAX_DEVICETYPE = 90; // 设备类型;
  17. const int MAX_CHECKSIZE = 60; // 校验符号长度;
  18. enum CommandType
  19. {
  20. CT_SET,
  21. CT_READ
  22. };
  23. // 是否应该包含地址?
  24. typedef struct _STSendCommand
  25. {
  26. //int iType; // 读写类型; == 0 读请求, == 1 写请求;
  27. //int iSNum; // 发送的顺序(默认 -1,大于0为特殊命令);这里最好是按发送优先级别插入,不然这个成员要判断才能知道哪个是最优先的;
  28. int iPort; // 成员port在某些地方才用到;有些地方可以进行忽略;
  29. int iAddr;
  30. bool bRecv; // 是否有返回数据(或是否保存);
  31. DWORD dwSID; // 记录该结构体的ID号(自增效果);
  32. int iSLen; // 命令实际长度;
  33. char szMark[MAX_MARKSIZE]; // 命令特征码;
  34. char szCheck[MAX_CHECKSIZE]; // 校验符号 ;
  35. BYTE bySend[MAX_SENDSIZE]; // 配置好的命令串;
  36. //_STSendCommand(){ delete []szMark;szMark = NULL; delete [](char*)bySend;bySend=NULL;}
  37. }STSendCommand, *pSTSendCommand;
  38. // 是否应该包含地址?
  39. #if 1
  40. typedef struct _STRecvMessage
  41. {
  42. int iPort; // 串口;
  43. int iAddr; // 地址 ;
  44. DWORD dwSID; // 记录该结构体的ID号(自增效果);
  45. int iRLen; // 实际接收字节;
  46. char szMark[MAX_MARKSIZE]; // 命令特征码;
  47. char szCheck[MAX_CHECKSIZE]; // 校验符号 ;
  48. BYTE byRecv[MAX_RECVSIZE]; // 用于存放返回数据;
  49. //_STRecvMessage(){ delete []szMark;szMark =NULL; delete [](char*)byRecv;byRecv=NULL;}
  50. }STRecvMessage, *pSTRecvMessage;
  51. #else
  52. typedef struct _STSubRecvMessage
  53. {
  54. DWORD dwSID; // 记录接收对应的命令号;
  55. int iRLen; // 实际接收字节;
  56. char szMark[MAX_MARKSIZE]; // 对应的命令特征码;
  57. char szCheck[MAX_CHECKSIZE]; // 校验符号 ;
  58. BYTE byRecv[MAX_RECVSIZE]; // 用于存放返回数据;
  59. //_STSubRecvMessage(){ delete []szMark;szMark =NULL; delete [](char*)byRecv;byRecv=NULL;}
  60. }STSubRecvMessage, *pSTSubRecvMessage;
  61. typedef struct _STRecvMessage
  62. {
  63. int iPort; // 串口;
  64. int iAddr; // 地址 ;
  65. char szCheck[MAX_CHECKSIZE]; // 校验符号 ;
  66. vector <STSubRecvMessage> vt_subrecvmessage;
  67. }STRecvMessage, *pSTRecvMessage;
  68. #endif
  69. /************************************************************************/
  70. /* Depot元素制定 */
  71. /************************************************************************/
  72. // 物理特性;
  73. typedef struct _STDepotPhysical
  74. {
  75. int iRate; // 1.波特率;
  76. int iDBit; // 2.数据位;
  77. int iSBit; // 3.停止位;
  78. int iPaty; // 4.校验位;
  79. int iIntl; // 5.超时值;
  80. int iRsTm; // 5.响应时间;
  81. char szLineType[90]; // 6.接线类型;(RS232,RS485,RJ45)
  82. char szComType[90]; // 7.通信类型;(RS232电总,RS485电总,RTU,ASCII,SNMP)
  83. char szPinDef[90]; // 8.针脚定义;(RS232:235-325,RS485:23-32...)
  84. //_STDepotPhysical(){ delete []szLineType;szLineType =NULL; delete []szComType;szComType=NULL;delete []szPinDef;szPinDef=NULL;}
  85. }STDepotPhysical,*pSTDepotPhysical;
  86. // 文档记录;
  87. typedef struct _STDeviceDocument
  88. {
  89. char szFactory[MAX_FACTORY]; // 1.生产厂家;
  90. char szdeviceType[MAX_DEVICETYPE]; // 2.设备类型;
  91. char szdeviceClass[MAX_CLASS]; // 3.设备系列;
  92. char szdeviceName[MAX_DEVICE]; // 4.设备名称;
  93. char szUnitType[120]; // 5.单元类型;
  94. char szProtocol[MAX_PROTOCOL]; // 6.设备协议;
  95. }STDeviceDocument,*pSTDeviceDocument;
  96. // 命令格式;
  97. typedef struct _STCommandFormat
  98. {
  99. char szName[50]; // 1.关键字名称;
  100. char szLen[30]; // 2.长度;
  101. char szData[256]; // 3.内容;
  102. char szType[10]; // 4.类型;
  103. int nDatalen; // 5.记录实际串长度;
  104. }STCommandFormat,*pSTCommandFormat;
  105. // 命令元素;
  106. typedef struct _STCommandStyle
  107. {
  108. char szName[90];
  109. char szData[1024];
  110. int nDatalen; // 记录实际串长度;
  111. }STCommandStyle, *pSTCommandStyle;
  112. typedef struct _STCommandTable
  113. {
  114. BOOL bRecv; // 命令是否保存返回;
  115. char szMark[MAX_MARKSIZE];
  116. char szTip[MAX_TIPSIZE];
  117. vector <STCommandStyle> vt_commandstyle;
  118. }STCommandTable, *pSTCommandTable;
  119. // 整个元素;
  120. typedef struct _STDepotObject
  121. {
  122. char szName[120]; // 0.设备名称;
  123. char szSID[MAX_STATICID]; // 1.静态ID号;
  124. STDepotPhysical st_depotphy; // 2.物理特性;
  125. STDeviceDocument st_depotdoc; // 3.文档记录;
  126. int ByteCount; // 4.格式串最大长度;
  127. vector <STCommandFormat> vt_commandformat; // 5.命令格式;
  128. vector <STCommandTable> vt_commandtable; // 6.具体命令;
  129. }STDepotObject, *pSTDepotObject;
  130. /************************************************************************/
  131. /* Depot元素制定 */
  132. /************************************************************************/
  133. /************************************************************************/
  134. /*
  135. 静态ID号说明 :
  136. 静态ID号由4段组成:
  137. A:设备的属类;(eg.属哪大类,UPS或空调或电量仪....);
  138. B:设备产家;(eg:艾默生或梅兰或泓格....);
  139. C:设备系列:(eg:艾默生Nx系列)
  140. D:设备型号;(eg:具体到艾默生UL33-0620L);
  141. 静态ID号在另一文档里记录,与depotobject.xml里的所有设备映射;
  142. 而设备的命令Mark特征码,则由 <静态ID号+本身Mark+地址位>
  143. 所以,Mark特征码是6段;
  144. */
  145. /************************************************************************/
  146. /************************************************************************/
  147. /* RunObject元素制定 */
  148. /************************************************************************/
  149. typedef struct _STRunCommand
  150. {
  151. BOOL bRecv;
  152. char szSCMD[255];
  153. char szMark[MAX_MARKSIZE];
  154. char szTip[256];
  155. }STRunCommand, *pSTRunCommand;
  156. typedef struct _STRunDevice
  157. {
  158. int iPort; // 该串口号,不在xml上显示,只用于程序计算;
  159. int iAddr;
  160. char szUName[MAX_CUSTOMNAME];
  161. char szCheck[MAX_CHECKSIZE]; // 校验符号 ;
  162. char szSID[MAX_STATICID];
  163. vector <STRunCommand> vt_rundevice;
  164. }STRunDevice, *pSTRunDevice;
  165. typedef struct _STRunPhysical
  166. {
  167. int iRate; // 1.波特率;
  168. int iDBit; // 2.数据位;
  169. int iSBit; // 3.停止位;
  170. int iPaty; // 4.校验位;
  171. int iIntl; // 5.超时值;
  172. int iRsTm; // 5.响应时间;
  173. char szLineType[50]; // 6.接线类型;(RS232,RS485,RJ45)
  174. char szComType[50]; // 7.通信类型;(RS232电总,RS485电总,RTU,ASCII,SNMP)
  175. char szPinDef[50]; // 8.针脚定义;(RS232:235-325,RS485:23-32...)
  176. }STRunPhysical, *pSTRunPhysical;
  177. #if 0
  178. // 运行时设备库元素;
  179. typedef struct _STRunObject
  180. {
  181. char szName[30]; // 1.设备名;
  182. char szSID[MAX_STATICID]; // 2.静态ID号;
  183. int iPort; // 3.串口号;
  184. STRunPhysical st_runphy; // 4.物理特性;
  185. STDeviceDocument st_rundoc; // 5.文档记录;
  186. STRunDevice st_rundevice; // 6.详细命令;
  187. }STRunObject, *pSTRunObject;
  188. #else
  189. // 新:运行时设备库元素;
  190. typedef struct _STRunObject
  191. {
  192. int iPort; // 1.串口号;
  193. int iCount; // 2.设备数;
  194. STRunPhysical st_runphy; // 3.串口属性;
  195. STRunDevice st_rundevice; // 4.设备;
  196. }STRunObject, *pSTRunObject;
  197. #endif
  198. typedef struct _STRunComInfo
  199. {
  200. int iPort;
  201. int iCount;
  202. STRunPhysical tRunPhysical;
  203. vector<STSendCommand> vtSendCommand;
  204. }STRunComInfo,*pSTRunComInfo;
  205. /************************************************************************/
  206. /* RunObject元素制定 */
  207. /************************************************************************/
  208. #endif