constants.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. const MAX_MODBUS_ADDRESS = 0xFFFF
  2. const MAX_STORAGE_ADDRESS = 0xFFFFFFFF
  3. const MAX_PARAMETER_GROUP_ITEMS = 256
  4. const DEFAULT_TEXT_BYTE_LENGTH = 32
  5. const MAX_TEXT_BYTE_LENGTH = 0xFFFF
  6. const REGISTER_TYPE_OPTIONS = [
  7. {
  8. functionCode: 0x03,
  9. key: 'holding',
  10. label: '保持寄存器',
  11. writable: true
  12. },
  13. {
  14. functionCode: 0x01,
  15. key: 'coil',
  16. label: '线圈',
  17. writable: true
  18. },
  19. {
  20. functionCode: 0x02,
  21. key: 'discrete',
  22. label: '离散输入状态',
  23. writable: false
  24. },
  25. {
  26. functionCode: 0x04,
  27. key: 'input',
  28. label: '输入寄存器',
  29. writable: false
  30. }
  31. ]
  32. const DATA_TYPE_OPTIONS = [
  33. {
  34. byteLength: 1,
  35. key: 'int8_t',
  36. label: 'int8_t',
  37. kind: 'number',
  38. wordCount: 1
  39. },
  40. {
  41. byteLength: 1,
  42. key: 'uint8_t',
  43. label: 'uint8_t',
  44. kind: 'number',
  45. wordCount: 1
  46. },
  47. {
  48. byteLength: 2,
  49. key: 'int16_t',
  50. label: 'int16_t',
  51. kind: 'number',
  52. wordCount: 1
  53. },
  54. {
  55. byteLength: 2,
  56. key: 'uint16_t',
  57. label: 'uint16_t',
  58. kind: 'number',
  59. wordCount: 1
  60. },
  61. {
  62. byteLength: 4,
  63. key: 'int32_t',
  64. label: 'int32_t',
  65. kind: 'number',
  66. wordCount: 2
  67. },
  68. {
  69. byteLength: 4,
  70. key: 'uint32_t',
  71. label: 'uint32_t',
  72. kind: 'number',
  73. wordCount: 2
  74. },
  75. {
  76. byteLength: 4,
  77. key: 'float',
  78. label: 'float',
  79. kind: 'number',
  80. wordCount: 2
  81. },
  82. {
  83. byteLength: 8,
  84. key: 'double',
  85. label: 'double',
  86. kind: 'number',
  87. wordCount: 4
  88. },
  89. {
  90. byteLength: 8,
  91. key: 'int64_t',
  92. label: 'int64_t',
  93. kind: 'number',
  94. wordCount: 4
  95. },
  96. {
  97. byteLength: 8,
  98. key: 'uint64_t',
  99. label: 'uint64_t',
  100. kind: 'number',
  101. wordCount: 4
  102. },
  103. {
  104. byteLength: 16,
  105. key: 'int128_t',
  106. label: 'int128_t',
  107. kind: 'number',
  108. wordCount: 8
  109. },
  110. {
  111. byteLength: 16,
  112. key: 'uint128_t',
  113. label: 'uint128_t',
  114. kind: 'number',
  115. wordCount: 8
  116. },
  117. {
  118. byteLength: 32,
  119. key: 'int256_t',
  120. label: 'int256_t',
  121. kind: 'number',
  122. wordCount: 16
  123. },
  124. {
  125. byteLength: 32,
  126. key: 'uint256_t',
  127. label: 'uint256_t',
  128. kind: 'number',
  129. wordCount: 16
  130. },
  131. {
  132. byteLength: DEFAULT_TEXT_BYTE_LENGTH,
  133. key: 'text',
  134. label: '文本',
  135. kind: 'text',
  136. maxByteLength: MAX_TEXT_BYTE_LENGTH,
  137. wordCount: DEFAULT_TEXT_BYTE_LENGTH / 2
  138. },
  139. {
  140. byteLength: 2,
  141. key: 'hex',
  142. label: 'HEX',
  143. kind: 'hex',
  144. wordCount: 1
  145. },
  146. {
  147. byteLength: 1,
  148. key: 'raw',
  149. label: '未配置',
  150. kind: 'raw',
  151. wordCount: 1
  152. }
  153. ]
  154. const DEFAULT_REGISTER_TYPE = REGISTER_TYPE_OPTIONS[0].key
  155. const DEFAULT_DATA_TYPE = 'uint16_t'
  156. const GROUP_LAYOUT_REGISTER = 'register'
  157. const GROUP_LAYOUT_STRUCT = 'struct'
  158. const BYTE_ADDRESS_MEMORY_AREAS = ['ADDR32', 'BIT', 'CODE', 'DATA', 'IDATA', 'XDATA']
  159. const SOURCE_REGISTER_FIELDS = [
  160. 'conversionFormula',
  161. 'enumName',
  162. 'enumOptions',
  163. 'sourceAddress',
  164. 'sourceAddressByteLength',
  165. 'sourceAddressText',
  166. 'sourceAddressWidth',
  167. 'sourceArrayDimensions',
  168. 'sourceArrayIndex',
  169. 'sourceArrayIndexPath',
  170. 'sourceByteLength',
  171. 'sourceDefinitionName',
  172. 'sourceElementByteLength',
  173. 'sourceElementCount',
  174. 'sourceElementType',
  175. 'sourceBitOffset',
  176. 'sourceBitWidth',
  177. 'sourceEntryKind',
  178. 'sourceInstanceName',
  179. 'sourceMemoryArea',
  180. 'sourceMemoryClass',
  181. 'sourceSymbolName',
  182. 'sourceSymbolType',
  183. 'sourceValueType'
  184. ]
  185. const STRUCT_REGISTER_FIELDS = [
  186. 'bitOffset',
  187. 'bitWidth',
  188. 'byteStart',
  189. 'isPlaceholderByteField',
  190. 'isBitField',
  191. 'structByteLength'
  192. ]
  193. const SOURCE_GROUP_FIELDS = [
  194. 'addressUnit',
  195. 'codeInfoContext',
  196. 'sourceAddress',
  197. 'sourceAddressByteLength',
  198. 'sourceAddressText',
  199. 'sourceAddressWidth',
  200. 'sourceArrayDimensions',
  201. 'sourceByteLength',
  202. 'sourceDefinitionName',
  203. 'sourceElementByteLength',
  204. 'sourceElementCount',
  205. 'sourceElementType',
  206. 'sourceEntryKind',
  207. 'sourceInstanceName',
  208. 'sourceMemoryArea',
  209. 'sourceMemoryClass',
  210. 'sourceSegment',
  211. 'sourceSegmentModule',
  212. 'sourceSymbolName',
  213. 'sourceSymbolType',
  214. 'sourceValueType'
  215. ]
  216. module.exports = {
  217. BYTE_ADDRESS_MEMORY_AREAS,
  218. DATA_TYPE_OPTIONS,
  219. DEFAULT_DATA_TYPE,
  220. DEFAULT_REGISTER_TYPE,
  221. DEFAULT_TEXT_BYTE_LENGTH,
  222. GROUP_LAYOUT_REGISTER,
  223. GROUP_LAYOUT_STRUCT,
  224. MAX_MODBUS_ADDRESS,
  225. MAX_STORAGE_ADDRESS,
  226. MAX_PARAMETER_GROUP_ITEMS,
  227. MAX_TEXT_BYTE_LENGTH,
  228. REGISTER_TYPE_OPTIONS,
  229. SOURCE_GROUP_FIELDS,
  230. SOURCE_REGISTER_FIELDS,
  231. STRUCT_REGISTER_FIELDS
  232. }