ReDoComm.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. #ifndef _DO_COMM_H_
  2. #define _DO_COMM_H_
  3. //------------------------------------------------------------------------------
  4. //--- common define ---
  5. //------------------------------------------------------------------------------
  6. #define CMP_ETH_IP_HEAD "192.168.100"
  7. #define DoIPAddress "192.168.100.1"
  8. #define DoTcpPort 36000
  9. #define IMAGE_FILE_PATH "../mnt"
  10. #define TFTP_PULL_CMD "tftp"
  11. #define SIGTERM_MSG "SegmentFault.~~~~\n"
  12. #define MAX_REGISTER_NUM 30
  13. #define CHECK_NETWORK_FAIL_COUNT 10
  14. #define CONNECT_SERVER_FAIL_COUNT 5
  15. #define WARNING_CODE_SIZE 6
  16. #define MAX_VOLTAGE 10000
  17. #define MAX_CURRENCY 5000
  18. #define MAX_POWER 3600
  19. #define DISPENSER_INIT_SUCC 0x01
  20. #define DISPENER_INIT_FAIL 0x02
  21. #define DISPENSER_SOCKET_RECONN 0x03
  22. #define VERSION_BUF_SIZE 32
  23. #define PRICES_UNIT 0.01
  24. #define PASS (1)
  25. #define FAIL (-1)
  26. #define YES (1)
  27. #define NO (0)
  28. #define NO_DEFINE 255
  29. #define LOOP_RETRY_TIME 1000 //1 second
  30. #define NORMAL 0
  31. #define ABNORMAL 1
  32. //------------------------------------------------------------------------------
  33. //--- dispenser ID ---
  34. //------------------------------------------------------------------------------
  35. #define ID_RESERVER 0x00
  36. #define ID_OF_DISPENSER 0x01
  37. #define ID_REGISTER 0xFF
  38. //------------------------------------------------------------------------------
  39. //--- dispenser operation ---
  40. //------------------------------------------------------------------------------
  41. #define OP_READ_DATA 0x01
  42. #define OP_WRITE_DATA 0x02
  43. #define OP_WAIT_RESPONSE 0x03
  44. //------------------------------------------------------------------------------
  45. //--- dispenser register ---
  46. //------------------------------------------------------------------------------
  47. #define REG_MODEL_NAME 0x01
  48. #define REG_CONNECTOR_ID 0x02
  49. #define REG_POWER_CABINET_STATUS 0x03
  50. #define REG_DISPENSER_STATUS 0x04
  51. #define REG_CHARGING_CAP 0x05
  52. #define REG_CHARGING_TARGET 0x06
  53. #define REG_SOFTWARE_UPDATE 0x07
  54. #define REG_PLUG_IN_STATE 0x08
  55. #define REG_CONNECTOR_STATE 0x09
  56. #define REG_USER_ID 0x0A
  57. #define REG_CHARGING_PERMISSION 0x0B
  58. #define REG_MISC_CONTROL 0X0C
  59. #define REG_REPORT_CSU_VERSION 0X0D
  60. #define REG_REPORT_OTHER_VERSION 0X0E
  61. #define REG_PRESENT_CHARGING_INFO 0X0F
  62. #define REG_QRCODE_URL_INFO 0X10
  63. #define REG_WAIT_PLUG_IT_STATE 0x11
  64. //------------------------------------------------------------------------------
  65. //--- dispenser result ---
  66. //------------------------------------------------------------------------------
  67. #define COMMAND_RESULT_OK 0x01
  68. #define COMMAND_RESULT_NG 0x02 //wait state
  69. //------------------------------------------------------------------------------
  70. //--- power cabinet misc status code ---
  71. //------------------------------------------------------------------------------
  72. #define MISC_ST_MISC_CMD "B40001"
  73. #define MISC_ST_VERSION "B40999"
  74. //------------------------------------------------------------------------------
  75. //--- power cabinet misc command ---
  76. //------------------------------------------------------------------------------
  77. #define MISC_CMD_CONNECOTOR_TIMEOUT 0X0001
  78. #define MISC_CMD_OPERATIVE_STATE 0X0002
  79. #define MISC_CMD_DEFAULT_PRICES 0x0003
  80. #define MISC_CMD_DEFAULT_CURRENCY 0x0004
  81. #define MISC_CMD_ACCOUNT_BALANCE 0x0005
  82. #define MISC_CMD_HARDWARE_REBOOT 0x0101
  83. #define MISC_CMD_SOFTWARE_RESTART 0x0102
  84. #define MISC_CMD_REMOTE_START_CHARGING 0x0103
  85. #define ST_UPDATE_FIRMWARE 0x01
  86. #define ST_NO_UPDATE_FIRMWARE 0x02
  87. //------------------------------------------------------------------------------
  88. #pragma pack(push)
  89. #pragma pack(1)
  90. typedef struct StDoCommGlobalVar {
  91. uint8_t SeqNum;
  92. uint8_t DisConnCount;
  93. uint8_t ConnectorID[2]; //keep from power cabinet
  94. uint8_t MiscCmd;
  95. uint8_t Reserved[4];
  96. } DoCommGblData;
  97. typedef struct StCommnadHead {
  98. uint8_t SeqNum; //sequence number 0 ~ 255
  99. uint8_t ID; //0: Reserved, 0x01 ~ 0xFE: connector ID, 0xFF: exists in register 1 and register 2
  100. uint8_t OP; //0x01: read, 0x02: write, 0x03: response from power cabinet
  101. uint8_t DataLen; //raw data Length
  102. } CmdHead;
  103. typedef struct StCommandData {
  104. uint8_t Register; /* 0x01: dispenser model name (maximum 32 bytes) and the value of dispenser switch
  105. 0x02: The ID to connector equipped at dispenser
  106. 0x03: Power cabinet status
  107. 0x04: Dispenser status
  108. 0x05: The charging capacity of each connector
  109. 0x06: The required voltage and current during charging
  110. 0x07: The indicator of software update to dispenser
  111. 0x08: Indicate whether the connector is plug-in or not
  112. 0x09: Indicate the connector state
  113. 0x0A: The user ID can be RFID card number, EVCCID, etc.
  114. 0x0B: Charging permission from power cabinet to dispenser
  115. */
  116. uint8_t Data[250];
  117. } CmdData;
  118. typedef struct StResultData {
  119. uint8_t Register; /* 0x01: dispenser model name (maximum 32 bytes) and the value of dispenser switch
  120. 0x02: The ID to connector equipped at dispenser
  121. 0x03: Power cabinet status
  122. 0x04: Dispenser status
  123. 0x05: The charging capacity of each connector
  124. 0x06: The required voltage and current during charging
  125. 0x07: The indicator of software update to dispenser
  126. 0x08: Indicate whether the connector is plug-in or not
  127. 0x09: Indicate the connector state
  128. 0x0A: The user ID can be RFID card number, EVCCID, etc.
  129. 0x0B: Charging permission from power cabinet to dispenser
  130. */
  131. uint8_t Result;
  132. uint8_t Data[249];
  133. } ResultData;
  134. typedef struct StCsuCmdPkt {
  135. CmdHead Head;
  136. CmdData Data;
  137. } CsuCmdPkt;
  138. typedef struct StCsuResultPkt {
  139. CmdHead Head;
  140. ResultData Data;
  141. } CsuResultPkt;
  142. typedef struct StMiscCommand {
  143. uint16_t CMD;
  144. uint8_t Value[4];
  145. } MiscCommand;
  146. typedef struct StPresentChargingInfo {
  147. int EvBatterySoc; // 0~100%
  148. int RemainChargingDuration; // second
  149. float PresentChargingVoltage; //0~6553.5 volt
  150. float PresentChargingCurrent; //0~6553.5 amp
  151. } PreChargingInfo;
  152. typedef struct StSoftwareUpdInfo {
  153. uint8_t UpdateState; //1:update , 2: not update
  154. uint8_t ImgName[248];
  155. } SoftwareUpdInfo;
  156. typedef struct StCapabilityInfo {
  157. uint16_t OutputVoltage;
  158. uint16_t OutputCurrent;
  159. uint16_t OutputPower;
  160. uint8_t Reserved[2];
  161. } CapabilityInfo;
  162. typedef struct StAccountInfo {
  163. uint8_t Currency;
  164. int UserPrices;
  165. int TotalCost;
  166. int Balance;
  167. uint8_t Reserved[3];
  168. } AccountInfo;
  169. #pragma pack(pop)
  170. #endif /* _DO_COMM_H_ */