Module_EvTxComm.c 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdint.h>
  4. #include <string.h>
  5. #include <fcntl.h>
  6. #include <unistd.h>
  7. #include <time.h>
  8. #include <sys/ioctl.h>
  9. #include <sys/stat.h>
  10. #include <sys/timeb.h>
  11. #include <sys/time.h>
  12. #include <net/if.h>
  13. #include <linux/can.h>
  14. #include <linux/can/raw.h>
  15. #include "../Config.h"
  16. #include "../Log/log.h"
  17. #include "../Define/define.h"
  18. #include "../ShareMemory/shmMem.h"
  19. #include "Ev_Comm.h"
  20. #include "Module_EvComm.h"
  21. //------------------------------------------------------------------------------
  22. static struct SysConfigData *pSysConfig = NULL;
  23. static struct SysInfoData *pSysInfo = NULL;
  24. static struct FaultCodeData *pFaultCode = NULL;
  25. static struct AlarmCodeData *pAlarmCode = NULL;
  26. static struct CHAdeMOData *ShmCHAdeMOData = NULL;
  27. static struct GBTData *ShmGBTData = NULL;
  28. static struct CcsData *ShmCcsData = NULL;
  29. static DcCommonInfo *ShmDcCommonData = NULL;
  30. // 限制最大充電電壓,因應不同 type 槍線來限制
  31. // Chademo : 500V, 125A,
  32. // GB : 750, 120A
  33. // CCS : 950V, 120A
  34. //DS60-120 add
  35. //static double chademoVol = 5000;
  36. //static double ccsVol = 9500;
  37. //static double gbVol = 7500;
  38. static float maxChargingVol[2] = { 0, 0 }; // 限制最大充電電壓,如依照模塊則填上 0
  39. // 限制最大充電電流與能量透過 Web
  40. static float maxChargingCur[2] = { 0, 0 }; // 限制最大充電電流,如依照模塊則填上 0
  41. static float maxChargingPow = 0; // 限制最大充電能量,如依照模塊則填上 0
  42. static float LogInfo[2][10]; //DS60-120 add
  43. static int CanFd = -1;
  44. //------------------------------------------------------------------------------
  45. extern void CANReceiver(int fd);
  46. extern void ClearAbnormalStatus_Chademo(uint8_t gun_index);
  47. extern void ClearAbnormalStatus_GB(uint8_t gun_index);
  48. extern void ClearAbnormalStatus_CCS(uint8_t gun_index);
  49. //------------------------------------------------------------------------------
  50. int GetCanFd(void)
  51. {
  52. return CanFd;
  53. }
  54. uint32_t GetTimeoutValue(struct timeval _sour_time)
  55. {
  56. struct timeval _end_time;
  57. gettimeofday(&_end_time, NULL);
  58. return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
  59. }
  60. int InitCanBus(void)
  61. {
  62. int s0, nbytes;
  63. struct timeval tv;
  64. struct ifreq ifr0;
  65. struct sockaddr_can addr0;
  66. struct can_filter rxfilter[3];
  67. system("/sbin/ip link set can0 down");
  68. system("/sbin/ip link set can0 type can bitrate 500000 restart-ms 100");
  69. system("/sbin/ip link set can0 up");
  70. s0 = socket(PF_CAN, SOCK_RAW, CAN_RAW);
  71. tv.tv_sec = 0;
  72. tv.tv_usec = 10000;
  73. if (setsockopt(s0, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval)) < 0) {
  74. #ifdef SystemLogMessage
  75. log_error("Set SO_RCVTIMEO NG");
  76. #endif
  77. }
  78. nbytes = 40960;
  79. if (setsockopt(s0, SOL_SOCKET, SO_RCVBUF, &nbytes, sizeof(int)) < 0) {
  80. #ifdef SystemLogMessage
  81. log_error("Set SO_RCVBUF NG");
  82. #endif
  83. }
  84. nbytes = 40960;
  85. if (setsockopt(s0, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0) {
  86. #ifdef SystemLogMessage
  87. log_error("Set SO_SNDBUF NG");
  88. #endif
  89. }
  90. rxfilter[0].can_id = 0x01;
  91. rxfilter[0].can_mask = 0x000000FF;
  92. rxfilter[1].can_id = 0x02;
  93. rxfilter[1].can_mask = 0x000000FF;
  94. rxfilter[2].can_id = 0x01FF;
  95. rxfilter[2].can_mask = 0x00000FFF;
  96. if (setsockopt(s0, SOL_CAN_RAW, CAN_RAW_FILTER,
  97. &rxfilter, sizeof(struct can_filter) * 3) < 0) {
  98. log_error("RX setsockopt CAN_RAW_FILTER failed");
  99. }
  100. strcpy(ifr0.ifr_name, "can0" );
  101. ioctl(s0, SIOCGIFINDEX, &ifr0); /* ifr.ifr_ifindex gets filled with that device's index */
  102. addr0.can_family = AF_CAN;
  103. addr0.can_ifindex = ifr0.ifr_ifindex;
  104. bind(s0, (struct sockaddr *)&addr0, sizeof(addr0));
  105. return s0;
  106. }
  107. float GetMaxChargingVol(uint8_t index)
  108. {
  109. return maxChargingVol[index];
  110. }
  111. float GetMaxCharginigCur(uint8_t index)
  112. {
  113. return maxChargingCur[index];
  114. }
  115. static void SendCommunicationOnly(uint8_t index)
  116. {
  117. struct ChargingInfoData *pDcCharginigInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
  118. uint8_t targetID = pDcCharginigInfo->Evboard_id;
  119. if (pSysConfig->TotalConnectorCount == 1 &&
  120. pDcCharginigInfo->Type == _Type_CCS_2 &&
  121. ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
  122. targetID += 1;
  123. }
  124. SetChargingPermission(index,
  125. COMMUNICATION,
  126. pDcCharginigInfo->AvailableChargingPower,
  127. 0,
  128. 0,
  129. targetID);
  130. }
  131. static void SendStopOnly(uint8_t index)
  132. {
  133. struct ChargingInfoData *pDcCharginigInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
  134. uint8_t targetID = pDcCharginigInfo->Evboard_id;
  135. if (pSysConfig->TotalConnectorCount == 1 &&
  136. pDcCharginigInfo->Type == _Type_CCS_2 &&
  137. ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
  138. targetID += 1;
  139. }
  140. SetChargingPermission(index,
  141. STOP,
  142. pDcCharginigInfo->AvailableChargingPower,
  143. 0,
  144. 0,
  145. targetID);
  146. }
  147. static uint8_t GetStopChargingReasonByEvse(uint8_t gunIndex, uint8_t *reason)
  148. {
  149. uint8_t result = NO;
  150. struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
  151. if (pAlarmCode->AlarmEvents.bits.EmergencyStopTrip == 0x01) {
  152. // 012251
  153. *(reason + 5) = 0;
  154. *(reason + 4) = 1;
  155. *(reason + 3) = 2;
  156. *(reason + 2) = 2;
  157. *(reason + 1) = 5;
  158. *(reason + 0) = 1;
  159. result = YES;
  160. }
  161. if (pDcChargingInfo->Type == _Type_Chademo) {
  162. if (pFaultCode->FaultEvents.bits.ChademoOutputRelayDrivingFault == YES) {
  163. // 011012
  164. *(reason + 5) = 0;
  165. *(reason + 4) = 1;
  166. *(reason + 3) = 1;
  167. *(reason + 2) = 0;
  168. *(reason + 1) = 1;
  169. *(reason + 0) = 2;
  170. result = YES;
  171. } else if (pAlarmCode->AlarmEvents.bits.ChademoOutputUVPFail == YES) {
  172. // 012289
  173. *(reason + 5) = 0;
  174. *(reason + 4) = 1;
  175. *(reason + 3) = 2;
  176. *(reason + 2) = 2;
  177. *(reason + 1) = 8;
  178. *(reason + 0) = 9;
  179. result = YES;
  180. } else if (pAlarmCode->AlarmEvents.bits.ChademoGfdTrip == YES) {
  181. // 012234
  182. *(reason + 5) = 0;
  183. *(reason + 4) = 1;
  184. *(reason + 3) = 2;
  185. *(reason + 2) = 2;
  186. *(reason + 1) = 3;
  187. *(reason + 0) = 4;
  188. result = YES;
  189. }
  190. } else if (pDcChargingInfo->Type == _Type_GB) {
  191. if (pFaultCode->FaultEvents.bits.ChademoOutputRelayDrivingFault == YES) {
  192. // 012290
  193. *(reason + 5) = 0;
  194. *(reason + 4) = 1;
  195. *(reason + 3) = 2;
  196. *(reason + 2) = 2;
  197. *(reason + 1) = 9;
  198. *(reason + 0) = 0;
  199. result = YES;
  200. } else if (pAlarmCode->AlarmEvents.bits.GbGfdTrip == YES) {
  201. // 012236
  202. *(reason + 5) = 0;
  203. *(reason + 4) = 1;
  204. *(reason + 3) = 2;
  205. *(reason + 2) = 2;
  206. *(reason + 1) = 3;
  207. *(reason + 0) = 6;
  208. result = YES;
  209. }
  210. } else if (pDcChargingInfo->Type == _Type_CCS_2) {
  211. if (pFaultCode->FaultEvents.bits.CcsOutputRelayDrivingFault == YES) {
  212. // 011014
  213. *(reason + 5) = 0;
  214. *(reason + 4) = 1;
  215. *(reason + 3) = 1;
  216. *(reason + 2) = 0;
  217. *(reason + 1) = 1;
  218. *(reason + 0) = 4;
  219. result = YES;
  220. } else if (pAlarmCode->AlarmEvents.bits.CcsOutputUVPFail == YES) {
  221. // 012288
  222. *(reason + 5) = 0;
  223. *(reason + 4) = 1;
  224. *(reason + 3) = 2;
  225. *(reason + 2) = 2;
  226. *(reason + 1) = 8;
  227. *(reason + 0) = 8;
  228. result = YES;
  229. } else if (pAlarmCode->AlarmEvents.bits.CcsGfdTrip == YES) {
  230. // 012235
  231. *(reason + 5) = 0;
  232. *(reason + 4) = 1;
  233. *(reason + 3) = 2;
  234. *(reason + 2) = 2;
  235. *(reason + 1) = 3;
  236. *(reason + 0) = 5;
  237. result = YES;
  238. }
  239. }
  240. return result;
  241. }
  242. static void setCurrentOutput(void)
  243. {
  244. struct ChargingInfoData *chargingData_1 = NULL;
  245. struct ChargingInfoData *chargingData_2 = NULL;
  246. if (pSysConfig->TotalConnectorCount == 1) {
  247. chargingData_1 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
  248. //chargingData_2 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
  249. if (chargingData_1->FireChargingVoltage <= 500) { //DS60-120 add
  250. chargingData_1->PresentChargingCurrent = 0;
  251. }
  252. } else if (pSysConfig->TotalConnectorCount == 2) {
  253. chargingData_1 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
  254. chargingData_2 = (struct ChargingInfoData *)GetDcChargingInfoData(1);
  255. if (chargingData_1->FireChargingVoltage <= 500) { //DS60-120 add
  256. chargingData_1->PresentChargingCurrent = 0;
  257. }
  258. if (chargingData_2->FireChargingVoltage <= 500) {
  259. chargingData_2->PresentChargingCurrent = 0;
  260. }
  261. }
  262. }
  263. static void SetPresentChargingOutputCap(void)
  264. {
  265. float pow1 = 0, cur1 = 0;
  266. float pow2 = 0, cur2 = 0;
  267. struct ChargingInfoData *chargingData_1 = NULL;
  268. struct ChargingInfoData *chargingData_2 = NULL;
  269. if (pSysConfig->TotalConnectorCount == 1) {
  270. chargingData_1 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
  271. chargingData_2 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
  272. } else if (pSysConfig->TotalConnectorCount == 2) {
  273. chargingData_1 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
  274. chargingData_2 = (struct ChargingInfoData *)GetDcChargingInfoData(1);
  275. }
  276. #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
  277. float vol = 0;
  278. #endif //!defined DD360 && !defined DD360Audi
  279. pow1 = chargingData_1->AvailableChargingPower;
  280. cur1 = chargingData_1->AvailableChargingCurrent;
  281. #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
  282. vol = chargingData_1->MaximumChargingVoltage;
  283. GetMaxVolAndCurMethod(chargingData_1->Index, &vol, &cur1);
  284. GetMaxPowerMethod(chargingData_1->Index, &pow1);
  285. #endif //!defined DD360 && !defined DD360Audi
  286. //DS60-120 add
  287. if (pow1 <= 0) {
  288. cur1 = 0;
  289. } else {
  290. if (chargingData_1->SystemStatus == S_CHARGING &&
  291. chargingData_1->FireChargingVoltage > 1500) {
  292. float maxCur = 0;
  293. maxCur = (pow1 * 1000) / chargingData_1->FireChargingVoltage;
  294. if (maxCur * 10 <= cur1) {
  295. //log_info("Gun1 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur1);
  296. cur1 = maxCur * 10;
  297. }
  298. }
  299. }
  300. pow2 = chargingData_2->AvailableChargingPower;
  301. cur2 = chargingData_2->AvailableChargingCurrent;
  302. #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
  303. vol = chargingData_2->MaximumChargingVoltage;
  304. GetMaxVolAndCurMethod(chargingData_2->Index, &vol, &cur2);
  305. GetMaxPowerMethod(chargingData_2->Index, &pow2);
  306. #endif //!defined DD360 && !defined DD360Audi
  307. //DS60-120 add
  308. if (pow2 <= 0) {
  309. cur2 = 0;
  310. } else {
  311. if (chargingData_2->SystemStatus == S_CHARGING &&
  312. chargingData_2->FireChargingVoltage > 1500) {
  313. float maxCur = 0;
  314. maxCur = (pow2 * 1000) / chargingData_2->FireChargingVoltage;
  315. if (maxCur * 10 <= cur2) {
  316. //log_info("Gun2 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur2);
  317. cur2 = maxCur * 10;
  318. }
  319. }
  320. }
  321. //DS60-120 add
  322. if ((LogInfo[0][EV_LOG_OUTPUT_CAP_POW] <= pow1 - 5 ||
  323. LogInfo[0][EV_LOG_OUTPUT_CAP_POW] >= pow1 + 5) ||
  324. (LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] <= cur1 - 5 ||
  325. LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] >= cur1 + 5) ||
  326. (LogInfo[1][EV_LOG_OUTPUT_CAP_POW] <= pow2 - 5 ||
  327. LogInfo[1][EV_LOG_OUTPUT_CAP_POW] >= pow2 + 5) ||
  328. (LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] <= cur2 - 5 ||
  329. LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] >= cur2 + 5)
  330. ) {
  331. //log_info("----------------------------------------------------- \n");
  332. log_info("To EV (Real) Power_1 = %.1f, Cur_1 = %.1f, Power_2 = %.1f, Cur_2 = %.1f\r\n",
  333. pow1 / 10, cur1 / 10, pow2 / 10, cur2 / 10);
  334. //log_info("----------------------------------------------------- \n");
  335. LogInfo[0][EV_LOG_OUTPUT_CAP_POW] = pow1;
  336. LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] = cur1;
  337. LogInfo[1][EV_LOG_OUTPUT_CAP_POW] = pow2;
  338. LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] = cur2;
  339. chargingData_1->RealMaxCurrent = cur1;
  340. chargingData_1->RealMaxPower = pow1;
  341. if (pSysConfig->TotalConnectorCount == 2) {
  342. chargingData_2->RealMaxCurrent = cur2;
  343. chargingData_2->RealMaxPower = pow2;
  344. }
  345. }
  346. SetPresentOutputCapacity(pow1, cur1, pow2, cur2);
  347. }
  348. static void GetMaxVolAndCurMethod(uint8_t index, float *vol, float *cur)
  349. {
  350. struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
  351. if (maxChargingVol[index] != 0 && maxChargingVol[index] <= *vol) {
  352. *vol = maxChargingVol[index];
  353. }
  354. if (maxChargingCur[index] != 0 && maxChargingCur[index] <= *cur) {
  355. *cur = maxChargingCur[index];
  356. }
  357. if (((pDcChargingInfo->SystemStatus >= S_PREPARING_FOR_EVSE &&
  358. pDcChargingInfo->SystemStatus <= S_CHARGING) ||
  359. (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
  360. pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) &&
  361. pDcChargingInfo->ChargingProfileCurrent >= 0 &&
  362. pDcChargingInfo->ChargingProfileCurrent <= *cur
  363. ) {
  364. *cur = pDcChargingInfo->ChargingProfileCurrent;
  365. }
  366. }
  367. static void SetPresentChargingOutputPower(void)
  368. {
  369. float vol1 = 0, cur1 = 0;
  370. float vol2 = 0, cur2 = 0;
  371. struct ChargingInfoData *chargingData_1 = NULL;
  372. struct ChargingInfoData *chargingData_2 = NULL;
  373. if (pSysConfig->TotalConnectorCount == 1) {
  374. chargingData_1 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
  375. chargingData_2 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
  376. } else if (pSysConfig->TotalConnectorCount == 2) {
  377. chargingData_1 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
  378. chargingData_2 = (struct ChargingInfoData *)GetDcChargingInfoData(1);
  379. }
  380. vol1 = chargingData_1->FireChargingVoltage;
  381. cur1 = (chargingData_1->PresentChargingCurrent * 10);
  382. vol2 = chargingData_2->FireChargingVoltage;
  383. cur2 = (chargingData_2->PresentChargingCurrent * 10);
  384. //DS60-120 add
  385. if ((LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] >= vol1 + CHK_VOL_RANGE) ||
  386. (LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] <= vol1 - CHK_VOL_RANGE) ||
  387. (LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] >= cur1 + CHK_CUR_RANGE) ||
  388. (LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] <= cur1 - CHK_CUR_RANGE) ||
  389. (LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] >= vol2 + CHK_VOL_RANGE) ||
  390. (LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] <= vol2 - CHK_VOL_RANGE) ||
  391. (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) ||
  392. (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE)
  393. ) {
  394. log_info("G1 -> Output Vol = %.1f, Output Cur = %.1f -- G2 -> Output Vol = %.1f, Output Cur = %.1f\r\n",
  395. vol1 / 10,
  396. cur1 / 10,
  397. vol2 / 10,
  398. cur2 / 10);
  399. LogInfo[0][EV_LOG_NOW_OUTPUT_VOL] = vol1;
  400. LogInfo[0][EV_LOG_NOW_OUTPUT_CUR] = cur1;
  401. LogInfo[1][EV_LOG_NOW_OUTPUT_VOL] = vol2;
  402. LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] = cur2;
  403. }
  404. //if (_outVol_1 != vol1 ||
  405. // _outCur_1 != cur1 ||
  406. // _outVol_2 != vol2 ||
  407. // _outCur_2 != cur2) {
  408. /*log_info("G1 -> Output Vol = %f, Output Cur = %f -- G2 -> Output Vol = %f, Output Cur = %f \n",
  409. vol1, cur1, vol2, cur2);
  410. */
  411. // _outVol_1 = vol1; _outCur_1 = cur1; _outVol_2 = vol2; _outCur_2 = cur2;
  412. //}
  413. SetPresentOutputPower(vol1, cur1, vol2, cur2);
  414. }
  415. static void checkConnectorOVPState(uint8_t gunIndex)
  416. {
  417. struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
  418. // 避免槍溫偵測誤判
  419. static uint8_t gunTempAllowCount[2] = {0};
  420. bool isOTP = false;
  421. switch (pDcChargingInfo->Type) {
  422. case _Type_Chademo:
  423. if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectOTP) {
  424. isOTP = true;
  425. }
  426. break;
  427. case _Type_CCS_2:
  428. if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectOTP) {
  429. isOTP = true;
  430. }
  431. break;
  432. case _Type_GB:
  433. if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectOTP) {
  434. isOTP = true;
  435. }
  436. break;
  437. }
  438. if (isOTP) {
  439. if (gunTempAllowCount[gunIndex] >= 2) {
  440. pDcChargingInfo->StopChargeFlag = YES;
  441. } else {
  442. gunTempAllowCount[gunIndex] += 1;
  443. }
  444. } else {
  445. gunTempAllowCount[gunIndex] = 0;
  446. }
  447. }
  448. static time_t GetRtcInfoForEpoch(void)
  449. {
  450. struct timeb csuTime;
  451. struct tm *tmCSU;
  452. struct tm t;
  453. time_t result;
  454. ftime(&csuTime);
  455. tmCSU = localtime(&csuTime.time);
  456. t.tm_year = tmCSU->tm_year;
  457. t.tm_mon = tmCSU->tm_mon;
  458. t.tm_mday = tmCSU->tm_mday;
  459. t.tm_hour = tmCSU->tm_hour;
  460. t.tm_min = tmCSU->tm_min;
  461. t.tm_sec = tmCSU->tm_sec;
  462. t.tm_isdst = -1;
  463. result = mktime(&t);
  464. return result;
  465. }
  466. static void FormatVoltageAndCurrent(void)
  467. {
  468. uint8_t gunIndex = 0;
  469. ParsingRatedCur parsingRatedCur = {0};
  470. RateCurInfo *pRatedCurInfo = NULL;
  471. if (RatedCurrentParsing((char *)pSysConfig->ModelName, &parsingRatedCur) != PASS) {
  472. log_error("Parsing rated current failed\r\n");
  473. return;
  474. }
  475. maxChargingPow = parsingRatedCur.Power;
  476. for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
  477. pRatedCurInfo = (RateCurInfo *)&parsingRatedCur.ParsingInfo[gunIndex];
  478. maxChargingVol[gunIndex] = pRatedCurInfo->Voltage;
  479. maxChargingCur[gunIndex] = pRatedCurInfo->Current;
  480. log_info("Conn %d GunType = %d, MaxVol = %f, MaxCur = %f \n",
  481. gunIndex,
  482. pRatedCurInfo->GunType,
  483. maxChargingVol[gunIndex],
  484. maxChargingCur[gunIndex]);
  485. }
  486. }
  487. int main(int argc, char *argv[])
  488. {
  489. bool chkChademoPermission[2] = {false};
  490. int isContinue = 1;
  491. uint8_t gunIndex = 0;
  492. uint8_t typeIndex = 0;
  493. uint8_t priorityLow = 1;
  494. uint8_t SendErrorCount[2] = { 0, 0};
  495. uint32_t _timeBuf = 0;
  496. uint32_t chargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY] = {0};
  497. struct timeval _chk_ratingPower_timeout[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  498. struct timeval _chk_chademo_permission_timeout[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  499. time_t rtc = {0};
  500. struct ChargingInfoData *pDcChargingInfo = NULL;
  501. if (CreateAllCsuShareMemory() == FAIL) {
  502. log_error("create share memory error\r\n");
  503. return FAIL;
  504. }
  505. MappingGunChargingInfo("EvComm Task");
  506. pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  507. pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  508. pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  509. pFaultCode = (struct FaultCodeData *)GetShmFaultCodeData();
  510. ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  511. ShmCHAdeMOData = (struct CHAdeMOData *)GetShmCHAdeMOData();
  512. ShmGBTData = (struct GBTData *)GetShmGBTData();
  513. ShmCcsData = (struct CcsData *)GetShmCcsData();
  514. CanFd = InitCanBus();
  515. FormatVoltageAndCurrent();
  516. CANReceiver(CanFd);
  517. rtc = GetRtcInfoForEpoch();
  518. while (isContinue) {
  519. for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
  520. pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
  521. typeIndex = pDcChargingInfo->type_index;
  522. if (priorityLow == 1) {
  523. // 優先權較低 - 只要有回應即不會再詢問
  524. if (pDcChargingInfo->Type == _Type_Chademo &&
  525. ShmCHAdeMOData->evse[typeIndex].SelfTest_Comp != PASS) {
  526. SyncRtcInfo(gunIndex, pDcChargingInfo->Evboard_id, (int)rtc);
  527. GetFirmwareVersion(gunIndex, pDcChargingInfo->Evboard_id);
  528. } else if (pDcChargingInfo->Type == _Type_GB &&
  529. ShmGBTData->evse[typeIndex].SelfTest_Comp != PASS) {
  530. SyncRtcInfo(gunIndex, pDcChargingInfo->Evboard_id, (int)rtc);
  531. GetFirmwareVersion(gunIndex, pDcChargingInfo->Evboard_id);
  532. } else if (pDcChargingInfo->Type == _Type_CCS_2) {
  533. if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121 &&
  534. ShmCcsData->V2GMessage_DIN70121[typeIndex].SelfTest_Comp != PASS) {
  535. SyncRtcInfo(gunIndex, pDcChargingInfo->Evboard_id, (int)rtc);
  536. GetFirmwareVersion(gunIndex, pDcChargingInfo->Evboard_id);
  537. }
  538. }
  539. // 固定要取得的資訊 : 1.槍鎖狀態, 2."Connector 1" 溫度, 3."Connector 2" 溫度, 4.Pilot Voltage
  540. //log_info("GetMiscellaneousInfo. index = %d, Eid = %d \n", gunIndex, pDcChargingInfo->Evboard_id);
  541. GetMiscellaneousInfo(gunIndex,
  542. pDcChargingInfo->RelayK1K2Status,
  543. pDcChargingInfo->PresentChargedEnergy,
  544. (pDcChargingInfo->PresentChargingVoltage * 10),
  545. pDcChargingInfo->Evboard_id);
  546. checkConnectorOVPState(gunIndex);
  547. }
  548. switch (pDcChargingInfo->SystemStatus) {
  549. case S_IDLE:
  550. case S_RESERVATION:
  551. if (pDcChargingInfo->Type == _Type_Chademo) {
  552. ClearAbnormalStatus_Chademo(gunIndex);
  553. if (pSysInfo->PageIndex == _LCM_WAIT_FOR_PLUG) {
  554. if (!chkChademoPermission[gunIndex]) {
  555. chkChademoPermission[gunIndex] = true;
  556. gettimeofday(&_chk_chademo_permission_timeout[gunIndex], NULL);
  557. SendCommunicationOnly(gunIndex);
  558. } else {
  559. _timeBuf = GetTimeoutValue(_chk_chademo_permission_timeout[gunIndex]);
  560. if (_timeBuf < 0) {
  561. gettimeofday(&_chk_chademo_permission_timeout[gunIndex], NULL);
  562. } else {
  563. if (_timeBuf / 1000 > 10000) {
  564. SendCommunicationOnly(gunIndex);
  565. gettimeofday(&_chk_chademo_permission_timeout[gunIndex], NULL);
  566. }
  567. }
  568. }
  569. } else if (chkChademoPermission[gunIndex]) {
  570. chkChademoPermission[gunIndex] = false;
  571. SendStopOnly(gunIndex);
  572. }
  573. if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectOTP == NO) {
  574. pDcChargingInfo->StopChargeFlag = NO;
  575. }
  576. } else if (pDcChargingInfo->Type == _Type_GB) {
  577. ClearAbnormalStatus_GB(gunIndex);
  578. if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectOTP == NO) {
  579. pDcChargingInfo->StopChargeFlag = NO;
  580. }
  581. } else if (pDcChargingInfo->Type == _Type_CCS_2) {
  582. ClearAbnormalStatus_CCS(gunIndex);
  583. if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectOTP == NO) {
  584. pDcChargingInfo->StopChargeFlag = NO;
  585. }
  586. }
  587. if (priorityLow == 1) {
  588. pDcChargingInfo->PresentChargedEnergy = 0;
  589. pDcChargingInfo->PresentChargingPower = 0;
  590. pDcChargingInfo->GroundFaultStatus = GFD_WAIT;
  591. pDcChargingInfo->RealRatingPower = 0;
  592. pDcChargingInfo->StopChargeFlag = NO;
  593. pDcChargingInfo->NormalStopChargeFlag = NO;//DS60-120 add
  594. pDcChargingInfo->ChargingFee = 0.0;
  595. pDcChargingInfo->EvBatterySoc = 0;
  596. pDcChargingInfo->EvBatteryStartSoc = 0; //DS60-120 add
  597. pDcChargingInfo->EvBatteryMaxVoltage = 0; //DS60-120 add
  598. pDcChargingInfo->ChargingProfilePower = -1; //DS60-120 add
  599. pDcChargingInfo->ChargingProfileCurrent = -1; //DS60-120 add
  600. if (pSysInfo->MainChargingMode == _MAIN_CHARGING_MODE_MAX) { //DS60-120 add
  601. pDcChargingInfo->PresentChargingVoltage = 0;
  602. pDcChargingInfo->PresentChargingCurrent = 0;
  603. pDcChargingInfo->EvBatteryMaxVoltage = 0;
  604. }
  605. chargingTime[gunIndex] = 0;
  606. //maxChargingCur[gunIndex] = pSysConfig->MaxChargingCurrent * 10;
  607. //maxChargingPow = (pSysConfig->MaxChargingPower * 10);
  608. //DS60-120 add
  609. SendErrorCount[gunIndex] = 0;
  610. //maxChargingPow = pSysConfig->MaxChargingPower * 10;
  611. // ShmPsuData->SystemAvailablePower 已是 * 10
  612. //maxChargingPow = ShmPsuData->SystemAvailablePower;
  613. if (pSysConfig->MaxChargingPower * 10 != 0 &&
  614. pSysConfig->MaxChargingPower * 10 < maxChargingPow) {
  615. maxChargingPow = pSysConfig->MaxChargingPower * 10;
  616. }
  617. LogInfo[gunIndex][EV_LOG_EVSE_MAX_VOL] = 0;
  618. LogInfo[gunIndex][EV_LOG_EVSE_MAX_CUR] = 0;
  619. LogInfo[gunIndex][EV_LOG_MAX_BATT_VOL] = 0;
  620. LogInfo[gunIndex][EV_LOG_SOC] = 0;
  621. SetPresentChargingOutputPower();
  622. }
  623. break;
  624. case S_PREPARNING:
  625. chkChademoPermission[gunIndex] = false; //DS60-120 add
  626. // 設定當前輸出
  627. SetPresentChargingOutputPower();
  628. pDcChargingInfo->PowerConsumption = 0;
  629. break;
  630. case S_PREPARING_FOR_EV:
  631. // 開始確認車端是否同意開始充電 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
  632. GetOutputReq(gunIndex, pDcChargingInfo->Evboard_id);
  633. // log_info("PresentChargingVoltage = %f \n", pDcChargingInfo->PresentChargingVoltage);
  634. // log_info("PresentChargingCurrent = %f \n", pDcChargingInfo->PresentChargingCurrent);
  635. // log_info("AvailableChargingPower = %f \n", pDcChargingInfo->AvailableChargingPower);
  636. // log_info("AvailableChargingCurrent = %f \n", pDcChargingInfo->AvailableChargingCurrent);
  637. // log_info("MaximumChargingVoltage = %f \n", pDcChargingInfo->MaximumChargingVoltage);
  638. // 設定當前輸出
  639. SetPresentChargingOutputPower();
  640. if (priorityLow == 1) {
  641. float maxVol, maxCur;
  642. // 樁端輸出能力
  643. maxVol = pDcChargingInfo->MaximumChargingVoltage;
  644. maxCur = pDcChargingInfo->AvailableChargingCurrent;
  645. GetMaxVolAndCurMethod(gunIndex, &maxVol, &maxCur);
  646. //DS60-120 add
  647. if (LogInfo[gunIndex][EV_LOG_EVSE_MAX_VOL] != maxVol ||
  648. LogInfo[gunIndex][EV_LOG_EVSE_MAX_CUR] != maxCur) {
  649. LogInfo[gunIndex][EV_LOG_EVSE_MAX_VOL] = maxVol;
  650. LogInfo[gunIndex][EV_LOG_EVSE_MAX_CUR] = maxCur;
  651. log_info("To EV_%d Max_Vol = %.1f, Cap_Cur = %.1f, Cap_Pow = %.1f \n",
  652. gunIndex, maxVol / 10, maxCur / 10, pDcChargingInfo->AvailableChargingPower / 10);
  653. }
  654. //log_info("To EV_%d Max_Vol = %f, Cap_Cur = %f, Cap_Pow = %f \n",
  655. // gunIndex, maxVol, maxCur, pDcChargingInfo->AvailableChargingPower);
  656. pDcChargingInfo->RealMaxVoltage = maxVol;
  657. SetChargingPermission(gunIndex,
  658. START,
  659. pDcChargingInfo->AvailableChargingPower,
  660. maxCur,
  661. maxVol,
  662. pDcChargingInfo->Evboard_id);
  663. // 取得車端電池資訊 : 1.AC or DC ? 2.Total battery cap, 3.Max battery vol, 4.Max battery cur
  664. GetEvBatteryInfo(gunIndex, pDcChargingInfo->Evboard_id);
  665. }
  666. gettimeofday(&_chk_ratingPower_timeout[gunIndex], NULL);
  667. break;
  668. case S_PREPARING_FOR_EVSE:
  669. case S_CCS_PRECHARGE_ST0:
  670. case S_CCS_PRECHARGE_ST1:
  671. // 開始確認車端是否同意開始充電
  672. GetOutputReq(gunIndex, pDcChargingInfo->Evboard_id);
  673. // 設定當前輸出
  674. SetPresentChargingOutputPower();
  675. if (priorityLow % 5 == 1) {
  676. // 取得車端電池資訊 : 1.AC or DC ? 2.Total battery cap, 3.Max battery vol, 4.Max battery cur
  677. GetEvBatteryInfo(gunIndex, pDcChargingInfo->Evboard_id); //DS60-120 add
  678. // 樁端輸出能力改變
  679. SetPresentChargingOutputCap();
  680. }
  681. //DS60-120 add
  682. if (LogInfo[gunIndex][EV_LOG_MAX_BATT_VOL] != pDcChargingInfo->EvBatteryMaxVoltage) {
  683. LogInfo[gunIndex][EV_LOG_MAX_BATT_VOL] = pDcChargingInfo->EvBatteryMaxVoltage;
  684. log_info("index = %d, Ev Maximum Battery Voltage = %f \n",
  685. gunIndex,
  686. pDcChargingInfo->EvBatteryMaxVoltage);
  687. }
  688. if (LogInfo[gunIndex][EV_LOG_SOC] != pDcChargingInfo->EvBatterySoc) {
  689. LogInfo[gunIndex][EV_LOG_SOC] = pDcChargingInfo->EvBatterySoc;
  690. log_info("index = %d, SOC = %d \n",
  691. gunIndex,
  692. pDcChargingInfo->EvBatterySoc);
  693. }
  694. // 持續通知 Isolation 測試狀態
  695. if (priorityLow == 1) {
  696. // 拉 500 V 如果在一秒鐘內 GFD 都符合則 PASS
  697. // if (_chargingData[_index]->FireChargingVoltage >= 3500)
  698. // pDcChargingInfo->GroundFaultStatus = GFD_PASS;
  699. //log_info("To EV_%d GFD = %d \n", _index,pDcChargingInfo->GroundFaultStatus);
  700. //if(_chargingData[_index]->GroundFaultStatus != GFD_WAIT)
  701. {
  702. //if ((GetTimeoutValue(_derating_time) / 1000) > 1000)
  703. uint8_t _result = pDcChargingInfo->GroundFaultStatus;
  704. // GB & Chademo ~ Warning 也先算 Pass,因為 CCS 認證會驗 Warning 故不可更動
  705. if (pDcChargingInfo->Type == _Type_Chademo ||
  706. pDcChargingInfo->Type == _Type_GB) {
  707. if (_result == GFD_WARNING) {
  708. _result = GFD_PASS;
  709. }
  710. }
  711. if (_result == GFD_WARNING || _result == GFD_PASS) {
  712. if (((GetTimeoutValue(_chk_ratingPower_timeout[gunIndex]) / 1000) > 12000 &&
  713. pDcChargingInfo->RealRatingPower > 0) ||
  714. (GetTimeoutValue(_chk_ratingPower_timeout[gunIndex]) / 1000) > 14000) {
  715. //log_info("**********EvComm : gunIndex= %d, RealRatingPower = %d \n",
  716. // gunIndex,pDcChargingInfo->RealRatingPower);
  717. //_result = GFD_PASS;
  718. //DS60-120 add
  719. if (LogInfo[gunIndex][EV_LOG_REAL_CAP_POW] != pDcChargingInfo->RealRatingPower) {
  720. LogInfo[gunIndex][EV_LOG_REAL_CAP_POW] = pDcChargingInfo->RealRatingPower;
  721. log_info("Conn %d, RealRatingPower = %d \n",
  722. gunIndex,
  723. pDcChargingInfo->RealRatingPower);
  724. }
  725. } else {
  726. _result = GFD_WAIT;
  727. }
  728. }
  729. SetIsolationStatus(gunIndex, _result, pDcChargingInfo->Evboard_id);
  730. }
  731. if (pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST0 &&
  732. pDcChargingInfo->PrechargeStatus == PRECHARGE_READY) {
  733. SetEvsePrechargeInfo(gunIndex, PRECHARGE_PRERELAY_PASS, pDcChargingInfo->Evboard_id);
  734. }
  735. }
  736. break;
  737. case S_CHARGING:
  738. // 計算 Power
  739. pDcChargingInfo->PresentChargingPower =
  740. ((float)((pDcChargingInfo->PresentChargingVoltage) *
  741. (pDcChargingInfo->PresentChargingCurrent)) / 1000);
  742. //DS60-120 remove
  743. if (chargingTime[gunIndex] == 0 ||
  744. chargingTime[gunIndex] > pDcChargingInfo->PresentChargedDuration) {
  745. chargingTime[gunIndex] = pDcChargingInfo->PresentChargedDuration;
  746. } else {
  747. int passTime = pDcChargingInfo->PresentChargedDuration - chargingTime[gunIndex];
  748. if (passTime > 0) {
  749. float changingPow = (pDcChargingInfo->PresentChargingPower) * passTime / 3600;
  750. if (pSysConfig->BillingData.isBilling) {
  751. pDcChargingInfo->ChargingFee += changingPow * pSysConfig->BillingData.Cur_fee;
  752. }
  753. pDcChargingInfo->PresentChargedEnergy += changingPow;
  754. pDcChargingInfo->PowerConsumption += changingPow;
  755. chargingTime[gunIndex] = pDcChargingInfo->PresentChargedDuration;
  756. }
  757. }
  758. // 開始確認車端是否同意開始充電
  759. GetOutputReq(gunIndex, pDcChargingInfo->Evboard_id);
  760. // 設定當前輸出
  761. SetPresentChargingOutputPower();
  762. // for test end
  763. if (priorityLow % 5 == 0) {
  764. // 樁端輸出能力改變
  765. SetPresentChargingOutputCap();
  766. }
  767. if ((pDcChargingInfo->GroundFaultStatus == GFD_FAIL) ||
  768. (pDcChargingInfo->Type == _Type_CCS_2)) {
  769. SetIsolationStatus(gunIndex, pDcChargingInfo->GroundFaultStatus, pDcChargingInfo->Evboard_id);
  770. }
  771. /*
  772. else if (pDcChargingInfo->Type == _Type_CCS_2) {
  773. SetIsolationStatus(gunIndex, pDcChargingInfo->GroundFaultStatus, pDcChargingInfo->Evboard_id);
  774. }*/
  775. // GFD 失敗再通知
  776. if (priorityLow == 1) {
  777. if (pDcChargingInfo->Type == _Type_CCS_2 &&
  778. pDcChargingInfo->PrechargeStatus == PRECHARGE_READY) {
  779. SetEvsePrechargeInfo(gunIndex, PRECHARGE_CHARELAY_PASS, pDcChargingInfo->Evboard_id);
  780. }
  781. }
  782. break;
  783. case S_ALARM:
  784. case S_TERMINATING:
  785. // 設定當前輸出
  786. setCurrentOutput();
  787. SetPresentChargingOutputPower();
  788. // 槍鎖還在,則代表是樁端要求的停止
  789. if (pDcChargingInfo->GunLocked == START ||
  790. pDcChargingInfo->Type == _Type_CCS_2) {
  791. uint8_t normalStop = 0x01;
  792. uint8_t stopReason[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
  793. if (GetStopChargingReasonByEvse(gunIndex, stopReason)) {
  794. normalStop = 0x02;
  795. }
  796. EvseStopChargingEvent(normalStop, stopReason, pDcChargingInfo->Evboard_id);
  797. SendErrorCount[gunIndex] += 1; //DS60-120 add
  798. }
  799. if (pDcChargingInfo->Type == _Type_CCS_2) {
  800. SetIsolationStatus(gunIndex, pDcChargingInfo->GroundFaultStatus, pDcChargingInfo->Evboard_id);
  801. }
  802. GetOutputReq(gunIndex, pDcChargingInfo->Evboard_id);
  803. //DS60-120 add
  804. if (pDcChargingInfo->SystemStatus == S_ALARM) {
  805. if (priorityLow == 1) {
  806. float maxVol, maxCur;
  807. // 樁端輸出能力
  808. maxVol = pDcChargingInfo->MaximumChargingVoltage;
  809. maxCur = pDcChargingInfo->AvailableChargingCurrent;
  810. GetMaxVolAndCurMethod(gunIndex, &maxVol, &maxCur);
  811. SetChargingPermission(gunIndex,
  812. STOP,
  813. pDcChargingInfo->AvailableChargingPower,
  814. maxCur,
  815. maxVol,
  816. pDcChargingInfo->Evboard_id);
  817. }
  818. }
  819. break;
  820. case S_COMPLETE:
  821. // 設定當前輸出
  822. SetPresentChargingOutputPower();
  823. if (priorityLow == 1) {
  824. float maxVol, maxCur;
  825. // 樁端輸出能力
  826. maxVol = pDcChargingInfo->MaximumChargingVoltage;
  827. maxCur = pDcChargingInfo->AvailableChargingCurrent;
  828. GetMaxVolAndCurMethod(gunIndex, &maxVol, &maxCur);
  829. SetChargingPermission(gunIndex,
  830. STOP,
  831. pDcChargingInfo->AvailableChargingPower,
  832. maxCur,
  833. maxVol,
  834. pDcChargingInfo->Evboard_id);
  835. //DS60-120 add
  836. //if (pDcChargingInfo->EvBatterySoc >= 100) {
  837. // //滿電,則直接清掉錯誤
  838. // if (pDcChargingInfo->Type == _Type_Chademo) {
  839. // ClearAbnormalStatus_Chademo(gunIndex);
  840. // } else if (pDcChargingInfo->Type == _Type_GB) {
  841. // ClearAbnormalStatus_GB(gunIndex);
  842. // } else if (pDcChargingInfo->Type == _Type_CCS_2) {
  843. // ClearAbnormalStatus_CCS(gunIndex);
  844. // }
  845. //}
  846. }
  847. break;
  848. }//switch
  849. }//for
  850. priorityLow >= 20 ? priorityLow = 1 : priorityLow++;
  851. usleep(50000);
  852. }//while
  853. return 0;
  854. }