Module_EvComm.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. // socket setting
  22. #define CONNECTION_LIMIT 5
  23. #define MAXIMUM_CONNECT_QUANTITY 2
  24. #define CCS_MAX_PHYSICAL_VOLTAGE 9500
  25. #define CCS_NATURAL_MAX_CURRENT 2000
  26. #define CCS_LIQUID_MAX_CURRENT 5000
  27. #define CCS_NATURAL_REMA_MAX_CURRENT 3000
  28. #define CHA_MAX_PHYSICAL_VOLTAGE 5000
  29. #define CHA_NATURAL_MAX_CURRENT 2000
  30. #define GBT_MAX_PHYSICAL_VOLTAGE 7500
  31. #define GBT_NATURAL_MAX_CURRENT 2500
  32. #define AUTO_GUN_SELECTION 0xFF
  33. struct Message
  34. {
  35. int size;
  36. unsigned char buffer[2048];
  37. };
  38. enum HEADER_OP
  39. {
  40. _Header_Read = 0x01,
  41. _Header_Write = 0x02,
  42. _Header_Response = 0x03,
  43. };
  44. enum PAYLOAD_REGISTER
  45. {
  46. _Reg_Dispenser_Model_Name = 0x01,
  47. _Reg_Connector_ID = 0x02,
  48. _Reg_Power_Cabinet_Status = 0x03,
  49. _Reg_Dispenser_Status = 0x04,
  50. _Reg_Charging_Capability = 0x05,
  51. _Reg_Charging_Target = 0x06,
  52. _Reg_Software_Update = 0x07,
  53. _Reg_Plug_In_Status = 0x08,
  54. _Reg_Connector_State = 0x09,
  55. _Reg_User_ID = 0x0A,
  56. _Reg_Charging_Permission = 0x0B,
  57. _Reg_Misc_Control = 0x0C,
  58. _Reg_Report_Csu_Version = 0x0D,
  59. _Reg_Report_Other_Version = 0x0E,
  60. _Reg_Charging_Info = 0x0F,
  61. _Reg_Charger_System_Id = 0x10,
  62. _Reg_WaitPlugIn = 0x11,
  63. };
  64. enum Response_Result
  65. {
  66. _R_OK = 0x01,
  67. _R_NG = 0x02,
  68. };
  69. enum Response_Upgrade
  70. {
  71. _R_NeedUpgrade = 0x01,
  72. _R_NoUpgrade = 0x02,
  73. };
  74. enum PlugIn_Status
  75. {
  76. _PIS_UnPlugged = 0x00,
  77. _PIS_PluggedIn = 0x01,
  78. };
  79. enum Connector_Remote_Status
  80. {
  81. _CRS_Idle = 0x00,
  82. _CRS_Preparing = 0x01,
  83. _CRS_Charging = 0x02,
  84. _CRS_Terminating = 0x03,
  85. _CRS_Alarm = 0x04,
  86. };
  87. typedef enum
  88. {
  89. _DAS_NotAllowed = 0x00,
  90. _DAS_Allowed = 0x01,
  91. _DAS_Wait = 0x02,
  92. }DispenserAck_Status;
  93. enum Permission_Status
  94. {
  95. _PS_NotPermitted = 0x00,
  96. _PS_Permitted = 0x01,
  97. };
  98. enum Accept_Status
  99. {
  100. _AS_Reject = 0x00,
  101. _AS_Accept = 0x01,
  102. };
  103. struct HEADER_STRUCTURE
  104. {
  105. unsigned char se;
  106. unsigned char id;
  107. unsigned char op;
  108. unsigned char len;
  109. };
  110. struct PAYLOAD_STRUCTURE
  111. {
  112. unsigned char reg;
  113. unsigned char data[MAXIMUM_PAYLOAD_LENGTH];
  114. };
  115. struct PACKET_STRUCTURE
  116. {
  117. struct HEADER_STRUCTURE Header;
  118. struct PAYLOAD_STRUCTURE Payload;
  119. }Packet_Structure;
  120. enum DispenserStatus
  121. {
  122. _DS_None = 0x00,
  123. _DS_Identification = 0x01,
  124. _DS_Idle = 0x02,
  125. _DS_Alarm = 0x03,
  126. _DS_Charging = 0x04,
  127. _DS_Timeout = 0x05,
  128. };
  129. enum ConnectionStatus
  130. {
  131. _CNS_FREE = 0x00,
  132. _CNS_WaitModelName = 0x01,
  133. _CNS_DispenserMatched = 0x02,
  134. };
  135. struct MISC_COMMAND
  136. {
  137. unsigned short Command;
  138. unsigned int Value;
  139. };
  140. enum MiscCommand
  141. {
  142. _MiscCmd_None = 0x0000,
  143. _MiscCmd_ConnectorTimeout = 0x0001,
  144. _MiscCmd_ChangeOperative = 0x0002,
  145. _MiscCmd_DefaultPrice = 0x0003,
  146. _MiscCmd_Currency = 0x0004,
  147. _MiscCmd_AccountBalance = 0x0005,
  148. _MiscCmd_BackendStatus = 0x0006,
  149. _MiscCmd_EthernetStatus = 0x0007,
  150. _MiscCmd_WiFiStatus = 0x0008,
  151. _MiscCmd_4GStatus = 0x0009,
  152. _MiscCmd_HardwareReboot = 0x0101,
  153. _MiscCmd_SoftwareRestart = 0x0102,
  154. _MiscCmd_RemoteStart = 0x0103,
  155. _MiscCmd_RemoteStop = 0x0104,
  156. _MiscCmd_UnlockStop = 0x0105,
  157. };
  158. struct ChargingCapabilityResponse
  159. {
  160. unsigned char ResponseResult; // 1: OK, 2 NG
  161. unsigned short MaxOuputVoltage; // unit = 0.1 volt
  162. unsigned short MaxOuputCurrent; // unit = 0.1 Amp
  163. unsigned short MaxOuputPower; // unit = 0.1 kW
  164. unsigned char Currency; // currency index
  165. unsigned int UserPrice; // unit = 0.01 dollar
  166. unsigned int TotalCost; // unit = 0.01 dollar
  167. int AccountBalance; // unit = 0.01 dollar
  168. };
  169. #endif /* MODULE_EVCOMM_H_ */