shmMem.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdint.h>
  4. #include <string.h>
  5. #include <stdbool.h>
  6. #include <unistd.h>
  7. #include <sys/ipc.h>
  8. #include <sys/shm.h>
  9. #include "../Define/define.h"
  10. //#include "../AudiCust.h"
  11. #include "../SelectGun/SelectGun.h"
  12. #include "../common.h"
  13. #include "../Log/log.h"
  14. #include "../Config.h"
  15. #include "shmMem.h"
  16. //------------------------------------------------------------------------------
  17. static struct SysConfigAndInfo *ShmSysConfigAndInfo = NULL;
  18. //static struct SysInfoData *ShmSysInfoData = NULL;
  19. //static struct SysConfigData *ShmSysConfigData = NULL;
  20. //static struct WARNING_CODE_INFO *SysWarningInfo = NULL;
  21. static struct StatusCodeData *ShmStatusCodeData = NULL;
  22. //static struct AlarmCodeData *ShmAlarmCodeData = NULL;
  23. //static struct FaultCodeData *ShmFaultCodeData = NULL;
  24. //static struct InfoCodeData *ShmInfoCodeData = NULL;
  25. static struct PsuData *ShmPsuData = NULL;
  26. static struct CHAdeMOData *ShmCHAdeMOData = NULL;
  27. static struct GBTData *ShmGBTData = NULL;
  28. static struct CcsData *ShmCcsData = NULL;
  29. static struct PrimaryMcuData *ShmPrimaryMcuData = NULL;
  30. static struct FanModuleData *ShmFanModuleData = NULL;
  31. static struct RelayModuleData *ShmRelayModuleData = NULL;
  32. static struct LedModuleData *ShmLedModuleData = NULL;
  33. static struct OCPP16Data *ShmOCPP16Data = NULL;
  34. static struct OCPP20Data* ShmOCPP20Data = NULL;
  35. static SelectGunInfo *ShmSelectGunInfo = NULL;
  36. static DcCommonInfo *ShmDcCommonData = NULL;
  37. static struct MeterInformation *ShmCsuMeterData = NULL;
  38. static struct ChargingInfoData *DcChargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY] = {NULL};
  39. static struct ChargingInfoData *AcChargingData[AC_QUANTITY] = {NULL};
  40. static GunIndexInfo gGunIndexInfo = {0};
  41. //struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  42. //struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  43. //struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
  44. //struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  45. //struct InfoCodeData *pInfoCode = (struct InfoCodeData *)GetShmInfoCodeData();
  46. //struct FaultCodeData *pFaultCode = (struct FaultCodeData *)GetShmFaultCodeData();
  47. //struct PsuData *ShmPsuData = (struct PsuData *)GetShmPsuData();
  48. //struct CHAdeMOData *ShmCHAdeMOData = (struct CHAdeMOData *)GetShmCHAdeMOData();
  49. //struct GBTData *ShmGBTData = (struct GBTData *)GetShmGBTData();
  50. //struct CcsData *ShmCcsData = (struct CcsData *)GetShmCcsData();
  51. //struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
  52. //struct FanModuleData *ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();
  53. //struct RelayModuleData *ShmRelayModuleData = (struct RelayModuleData *)GetShmRelayModuleData();
  54. //struct LedModuleData *ShmLedModuleData = (struct LedModuleData *)GetShmLedModuleData();
  55. //struct OCPP16Data *ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
  56. //SelectGunInfo *ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
  57. //DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
  58. //struct ChargingInfoData *pDcChargingInfo = NULL;
  59. //struct ChargingInfoData *pAcChargingInfo = NULL;
  60. //------------------------------------------------------------------------------
  61. void *GetGunIndexInfo(void)
  62. {
  63. return &gGunIndexInfo;
  64. }
  65. #if 0
  66. static int findChargingInfoData(uint8_t target, struct ChargingInfoData **chargingData)
  67. {
  68. uint8_t i = 0;
  69. for (i = 0; i < CHAdeMO_QUANTITY; i++) {
  70. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[i].Index == target) {
  71. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[i];
  72. return PASS;
  73. }
  74. }
  75. for (i = 0; i < CCS_QUANTITY; i++) {
  76. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[i].Index == target) {
  77. log_info("Index = %d, %d", target, ShmSysConfigAndInfo->SysInfo.CcsChargingData[i].Index);
  78. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[i];
  79. return PASS;
  80. }
  81. }
  82. for (i = 0; i < GB_QUANTITY; i++) {
  83. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[i].Index == target) {
  84. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[i];
  85. return PASS;
  86. }
  87. }
  88. return FAIL;
  89. }
  90. void MappingChargingInfoData(void) //DS60-120 add
  91. {
  92. bool isPass = true;
  93. uint8_t i = 0;
  94. while (isPass) {
  95. for (i = 0; i < 2; i++) {
  96. if (!findChargingInfoData(i, &DcChargingData[0])) {
  97. log_error("Find ChargingInfoData failed");
  98. isPass = false;
  99. break;
  100. }
  101. }
  102. sleep(1);
  103. }
  104. }
  105. #endif //0
  106. void SetAcChargingInfoData(uint8_t index, struct ChargingInfoData *chargingInfoIndex)
  107. {
  108. AcChargingData[index] = chargingInfoIndex;
  109. }
  110. void *GetAcChargingInfoData(uint8_t index)
  111. {
  112. return AcChargingData[index];
  113. }
  114. void SetDcChargingInfoData(uint8_t index, struct ChargingInfoData *chargingInfoIndex)
  115. {
  116. DcChargingData[index] = chargingInfoIndex;
  117. }
  118. void *GetDcChargingInfoData(uint8_t index)
  119. {
  120. return DcChargingData[index];
  121. }
  122. void *GetShmSysWarningInfo(void)
  123. {
  124. if (ShmSysConfigAndInfo == NULL) {
  125. return NULL;
  126. }
  127. return &ShmSysConfigAndInfo->SysWarningInfo;
  128. }
  129. void *GetShmSysConfigData(void)
  130. {
  131. if (ShmSysConfigAndInfo == NULL) {
  132. return NULL;
  133. }
  134. return &ShmSysConfigAndInfo->SysConfig;
  135. }
  136. void *GetShmSysInfoData(void)
  137. {
  138. if (ShmSysConfigAndInfo == NULL) {
  139. return NULL;
  140. }
  141. return &ShmSysConfigAndInfo->SysInfo;
  142. }
  143. void *GetShmSysConfigAndInfo(void)
  144. {
  145. if (ShmSysConfigAndInfo == NULL) {
  146. return NULL;
  147. }
  148. return ShmSysConfigAndInfo;
  149. }
  150. void *GetShmInfoCodeData(void)
  151. {
  152. if (ShmStatusCodeData == NULL) {
  153. return NULL;
  154. }
  155. return &ShmStatusCodeData->InfoCode;
  156. }
  157. void *GetShmFaultCodeData(void)
  158. {
  159. if (ShmStatusCodeData == NULL) {
  160. return NULL;
  161. }
  162. return &ShmStatusCodeData->FaultCode;
  163. }
  164. void *GetShmAlarmCodeData(void)
  165. {
  166. if (ShmStatusCodeData == NULL) {
  167. return NULL;
  168. }
  169. return &ShmStatusCodeData->AlarmCode;
  170. }
  171. void *GetShmStatusCodeData(void)
  172. {
  173. if (ShmStatusCodeData == NULL) {
  174. return NULL;
  175. }
  176. return ShmStatusCodeData;
  177. }
  178. void *GetShmPsuData(void)
  179. {
  180. if (ShmPsuData == NULL) {
  181. return NULL;
  182. }
  183. return ShmPsuData;
  184. }
  185. void *GetShmCHAdeMOData(void)
  186. {
  187. if (ShmCHAdeMOData == NULL) {
  188. return NULL;
  189. }
  190. return ShmCHAdeMOData;
  191. }
  192. void *GetShmGBTData(void)
  193. {
  194. if (ShmGBTData == NULL) {
  195. return NULL;
  196. }
  197. return ShmGBTData;
  198. }
  199. void *GetShmCcsData(void)
  200. {
  201. if (ShmCcsData == NULL) {
  202. return NULL;
  203. }
  204. return ShmCcsData;
  205. }
  206. void *GetShmPrimaryMcuData(void)
  207. {
  208. if (ShmPrimaryMcuData == NULL) {
  209. return NULL;
  210. }
  211. return ShmPrimaryMcuData;
  212. }
  213. void *GetShmFanModuleData(void)
  214. {
  215. if (ShmFanModuleData == NULL) {
  216. return NULL;
  217. }
  218. return ShmFanModuleData;
  219. }
  220. void *GetShmRelayModuleData(void)
  221. {
  222. if (ShmRelayModuleData == NULL) {
  223. return NULL;
  224. }
  225. return ShmRelayModuleData;
  226. }
  227. void *GetShmLedModuleData(void)
  228. {
  229. if (ShmLedModuleData == NULL) {
  230. return NULL;
  231. }
  232. return ShmLedModuleData;
  233. }
  234. void *GetShmOCPP16Data(void)
  235. {
  236. if (ShmOCPP16Data == NULL) {
  237. return NULL;
  238. }
  239. return ShmOCPP16Data;
  240. }
  241. void* GetShmOCPP20Data(void)
  242. {
  243. if (ShmOCPP20Data == NULL) {
  244. return NULL;
  245. }
  246. return ShmOCPP20Data;
  247. }
  248. void *GetShmSelectGunInfo(void)
  249. {
  250. if (ShmSelectGunInfo == NULL) {
  251. return NULL;
  252. }
  253. return ShmSelectGunInfo;
  254. }
  255. void *GetShmDcCommonData(void)
  256. {
  257. if (ShmDcCommonData == NULL) {
  258. return NULL;
  259. }
  260. return ShmDcCommonData;
  261. }
  262. void *GetShmCsuMeterData(void)
  263. {
  264. if (ShmCsuMeterData == NULL) {
  265. return NULL;
  266. }
  267. return ShmCsuMeterData;
  268. }
  269. //------------------------------------------------------------------------------
  270. static void initialGunIndexToUnUse(void)
  271. {
  272. uint8_t index = 0;
  273. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  274. for (index = 0; index < CHAdeMO_QUANTITY; index++) {
  275. pSysInfo->ChademoChargingData[index].Index = NO_DEFINE;
  276. }
  277. for (index = 0; index < CCS_QUANTITY; index++) {
  278. pSysInfo->CcsChargingData[index].Index = NO_DEFINE;
  279. }
  280. for (index = 0; index < GB_QUANTITY; index++) {
  281. pSysInfo->GbChargingData[index].Index = NO_DEFINE;
  282. }
  283. for (index = 0; index < AC_QUANTITY; index++) {
  284. pSysInfo->AcChargingData[index].Index = NO_DEFINE;
  285. }
  286. }
  287. #if 0
  288. static void getFirmwareVersion(void)
  289. {
  290. uint8_t count = 0, chademo = 0, ccs = 0, gb = 0;
  291. uint8_t index = 0;
  292. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  293. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  294. // Get CSU root file system version
  295. sprintf((char *)pSysInfo->CsuRootFsFwRev, fwVersion);
  296. for (index = 0; index < 3; index++) {
  297. if (pSysConfig->ModelName[7 + index] == 'J') {
  298. chademo++;
  299. count++;
  300. } else if (pSysConfig->ModelName[7 + index] == 'G') {
  301. gb++;
  302. count++;
  303. } else if (pSysConfig->ModelName[7 + index] == 'U' ||
  304. pSysConfig->ModelName[7 + index] == 'V' ||
  305. pSysConfig->ModelName[7 + index] == 'E') {
  306. ccs++;
  307. count++;
  308. }
  309. }
  310. if (count == 1) {
  311. if (chademo > 0) {
  312. pSysInfo->CsuRootFsFwRev[7] = '1';
  313. } else if (ccs > 0) {
  314. pSysInfo->CsuRootFsFwRev[7] = '2';
  315. } else if (gb > 0) {
  316. pSysInfo->CsuRootFsFwRev[7] = '3';
  317. }
  318. } else {
  319. if (chademo > 0 && ccs > 0) {
  320. pSysInfo->CsuRootFsFwRev[7] = '4';
  321. } else if (chademo > 0 && gb > 0) {
  322. pSysInfo->CsuRootFsFwRev[7] = '5';
  323. } else if (ccs > 0 && gb > 0) {
  324. pSysInfo->CsuRootFsFwRev[7] = '6';
  325. }
  326. }
  327. // Get network option from model name
  328. switch (pSysConfig->ModelName[10]) {
  329. case 'B':
  330. case 'U':
  331. //Blue tooth
  332. pSysInfo->CsuRootFsFwRev[9] = '3';
  333. break;
  334. case 'W':
  335. // WIFI
  336. pSysInfo->CsuRootFsFwRev[9] = '1';
  337. break;
  338. case 'T':
  339. // 3G/4G
  340. pSysInfo->CsuRootFsFwRev[9] = '2';
  341. break;
  342. case 'D': //DS60-120 add
  343. pSysInfo->CsuRootFsFwRev[9] = '5';
  344. break;
  345. default:
  346. // LAN
  347. pSysInfo->CsuRootFsFwRev[9] = '0';
  348. break;
  349. }
  350. // Get rating power from model name
  351. memcpy(&pSysInfo->CsuRootFsFwRev[10], &pSysConfig->ModelName[4], 0x03);
  352. // Get IEC or UL
  353. char _buf[3] = {0};
  354. memcpy(_buf, &pSysConfig->ModelName[2], 2);
  355. if (strcmp(_buf, "YE") == EQUAL || strcmp(_buf, "YC") == EQUAL) {
  356. pSysInfo->ChargerType = _CHARGER_TYPE_IEC;
  357. log_info("IEC model");
  358. } else if (strcmp(_buf, "WU") == EQUAL) {
  359. pSysInfo->ChargerType = _CHARGER_TYPE_UL;
  360. log_info("UL model");
  361. }
  362. }
  363. #endif //0
  364. void InitialShareMemoryInfo(void)
  365. {
  366. FILE *fp = NULL;
  367. char cmd[512] = {0};
  368. char buf[512] = {0};
  369. struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  370. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  371. struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
  372. //SysConfig init
  373. sprintf((char *)pSysConfig->TelecomInterface.TelcomApn, "Internet");
  374. sprintf((char *)pSysConfig->TelecomInterface.TelcomChapPapId, " ");
  375. sprintf((char *)pSysConfig->TelecomInterface.TelcomChapPapPwd, " ");
  376. pSysConfig->TotalConnectorCount = 0;
  377. pSysConfig->AcConnectorCount = 0;
  378. memcpy(pSysInfo->CsuBootLoadFwRev,
  379. pSysConfig->CsuBootLoadFwRev,
  380. ARRAY_SIZE(pSysConfig->CsuBootLoadFwRev));
  381. strcpy((char *) pSysConfig->UserId, "");
  382. pSysConfig->QRCodeMadeMode = NO; //DS60-120 add
  383. pSysConfig->SwitchDebugFlag = NO;
  384. pSysConfig->AlwaysGfdFlag = NO;
  385. //SysInfo init
  386. pSysInfo->FactoryConfiguration = 0;
  387. pSysInfo->InputVoltageR = 0;
  388. pSysInfo->InputVoltageS = 0;
  389. pSysInfo->InputVoltageT = 0;
  390. pSysInfo->SystemFanRotaSpeed = 0;
  391. pSysInfo->PsuFanRotaSpeed = 0;
  392. pSysInfo->AuxPower5V = 0;
  393. pSysInfo->AuxPower12V = 0;
  394. pSysInfo->AuxPower24V = 0;
  395. pSysInfo->AuxPower48V = 0;
  396. sprintf((char *)pSysInfo->CsuHwRev, "REV:5.0");
  397. sprintf(cmd, "/bin/uname -r");
  398. fp = popen(cmd, "r");
  399. if (fp == NULL) {
  400. sprintf((char *)pSysInfo->CsuKernelFwRev, "Unknown version");
  401. } else {
  402. while (fgets(buf, sizeof(buf), fp) != NULL) {
  403. strcpy((char *)pSysInfo->CsuKernelFwRev, buf);
  404. }
  405. }
  406. // 雙槍 CCS + Chademo
  407. //getFirmwareVersion();
  408. //sprintf((char *) pSysInfo->CsuRootFsFwRev, fwVersion);
  409. sprintf((char *) pSysInfo->CsuPrimFwRev, " ");
  410. sprintf((char *)pSysInfo->LcmHwRev, " ");
  411. sprintf((char *)pSysInfo->LcmFwRev, " ");
  412. sprintf((char *)pSysInfo->PsuHwRev, " ");
  413. sprintf((char *)pSysInfo->PsuPrimFwRev, " ");
  414. sprintf((char *)pSysInfo->PsuSecFwRev, " ");
  415. sprintf((char *)pSysInfo->AuxPwrHwRev, " ");
  416. sprintf((char *)pSysInfo->AuxPwrFwRev, " ");
  417. sprintf((char *)pSysInfo->FanModuleHwRev, " ");
  418. sprintf((char *)pSysInfo->FanModuleFwRev, " ");
  419. sprintf((char *)pSysInfo->RelayModuleHwRev, " ");
  420. sprintf((char *)pSysInfo->RelayModuleFwRev, " ");
  421. sprintf((char *)pSysInfo->TelcomModemFwRev, " ");
  422. pSysInfo->SystemAmbientTemp = 0;
  423. pSysInfo->SystemCriticalTemp = 0;
  424. pSysInfo->PsuAmbientTemp = 0;
  425. pSysInfo->CcsConnectorTemp = 0;
  426. pSysInfo->InternetConn = 0;
  427. pSysInfo->OcppConnStatus = 0;
  428. pSysInfo->OrderCharging = NO_DEFINE;
  429. memset(pSysInfo->FanModuleFwRev, 0, ARRAY_SIZE(pSysInfo->FanModuleFwRev));
  430. memset(pSysInfo->RelayModuleFwRev, 0, ARRAY_SIZE(pSysInfo->RelayModuleFwRev));
  431. #if defined DD360Audi
  432. pSysInfo->SystemPage = _LCM_SELECT_GUN;
  433. #else
  434. pSysInfo->SystemPage = _LCM_NONE;
  435. #endif //defined DD360Audi
  436. pSysInfo->MainChargingMode = _MAIN_CHARGING_MODE_MAX;
  437. pSysInfo->ReAssignedFlag = _REASSIGNED_NONE;
  438. pSysInfo->CurGunSelectedByAc = NO_DEFINE;
  439. pSysInfo->BootingStatus = BOOTTING; //DS60-120 add
  440. //other board init
  441. ShmPrimaryMcuData->SelfTest_Comp = NO;
  442. ShmRelayModuleData->SelfTest_Comp = NO;
  443. ShmFanModuleData->SelfTest_Comp = NO;
  444. ShmLedModuleData->SelfTest_Comp = NO;
  445. ShmFanModuleData->TestFanSpeed = 0;
  446. //status code init
  447. pAlarmCode->AlarmEvents.bits.RelayboardStestFail = NO;
  448. pAlarmCode->AlarmEvents.bits.FanboardStestFail = NO;
  449. pAlarmCode->AlarmEvents.bits.PrimaryStestFail = NO;
  450. pAlarmCode->AlarmEvents.bits.LedboardStestFail = NO; //DS60-120 Add
  451. pAlarmCode->AlarmEvents.bits.ChademoboardStestFail = NO;
  452. pAlarmCode->AlarmEvents.bits.CCSboardStestFail = NO;
  453. pAlarmCode->AlarmEvents.bits.AcContactStestFail = NO;
  454. pAlarmCode->AlarmEvents.bits.PsuModuleStestFail = NO;
  455. pAlarmCode->AlarmEvents.bits.PsuDipSwitchStestFail = NO; //DS60-120 Add
  456. pAlarmCode->AlarmEvents.bits.ModelNameNoneMatchStestFail = NO;
  457. pAlarmCode->AlarmEvents.bits.PsuNoResource = NO;
  458. pAlarmCode->AlarmEvents.bits.FailToCreateShareMemory = NO;
  459. initialGunIndexToUnUse();//DS60-120 add
  460. //ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V015S0;
  461. //ShmDcCommonData->psuKeepCommunication = NO;
  462. //ShmDcCommonData->acContactSwitch = NO;
  463. ShmDcCommonData->ConnectErrList[0].GunErrMessage = 0;
  464. ShmDcCommonData->ConnectErrList[1].GunErrMessage = 0;
  465. ShmDcCommonData->TestTemperature = NO;
  466. //ShmDcCommonData->LcmFwVersion = 0;
  467. }
  468. int InitSelectGunShmMem(void)
  469. {
  470. int MeterSMId = FAIL;
  471. #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
  472. return;
  473. #endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
  474. if ((MeterSMId = shmget(ShmSelectGunInfoKey, sizeof(SelectGunInfo), IPC_CREAT | 0777)) < 0) {
  475. return FAIL;
  476. } else if ((ShmSelectGunInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  477. return FAIL;
  478. }
  479. return PASS;
  480. }
  481. int InitCommonShmMem(void)
  482. {
  483. int MeterSMId = FAIL;
  484. if ((MeterSMId = shmget(ShmCommonKey, sizeof(DcCommonInfo), IPC_CREAT | 0777)) < 0) {
  485. return FAIL;
  486. } else if ((ShmDcCommonData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  487. return FAIL;
  488. }
  489. return PASS;
  490. }
  491. //int InitCSUMeterShmMem(void)
  492. //{
  493. // int MeterSMId = FAIL;
  494. //
  495. // if ((MeterSMId = shmget(ShmCsuMeterKey, sizeof(struct MeterInformation), IPC_CREAT | 0777)) < 0) {
  496. // return FAIL;
  497. // } else if ((ShmCsuMeterInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  498. // return FAIL;
  499. // }
  500. //
  501. // return PASS;
  502. //}
  503. int InitOCPPShmMem(void)
  504. {
  505. int MeterSMId = FAIL;
  506. if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), IPC_CREAT | 0777)) < 0) {
  507. log_info("Get OCPP share memory error");
  508. return FAIL;
  509. } else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  510. log_info("Create OCPP share memory error");
  511. return FAIL;
  512. }
  513. return PASS;
  514. }
  515. int InitOCPP20ShmMem(void)
  516. {
  517. int MeterSMId = FAIL;
  518. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), IPC_CREAT | 0777)) < 0) {
  519. log_info("Get OCPP20 share memory error");
  520. return FAIL;
  521. } else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void*)-1) {
  522. log_info("Create OCPP20 share memory error");
  523. return FAIL;
  524. }
  525. return PASS;
  526. }
  527. int InitLEDShmMem(void)
  528. {
  529. int MeterSMId = FAIL;
  530. if ((MeterSMId = shmget(ShmLedBdKey, sizeof(struct LedModuleData), IPC_CREAT | 0777)) < 0) {
  531. return FAIL;
  532. } else if ((ShmLedModuleData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  533. return FAIL;
  534. }
  535. return PASS;
  536. }
  537. int InitRelayShmMem(void)
  538. {
  539. int MeterSMId = FAIL;
  540. if ((MeterSMId = shmget(ShmRelayBdKey, sizeof(struct RelayModuleData), IPC_CREAT | 0777)) < 0) {
  541. return FAIL;
  542. } else if ((ShmRelayModuleData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  543. return FAIL;
  544. }
  545. return PASS;
  546. }
  547. int InitFanShmMem(void)
  548. {
  549. int MeterSMId = FAIL;
  550. if ((MeterSMId = shmget(ShmFanBdKey, sizeof(struct FanModuleData), IPC_CREAT | 0777)) < 0) {
  551. return FAIL;
  552. } else if ((ShmFanModuleData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  553. return FAIL;
  554. }
  555. return PASS;
  556. }
  557. int InitPrimaryShmMem(void)
  558. {
  559. int MeterSMId = FAIL;
  560. if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), IPC_CREAT | 0777)) < 0) {
  561. return FAIL;
  562. } else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  563. return FAIL;
  564. }
  565. return PASS;
  566. }
  567. int InitCCSShmMem(void)
  568. {
  569. int MeterSMId = FAIL;
  570. if ((MeterSMId = shmget(ShmCcsCommKey, sizeof(struct CcsData), IPC_CREAT | 0777)) < 0) {
  571. return FAIL;
  572. } else if ((ShmCcsData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  573. return FAIL;
  574. }
  575. return PASS;
  576. }
  577. int InitGBShmMem(void)
  578. {
  579. int MeterSMId = FAIL;
  580. if ((MeterSMId = shmget(ShmGBTCommKey, sizeof(struct GBTData), IPC_CREAT | 0777)) < 0) {
  581. return FAIL;
  582. } else if ((ShmGBTData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  583. return FAIL;
  584. }
  585. return PASS;
  586. }
  587. int InitCHADeMoShmMem(void)
  588. {
  589. int MeterSMId = FAIL;
  590. if ((MeterSMId = shmget(ShmCHAdeMOCommKey, sizeof(struct CHAdeMOData), IPC_CREAT | 0777)) < 0) {
  591. return FAIL;
  592. } else if ((ShmCHAdeMOData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  593. return FAIL;
  594. }
  595. return PASS;
  596. }
  597. int InitPSUDataShmMem(void)
  598. {
  599. int MeterSMId = FAIL;
  600. //creat ShmPsuData
  601. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), IPC_CREAT | 0777)) < 0) {
  602. return FAIL;
  603. } else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  604. return FAIL;
  605. }
  606. return PASS;
  607. }
  608. int InitStatusCodeShmMem(void)
  609. {
  610. int MeterSMId = FAIL;
  611. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), IPC_CREAT | 0777)) < 0) {
  612. return FAIL;
  613. } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  614. return FAIL;
  615. }
  616. return PASS;
  617. }
  618. int InitSysConfigAndInfoShmMem(void)
  619. {
  620. int MeterSMId = FAIL;
  621. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), IPC_CREAT | 0777)) < 0) {
  622. printf("1 InitSysConfigAndInfoShmMem");
  623. return FAIL;
  624. } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
  625. printf("2 InitSysConfigAndInfoShmMem");
  626. return FAIL;
  627. }
  628. return PASS;
  629. }
  630. int InitShmCsuMeterShmMem(void)
  631. {
  632. int MeterSMId = FAIL;
  633. if ((MeterSMId = shmget(ShmCsuMeterKey, sizeof(struct MeterInformation), IPC_CREAT | 0777)) < 0)
  634. {
  635. printf("shmget ShmCsuMeterKey NG \n");
  636. return 0;
  637. }
  638. else if ((ShmCsuMeterData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  639. {
  640. printf("shmat ShmCsuMeterData NG \n");
  641. return 0;
  642. }
  643. return PASS;
  644. }
  645. void ClearAllShmMemParameter(void)
  646. {
  647. uint8_t i = 0;
  648. memset(ShmSysConfigAndInfo, 0, sizeof(struct SysConfigAndInfo));
  649. memset(ShmStatusCodeData, 0, sizeof(struct StatusCodeData));
  650. memset(ShmPsuData, 0, sizeof(struct PsuData));
  651. if (CHAdeMO_QUANTITY > 0) {
  652. memset(ShmCHAdeMOData, 0, sizeof(struct CHAdeMOData));
  653. }
  654. if (GB_QUANTITY > 0) {
  655. memset(ShmGBTData, 0, sizeof(struct GBTData));
  656. }
  657. if (CCS_QUANTITY > 0) {
  658. memset(ShmCcsData, 0, sizeof(struct CcsData));
  659. }
  660. memset(ShmPrimaryMcuData, 0, sizeof(struct PrimaryMcuData));
  661. memset(ShmFanModuleData, 0, sizeof(struct FanModuleData));
  662. memset(ShmRelayModuleData, 0, sizeof(struct RelayModuleData));
  663. memset(ShmLedModuleData, 0, sizeof(struct LedModuleData));
  664. //memset(ShmOCPP16Data,0,sizeof(struct OCPP16Data));
  665. //memset(ShmCsuMeterInfo, 0, sizeof(struct MeterInformation));
  666. memset(ShmDcCommonData, 0, sizeof(DcCommonInfo));
  667. #if defined DD360 || defined DD360Audi || defined DD360ComBox
  668. memset(ShmSelectGunInfo, 0, sizeof(SelectGunInfo));
  669. for (i = 0; i < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; i++) {
  670. ShmSelectGunInfo->PricesInfo[i].Balance = FAIL_BALANCE_PRICES;
  671. }
  672. #endif //defined DD360 || defined DD360Audi || defined DD360ComBox
  673. }
  674. static void setAcGunTiggerStatus(void)
  675. {
  676. struct ChargingInfoData *pAcChargingInfo = NULL;
  677. if (gGunIndexInfo.AcGunIndex == 0) {
  678. return;
  679. }
  680. pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(gGunIndexInfo.AcGunIndex);
  681. pAcChargingInfo->schedule.isTriggerStart = NO; //DS60-120 add
  682. pAcChargingInfo->schedule.isTriggerStop = NO; //DS60-120 add
  683. }
  684. static int findAcChargingInfoData(uint8_t gunIndex)
  685. {
  686. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  687. //acChargingData[gunIndex] = &pSysInfo->AcChargingData[0];
  688. SetAcChargingInfoData(gunIndex, &pSysInfo->AcChargingData[0]);
  689. return PASS;
  690. }
  691. static int findDcChargingInfoData(uint8_t gunIndex)
  692. {
  693. uint8_t i = 0;
  694. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  695. //printf("Chademo count = %d\n", gGunIndexInfo.ChademoIndex);
  696. for (i = 0; i < gGunIndexInfo.DcGunIndex; i++) {
  697. if (pSysInfo->ChademoChargingData[i].Index == gunIndex) {
  698. //printf("chademo index = %d, %d\n", pSysInfo->ChademoChargingData[i].Index, gunIndex);
  699. //dcChargingData[gunIndex] = &pSysInfo->ChademoChargingData[i];
  700. SetDcChargingInfoData(pSysInfo->ChademoChargingData[i].Index, &pSysInfo->ChademoChargingData[i]);
  701. return PASS;
  702. }
  703. }
  704. //printf("ccs count = %d\n", gGunIndexInfo.CcsIndex);
  705. for (i = 0; i < gGunIndexInfo.DcGunIndex; i++) {
  706. if (pSysInfo->CcsChargingData[i].Index == gunIndex) {
  707. //printf("ccs index = %d, %d\n", pSysInfo->CcsChargingData[i].Index, gunIndex);
  708. //dcChargingData[gunIndex] = (struct ChargingInfoData *)&pSysInfo->CcsChargingData[i];
  709. SetDcChargingInfoData(pSysInfo->CcsChargingData[i].Index, &pSysInfo->CcsChargingData[i]);
  710. return PASS;
  711. }
  712. }
  713. for (i = 0; i < gGunIndexInfo.DcGunIndex; i++) {
  714. if (pSysInfo->GbChargingData[i].Index == gunIndex) {
  715. //dcChargingData[gunIndex] = &pSysInfo->GbChargingData[i];
  716. SetDcChargingInfoData(pSysInfo->GbChargingData[i].Index, &pSysInfo->GbChargingData[i]);
  717. return PASS;
  718. }
  719. }
  720. return FAIL;
  721. }
  722. static bool addGunInfoByConnector(uint8_t typeValue, uint8_t slots,char *whichtask)
  723. {
  724. bool result = true;
  725. struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
  726. struct ChargingInfoData *pDcChargingInfo = NULL;
  727. struct ChargingInfoData *pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(gGunIndexInfo.AcGunIndex);
  728. struct CcsData *pCcsData = (struct CcsData *)GetShmCcsData();
  729. switch (typeValue) {
  730. // AC Gun Type -------------------------------------------------------------
  731. case '0': // none
  732. break;
  733. case '1': // IEC 62196-2 Type 1/SAE J1772 Plug
  734. break;
  735. case '2': // IEC 62196-2 Type 1/SAE J1772 Socket
  736. break;
  737. case '3': // IEC 62196-2 Type 2 Plug
  738. case '4': // IEC 62196-2 Type 2 Socket
  739. if (AC_QUANTITY > gGunIndexInfo.AcIndex) {
  740. pAcChargingInfo = (struct ChargingInfoData *)&pSysInfo->AcChargingData[gGunIndexInfo.AcIndex];
  741. // AC 固定 index
  742. pAcChargingInfo->Index = 0;
  743. pAcChargingInfo->ReservationId = -1;
  744. pAcChargingInfo->SystemStatus = S_IDLE;
  745. pAcChargingInfo->Type = _Type_AC;
  746. pAcChargingInfo->schedule.isTriggerStart = NO; //DS60-120 add
  747. pAcChargingInfo->schedule.isTriggerStop = NO; //DS60-120 add
  748. //if( strcmp(whichtask,"CSU task") == EQUAL )
  749. {
  750. gGunIndexInfo.AcIndex++;
  751. gGunIndexInfo.AcGunIndex++;
  752. pAcChargingInfo->IsAvailable = YES;
  753. }
  754. } else {
  755. result = false;
  756. }
  757. break;
  758. case '5': // GB/T AC Plug
  759. break;
  760. case '6': // GB/T AC Socket
  761. break;
  762. //DC Gun Type --------------------------------------------------------------
  763. case 'J': // CHAdeMO
  764. case 'K': // CHAdeMO 200A
  765. if (CHAdeMO_QUANTITY > gGunIndexInfo.ChademoIndex) {
  766. pDcChargingInfo = (struct ChargingInfoData *)&pSysInfo->ChademoChargingData[gGunIndexInfo.ChademoIndex];
  767. pDcChargingInfo->Index = gGunIndexInfo.DcGunIndex;
  768. pDcChargingInfo->ReservationId = -1;
  769. pDcChargingInfo->slotsIndex = slots;
  770. //pDcChargingInfo->SystemStatus = S_BOOTING;
  771. //pDcChargingInfo->SystemStatus = S_IDLE;
  772. pDcChargingInfo->Type = _Type_Chademo;
  773. pDcChargingInfo->type_index = gGunIndexInfo.ChademoIndex;
  774. setAcGunTiggerStatus();
  775. //if( strcmp(whichtask,"CSU task") == EQUAL )
  776. {
  777. pDcChargingInfo->IsAvailable = YES;
  778. gGunIndexInfo.ChademoIndex++;
  779. gGunIndexInfo.DcGunIndex++;
  780. }
  781. } else {
  782. result = false;
  783. }
  784. break;
  785. case 'V': // Liquid CCS1 combo
  786. case 'F': // Liquid CCS2 combo
  787. case 'T': // Rema CCS1
  788. case 'D': // Rema CCS2
  789. case 'U': // CCS1 combo
  790. case 'E': // CCS2 combo
  791. case 'M': // 80A CCS2
  792. case 'N': // 80A CCS1
  793. case 'P': // 急電弓
  794. if (CCS_QUANTITY > gGunIndexInfo.CcsIndex) {
  795. pDcChargingInfo = (struct ChargingInfoData *)&pSysInfo->CcsChargingData[gGunIndexInfo.CcsIndex];
  796. pDcChargingInfo->Index = gGunIndexInfo.DcGunIndex;
  797. pDcChargingInfo->ReservationId = -1;
  798. pDcChargingInfo->slotsIndex = slots;
  799. //pDcChargingInfo->SystemStatus = S_BOOTING;
  800. pDcChargingInfo->Type = _Type_CCS_2;
  801. pDcChargingInfo->type_index = gGunIndexInfo.CcsIndex;
  802. setAcGunTiggerStatus();
  803. // 現階段預設為走 DIN70121
  804. pCcsData->CommProtocol = _CCS_COMM_V2GMessage_DIN70121;
  805. //if( strcmp(whichtask,"CSU task") == EQUAL )
  806. {
  807. pDcChargingInfo->IsAvailable = YES;
  808. gGunIndexInfo.CcsIndex++;
  809. gGunIndexInfo.DcGunIndex++;
  810. }
  811. if(typeValue == 'P') {
  812. pDcChargingInfo->PantographFlag = YES;
  813. } else if (typeValue == 'V') {
  814. pDcChargingInfo->CCSGunType = _TYPE_CCS1_Liquid;
  815. } else if (typeValue == 'F') {
  816. pDcChargingInfo->CCSGunType = _TYPE_CCS2_Liquid;
  817. } else if (typeValue == 'T' || typeValue == 'U' || typeValue == 'N') {
  818. pDcChargingInfo->CCSGunType = _TYPE_CCS1_Natural;
  819. } else if (typeValue == 'D' || typeValue == 'E' || typeValue == 'M') {
  820. pDcChargingInfo->CCSGunType = _TYPE_CCS2_Natural;
  821. } else
  822. pDcChargingInfo->CCSGunType = _TYPE_CCS_NONE;
  823. } else {
  824. result = false;
  825. }
  826. break;
  827. case 'G': // GBT DC
  828. case 'B': // GBT YG PT100
  829. if (GB_QUANTITY > gGunIndexInfo.GbIndex) {
  830. pDcChargingInfo = (struct ChargingInfoData *)&pSysInfo->GbChargingData[gGunIndexInfo.GbIndex];
  831. pDcChargingInfo->Index = gGunIndexInfo.DcGunIndex;
  832. pDcChargingInfo->ReservationId = -1;
  833. pDcChargingInfo->slotsIndex = slots;
  834. //pDcChargingInfo->SystemStatus = S_BOOTING;
  835. pDcChargingInfo->Type = _Type_GB;
  836. pDcChargingInfo->type_index = gGunIndexInfo.GbIndex;
  837. setAcGunTiggerStatus();
  838. //if( strcmp(whichtask,"CSU task") == EQUAL )
  839. {
  840. pDcChargingInfo->IsAvailable = YES;
  841. gGunIndexInfo.GbIndex++;
  842. gGunIndexInfo.DcGunIndex++;
  843. }
  844. } else {
  845. result = false;
  846. }
  847. break;
  848. //case 'D': // GBT DC x 2
  849. // break;
  850. //default:
  851. // result = false;
  852. // break;
  853. }
  854. return result;
  855. }
  856. bool MappingGunChargingInfo(char *whichTask)
  857. {
  858. bool result = true;
  859. uint8_t typeIndex = 0;
  860. uint8_t slots = 1;
  861. uint8_t gunIndex = 0;
  862. struct SysConfigData *pSysConfig = NULL;
  863. //struct ChargingInfoData *pDcChargingInfo = NULL;
  864. struct ChargingInfoData *pAcChargingInfo = NULL;
  865. if (ShmSysConfigAndInfo == NULL) {
  866. log_error("ShmSysConfigAndInfo failed");
  867. return false;
  868. }
  869. pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
  870. if (strlen((char *)pSysConfig->ModelName) < 9) {
  871. log_error("Module name length < 9 get %s", (char *)pSysConfig->ModelName);
  872. return false;
  873. }
  874. ShmDcCommonData->ChillerValve.MultiChillerGun = 0;
  875. //printf("1 CheckConnectorTypeStatus\n");
  876. for (typeIndex = 7; typeIndex <= 9; typeIndex++) {
  877. if (!addGunInfoByConnector(pSysConfig->ModelName[typeIndex], slots, whichTask)) {
  878. log_error("%s add gun info failed", whichTask);
  879. return false;
  880. }
  881. //確認有幾把水冷槍
  882. if (strncmp((char *)&pSysConfig->ModelName[typeIndex], "V", 1) == 0 ||
  883. strncmp((char *)&pSysConfig->ModelName[typeIndex], "F", 1) == 0
  884. ) {
  885. ShmDcCommonData->ChillerValve.MultiChillerGun++; //水冷槍數
  886. }
  887. slots++;
  888. }
  889. if (ShmDcCommonData->ChillerValve.MultiChillerGun != 0) {
  890. ShmDcCommonData->ChillerValve.MultiChillerGun |= 0x80; //有水冷槍標記
  891. if (strncmp(whichTask, "CSU Task", 8) == EQUAL) {
  892. log_info("get chiller gun = %x, chiller gun count = %d",
  893. (ShmDcCommonData->ChillerValve.MultiChillerGun & 0x80) >> 7,
  894. ShmDcCommonData->ChillerValve.MultiChillerGun & 0x7F);
  895. }
  896. }
  897. // AC index 接在 DC 後面
  898. //if (AC_QUANTITY > 0) {
  899. if (gGunIndexInfo.AcIndex > 0) { //DS60-120 add
  900. pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
  901. pAcChargingInfo->Index += gGunIndexInfo.DcGunIndex;
  902. }
  903. pSysConfig->TotalConnectorCount = gGunIndexInfo.DcGunIndex;
  904. pSysConfig->AcConnectorCount = gGunIndexInfo.AcGunIndex;
  905. if (strcmp(whichTask, "CSU Task") == 0) {
  906. log_info("DC connector Quality = %d, AC connector Quality = %d",
  907. pSysConfig->TotalConnectorCount,
  908. pSysConfig->AcConnectorCount);
  909. }
  910. for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
  911. findDcChargingInfoData(gunIndex);
  912. }
  913. findAcChargingInfoData(gunIndex);
  914. //log_info("Type 0~3 = CHAdeMO, CCS, GB, AC");
  915. if (pSysConfig->TotalConnectorCount == 0 && pSysConfig->AcConnectorCount == 0) {
  916. log_error("DC %d or AC %d connector failed",
  917. pSysConfig->TotalConnectorCount,
  918. pSysConfig->AcConnectorCount);
  919. result = false;
  920. }
  921. return result;
  922. }
  923. int CreateAllCsuShareMemory(void)
  924. {
  925. int ret = FAIL;
  926. if ((ret = InitSysConfigAndInfoShmMem()) == FAIL) {
  927. return ret;
  928. }
  929. if ((ret = InitStatusCodeShmMem()) == FAIL) {
  930. return ret;
  931. }
  932. if ((ret = InitPSUDataShmMem()) == FAIL) {
  933. return ret;
  934. }
  935. if (CHAdeMO_QUANTITY > 0) {
  936. if ((ret = InitCHADeMoShmMem()) == FAIL) {
  937. return ret;
  938. }
  939. }
  940. if (GB_QUANTITY > 0) {
  941. if ((ret = InitGBShmMem()) == FAIL) {
  942. return ret;
  943. }
  944. }
  945. //creat ShmCcsData
  946. if (CCS_QUANTITY > 0) {
  947. if ((ret = InitCCSShmMem()) == FAIL) {
  948. return ret;
  949. }
  950. }
  951. if ((ret = InitPrimaryShmMem()) == FAIL) {
  952. return ret;
  953. }
  954. if ((ret = InitFanShmMem()) == FAIL) {
  955. return ret;
  956. }
  957. if ((ret = InitRelayShmMem()) == FAIL) {
  958. return ret;
  959. }
  960. if ((ret = InitLEDShmMem()) == FAIL) {
  961. return ret;
  962. }
  963. if ((ret = InitOCPPShmMem()) == FAIL) {
  964. return ret;
  965. }
  966. if ((ret = InitOCPP20ShmMem()) == FAIL) {
  967. return ret;
  968. }
  969. if ((ret = InitSelectGunShmMem()) == FAIL) {
  970. return ret;
  971. }
  972. if ((ret = InitSelectGunShmMem()) == FAIL) {
  973. return ret;
  974. }
  975. if ((ret = InitCommonShmMem()) == FAIL) {
  976. return ret;
  977. }
  978. if ((ret = InitShmCsuMeterShmMem()) == FAIL) {
  979. return ret;
  980. }
  981. //ClearAllShmMemParameter();
  982. //MappingChargingInfoData();
  983. //initialShareMemoryParameter();
  984. //initialGunIndexToUnUse();
  985. sleep(1);
  986. return PASS;
  987. }