Module_EvComm.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. struct Message
  25. {
  26. int size;
  27. unsigned char buffer[2048];
  28. };
  29. enum HEADER_OP
  30. {
  31. _Header_Read = 0x01,
  32. _Header_Write = 0x02,
  33. _Header_Response = 0x03,
  34. };
  35. enum PAYLOAD_REGISTER
  36. {
  37. _Reg_Dispenser_Model_Name = 0x01,
  38. _Reg_Connector_ID = 0x02,
  39. _Reg_Power_Cabinet_Status = 0x03,
  40. _Reg_Dispenser_Status = 0x04,
  41. _Reg_Charging_Capability = 0x05,
  42. _Reg_Charging_Target = 0x06,
  43. _Reg_Software_Update = 0x07,
  44. _Reg_Plug_In_Status = 0x08,
  45. _Reg_Connector_State = 0x09,
  46. _Reg_User_ID = 0x0A,
  47. _Reg_Charging_Permission = 0x0B,
  48. };
  49. enum Response_Result
  50. {
  51. _R_OK = 0x01,
  52. _R_NG = 0x02,
  53. };
  54. enum PlugIn_Status
  55. {
  56. _PIS_UnPlugged = 0x00,
  57. _PIS_PluggedIn = 0x01,
  58. };
  59. enum Connector_Remote_Status
  60. {
  61. _CRS_Idle = 0x00,
  62. _CRS_Preparing = 0x01,
  63. _CRS_Charging = 0x02,
  64. _CRS_Terminating = 0x03,
  65. };
  66. typedef enum
  67. {
  68. _DAS_NotAllowed = 0x00,
  69. _DAS_Allowed = 0x01,
  70. _DAS_Wait = 0x02,
  71. }DispenserAck_Status;
  72. enum Permission_Status
  73. {
  74. _PS_NotPermitted = 0x00,
  75. _PS_Permitted = 0x01,
  76. };
  77. enum Accept_Status
  78. {
  79. _AS_Reject = 0x00,
  80. _AS_Accept = 0x01,
  81. };
  82. struct HEADER_STRUCTURE
  83. {
  84. unsigned char se;
  85. unsigned char id;
  86. unsigned char op;
  87. unsigned char len;
  88. };
  89. struct PAYLOAD_STRUCTURE
  90. {
  91. unsigned char reg;
  92. unsigned char data[MAXIMUM_PAYLOAD_LENGTH];
  93. };
  94. struct PACKET_STRUCTURE
  95. {
  96. struct HEADER_STRUCTURE Header;
  97. struct PAYLOAD_STRUCTURE Payload;
  98. }Packet_Structure;
  99. enum DispenserStatus
  100. {
  101. _DS_None = 0x00,
  102. _DS_Identification = 0x01,
  103. _DS_Idle = 0x02,
  104. _DS_Alarm = 0x03,
  105. _DS_Charging = 0x04,
  106. _DS_Timeout = 0x05,
  107. };
  108. enum ConnectionStatus
  109. {
  110. _CNS_FREE = 0x00,
  111. _CNS_WaitModelName = 0x01,
  112. _CNS_DispenserMatched = 0x02,
  113. };
  114. #endif /* MODULE_EVCOMM_H_ */