Config.h 35 KB

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