Module_EvComm.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. * Module_EvComm.h
  3. *
  4. * Created on: 2020年9月14日
  5. * Author: Wendell
  6. */
  7. #ifndef MODULE_EVCOMM_H_
  8. #define MODULE_EVCOMM_H_
  9. // server protocol setting
  10. #define SOCKET_SERVER_IP "192.168.0.10"
  11. #define PACKET_HEADER_LENGTH 4
  12. #define MAXIMUM_PAYLOAD_LENGTH 249 // 249 bytes
  13. #define TCP_LISTEN_PORT 36000
  14. #define SOCKET_RECEIVE_INTERVAL 10 // 10ms
  15. #define DISPENSER_SOCKET_TIMEOUT 10000 // 10s
  16. // client protocol setting
  17. #define DISPENSER_MODEL_NAME_RESEND 3000 // 3s
  18. #define DISPENSER_CONNECTOR_RESEND 3000 // 3s
  19. #define CABINET_STATUS_REQUEST_RESEND 1000 // 1s
  20. #define CHARGING_CAPABILITY_RESEND 1000 // 1s
  21. #define IP_CONFLICTED_TIME 1000 // 1s
  22. // socket setting
  23. #define CONNECTION_LIMIT 5
  24. #define MAXIMUM_CONNECT_QUANTITY 4
  25. #define CCS_MAX_PHYSICAL_VOLTAGE 9500
  26. #define CCS_NATURAL_MAX_CURRENT 2000
  27. #define CCS_LIQUID_MAX_CURRENT 5000
  28. #define CCS_NATURAL_REMA_MAX_CURRENT 3000
  29. #define CHA_MAX_PHYSICAL_VOLTAGE 5000
  30. #define CHA_NATURAL_MAX_CURRENT 2000
  31. #define GBT_MAX_PHYSICAL_VOLTAGE 7500
  32. #define GBT_NATURAL_MAX_CURRENT 2500
  33. #define AUTO_GUN_SELECTION 0xFF
  34. struct Message
  35. {
  36. int size;
  37. unsigned char buffer[2048];
  38. };
  39. enum HEADER_OP
  40. {
  41. _Header_Read = 0x01,
  42. _Header_Write = 0x02,
  43. _Header_Response = 0x03,
  44. };
  45. enum PAYLOAD_REGISTER
  46. {
  47. _Reg_Dispenser_Model_Name = 0x01,
  48. _Reg_Connector_ID = 0x02,
  49. _Reg_Power_Cabinet_Status = 0x03,
  50. _Reg_Dispenser_Status = 0x04,
  51. _Reg_Charging_Capability = 0x05,
  52. _Reg_Charging_Target = 0x06,
  53. _Reg_Software_Update = 0x07,
  54. _Reg_Plug_In_Status = 0x08,
  55. _Reg_Connector_State = 0x09,
  56. _Reg_User_ID = 0x0A,
  57. _Reg_Charging_Permission = 0x0B,
  58. _Reg_Misc_Control = 0x0C,
  59. _Reg_Report_Csu_Version = 0x0D,
  60. _Reg_Report_Other_Version = 0x0E,
  61. _Reg_Charging_Info = 0x0F,
  62. _Reg_Charger_System_Id = 0x10,
  63. _Reg_WaitPlugIn = 0x11,
  64. _Reg_GroundFaultDetection = 0x12,
  65. _Reg_Get_Cabinet_CSU_Version = 0x13,
  66. _Reg_Get_Cabinet_Other_Version = 0x14,
  67. _Reg_Get_Psu_Quantity = 0x15,
  68. _Reg_Get_Psu_Version = 0x16,
  69. _Reg_Get_Reservation = 0x17,
  70. _Reg_Dispenser_Request = 0x18,
  71. _Reg_RemoteStartNoIDState = 0x19,
  72. _Reg_RefundAmount = 0x1A,
  73. _Reg_PrepaymentInfo = 0x1B,
  74. _Reg_PaymentFailReason = 0x1C,
  75. _Reg_ConnectorQRCode = 0x1D,
  76. _Reg_StationInfo = 0x1E,
  77. _Reg_DeductResult = 0x1F,
  78. };
  79. enum Response_Result
  80. {
  81. _R_OK = 0x01,
  82. _R_NG = 0x02,
  83. };
  84. enum Response_Upgrade
  85. {
  86. _R_NeedUpgrade = 0x01,
  87. _R_NoUpgrade = 0x02,
  88. };
  89. enum PlugIn_Status
  90. {
  91. _PIS_UnPlugged = 0x00,
  92. _PIS_PluggedIn = 0x01,
  93. };
  94. enum Connector_Remote_Status
  95. {
  96. _CRS_Idle = 0x00,
  97. _CRS_Preparing = 0x01,
  98. _CRS_Charging = 0x02,
  99. _CRS_Terminating = 0x03,
  100. _CRS_Alarm = 0x04,
  101. };
  102. typedef enum
  103. {
  104. _DAS_NotAllowed = 0x00,
  105. _DAS_Allowed = 0x01,
  106. _DAS_Wait = 0x02,
  107. }DispenserAck_Status;
  108. enum Permission_Status
  109. {
  110. _PS_NotPermitted = 0x00,
  111. _PS_Permitted = 0x01,
  112. };
  113. enum Accept_Status
  114. {
  115. _AS_Reject = 0x00,
  116. _AS_Accept = 0x01,
  117. };
  118. struct HEADER_STRUCTURE
  119. {
  120. unsigned char se;
  121. unsigned char id;
  122. unsigned char op;
  123. unsigned char len;
  124. };
  125. struct PAYLOAD_STRUCTURE
  126. {
  127. unsigned char reg;
  128. unsigned char data[MAXIMUM_PAYLOAD_LENGTH];
  129. };
  130. struct PACKET_STRUCTURE
  131. {
  132. struct HEADER_STRUCTURE Header;
  133. struct PAYLOAD_STRUCTURE Payload;
  134. }Packet_Structure;
  135. enum DispenserStatus
  136. {
  137. _DS_None = 0x00,
  138. _DS_Identification = 0x01,
  139. _DS_Idle = 0x02,
  140. _DS_Alarm = 0x03,
  141. _DS_Charging = 0x04,
  142. _DS_Timeout = 0x05,
  143. };
  144. enum ConnectionStatus
  145. {
  146. _CNS_FREE = 0x00,
  147. _CNS_WaitModelName = 0x01,
  148. _CNS_DispenserMatched = 0x02,
  149. };
  150. enum LcmPage
  151. {
  152. _LCM_None = 0x00,
  153. _LCM_Page_RemoteStartNoID = 0x01,
  154. };
  155. struct MISC_COMMAND
  156. {
  157. unsigned short Command;
  158. unsigned int Value;
  159. };
  160. enum MiscCommand
  161. {
  162. _MiscCmd_None = 0x0000,
  163. _MiscCmd_ConnectorTimeout = 0x0001,
  164. _MiscCmd_ChangeOperative = 0x0002,
  165. _MiscCmd_DefaultPrice = 0x0003,
  166. _MiscCmd_Currency = 0x0004,
  167. _MiscCmd_AccountBalance = 0x0005,
  168. _MiscCmd_BackendStatus = 0x0006,
  169. _MiscCmd_EthernetStatus = 0x0007,
  170. _MiscCmd_WiFiStatus = 0x0008,
  171. _MiscCmd_4GStatus = 0x0009,
  172. _MiscCmd_Billing = 0x000A,
  173. _MiscCmd_StopButton = 0x000B,
  174. _MiscCmd_AuthDisable = 0x000C,
  175. _MiscCmd_EVCCIDEnable = 0x000D,
  176. _MiscCmd_LEDIntensity = 0x000E,
  177. _MiscCmd_AcContactor = 0x000E,
  178. _MiscCmd_TimeOffset = 0x0010,
  179. _MiscCmd_HardwareReboot = 0x0101,
  180. _MiscCmd_SoftwareRestart = 0x0102,
  181. _MiscCmd_RemoteStart = 0x0103,
  182. _MiscCmd_RemoteStop = 0x0104,
  183. _MiscCmd_UnlockStop = 0x0105,
  184. _MiscCmd_Reservation = 0x0106,
  185. _MiscCmd_ChangeLcmPage = 0x0107,
  186. _MiscCmd_QRCodeRequest = 0x0108,
  187. _MiscCmd_StationInfo = 0x0109,
  188. _MiscCmd_FinalCost = 0x010A,
  189. _MiscCmd_LineStatus = 0x010B,
  190. };
  191. enum DispenserMisc_Request
  192. {
  193. _DisReq_None = 0x0000,
  194. _DisReq_ChargingCancel = 0x0001,
  195. };
  196. typedef struct
  197. {
  198. unsigned char ResponseResult; // 1: OK, 2 NG
  199. unsigned short MaxOuputVoltage; // unit = 0.1 volt
  200. unsigned short MaxOuputCurrent; // unit = 0.1 Amp
  201. unsigned short MaxOuputPower; // unit = 0.1 kW
  202. unsigned char Currency; // currency index
  203. unsigned int UserPrice; // unit = 0.01 dollar
  204. unsigned int TotalCost; // unit = 0.01 dollar
  205. int AccountBalance; // unit = 0.01 dollar
  206. int CostDiscount; // unit = 0.01 dollar
  207. int TransactionId; // unit = 0.01 dollar
  208. char CurrencyString[4];
  209. }ChargingCapabilityResponseInfo;
  210. enum WaitPlug
  211. {
  212. _WaitPlug_None = 0x0,
  213. _WaitPlug_Start = 0x1,
  214. };
  215. enum GroundFaultDetection
  216. {
  217. _GFD_Disable = 0x0,
  218. _GFD_Enable = 0x1,
  219. };
  220. typedef struct
  221. {
  222. char ChargingDate[32]; // charging date in string format
  223. char Prepayment[32]; // prepayment in string format
  224. char ActualCost[32]; // actual cost in string format
  225. char RefundAmount[32]; // refund amount in string format
  226. }RefundResponse;
  227. typedef struct
  228. {
  229. unsigned char PaymentType;
  230. char TopUp[32]; // top up in string format
  231. char AccountAmount[32]; // account amount in string format
  232. char Prepayment[32]; // prepayment in string format
  233. char Balance[32]; // balance in string format
  234. }PrepaymentResponseInfo;
  235. typedef struct
  236. {
  237. unsigned char ReasonIndex; // index start from 1 ~ 200
  238. char Reason[128]; // reason in string format
  239. }PaymentFailResponse;
  240. #endif /* MODULE_EVCOMM_H_ */