Module_EvComm.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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_U_E_MAX_CURRENT 2000
  27. #define CCS_LIQUID_V_F_MAX_CURRENT 5000
  28. #define CCS_LIQUID_80_DERATING_1_CUR 4000
  29. #define CCS_LIQUID_85_DERATING_2_CUR 3000
  30. #define CCS_PANTOGRAPH_MAX_CURRENT 5000
  31. #define CCS_NATURAL_T_D_MAX_CURRENT 3000
  32. #define CCS_NATURAL_I_Q_BOOST_CURRENT 5000
  33. #define CCS_NATURAL_I_Q_MAX_CURRENT 3000
  34. #define CCS_NATURAL_I_Q_85_DERATING_CUR 1000
  35. #define CCS_NATURAL_Y_Z_MAX_CURRENT 1500
  36. #define CHA_MAX_PHYSICAL_VOLTAGE 5000
  37. #define CHA_NATURAL_K_MAX_CURRENT 2000
  38. #define CHA_NATURAL_J_MAX_CURRENT 1200
  39. #define CHA_NATURAL_J_JARI_MAX_CURRENT 1250
  40. #define CHA_NATURAL_S_MAX_CURRENT 1250
  41. #define CHA_NATURAL_S_BOOST_CURRENT 2000
  42. #define CHA_NATURAL_O_BOOST_CURRENT 3500
  43. #define CHA_NATURAL_O_MAX_CURRENT 2000
  44. #define GBT_MAX_PHYSICAL_VOLTAGE 7500
  45. #define GBT_NATURAL_MAX_CURRENT 2500
  46. #define AUTO_GUN_SELECTION_ID 0xFF
  47. //#define DQC480
  48. struct Message
  49. {
  50. int size;
  51. unsigned char buffer[2048];
  52. };
  53. enum HEADER_OP
  54. {
  55. _Header_Read = 0x01,
  56. _Header_Write = 0x02,
  57. _Header_Response = 0x03,
  58. };
  59. enum PAYLOAD_REGISTER
  60. {
  61. _Reg_Dispenser_Model_Name = 0x01,
  62. _Reg_Connector_ID = 0x02,
  63. _Reg_Power_Cabinet_Status = 0x03,
  64. _Reg_Dispenser_Status = 0x04,
  65. _Reg_Charging_Capability = 0x05,
  66. _Reg_Charging_Target = 0x06,
  67. _Reg_Software_Update = 0x07,
  68. _Reg_Plug_In_Status = 0x08,
  69. _Reg_Connector_State = 0x09,
  70. _Reg_User_ID = 0x0A,
  71. _Reg_Charging_Permission = 0x0B,
  72. _Reg_Misc_Control = 0x0C,
  73. _Reg_Report_Csu_Version = 0x0D,
  74. _Reg_Report_Other_Version = 0x0E,
  75. _Reg_Charging_Info = 0x0F,
  76. _Reg_QR_Code_Date = 0x10,
  77. _Reg_WaitPlugIn = 0x11,
  78. _Reg_GroundFaultDetection = 0x12,
  79. _Reg_Get_Cabinet_CSU_Version = 0x13,
  80. _Reg_Get_Cabinet_Other_Version = 0x14,
  81. _Reg_Get_Psu_Quantity = 0x15,
  82. _Reg_Get_Psu_Version = 0x16,
  83. _Reg_Get_Reservation = 0x17,
  84. _Reg_Dispenser_Request = 0x18,
  85. _Reg_RemoteStartNoIDState = 0x19,
  86. _Reg_RefundAmount = 0x1A,
  87. _Reg_PrepaymentInfo = 0x1B,
  88. _Reg_PaymentFailReason = 0x1C,
  89. _Reg_ConnectorQRCode = 0x1D,
  90. _Reg_StationInfo = 0x1E,
  91. _Reg_DeductResult = 0x1F,
  92. _Reg_CabinetSystemID = 0x20,
  93. _Reg_DefaultPriceString = 0x21,
  94. _Reg_UserPriceString = 0x22,
  95. _Reg_Receipt = 0x23,
  96. _Reg_PowerConsumption = 0x24,
  97. _Reg_ChargingTimestamp = 0x25,
  98. _Reg_ChargingBill = 0x26,
  99. _Reg_ParkingStatus = 0x27,
  100. _Reg_ParkingBill = 0x28,
  101. _Reg_OCMF_Info = 0x29,
  102. _Reg_None = 0x2A,
  103. };
  104. enum Response_Result
  105. {
  106. _R_OK = 0x01,
  107. _R_NG = 0x02,
  108. };
  109. enum Response_Upgrade
  110. {
  111. _R_NeedUpgrade = 0x01,
  112. _R_NoUpgrade = 0x02,
  113. };
  114. enum PlugIn_Status
  115. {
  116. _PIS_UnPlugged = 0x00,
  117. _PIS_PluggedIn = 0x01,
  118. };
  119. enum Connector_Remote_Status
  120. {
  121. _CRS_Idle = 0x00,
  122. _CRS_Preparing = 0x01,
  123. _CRS_Charging = 0x02,
  124. _CRS_Terminating = 0x03,
  125. _CRS_Alarm = 0x04,
  126. };
  127. typedef enum
  128. {
  129. _DAS_NotAllowed = 0x00,
  130. _DAS_Allowed = 0x01,
  131. _DAS_Wait = 0x02,
  132. }DispenserAck_Status;
  133. enum Permission_Status
  134. {
  135. _PS_NotPermitted = 0x00,
  136. _PS_Permitted = 0x01,
  137. };
  138. enum Accept_Status
  139. {
  140. _AS_Reject = 0x00,
  141. _AS_Accept = 0x01,
  142. };
  143. struct HEADER_STRUCTURE
  144. {
  145. unsigned char se;
  146. unsigned char id;
  147. unsigned char op;
  148. unsigned char len;
  149. };
  150. struct PAYLOAD_STRUCTURE
  151. {
  152. unsigned char reg;
  153. unsigned char data[MAXIMUM_PAYLOAD_LENGTH];
  154. };
  155. struct PACKET_STRUCTURE
  156. {
  157. struct HEADER_STRUCTURE Header;
  158. struct PAYLOAD_STRUCTURE Payload;
  159. }Packet_Structure;
  160. enum DispenserStatus
  161. {
  162. _DS_None = 0x00,
  163. _DS_Identification = 0x01,
  164. _DS_Idle = 0x02,
  165. _DS_Alarm = 0x03,
  166. _DS_Charging = 0x04,
  167. _DS_Timeout = 0x05,
  168. };
  169. enum ConnectionStatus
  170. {
  171. _CNS_FREE = 0x00,
  172. _CNS_WaitModelName = 0x01,
  173. _CNS_DispenserMatched = 0x02,
  174. };
  175. enum LcmPage
  176. {
  177. _LCM_None = 0x00,
  178. _LCM_Page_RemoteStartNoID = 0x01,
  179. };
  180. struct MISC_COMMAND
  181. {
  182. unsigned short Command;
  183. unsigned int Value;
  184. };
  185. enum MiscCommand
  186. {
  187. _MiscCmd_None = 0x0000,
  188. _MiscCmd_ConnectorTimeout = 0x0001,
  189. _MiscCmd_ChangeOperative = 0x0002,
  190. _MiscCmd_DefaultPrice = 0x0003,
  191. _MiscCmd_Currency = 0x0004,
  192. _MiscCmd_AccountBalance = 0x0005,
  193. _MiscCmd_BackendStatus = 0x0006,
  194. _MiscCmd_EthernetStatus = 0x0007,
  195. _MiscCmd_WiFiStatus = 0x0008,
  196. _MiscCmd_4GStatus = 0x0009,
  197. _MiscCmd_Billing = 0x000A,
  198. _MiscCmd_StopButton = 0x000B,
  199. _MiscCmd_AuthDisable = 0x000C,
  200. _MiscCmd_EVCCIDEnable = 0x000D,
  201. _MiscCmd_LEDIntensity = 0x000E,
  202. _MiscCmd_AcContactor = 0x000E,
  203. _MiscCmd_TimeOffset = 0x0010,
  204. _MiscCmd_ParkingPrice = 0x0011,
  205. _MiscCmd_RFIDCardEndian = 0x0012,
  206. _MiscCmd_RFIDEnable = 0x0013,
  207. _MiscCmd_HardwareReboot = 0x0101,
  208. _MiscCmd_SoftwareRestart = 0x0102,
  209. _MiscCmd_RemoteStart = 0x0103,
  210. _MiscCmd_RemoteStop = 0x0104,
  211. _MiscCmd_UnlockStop = 0x0105,
  212. _MiscCmd_Reservation = 0x0106,
  213. _MiscCmd_ChangeLcmPage = 0x0107,
  214. _MiscCmd_QRCodeRequest = 0x0108,
  215. _MiscCmd_StationInfo = 0x0109,
  216. _MiscCmd_FinalCost = 0x010A,
  217. _MiscCmd_LineStatus = 0x010B,
  218. _MiscCmd_DefaultPriceString = 0x010C,
  219. _MiscCmd_UserPriceString = 0x010D,
  220. _MiscCmd_Receipt = 0x010E,
  221. _MiscCmd_ChargingBill = 0x010F,
  222. _MiscCmd_ParkingRequest = 0x0110,
  223. };
  224. enum DispenserMisc_Request
  225. {
  226. _DisReq_None = 0x0000,
  227. _DisReq_ChargingCancel = 0x0001,
  228. _DisReq_ParkingFee = 0x0002,
  229. };
  230. typedef struct
  231. {
  232. unsigned char ResponseResult; // 1: OK, 2 NG
  233. unsigned short MaxOuputVoltage; // unit = 0.1 volt
  234. unsigned short MaxOuputCurrent; // unit = 0.1 Amp
  235. unsigned short MaxOuputPower; // unit = 0.1 kW
  236. unsigned char Currency; // currency index
  237. unsigned int UserPrice; // unit = 0.01 dollar
  238. unsigned int TotalCost; // unit = 0.01 dollar
  239. int AccountBalance; // unit = 0.01 dollar
  240. int CostDiscount; // unit = 0.01 dollar
  241. int TransactionId; // unit = 0.01 dollar
  242. int EnergyCost; // unit = 0.01 dollar
  243. int ParkingFee; // unit = 0.01 dollar
  244. int RemainAmount; // unit = 0.01 dollar
  245. char CurrencyString[4];
  246. }ChargingCapabilityResponseInfo;
  247. enum WaitPlug
  248. {
  249. _WaitPlug_None = 0x0,
  250. _WaitPlug_Start = 0x1,
  251. };
  252. enum GroundFaultDetection
  253. {
  254. _GFD_Disable = 0x0,
  255. _GFD_Enable = 0x1,
  256. };
  257. typedef struct
  258. {
  259. char ChargingDate[32]; // charging date in string format
  260. char Prepayment[32]; // prepayment in string format
  261. char ActualCost[32]; // actual cost in string format
  262. char RefundAmount[32]; // refund amount in string format
  263. }RefundResponse;
  264. typedef struct
  265. {
  266. unsigned char PaymentType;
  267. char TopUp[32]; // top up in string format
  268. char AccountAmount[32]; // account amount in string format
  269. char Prepayment[32]; // prepayment in string format
  270. char Balance[32]; // balance in string format
  271. }PrepaymentResponseInfo;
  272. typedef struct
  273. {
  274. unsigned char ReasonIndex; // index start from 1 ~ 200
  275. char Reason[128]; // reason in string format
  276. }PaymentFailResponse;
  277. typedef struct
  278. {
  279. unsigned char ParkingStatus; // index start from 1 ~ 200
  280. char OccupancySn[37]; // reason in string format
  281. }OccupancyResponse;
  282. #endif /* MODULE_EVCOMM_H_ */