Config.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. /*
  2. * Config.h
  3. *
  4. * Created on: 2019年4月23日
  5. * Author: foluswen
  6. */
  7. #ifndef CONFIG_H_
  8. #define CONFIG_H_
  9. #include <stdbool.h>
  10. typedef unsigned char byte;
  11. #define MODE_BOOT 0
  12. #define MODE_IDLE 1
  13. #define MODE_AUTHORIZING 2
  14. #define MODE_REASSIGN_CHECK 3
  15. #define MODE_REASSIGN 4
  16. #define MODE_PRECHARGE 5
  17. #define MODE_PREPARE_FOR_EV 6
  18. #define MODE_PREPARE_FOR_EVSE 7
  19. #define MODE_CHARGING 8
  20. #define MODE_TERMINATING 9
  21. #define MODE_COMPLETE 10
  22. #define MODE_ALARM 11
  23. #define MODE_FAULT 12
  24. #define MODE_RESERVATION 13
  25. #define MODE_BOOKING 14
  26. #define MODE_MAINTAIN 15
  27. #define MODE_DEBUG 16
  28. #define MODE_CCS_PRECHARGE_STEP0 17 // ready for ccs precharge processing, For D+ relay to precharge relay
  29. #define MODE_CCS_PRECHARGE_STEP1 18 // waitting for ev board inform to enter to charging, For precharge relay to D+ relay
  30. #define MODE_UPDATE 19
  31. #define GFD_WAIT 0
  32. #define GFD_PASS 1
  33. #define GFD_FAIL 2
  34. #define GFD_WARNING 3
  35. #define PRECHARGE_WAIT 0
  36. #define PRECHARGE_READY 1
  37. #define PRECHARGE_PRERELAY_PASS 2
  38. #define PRECHARGE_CHARELAY_PASS 3
  39. #define BOOTTING 0
  40. #define BOOT_COMPLETE 1
  41. #define uSEC_VAL 1000000
  42. #define mSEC_VAL 1000
  43. #define MAX_GROUP_QUANTITY 4
  44. #define MAX_PSU_MODULE_QUANTITY 62
  45. #define MAX_MODULE_PER_GROUP 12
  46. #define SM_ChargerInfoKey 3000
  47. #define SAFETY_TEST_ENABLE 0
  48. #define MAX_SLAVE_CABINET_QUANTITY 4
  49. #define MASTER_ETH1_IP "192.168.100.1"
  50. #define MASTER_ETH1_SUBMASK "255.255.255.0"
  51. #define SLAVE_ETH1_IP "192.168.0.10"
  52. #define SLAVE_ETH1_SUBMASK "255.255.255.0"
  53. // ********** Audi ********** //
  54. // Model Name: DOYC182000D2AD
  55. // Model Name: DDYC182V0UE2AD
  56. // ********** e4you ********** //
  57. // Model Name: DKYE182000D1E4
  58. // Model Name: DXYE182E00E1E4
  59. // ********** xpeng ********** //
  60. // Model Name: DOYE362000D2XP
  61. // Model Name: DDYE362F0KE2XP
  62. // *********** BYD *********** //
  63. // Model Name: DOYE242000D2BD
  64. // Model Name: DDYE242V0UE2BD
  65. // *********** TCC *********** //
  66. // Model Name: DBYE182000D1PH
  67. enum _SYSTEM_STATUS
  68. {
  69. S_BOOTING = 0,
  70. S_IDLE,
  71. S_AUTHORIZING,
  72. S_REASSIGN_CHECK,
  73. S_REASSIGN,
  74. S_PREPARNING,
  75. S_PREPARING_FOR_EV,
  76. S_PREPARING_FOR_EVSE,
  77. S_CHARGING,
  78. S_TERMINATING,
  79. S_COMPLETE,
  80. S_ALARM,
  81. S_FAULT,
  82. S_RESERVATION,
  83. S_BOOKING,
  84. S_MAINTAIN,
  85. S_DEBUG,
  86. S_CCS_PRECHARGE_ST0,
  87. S_CCS_PRECHARGE_ST1,
  88. S_UPDATE,
  89. S_NONE,
  90. };
  91. enum _AC_SYSTEM_STATUS
  92. {
  93. AC_SYS_NONE = 0,
  94. AC_SYS_A,
  95. AC_SYS_B,
  96. AC_SYS_C,
  97. AC_SYS_D,
  98. AC_SYS_E
  99. };
  100. #define STR_GUN_TYPE_CHADEMO "CHAdeMO"
  101. #define STR_GUN_TYPE_CCS "CCS"
  102. #define STR_GUN_TYPE_GBT "GBT"
  103. #define STR_GUN_TYPE_AC "AC"
  104. #define STR_GUN_TYPE_UNKNOWN "Unknown Type"
  105. enum _GUN_TYPE
  106. {
  107. _Type_Chademo = 0,
  108. _Type_CCS_2,
  109. _Type_GB,
  110. _Type_AC,
  111. _Type_Unknown = 0xFF
  112. };
  113. enum _LCM_INDEX
  114. {
  115. _LCM_INIT = 0x00,
  116. _LCM_IDLE = 0x01,
  117. _LCM_AUTHORIZING = 0x02,
  118. _LCM_AUTHORIZ_COMP = 0x03,
  119. _LCM_AUTHORIZ_FAIL = 0x04,
  120. _LCM_WAIT_FOR_PLUG = 0x05,
  121. _LCM_PRE_CHARGE = 0x06,
  122. _LCM_CHARGING = 0x07,
  123. _LCM_COMPLETE = 0x08,
  124. _LCM_FIX = 0x09,
  125. _LCM_NONE = 0xFF,
  126. };
  127. enum _DispenserAuthorizeStatus
  128. {
  129. _AuthorizeStatus_Idle = 0x00,
  130. _AuthorizeStatus_Wait = 0x01,
  131. _AuthorizeStatus_Busy = 0x02,
  132. _AuthorizeStatus_Done = 0x03,
  133. _AuthorizeStatus_End = 0x04,
  134. };
  135. enum _ConnectorAuthorizeResult
  136. {
  137. _AuthResult_None = 0x00,
  138. _AuthResult_Valid = 0x01,
  139. _AuthResult_Invalid = 0x02,
  140. };
  141. enum _AuthorizedType
  142. {
  143. _AuthType_None = 0x00,
  144. _AuthType_RFID = 0x01,
  145. _AuthType_RemoteStart = 0x02,
  146. };
  147. enum _SELF_TEST_SEQ
  148. {
  149. _STEST_VERSION = 0x00,
  150. _STEST_CabinetSwitch = 0x01,
  151. _STEST_AC_CONTACTOR = 0x02,
  152. _STEST_PSU_DETECT = 0x03,
  153. _STEST_PSU_CAP = 0x04,
  154. _STEST_PSU_RETRY = 0x05,
  155. _STEST_EMG_BTN = 0x06,
  156. _STEST_FAIL = 0x07,
  157. _STEST_COMPLETE = 0xEE,
  158. };
  159. enum _MODULE_PSU_WORK_STEP
  160. {
  161. INITIAL_START = 0,
  162. GET_PSU_COUNT = 1,
  163. Get_PSU_LOCATION = 2,
  164. Get_PSU_VERSION = 3,
  165. PSU_COUNT_CONFIRM = 4,
  166. GET_SYS_CAP = 5,
  167. BOOTING_COMPLETE = 6,
  168. _WORK_CHARGING = 10,
  169. _TEST_MODE = 20,
  170. _NO_WORKING = 254,
  171. _INIT_PSU_STATUS = 255
  172. };
  173. enum _OFFLINE_POLICY
  174. {
  175. _OFFLINE_POLICY_LOCAL_LIST = 0x00,
  176. _OFFLINE_POLICY_PHIHONG_RFID_TAG = 0x01,
  177. _OFFLINE_POLICY_FREE_CHARGING = 0x02,
  178. _OFFLINE_POLICY_NO_CHARGING = 0x03,
  179. };
  180. enum _REASSIGNED_RESOURCE_STEP
  181. {
  182. _REASSIGNED_NONE = 0, //
  183. _REASSIGNED_PREPARE_M_TO_A = 1, // 系統收到需要降載需求 (輸出總電流降低),PSU Task 收到將狀態切換至下個狀態
  184. _REASSIGNED_GET_NEW_CAP = 2, // 充電中的重新取得屬於自己火線上的總能量並透過小板通知車端 - 超過10秒直接跳下一步
  185. _REASSIGNED_ADJUST_M_TO_A = 3, // 模塊重新分配完成
  186. _REASSIGNED_RELAY_M_TO_A = 4, // 切斷橋接的 Relay
  187. _REASSIGNED_PREPARE_A_TO_M = 11,
  188. _REASSIGNED_ADJUST_A_TO_M = 12, // 模塊升壓
  189. _REASSIGNED_RELAY_A_TO_M = 13, // 搭接橋接的 Relay
  190. _REASSIGNED_WAITING = 14,
  191. _REASSIGNED_COMP = 15
  192. };
  193. enum _MAIN_CHARGING_MODE
  194. {
  195. _MAIN_CHARGING_MODE_MAX = 0,
  196. _MAIN_CHARGING_MODE_AVER = 1,
  197. };
  198. enum _EXTRA_ERR_PROCESS
  199. {
  200. _EXTRA_ERR_PROCESS_NONE = 0,
  201. _EXTRA_ERR_PROCESS_INUVP = 1,
  202. _EXTRA_ERR_PROCESS_INOVP = 2,
  203. _EXTRA_ERR_PROCESS_PRIMARY = 3,
  204. };
  205. enum _CHARGER_TYPE
  206. {
  207. _CHARGER_TYPE_IEC = 0,
  208. _CHARGER_TYPE_UL = 1,
  209. };
  210. enum _SYS_WIFI_MODE
  211. {
  212. _SYS_WIFI_MODE_DISABLE = 0,
  213. _SYS_WIFI_MODE_STATION = 1,
  214. _SYS_WIFI_MODE_AP = 2
  215. };
  216. enum _LED_INTENSITY_LV
  217. {
  218. _LED_INTENSITY_DARKEST = 0,
  219. _LED_INTENSITY_MEDIUM = 1,
  220. _LED_INTENSITY_BRIGHTEST = 2
  221. };
  222. enum _CCS_COMM_PROTOCOL
  223. {
  224. _CCS_COMM_V2GMessage_DIN70121 = 0x01,
  225. _CCS_COMM_V2GMessage_ISO15118_2014 = 0x02,
  226. _CCS_COMM_V2GMessage_ISO15118_2018 = 0x03
  227. };
  228. enum _ETHERNET_USAGE
  229. {
  230. _ETHERNET_USAGE_NONE = 0,
  231. _ETHERNET_USAGE_LAN,
  232. _ETHERNET_USAGE_WIFI,
  233. _ETHERNET_USAGE_3G_4g
  234. };
  235. #define STR_CONN_DISABLE "Disable"
  236. #define STR_CONN_CONNECTED "Connected"
  237. #define STR_CONN_DISCONNECTED "Disconnected"
  238. enum _CONN_STATUS
  239. {
  240. _Connnection_Disable = 0,
  241. _Connnection_Connected = 1,
  242. _Connnection_Disconnected = 2,
  243. };
  244. enum _LED_INDICATION_STATUS
  245. {
  246. _LED_INDICATION_OFF = 0, // all led off
  247. _LED_INDICATION_RUN = 1, // green led on, red led off
  248. _LED_INDICATION_FAULT = 2, // green led off, red led on
  249. _LED_INDICATION_ON = 3, // all led on
  250. _LED_INDICATION_GREEN_TOGGLE = 4, // green led toggle
  251. _LED_INDICATION_RED_TOGGLE = 5, // red led toggle
  252. };
  253. enum _STANDARD_INDICATION_STATUS
  254. {
  255. _STANDARD_LED_None = 0,
  256. _STANDARD_LED_Disconnection = 1,
  257. _STANDARD_LED_Running = 2,
  258. _STANDARD_LED_Alarm = 3,
  259. };
  260. enum _E4YOU_INDICATION_STATUS
  261. {
  262. _E4YOU_LED_None = 0,
  263. _E4YOU_LED_Disconnection = 1,
  264. _E4YOU_LED_Idle = 2,
  265. _E4YOU_LED_Charging = 3,
  266. _E4YOU_LED_Alarm = 4,
  267. };
  268. enum _QR_MODE
  269. {
  270. _QR_MODE_Default = 0,
  271. _QR_MODE_Customized = 1,
  272. _QR_MODE_ChargeBoxId = 2, // for audi
  273. };
  274. #define STR_CABINET_ROLE_NONE "Single"
  275. #define STR_CABINET_ROLE_MASTER "Master"
  276. #define STR_CABINET_ROLE_SLAVE "Slave"
  277. enum _CABINET_ROLE
  278. {
  279. _CROLE_SINGLE = 0, // single power cabinet mode
  280. _CROLE_MASTER = 1, // power cabinet master mode
  281. _CROLE_SLAVE = 2, // power cabinet slave mode
  282. };
  283. typedef union
  284. {
  285. unsigned int CtrlValue;
  286. struct
  287. {
  288. unsigned int SelfTestOK:1; // 0: self test not completed, 1: self test ok
  289. unsigned int NeedSelfTest:1; // 0: no effect, 1: need execute self test
  290. unsigned int NeedSoftReset:1; // 0: no effect, 1: system need soft reset
  291. unsigned int NeedHardReset:1; // 0: no effect, 1: system need hard reset
  292. unsigned int PrimaryDisable:1; // 0: primary enable, 1: primary disable
  293. unsigned int RelayBoardDisable:1; // 0: relay board enable, 1: relay board disable
  294. unsigned int FanBoardDisable:1; // 0: fan board enable, 1: fan board disable
  295. unsigned int LedBoardDisable:1; // 0: led board enable, 1: led board disable
  296. unsigned int SecondRelayBoardEnable:1; // 0: second relay disable, 1: second relay enable
  297. unsigned int DOLedIndication:1; // 0: no led indication, 1: enable DO Model led indication
  298. unsigned int DKLedIndication:1; // 0: no led indication, 1: enable DK Model led indication
  299. unsigned int BackendEnable:1; // 0: backend disable, 1: backend enable
  300. unsigned int Wifi4gResetEnable:1; // 0: wifi/4g reset io disable, 1: wifi/4g reset io enable
  301. unsigned int res:19;
  302. }bits;
  303. }SystemControl;
  304. typedef union
  305. {
  306. unsigned int CtrlValue;
  307. struct
  308. {
  309. unsigned int DisableBalance:1; // 0: no effect, 1: disable announce balance
  310. unsigned int FastStandbyTime:1; // 0: no effect, 1: enable fast standby time
  311. unsigned int ChargingSimulation:1; // 0: no effect, 1: enable charging simulation
  312. unsigned int res:29;
  313. }bits;
  314. }TestControl;
  315. typedef union
  316. {
  317. unsigned int CtrlValue;
  318. struct
  319. {
  320. unsigned int MsgMain:1; // 0: no effect, 1: enable debug message in main
  321. unsigned int MsgPrimaryComm:1; // 0: no effect, 1: enable debug message in primary comm
  322. unsigned int MsgPsu:1; // 0: no effect, 1: enable debug message in psu
  323. unsigned int MsgEvComm:1; // 0: no effect, 1: enable debug message in ev comm
  324. unsigned int MsgInternalComm:1; // 0: no effect, 1: enable debug message in internal comm
  325. unsigned int res:27;
  326. }bits;
  327. }DebugControl;
  328. typedef union
  329. {
  330. unsigned int CtrlValue;
  331. struct
  332. {
  333. unsigned int EnableForceCharging:1; // 0: disable, 1: enable force charging
  334. unsigned int StartForceCharging:1; // 0: disable, 1: start force charging
  335. unsigned int res:30;
  336. }bits;
  337. }ForceChargingControl;
  338. typedef struct
  339. {
  340. ForceChargingControl FCtrl;
  341. unsigned short FTargetVoltage; // target voltage, unit: 0.1V
  342. unsigned short FTargetCurrent; // target current, unit: 0.1A
  343. }ForceCharging;
  344. typedef union
  345. {
  346. unsigned int AuthFlag;
  347. struct
  348. {
  349. unsigned int AutoStartEnable:1; // 0: disable, 1: enable auto charging after plug in
  350. unsigned int APPEnable:1; // 0: disable, 1: app auth enable
  351. unsigned int QRCodeEnable:1; // 0: disable, 1: qr code auth enable
  352. unsigned int RFIDEnable:1; // 0: disable, 1: rfid auth enable
  353. unsigned int res:24;
  354. }bits;
  355. }AuthModeInfo;
  356. typedef struct
  357. {
  358. AuthModeInfo AuthMode;
  359. unsigned char QRCodeMode; // 0: default, 1: customized, 2: audi type
  360. unsigned char res[3];
  361. }SystemAuthInfoData;
  362. typedef union
  363. {
  364. unsigned int CtrlValue;
  365. struct
  366. {
  367. unsigned int SelfTestOK:1; // 0: self test not completed, 1: self test ok
  368. unsigned int NeedSelfTest:1; // 0: no effect, 1: need execute self test
  369. unsigned int Paused:1; // 0: no effect, 1: primary paused
  370. unsigned int DisableDoorSensor:1; // 0: door sensor enable, 1: door sensor disable
  371. unsigned int DisableEmergencyButton:1; // 0: emergency button enable, 1: emergency button disable
  372. unsigned int DoorSensorReverse:1; // 0: the same as ds's, 1: status is different from ds's
  373. unsigned int AcContactorReverse:1; // 0: the same as ds's, 1: status is different from ds's
  374. unsigned int CabinetSwitchDetect:1; // 0: no effect, 1: need detect cabinet switch
  375. unsigned int res:24;
  376. }bits;
  377. }PrimaryControl;
  378. typedef union
  379. {
  380. unsigned int CtrlValue;
  381. struct
  382. {
  383. unsigned int SelfTestOK:1; // 0: self test not completed, 1: self test ok
  384. unsigned int NeedSelfTest:1; // 0: no effect, 1: need execute self test
  385. unsigned int Paused:1; // 0: no effect, 1: relay paused
  386. unsigned int AcContactor:1; // 0: ac contactor off, 1: ac contactor on
  387. unsigned int AcContactorOffByPsu:1; // 0: no effect, 1: ac contactor off
  388. unsigned int AcContactorOffByEmergency:1; // 0: no effect, 1: ac contactor off
  389. unsigned int StandbyCountdown:1; // 0: charger is using, 1: start countdown
  390. unsigned int AcInputDisable:1; // 0: ac input enable, 1: ac input disable
  391. unsigned int DcInputEnable:1; // 0: dc input disable, 1: dc input enable
  392. unsigned int res:23;
  393. }bits;
  394. }RelayControl;
  395. typedef union
  396. {
  397. unsigned int CtrlValue;
  398. struct
  399. {
  400. unsigned int SelfTestOK:1; // 0: self test not completed, 1: self test ok
  401. unsigned int NeedSelfTest:1; // 0: no effect, 1: need execute self test
  402. unsigned int Paused:1; // 0: no effect, 1: fan paused
  403. unsigned int res:29;
  404. }bits;
  405. }FanControl;
  406. typedef union
  407. {
  408. unsigned int CtrlValue;
  409. struct
  410. {
  411. unsigned int SelfTestOK:1; // 0: self test not completed, 1: self test ok
  412. unsigned int NeedSelfTest:1; // 0: no effect, 1: need execute self test
  413. unsigned int Paused:1; // 0: no effect, 1: led paused
  414. unsigned int res:29;
  415. }bits;
  416. }LedFanControl;
  417. typedef union
  418. {
  419. unsigned int CtrlValue;
  420. struct
  421. {
  422. unsigned int SelfTestOK:1; // 0: self test not completed, 1: self test ok
  423. unsigned int NeedSelfTest:1; // 0: no effect, 1: need execute self test
  424. unsigned int Paused:1; // 0: no effect, 1: psu paused
  425. unsigned int FailureResume:1; // 0: no error, 1: psu failure, need resume
  426. unsigned int res:28;
  427. }bits;
  428. }PsuControl;
  429. typedef struct
  430. {
  431. unsigned char MaxDispenser;
  432. unsigned char MaxConnector;
  433. unsigned char CabinetSwitch;
  434. unsigned char CabinetRole;
  435. unsigned char SelfTestStep;
  436. unsigned char res;
  437. unsigned short ChargerRatingPower; // unit: 0.1kw, charger rating power, parsing from model name
  438. SystemControl SysCtrl;
  439. TestControl TestCtrl;
  440. DebugControl DebugCtrl;
  441. PrimaryControl PrimaryCtrl;
  442. RelayControl RelayCtrl;
  443. FanControl FanCtrl;
  444. LedFanControl LedCtrl;
  445. PsuControl PsuCtrl;
  446. ForceCharging FCharging[MAX_GROUP_QUANTITY];
  447. unsigned char GunAvailable[MAX_GROUP_QUANTITY];
  448. }SysControl;
  449. // ************************************************************************************************* //
  450. typedef struct
  451. {
  452. bool CheckIn;
  453. unsigned char Address;
  454. unsigned char GroupNo;
  455. unsigned char GIndex;
  456. }PsuAddressInfoData;
  457. typedef struct
  458. {
  459. unsigned char GroupPsuQuantity;
  460. unsigned char res;
  461. unsigned char PsuSN[MAX_MODULE_PER_GROUP];
  462. }GroupInfoData;
  463. typedef struct
  464. {
  465. bool PsuLocationInit;
  466. bool ReInitPsuLocation;
  467. unsigned char TotalPsuQuantity;
  468. GroupInfoData GroupLocationInfo[MAX_GROUP_QUANTITY];
  469. PsuAddressInfoData PsuAddressInfo[MAX_PSU_MODULE_QUANTITY];
  470. }PsuPositionInfoData;
  471. // ************************************************************************************************* //
  472. typedef enum
  473. {
  474. _GROLE_IDLE = 0,
  475. _GROLE_MASTER = 1,
  476. _GROLE_SLAVE = 2,
  477. _GROLE_PREPARE_SWITCH_OFF = 10, // reduce output current capability
  478. _GROLE_SLAVE_POWER_OFF = 11, // power off
  479. _GROLE_SWITCH_OFF_OK = 12, // power off completed
  480. _GROLE_WAIT_IDLE = 13, // wait a while to change to idle, open parallel relay at this state
  481. _GROLE_WAIT_SLAVE = 14, // wait a while to change to slave
  482. _GROLE_PREPARE_ATTACH_ON = 20, // raise voltage to master output voltage
  483. _GROLE_PRECHARGE_READY = 21, // extend pre-charge ready
  484. _GROLE_EXTEND_STOP = 22, // extend capability stop
  485. _GROLE_REQUEST_TO_CHARGING = 30,
  486. _GROLE_TERMINATE = 40,
  487. _GROLE_WAIT_TERMINATED = 41,
  488. _GROLE_NONE = 99,
  489. }_GROUP_ROLE;
  490. typedef union
  491. {
  492. unsigned int CtrlValue[6];
  493. struct
  494. {
  495. unsigned int IdleCtrlValue;
  496. unsigned int MasterCtrlValue;
  497. unsigned int StopChargingCtrlValue;
  498. unsigned int DeratingCtrlValue;
  499. unsigned int ExtendCapabilityCtrlValue;
  500. unsigned int SlaveCtrlValue;
  501. }RoleCtrl;
  502. struct
  503. {
  504. // IdleCtrlValue
  505. unsigned int ChargingRequest:1; // 0: no effect, 1: charging request from main.c
  506. unsigned int ChargingRequestConfirmed:1; // 0: no effect, 1: request confirmed by psu task
  507. unsigned int GroupShareCheck:1; // 0: no effect, 1: check is there any psu can share
  508. unsigned int ShareConfirmed:1; // 0: no effect, 1: psu share confirmed
  509. unsigned int GrabGroupWait:1; // 0: no effect, 1: need to wait grab psu
  510. unsigned int ShareCheckDone:1; // 0: no effect, 1: psu share completed
  511. unsigned int FindGroupPartner:1; // 0: no effect, 1: find available group partner
  512. unsigned int ParallelRelayOn:1; // 0: no effect, 1: set parallel relay on
  513. unsigned int ParallelRelayConfirmed:1; // 0: no effect, 1: parallel relay confirmed
  514. unsigned int GroupingDone:1; // 0: no effect, 1: grouping completed
  515. unsigned int IdleCtrlRes:22;
  516. // MasterCtrlValue
  517. unsigned int CableCheckDone:1; // 0: no effect, 1: CableCheck done
  518. unsigned int InPrechargeMode:1; // 0: no effect, 1: system status in PreCharge mode
  519. unsigned int AlreadyInChargingMode:1; // 0: no effect, 1: system status ever enter charging mode
  520. unsigned int ExtendAvailable:1; // 0: no effect, 1: extend capability is available
  521. unsigned int NeedCurrentBalance:1; // 0: no effect, 1: need to current balance
  522. unsigned int OutputCurrentStable:1; // 0: no effect, 1: output current is stable
  523. unsigned int ReachMaxCurrentDemand:1; // 0: no effect, 1: reach ev max current demand
  524. unsigned int ReachMaxStageCurrent:1; // 0: no effect, 1: reach ev max stage current
  525. unsigned int MasterCtrlRes:24;
  526. // StopChargingCtrlValue
  527. unsigned int StopChargingRequest:1; // 0: no effect, 1: master need to stop
  528. unsigned int StopChargingConfirmed:1; // 0: no effect, 1: stop charging confirmed
  529. unsigned int AllPowerOffDone:1; // 0: no effect, 1: all member power off done
  530. unsigned int AllParallelRelayOff:1; // 0: no effect, 1: all member's parallel relay off
  531. unsigned int AllParallelRelayConfirmed:1; // 0: no effect, 1: all member's parallel relay off confirmed
  532. unsigned int AllMemberStopCompleted:1; // 0: no effect, 1: all member stop completed
  533. unsigned int StopChargingCompleted:1; // 0: no effect, 1: stop charging completed
  534. unsigned int StopChargingCtrlRes:25;
  535. // DeratingCtrlValue
  536. unsigned int NeedDerating:1; // 0: no effect, 1: need derating
  537. unsigned int DeratingConfirmed:1; // 0: no effect, 1: derating confirmed
  538. unsigned int DeratingStart:1; // 0: no effect, 1: derating start
  539. unsigned int DeratingPowerOffDone:1; // 0: no effect, 1: derating member power off done
  540. unsigned int DeratingRelayOff:1; // 0: no effect, 1: set derating member parallel relay off
  541. unsigned int DeratingRelayConfirmed:1; // 0: no effect, 1: derating member parallel relay confirmed
  542. unsigned int DeratingCompleted:1; // 0: no effect, 1: derating completed
  543. unsigned int DeratingCtrlRes:25;
  544. // ExtendCapabilityCtrlValue
  545. unsigned int MorePowerRequest:1; // 0: no effect, 1: need to request more psu
  546. unsigned int MorePowerConfirmed:1; // 0: no effect, 1: request more psu confirmed
  547. unsigned int ExtendPrecharge:1; // 0: no effect, 1: extend group need to pre-charge
  548. unsigned int ExtendPrechargeDone:1; // 0: no effect, 1: extend group pre-charge completed
  549. unsigned int ExtendRelayOn:1; // 0: no effect, 1: extend group parallel relay on
  550. unsigned int ExtendRelayConfirmed:1; // 0: no effect, 1: extend group parallel relay confirmed
  551. unsigned int ExtendCompleted:1; // 0: no effect, 1: extend capability completed
  552. unsigned int ExtendCapabilityCtrlRes:25;
  553. // SlaveCtrlValue
  554. unsigned int SlaveChargingRequest:1; // 0: no effect, 1: request slave to charging after power off
  555. unsigned int CheckSlaveReady:1; // 0: no effect, 1: check if slave is ready
  556. unsigned int WaitSlaveReady:1; // 0: no effect, 1: wait slave is ready
  557. unsigned int SlavePowerOffRequest:1; // 0: no effect, 1: request slave to power off
  558. unsigned int SlavePowerOffConfirmed:1; // 0: no effect, 1: slave power off confirmed
  559. unsigned int SlaveCtrlRes:27;
  560. }bits;
  561. }PsuGroupControl;
  562. typedef struct
  563. {
  564. unsigned char Quantity;
  565. unsigned char RealQuantity;
  566. unsigned char Member[MAX_GROUP_QUANTITY]; // record slave group index
  567. }PsuGroupPartner;
  568. typedef struct
  569. {
  570. unsigned char Index;
  571. unsigned char Role;
  572. unsigned char PreRole;
  573. unsigned char Location;
  574. PsuGroupPartner Partner; // record slave group information
  575. PsuGroupPartner PossibleMember; // record possible slave group information
  576. unsigned char TargetGroup; // target group index + 1
  577. unsigned char ReservedTarget; // reserved target group index + 1
  578. PsuGroupControl GroupCtrl;
  579. unsigned short ReAssignAvailableCurrent; // group available current when reassign, unit: 0.1A
  580. unsigned short ParallelCheck;
  581. unsigned char ParallelConfig[MAX_GROUP_QUANTITY]; // group parallel relay setting
  582. unsigned short GunLoading; // gun output loading, unit: 0.01%
  583. unsigned char GunPsuQuantity; // record psu quantity at this gun
  584. unsigned char res;
  585. }PsuGroupCollectionData;
  586. typedef struct
  587. {
  588. unsigned short GTargetVoltage; // group target voltage config, unit: 0.1V
  589. unsigned short GTargetCurrent; // group target current config, unit: 0.1A
  590. unsigned short OutputLoading; // group output loading, unit: 0.01%
  591. }GroupOutputConfigInfo;
  592. typedef union
  593. {
  594. unsigned short CtrlValue;
  595. struct
  596. {
  597. unsigned short Output_N:1; // 0: set Output_N off, 1: set Output_N on
  598. unsigned short Output_P:1; // 0: set Output_P off, 1: set Output_P on
  599. unsigned short res:14;
  600. }bits;
  601. }PsuGroupOutputRelay;
  602. typedef union
  603. {
  604. unsigned short CtrlValue;
  605. struct
  606. {
  607. unsigned short Location_1_2:1; // 0: set parallel off, 1: set parallel on
  608. unsigned short Location_2_3:1; // 0: set parallel off, 1: set parallel on
  609. unsigned short Location_3_4:1; // 0: set parallel off, 1: set parallel on
  610. unsigned short Location_4_5:1; // 0: set parallel off, 1: set parallel on
  611. unsigned short res:12;
  612. }bits;
  613. }PsuGroupParallelRelay;
  614. typedef struct
  615. {
  616. byte Location[MAX_GROUP_QUANTITY];
  617. byte Layout[MAX_GROUP_QUANTITY];
  618. PsuGroupCollectionData GroupCollection[MAX_GROUP_QUANTITY];
  619. GroupOutputConfigInfo GroupOutput[MAX_GROUP_QUANTITY];
  620. PsuGroupOutputRelay OutputRelayConfig[MAX_GROUP_QUANTITY];
  621. PsuGroupOutputRelay OutputRelayConfirmed[MAX_GROUP_QUANTITY];
  622. PsuGroupParallelRelay ParallelRelayConfig;
  623. PsuGroupParallelRelay ParallelRelayConfirmed;
  624. }PsuGroupingInfoData;
  625. // ************************************************************************************************* //
  626. typedef enum
  627. {
  628. _SCONN_FREE = 0,
  629. _SCONN_WAIT = 1,
  630. _SCONN_MATCHED = 2,
  631. }_SOCKET_CONN_STATUS;
  632. typedef enum
  633. {
  634. _DeviceStatus_DisConnect = 0x00, // _DS_None , slave cabinet in re-connection
  635. _DeviceStatus_Identification = 0x01, // _DS_Identification , slave cabinet in identification
  636. _DeviceStatus_Idle = 0x02, // _DS_Idle , slave cabinet in idle
  637. _DeviceStatus_Alarm = 0x03, // _DS_Alarm , slave cabinet in alarm
  638. _DeviceStatus_Charging = 0x04, // _DS_Charging , no use in slave cabinet
  639. _DeviceStatus_Timeout = 0x05, // _DS_Timeout , no use in slave cabinet
  640. _DeviceStatus_RetryWait = 0x06,
  641. }_DEVICE_STATUS;
  642. typedef enum
  643. {
  644. _Parallel_None = 0,
  645. _Parallel_Wait = 1, // ac contactor off, 3s
  646. _Parallel_Working = 2, // ac contactor on and start re-initial psu
  647. _Parallel_Done = 3, // re-initial psu done
  648. }_PARALLEL_STATUS;
  649. typedef struct
  650. {
  651. unsigned char Status; // 0: free, 1: WaitModelName, 2: DispenserMatched
  652. unsigned char DeviceIndex; // record device index
  653. unsigned int IpAddress; // record device ip address
  654. unsigned char DuplicateIp; // 0: unique ip, 1: duplicate ip
  655. unsigned char res;
  656. }SocketConnInfoData;
  657. typedef struct
  658. {
  659. unsigned char LocalStatus; // 0: None, 1: Identification, 2: Idle, 3: Alarm, 4: Charging, 5: _DS_Timeout
  660. unsigned char SlaveID;
  661. unsigned char ModelName[64]; //charger model name
  662. unsigned char SerialNumber[64]; //charger system serial number
  663. unsigned char SystemId[128]; //charger system ID
  664. unsigned char CsuBootLoadFwRev[32]; //CSU board bootloader firmware version
  665. unsigned char CsuKernelFwRev[32]; //CSU board OS kernel firmware version
  666. unsigned char CsuRootFsFwRev[32]; //CSU board root file system firmware version
  667. unsigned char CsuPrimFwRev[32]; //CSU board root file system firmware version
  668. unsigned char LcmFwRev[32]; //LCM module firmware version
  669. unsigned char PsuPrimFwRev[32]; //PSU primary firmware version
  670. unsigned char PsuSecFwRev[32]; //PSU secondary firmware version
  671. unsigned char FanModuleFwRev[32]; //Fan module firmware version
  672. unsigned char RelayModuleFwRev[32]; //Relay control module firmware version
  673. unsigned char TelcomModemFwRev[32]; //the 3G/4G modem firmware version
  674. unsigned char LedModuleFwRev[32]; //LED control module firmware version
  675. unsigned char Connector1FwRev[32]; //Connector1 module firmware version
  676. unsigned char Connector2FwRev[32]; //Connector2 module firmware version
  677. unsigned char AcContactorSetting; // 0: OFF, 1: ON Master -> Slave
  678. unsigned char AcContactorState; // 0: OFF, 1: ON Slave -> Master
  679. unsigned char OutputRelaySetting[MAX_GROUP_QUANTITY]; // 0: OFF, 1: ON Master -> Slave
  680. unsigned char GunOutputRelayState[MAX_GROUP_QUANTITY]; // 0: OFF, 1: ON Slave -> Master
  681. unsigned char ParallelRelaySetting[MAX_GROUP_QUANTITY]; // 0: OFF, 1: ON Master -> Slave
  682. unsigned char ParallelRelayState[MAX_GROUP_QUANTITY]; // 0: OFF, 1: ON Slave -> Master
  683. unsigned char UpdateRequest; // 0: no effect, 1: need to update
  684. unsigned char res;
  685. char FwFileName[128];
  686. unsigned char SocketChannel; // record socket index
  687. unsigned char IpDuplicatedFlag; // 0: no effect, 1: ip is duplicated
  688. unsigned char ParallelRequest; // 0: no effect, 1: parallel request
  689. unsigned char ParallelConfirm; // 0: no effect, 1: parallel confirm
  690. unsigned short ParallelPower; // parallel power, unit: 0.1kw
  691. }SlaveCabinetInfoData;
  692. typedef struct
  693. {
  694. unsigned char ParallelStatus; // 0: parallel none, 1: wait, 2: in paralleling, 3: parallel done
  695. unsigned char ParallelCabinetQuantity; // record max dispenser quantity
  696. unsigned char PresentParallelCabinetQuantity; // present slave cabinet quantity
  697. unsigned char res;
  698. SlaveCabinetInfoData PCabinet[MAX_SLAVE_CABINET_QUANTITY];
  699. unsigned char PCUpdateState[MAX_SLAVE_CABINET_QUANTITY]; // 0: Not in Update, 1: Updating, 2: Updated
  700. unsigned short TotalParallelPower; // max total parallel power, unit: 0.1kw
  701. }ParallelCabinetInfoData;
  702. typedef struct
  703. {
  704. unsigned char SCabinetStatus;
  705. unsigned char SCabinetID;
  706. unsigned char SOutputRelay[MAX_GROUP_QUANTITY]; // parallel cabinet output relay state
  707. unsigned char SParallelRelay[MAX_GROUP_QUANTITY]; // parallel cabinet parallel relay state
  708. unsigned char SAcContactor; // slave cabinet ac contactor state
  709. unsigned char NeedUpgrade; // 1: Need Upgrade, 2: No Update
  710. unsigned char UpgradeState; // 0: Not in Update, 1: Updating, 2: Updated
  711. unsigned char res;
  712. char FwFileName[128];
  713. }SlaveCabinetControl;
  714. // ************************************************************************************************* //
  715. typedef struct
  716. {
  717. SystemAuthInfoData AuthInfo;
  718. SysControl Control;
  719. PsuPositionInfoData PsuPosition;
  720. PsuGroupingInfoData PsuGrouping;
  721. SocketConnInfoData CabinetConnInfo[MAX_SLAVE_CABINET_QUANTITY];
  722. ParallelCabinetInfoData ParallelCabinet;
  723. SlaveCabinetControl SCabinetControl;
  724. }ChargerInfoData;
  725. #endif /* CONFIG_H_ */