Struct_Def_b1.h 6.4 KB

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