Module_AlarmDetect.c 93 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926
  1. /*
  2. * Module_AlarmDetect.c
  3. *
  4. * Created on: 2020/01/15
  5. * Author: Eason Yang
  6. */
  7. #include <sys/types.h>
  8. #include <sys/stat.h>
  9. #include <sys/time.h>
  10. #include <sys/timeb.h>
  11. #include <sys/ipc.h>
  12. #include <sys/shm.h>
  13. #include <sys/mman.h>
  14. #include <unistd.h>
  15. #include <stdarg.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <unistd.h>
  19. #include <fcntl.h>
  20. #include <termios.h>
  21. #include <errno.h>
  22. #include <errno.h>
  23. #include <string.h>
  24. #include <time.h>
  25. #include <ctype.h>
  26. #include "define.h"
  27. #include "main.h"
  28. #define FILTER_SPEC 2
  29. #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
  30. #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
  31. #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__), __LINE__, __FUNCTION__, ##args)
  32. #define Debug
  33. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  34. #define PASS 1
  35. #define FAIL 0
  36. #define ON 1
  37. #define OFF 0
  38. #define SPEC_OV 275
  39. #define SPEC_UV 160
  40. #define SPEC_OC (32*1.1)
  41. #define SPEC_OT 85
  42. #define HYSTERETIC_OUV 10
  43. #define HYSTERETIC_OT 10
  44. #define HYSTERETIC_OC 10
  45. struct{
  46. unsigned short int OV[3];
  47. unsigned short int UV[3];
  48. unsigned short int OC[3];
  49. unsigned short int OT_AMB;
  50. unsigned short int GMI;
  51. unsigned short int Short[3];
  52. unsigned short int Leakage;
  53. unsigned short int HandShakingTimeout;
  54. unsigned short int EmrgencyBTN;
  55. unsigned short int Relay_Welding;
  56. unsigned short int Relay_DrivingFault;
  57. unsigned short int CP_LevelFail;
  58. unsigned short int MCU_SelfTestFail;
  59. }Alarm_Counter[2];
  60. void trim(char *s);
  61. void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
  62. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  63. struct StatusCodeData *ShmStatusCodeData;
  64. struct OCPP16Data *ShmOCPP16Data;
  65. struct OCPP20Data *ShmOCPP20Data;
  66. struct Charger *ShmCharger;
  67. unsigned long previousAlarmCode[AC_QUANTITY];
  68. int StoreLogMsg(const char *fmt, ...)
  69. {
  70. char Buf[4096+256];
  71. char buffer[4096];
  72. time_t CurrentTime;
  73. struct tm *tm;
  74. struct timeval tv;
  75. va_list args;
  76. va_start(args, fmt);
  77. int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
  78. va_end(args);
  79. memset(Buf,0,sizeof(Buf));
  80. CurrentTime = time(NULL);
  81. tm=localtime(&CurrentTime);
  82. gettimeofday(&tv, NULL); // get microseconds, 10^-6
  83. if((ShmSysConfigAndInfo->SysConfig.ModelName != NULL) && (ShmSysConfigAndInfo->SysConfig.SerialNumber != NULL) && (strlen((char*)ShmSysConfigAndInfo->SysConfig.ModelName) >= 14))
  84. {
  85. sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >> /Storage/SystemLog/[%04d.%02d]%s_%s_SystemLog",
  86. tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
  87. buffer,
  88. tm->tm_year+1900,tm->tm_mon+1,
  89. ShmSysConfigAndInfo->SysConfig.ModelName,
  90. ShmSysConfigAndInfo->SysConfig.SerialNumber);
  91. }
  92. else
  93. {
  94. sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
  95. tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
  96. buffer,
  97. tm->tm_year+1900,tm->tm_mon+1);
  98. }
  99. #ifdef SystemLogMessage
  100. system(Buf);
  101. #endif
  102. #ifdef ConsloePrintLog
  103. printf("[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec, buffer);
  104. #endif
  105. return rc;
  106. }
  107. int DiffTimeb(struct timeb ST, struct timeb ET)
  108. {
  109. //return milli-second
  110. unsigned int StartTime,StopTime;
  111. StartTime=(unsigned int)ST.time;
  112. StopTime=(unsigned int)ET.time;
  113. return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
  114. }
  115. //==========================================
  116. // Init all share memory
  117. //==========================================
  118. int InitShareMemory()
  119. {
  120. int result = PASS;
  121. int MeterSMId;
  122. //creat ShmSysConfigAndInfo
  123. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  124. {
  125. #ifdef SystemLogMessage
  126. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  127. #endif
  128. result = FAIL;
  129. }
  130. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  131. {
  132. #ifdef SystemLogMessage
  133. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  134. #endif
  135. result = FAIL;
  136. }
  137. else
  138. {}
  139. //creat ShmStatusCodeData
  140. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  141. {
  142. #ifdef SystemLogMessage
  143. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  144. #endif
  145. result = FAIL;
  146. }
  147. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  148. {
  149. #ifdef SystemLogMessage
  150. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  151. #endif
  152. result = FAIL;
  153. }
  154. else
  155. {}
  156. //creat ShmStatusCodeData
  157. if ((MeterSMId = shmget(ShmChargerKey, sizeof(struct Charger), 0777)) < 0)
  158. {
  159. DEBUG_ERROR("shmget ShmCharger NG\n");
  160. result = FAIL;
  161. }
  162. else if ((ShmCharger = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  163. {
  164. DEBUG_ERROR("shmat ShmCharger NG\n");
  165. result = FAIL;
  166. }
  167. else
  168. {}
  169. //creat ShmOCPP16Data
  170. if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), 0777)) < 0)
  171. {
  172. DEBUG_ERROR("shmget ShmOCPP16Data NG\n");
  173. result = FAIL;
  174. }
  175. else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  176. {
  177. DEBUG_ERROR("shmat ShmOCPP16Data NG\n");
  178. result = FAIL;
  179. }
  180. else
  181. {}
  182. //creat ShmOCPP20Data
  183. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  184. {
  185. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  186. result = FAIL;
  187. }
  188. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  189. {
  190. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  191. result = FAIL;
  192. }
  193. else
  194. {}
  195. return result;
  196. }
  197. //==========================================
  198. // Common routine
  199. //==========================================
  200. void trim(char *s)
  201. {
  202. int i=0, j, k, l=0;
  203. while((s[i]==' ')||(s[i]=='\t')||(s[i]=='\n'))
  204. i++;
  205. j = strlen(s)-1;
  206. while((s[j]==' ')||(s[j]=='\t')||(s[j]=='\n'))
  207. j--;
  208. if(i==0 && j==strlen(s)-1) { }
  209. else if(i==0) s[j+1] = '\0';
  210. else {
  211. for(k=i; k<=j; k++) s[l++] = s[k];
  212. s[l] = '\0';
  213. }
  214. }
  215. void substr(char *dest, const char* src, unsigned int start, unsigned int cnt)
  216. {
  217. strncpy(dest, src + start, cnt);
  218. dest[cnt] = 0;
  219. }
  220. void getNowDatetime(uint8_t *data)
  221. {
  222. time_t t = time(NULL);
  223. struct tm tm = *localtime(&t);
  224. sprintf((char*)data, "%04d-%02d-%02dT%02d:%02d:%02dZ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  225. }
  226. //==========================================
  227. // Main process
  228. //==========================================
  229. int main(void)
  230. {
  231. if(InitShareMemory() == FAIL)
  232. {
  233. DEBUG_ERROR("InitShareMemory NG\n");
  234. if(ShmStatusCodeData!=NULL)
  235. {
  236. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  237. }
  238. sleep(5);
  239. return FAIL;
  240. }
  241. for(;;)
  242. {
  243. for(int gun_index = 0;gun_index<AC_QUANTITY;gun_index++)
  244. {
  245. //=====================================
  246. // Over voltage detection
  247. //=====================================
  248. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L1 == ON)
  249. {
  250. if(Alarm_Counter[gun_index].OV[0] > FILTER_SPEC)
  251. {
  252. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == OFF)
  253. {
  254. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = ON;
  255. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_L1_OVER_VOLTAGE;
  256. DEBUG_INFO("ALARM_L1_OVER_VOLTAGE : alarm \n");
  257. }
  258. }
  259. else
  260. {
  261. Alarm_Counter[gun_index].OV[0]++;
  262. }
  263. }
  264. else
  265. {
  266. Alarm_Counter[gun_index].OV[0] = 0;
  267. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == ON)
  268. {
  269. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = OFF;
  270. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_OVER_VOLTAGE;
  271. DEBUG_INFO("ALARM_L1_OVER_VOLTAGE : recover \n");
  272. }
  273. }
  274. if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
  275. {
  276. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L2 == ON)
  277. {
  278. if(Alarm_Counter[gun_index].OV[1] > FILTER_SPEC)
  279. {
  280. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == OFF)
  281. {
  282. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = ON;
  283. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_L2_OVER_VOLTAGE;
  284. DEBUG_INFO("ALARM_L2_OVER_VOLTAGE : alarm \n");
  285. }
  286. }
  287. else
  288. {
  289. Alarm_Counter[gun_index].OV[1]++;
  290. }
  291. }
  292. else
  293. {
  294. Alarm_Counter[gun_index].OV[1] = 0;
  295. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == ON)
  296. {
  297. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = OFF;
  298. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_OVER_VOLTAGE;
  299. DEBUG_INFO("ALARM_L2_OVER_VOLTAGE : recover \n");
  300. }
  301. }
  302. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OVP_L3 == ON)
  303. {
  304. if(Alarm_Counter[gun_index].OV[2] > FILTER_SPEC)
  305. {
  306. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == OFF)
  307. {
  308. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = ON;
  309. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_L3_OVER_VOLTAGE;
  310. DEBUG_INFO("ALARM_L3_OVER_VOLTAGE : alarm \n");
  311. }
  312. }
  313. else
  314. {
  315. Alarm_Counter[gun_index].OV[2]++;
  316. }
  317. }
  318. else
  319. {
  320. Alarm_Counter[gun_index].OV[2] = 0;
  321. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == ON)
  322. {
  323. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = OFF;
  324. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_OVER_VOLTAGE;
  325. DEBUG_INFO("ALARM_L3_OVER_VOLTAGE : recover \n");
  326. }
  327. }
  328. }
  329. //=====================================
  330. // Under voltage detection
  331. //=====================================
  332. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L1 == ON)
  333. {
  334. if(Alarm_Counter[gun_index].UV[0] > FILTER_SPEC)
  335. {
  336. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == OFF)
  337. {
  338. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = ON;
  339. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_L1_UNDER_VOLTAGE;
  340. DEBUG_INFO("ALARM_L1_UNDER_VOLTAGE : alarm \n");
  341. }
  342. }
  343. else
  344. {
  345. Alarm_Counter[gun_index].UV[0]++;
  346. }
  347. }
  348. else
  349. {
  350. Alarm_Counter[gun_index].UV[0] = 0;
  351. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == ON)
  352. {
  353. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = OFF;
  354. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_UNDER_VOLTAGE;
  355. DEBUG_INFO("ALARM_L1_UNDER_VOLTAGE : recover \n");
  356. }
  357. }
  358. if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
  359. {
  360. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L2 == ON)
  361. {
  362. if(Alarm_Counter[gun_index].UV[1] > FILTER_SPEC)
  363. {
  364. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == OFF)
  365. {
  366. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = ON;
  367. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_L2_UNDER_VOLTAGE;
  368. DEBUG_INFO("ALARM_L2_UNDER_VOLTAGE : alarm \n");
  369. }
  370. }
  371. else
  372. {
  373. Alarm_Counter[gun_index].UV[1]++;
  374. }
  375. }
  376. else
  377. {
  378. Alarm_Counter[gun_index].UV[1] = 0;
  379. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == ON)
  380. {
  381. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = OFF;
  382. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_UNDER_VOLTAGE;
  383. DEBUG_INFO("ALARM_L2_UNDER_VOLTAGE : recover \n");
  384. }
  385. }
  386. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.UVP_L3 == ON)
  387. {
  388. if(Alarm_Counter[gun_index].UV[2] > FILTER_SPEC)
  389. {
  390. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == OFF)
  391. {
  392. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = ON;
  393. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_L3_UNDER_VOLTAGE;
  394. DEBUG_INFO("ALARM_L3_UNDER_VOLTAGE : alarm \n");
  395. }
  396. }
  397. else
  398. {
  399. Alarm_Counter[gun_index].UV[2]++;
  400. }
  401. }
  402. else
  403. {
  404. Alarm_Counter[gun_index].UV[2] = 0;
  405. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == ON)
  406. {
  407. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = OFF;
  408. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_UNDER_VOLTAGE;
  409. DEBUG_INFO("ALARM_L3_UNDER_VOLTAGE : recover \n");
  410. }
  411. }
  412. }
  413. //=====================================
  414. // Over current detection
  415. //=====================================
  416. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L1 == ON)
  417. {
  418. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP == OFF)
  419. {
  420. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP = ON;
  421. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_L1_OVER_CURRENT;
  422. DEBUG_INFO("ALARM_L1_OVER_CURRENT : alarm \n");
  423. }
  424. }
  425. else
  426. {
  427. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP == ON)
  428. {
  429. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP = OFF;
  430. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_OVER_CURRENT;
  431. DEBUG_INFO("ALARM_L1_OVER_CURRENT : recover \n");
  432. }
  433. }
  434. if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
  435. {
  436. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L2 == ON)
  437. {
  438. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 == OFF)
  439. {
  440. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 = ON;
  441. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_L2_OVER_CURRENT;
  442. DEBUG_INFO("ALARM_L2_OVER_CURRENT : alarm \n");
  443. }
  444. }
  445. else
  446. {
  447. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 == ON)
  448. {
  449. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 = OFF;
  450. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_OVER_CURRENT;
  451. DEBUG_INFO("ALARM_L2_OVER_CURRENT : recover \n");
  452. }
  453. }
  454. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OCP_L3 == ON)
  455. {
  456. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 == OFF)
  457. {
  458. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 = ON;
  459. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_L3_OVER_CURRENT;
  460. DEBUG_INFO("ALARM_L3_OVER_CURRENT : alarm \n");
  461. }
  462. }
  463. else
  464. {
  465. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 == ON)
  466. {
  467. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 = OFF;
  468. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_OVER_CURRENT;
  469. DEBUG_INFO("ALARM_L3_OVER_CURRENT : recover \n");
  470. }
  471. }
  472. }
  473. //=====================================
  474. // Over temperature detection
  475. //=====================================
  476. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.OTP == ON)
  477. {
  478. if(Alarm_Counter[gun_index].OT_AMB > FILTER_SPEC)
  479. {
  480. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP == OFF)
  481. {
  482. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP = ON;
  483. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_OVER_TEMPERATURE;
  484. DEBUG_INFO("ALARM_OVER_TEMPERATURE : alarm \n");
  485. }
  486. }
  487. else
  488. {
  489. Alarm_Counter[gun_index].OT_AMB++;
  490. }
  491. }
  492. else
  493. {
  494. Alarm_Counter[gun_index].OT_AMB = 0;
  495. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP == ON)
  496. {
  497. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP = OFF;
  498. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_OVER_TEMPERATURE;
  499. DEBUG_INFO("ALARM_OVER_TEMPERATURE : recover \n");
  500. }
  501. }
  502. //=====================================
  503. // Ground fault detection
  504. //=====================================
  505. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.gmi_fault == ON)
  506. {
  507. if(Alarm_Counter[gun_index].GMI > FILTER_SPEC)
  508. {
  509. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail == OFF)
  510. {
  511. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail = ON;
  512. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_GROUND_FAIL;
  513. DEBUG_INFO("ALARM_GROUND_FAIL : alarm \n");
  514. }
  515. }
  516. else
  517. {
  518. Alarm_Counter[gun_index].GMI++;
  519. }
  520. }
  521. else
  522. {
  523. Alarm_Counter[gun_index].GMI = 0;
  524. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail == ON)
  525. {
  526. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail = OFF;
  527. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_GROUND_FAIL;
  528. DEBUG_INFO("ALARM_GROUND_FAIL : recover \n");
  529. }
  530. }
  531. //=====================================
  532. // CP level fail detection
  533. //=====================================
  534. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.cp_fault == ON)
  535. {
  536. if(Alarm_Counter[gun_index].CP_LevelFail > FILTER_SPEC)
  537. {
  538. if(ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault == OFF)
  539. {
  540. ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault = ON;
  541. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_CP_ERROR;
  542. DEBUG_INFO("ALARM_CP_ERROR : alarm \n");
  543. }
  544. }
  545. else
  546. {
  547. Alarm_Counter[gun_index].CP_LevelFail++;
  548. }
  549. }
  550. else
  551. {
  552. Alarm_Counter[gun_index].CP_LevelFail= 0;
  553. if(ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault == ON)
  554. {
  555. ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault = OFF;
  556. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CP_ERROR;
  557. DEBUG_INFO("ALARM_CP_ERROR : recover \n");
  558. }
  559. }
  560. //=====================================
  561. // Current AC/DC leak detection
  562. //=====================================
  563. if((ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.ac_leak == ON) ||
  564. (ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.dc_leak == ON))
  565. {
  566. if(Alarm_Counter[gun_index].Leakage > FILTER_SPEC)
  567. {
  568. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip == OFF)
  569. {
  570. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = ON;
  571. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.ac_leak == ON)
  572. {
  573. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_CURRENT_LEAK_AC;
  574. ShmCharger->gun_info[gun_index].otherAlarmCode.isACLeakage = ON;
  575. DEBUG_INFO("ALARM_CURRENT_LEAK_AC : alarm \n");
  576. }
  577. else if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.dc_leak == ON)
  578. {
  579. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_CURRENT_LEAK_DC;
  580. ShmCharger->gun_info[gun_index].otherAlarmCode.isDcLeakage = ON;
  581. DEBUG_INFO("ALARM_CURRENT_LEAK_DC : alarm \n");
  582. }
  583. }
  584. }
  585. else
  586. {
  587. Alarm_Counter[gun_index].Leakage++;
  588. }
  589. }
  590. else
  591. {
  592. Alarm_Counter[gun_index].Leakage = 0;
  593. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip == ON)
  594. {
  595. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = OFF;
  596. if(ShmCharger->gun_info[gun_index].otherAlarmCode.isACLeakage == ON)
  597. {
  598. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CURRENT_LEAK_AC;
  599. ShmCharger->gun_info[gun_index].otherAlarmCode.isACLeakage = OFF;
  600. DEBUG_INFO("ALARM_CURRENT_LEAK_AC : recover \n");
  601. }
  602. else if(ShmCharger->gun_info[gun_index].otherAlarmCode.isDcLeakage == ON)
  603. {
  604. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_CURRENT_LEAK_DC;
  605. ShmCharger->gun_info[gun_index].otherAlarmCode.isDcLeakage = OFF;
  606. DEBUG_INFO("ALARM_CURRENT_LEAK_DC : recover \n");
  607. }
  608. }
  609. }
  610. //=====================================
  611. // MCU self test fail detection
  612. //=====================================
  613. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.mcu_selftest_fail == ON)
  614. {
  615. if(Alarm_Counter[gun_index].MCU_SelfTestFail > FILTER_SPEC)
  616. {
  617. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail == OFF)
  618. {
  619. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail = ON;
  620. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_MCU_TESTFAIL;
  621. DEBUG_INFO("ALARM_MCU_TESTFAIL : alarm \n");
  622. }
  623. }
  624. else
  625. {
  626. Alarm_Counter[gun_index].MCU_SelfTestFail++;
  627. }
  628. }
  629. else
  630. {
  631. Alarm_Counter[gun_index].MCU_SelfTestFail = 0;
  632. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail == ON)
  633. {
  634. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail = OFF;
  635. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_MCU_TESTFAIL;
  636. DEBUG_INFO("ALARM_MCU_TESTFAIL : recover \n");
  637. }
  638. }
  639. //=====================================
  640. // Hand shaking timeout detection
  641. //=====================================
  642. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.handshaking_timeout == ON)
  643. {
  644. if(ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut == OFF)
  645. {
  646. ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut = ON;
  647. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_HANDSHAKE_TIMEOUT;
  648. DEBUG_INFO("ALARM_HANDSHAKE_TIMEOUT : alarm \n");
  649. }
  650. }
  651. else
  652. {
  653. if(ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut == ON)
  654. {
  655. ShmCharger->gun_info[gun_index].otherAlarmCode.isHandshakingTimeOut = OFF;
  656. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_HANDSHAKE_TIMEOUT;
  657. DEBUG_INFO("ALARM_HANDSHAKE_TIMEOUT : recover \n");
  658. }
  659. }
  660. //=====================================
  661. // Emergency stop detection
  662. //=====================================
  663. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.emergency_stop == ON)
  664. {
  665. if(Alarm_Counter[gun_index].EmrgencyBTN > FILTER_SPEC)
  666. {
  667. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == OFF)
  668. {
  669. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = ON;
  670. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_EMERGENCY_STOP;
  671. DEBUG_INFO("ALARM_EMERGENCY_STOP : alarm \n");
  672. }
  673. }
  674. else
  675. {
  676. Alarm_Counter[gun_index].EmrgencyBTN++;
  677. }
  678. }
  679. else
  680. {
  681. Alarm_Counter[gun_index].EmrgencyBTN = 0;
  682. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == ON)
  683. {
  684. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = OFF;
  685. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_EMERGENCY_STOP;
  686. DEBUG_INFO("ALARM_EMERGENCY_STOP : recover \n");
  687. }
  688. }
  689. //=====================================
  690. // Relay welding detection
  691. //=====================================
  692. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.relay_welding == ON)
  693. {
  694. if(Alarm_Counter[gun_index].Relay_Welding > FILTER_SPEC)
  695. {
  696. if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding == OFF)
  697. {
  698. ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding = ON;
  699. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_RELAY_WELDING;
  700. DEBUG_INFO("ALARM_RELAY_STATUS : alarm \n");
  701. }
  702. }
  703. else
  704. {
  705. Alarm_Counter[gun_index].Relay_Welding++;
  706. }
  707. }
  708. else
  709. {
  710. Alarm_Counter[gun_index].Relay_Welding = 0;
  711. if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding == ON)
  712. {
  713. ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding = OFF;
  714. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_RELAY_WELDING;
  715. DEBUG_INFO("ALARM_RELAY_STATUS : recover \n");
  716. }
  717. }
  718. //=====================================
  719. // Relay driving fault detection
  720. //=====================================
  721. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.relay_drive_fault == ON)
  722. {
  723. if(Alarm_Counter[gun_index].Relay_DrivingFault > FILTER_SPEC)
  724. {
  725. if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault == OFF)
  726. {
  727. ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault = ON;
  728. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_RELAY_DRIVE_FAULT;
  729. DEBUG_INFO("ALARM_RELAY_DRIVE_FAULT : alarm \n");
  730. }
  731. }
  732. else
  733. {
  734. Alarm_Counter[gun_index].Relay_DrivingFault++;
  735. }
  736. }
  737. else
  738. {
  739. Alarm_Counter[gun_index].Relay_DrivingFault = 0;
  740. if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault == ON)
  741. {
  742. ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault = OFF;
  743. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_RELAY_DRIVE_FAULT;
  744. DEBUG_INFO("ALARM_RELAY_DRIVE_FAULT : recover \n");
  745. }
  746. }
  747. //=====================================
  748. // Current short detection
  749. //=====================================
  750. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L1 == ON)
  751. {
  752. if(Alarm_Counter[gun_index].Short[0] > FILTER_SPEC)
  753. {
  754. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort == OFF)
  755. {
  756. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort = ON;
  757. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_L1_CIRCUIT_SHORT;
  758. DEBUG_INFO("ALARM_L1_CIRCUIT_SHORT : alarm \n");
  759. }
  760. }
  761. else
  762. {
  763. Alarm_Counter[gun_index].Short[0]++;
  764. }
  765. }
  766. else
  767. {
  768. Alarm_Counter[gun_index].Short[0] = 0;
  769. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort == ON)
  770. {
  771. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort = OFF;
  772. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L1_CIRCUIT_SHORT;
  773. DEBUG_INFO("ALARM_L1_CIRCUIT_SHORT : recover \n");
  774. }
  775. }
  776. if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 3)
  777. {
  778. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L2 == ON)
  779. {
  780. if(Alarm_Counter[gun_index].Short[1] > FILTER_SPEC)
  781. {
  782. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 == OFF)
  783. {
  784. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 = ON;
  785. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_L2_CIRCUIT_SHORT;
  786. DEBUG_INFO("ALARM_L2_CIRCUIT_SHORT : alarm \n");
  787. }
  788. }
  789. else
  790. {
  791. Alarm_Counter[gun_index].Short[1]++;
  792. }
  793. }
  794. else
  795. {
  796. Alarm_Counter[gun_index].Short[1] = 0;
  797. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 == ON)
  798. {
  799. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 = OFF;
  800. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L2_CIRCUIT_SHORT;
  801. DEBUG_INFO("ALARM_L2_CIRCUIT_SHORT : recover \n");
  802. }
  803. }
  804. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.short_circuit_L3 == ON)
  805. {
  806. if(Alarm_Counter[gun_index].Short[2] > FILTER_SPEC)
  807. {
  808. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 == OFF)
  809. {
  810. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 = ON;
  811. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_L3_CIRCUIT_SHORT;
  812. DEBUG_INFO("ALARM_L3_CIRCUIT_SHORT : alarm \n");
  813. }
  814. }
  815. else
  816. {
  817. Alarm_Counter[gun_index].Short[2]++;
  818. }
  819. }
  820. else
  821. {
  822. Alarm_Counter[gun_index].Short[2] = 0;
  823. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 == ON)
  824. {
  825. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 = OFF;
  826. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_L3_CIRCUIT_SHORT;
  827. DEBUG_INFO("ALARM_L3_CIRCUIT_SHORT : recover \n");
  828. }
  829. }
  830. }
  831. //=====================================
  832. // Rotatory switch detection
  833. //=====================================
  834. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.rotate_switch_fault == ON)
  835. {
  836. if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault == OFF)
  837. {
  838. ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault = ON;
  839. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_ROTATORY_SWITCH_FAULT;
  840. DEBUG_INFO("ALARM_ROTATORY_SWITCH_FAULT : alarm \n");
  841. }
  842. }
  843. else
  844. {
  845. if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault == ON)
  846. {
  847. ShmStatusCodeData->FaultCode.FaultEvents.bits.RotarySwitchFault = OFF;
  848. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_ROTATORY_SWITCH_FAULT;
  849. DEBUG_INFO("ALARM_ROTATORY_SWITCH_FAULT : recover \n");
  850. }
  851. }
  852. //=====================================
  853. // Leakage module detection
  854. //=====================================
  855. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.leak_module_fail == ON)
  856. {
  857. if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail == OFF)
  858. {
  859. ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = ON;
  860. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_LEAK_MODULE_FAIL;
  861. DEBUG_INFO("ALARM_LEAK_MODULE_FAIL : alarm \n");
  862. }
  863. }
  864. else
  865. {
  866. if(ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail == ON)
  867. {
  868. ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = OFF;
  869. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_LEAK_MODULE_FAIL;
  870. DEBUG_INFO("ALARM_LEAK_MODULE_FAIL : recover \n");
  871. }
  872. }
  873. //=====================================
  874. // Shutter detection
  875. //=====================================
  876. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.shutter_fault == ON)
  877. {
  878. if(ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault == OFF)
  879. {
  880. ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault = ON;
  881. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_SHUTTER_FAULT;
  882. DEBUG_INFO("ALARM_SHUTTER_FAULT : alarm \n");
  883. }
  884. }
  885. else
  886. {
  887. if(ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault == ON)
  888. {
  889. ShmStatusCodeData->FaultCode.FaultEvents.bits.ShutterFault = OFF;
  890. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_SHUTTER_FAULT;
  891. DEBUG_INFO("ALARM_SHUTTER_FAULT : recover \n");
  892. }
  893. }
  894. //=====================================
  895. // Locker detection
  896. //=====================================
  897. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.locker_fault == ON)
  898. {
  899. if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail == OFF)
  900. {
  901. ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = ON;
  902. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_LOCKER_FAULT;
  903. DEBUG_INFO("ALARM_LOCKER_FAULT : alarm \n");
  904. }
  905. }
  906. else
  907. {
  908. if(ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail == ON)
  909. {
  910. ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = OFF;
  911. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_LOCKER_FAULT;
  912. DEBUG_INFO("ALARM_LOCKER_FAULT : recover \n");
  913. }
  914. }
  915. //=====================================
  916. // Power drop detection
  917. //=====================================
  918. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.power_drop == ON)
  919. {
  920. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == OFF)
  921. {
  922. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = ON;
  923. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_POWER_DROP;
  924. DEBUG_INFO("ALARM_POWER_DROP : alarm \n");
  925. }
  926. }
  927. else
  928. {
  929. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == ON)
  930. {
  931. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = OFF;
  932. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_POWER_DROP;
  933. DEBUG_INFO("ALARM_POWER_DROP : recover \n");
  934. }
  935. }
  936. //=====================================
  937. // Meter communication timeout detection
  938. //=====================================
  939. if(ShmCharger->gun_info[gun_index].primaryMcuAlarm.bits.meter_comm_timeout)
  940. {
  941. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout == OFF)
  942. {
  943. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = ON;
  944. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode |= ALARM_METER_TIMEOUT;
  945. DEBUG_INFO("ALARM_METER_TIMEOUT : alarm \n");
  946. }
  947. }
  948. else
  949. {
  950. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout == ON)
  951. {
  952. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MeterCommTimeout = OFF;
  953. ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode &= ~ALARM_METER_TIMEOUT;
  954. DEBUG_INFO("ALARM_METER_TIMEOUT : recover \n");
  955. }
  956. }
  957. //=====================================
  958. // OCPP error code message
  959. //=====================================
  960. if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
  961. {
  962. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_VOLTAGE) ||
  963. (ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_VOLTAGE) ||
  964. (ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_VOLTAGE))
  965. {
  966. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OverVoltage");
  967. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == ON)
  968. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012200");
  969. else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == ON)
  970. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012201");
  971. else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == ON)
  972. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012202");
  973. }
  974. else if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_UNDER_VOLTAGE) ||
  975. (ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_UNDER_VOLTAGE) ||
  976. (ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_UNDER_VOLTAGE))
  977. {
  978. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "UnderVoltage");
  979. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == ON)
  980. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012203");
  981. else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == ON)
  982. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012204");
  983. else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == ON)
  984. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012205");
  985. }
  986. else if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_CURRENT) ||
  987. (ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_CURRENT) ||
  988. (ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_CURRENT))
  989. {
  990. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OverCurrentFailure");
  991. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP == ON)
  992. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012216");
  993. else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL2 == ON)
  994. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012299");
  995. else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCPL3 == ON)
  996. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012300");
  997. }
  998. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_OVER_TEMPERATURE)
  999. {
  1000. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "HighTemperature");
  1001. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012223");
  1002. }
  1003. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GROUND_FAIL)
  1004. {
  1005. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "GroundFailure");
  1006. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012256");
  1007. }
  1008. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CP_ERROR)
  1009. {
  1010. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1011. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "023703");
  1012. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "CpError");
  1013. }
  1014. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_AC)
  1015. {
  1016. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1017. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012233");
  1018. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "ACLeakage");
  1019. }
  1020. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_DC)
  1021. {
  1022. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1023. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012233");
  1024. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "DCLeakage");
  1025. }
  1026. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_MCU_TESTFAIL)
  1027. {
  1028. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1029. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012257");
  1030. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "McuTestFail");
  1031. }
  1032. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT)
  1033. {
  1034. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1035. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "HandshakeTimeout");
  1036. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "HandshakeTimeout");
  1037. }
  1038. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP)
  1039. {
  1040. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1041. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012251");
  1042. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "EmergencyStop");
  1043. }
  1044. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_WELDING)
  1045. {
  1046. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1047. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011009");
  1048. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "RelayWelding");
  1049. }
  1050. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LEAK_MODULE_FAIL)
  1051. {
  1052. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1053. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011004");
  1054. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "LeakageModuleFail");
  1055. }
  1056. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT)
  1057. {
  1058. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1059. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011034");
  1060. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "ShutterFault");
  1061. }
  1062. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LOCKER_FAULT)
  1063. {
  1064. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "ConnectorLockFailure");
  1065. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011027");
  1066. }
  1067. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_POWER_DROP)
  1068. {
  1069. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1070. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == ON)
  1071. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012212");
  1072. else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputDrop == ON)
  1073. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012213");
  1074. else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputDrop == ON)
  1075. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012214");
  1076. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "PowerDrop");
  1077. }
  1078. else if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_CIRCUIT_SHORT) ||
  1079. (ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_CIRCUIT_SHORT) ||
  1080. (ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_CIRCUIT_SHORT))
  1081. {
  1082. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1083. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort == ON)
  1084. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012262");
  1085. else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL2 == ON)
  1086. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012301");
  1087. else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShortL3 == ON)
  1088. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012302");
  1089. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "CircuitShort");
  1090. }
  1091. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_ROTATORY_SWITCH_FAULT)
  1092. {
  1093. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1094. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011036");
  1095. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "RotatorySwitchFault");
  1096. }
  1097. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_DRIVE_FAULT)
  1098. {
  1099. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1100. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "011010");
  1101. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "RelayDriveFault");
  1102. }
  1103. else if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_METER_TIMEOUT)
  1104. {
  1105. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "OtherError");
  1106. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode , "012305");
  1107. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].Info , "MeterCommunicationTimeout");
  1108. }
  1109. else
  1110. {
  1111. sprintf((char*)ShmOCPP16Data->StatusNotification[gun_index].ErrorCode , "NoError");
  1112. memset(ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode, 0x00, ARRAY_SIZE(ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode));
  1113. }
  1114. }
  1115. else if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_20)
  1116. {
  1117. uint8_t idxEvent = 0;
  1118. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_VOLTAGE) != (previousAlarmCode[gun_index] & ALARM_L1_OVER_VOLTAGE))
  1119. {
  1120. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1121. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1122. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1123. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_VOLTAGE)?"true":"false"));
  1124. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_VOLTAGE)?OFF:ON);
  1125. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1126. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012200");
  1127. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "System L1 input OVP");
  1128. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Voltage");
  1129. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1130. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1131. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1132. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_VOLTAGE)
  1133. previousAlarmCode[gun_index] |= ALARM_L1_OVER_VOLTAGE;
  1134. else
  1135. previousAlarmCode[gun_index] &= ~ALARM_L1_OVER_VOLTAGE;
  1136. }
  1137. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_VOLTAGE) != (previousAlarmCode[gun_index] & ALARM_L2_OVER_VOLTAGE))
  1138. {
  1139. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1140. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1141. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1142. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_VOLTAGE)?"true":"false"));
  1143. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_VOLTAGE)?OFF:ON);
  1144. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1145. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012201");
  1146. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "System L2 input OVP");
  1147. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Voltage");
  1148. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1149. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1150. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1151. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_VOLTAGE)
  1152. previousAlarmCode[gun_index] |= ALARM_L2_OVER_VOLTAGE;
  1153. else
  1154. previousAlarmCode[gun_index] &= ~ALARM_L2_OVER_VOLTAGE;
  1155. }
  1156. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_VOLTAGE) != (previousAlarmCode[gun_index] & ALARM_L3_OVER_VOLTAGE))
  1157. {
  1158. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1159. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1160. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1161. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_VOLTAGE)?"true":"false"));
  1162. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_VOLTAGE)?OFF:ON);
  1163. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1164. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012202");
  1165. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "System L3 input OVP");
  1166. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Voltage");
  1167. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1168. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1169. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1170. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_VOLTAGE)
  1171. previousAlarmCode[gun_index] |= ALARM_L3_OVER_VOLTAGE;
  1172. else
  1173. previousAlarmCode[gun_index] &= ~ALARM_L3_OVER_VOLTAGE;
  1174. }
  1175. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_UNDER_VOLTAGE) != (previousAlarmCode[gun_index] & ALARM_L1_UNDER_VOLTAGE))
  1176. {
  1177. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1178. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1179. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1180. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_UNDER_VOLTAGE)?"true":"false"));
  1181. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_UNDER_VOLTAGE)?OFF:ON);
  1182. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1183. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012203");
  1184. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "System L1 input UVP");
  1185. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Voltage");
  1186. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1187. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1188. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1189. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_UNDER_VOLTAGE)
  1190. previousAlarmCode[gun_index] |= ALARM_L1_UNDER_VOLTAGE;
  1191. else
  1192. previousAlarmCode[gun_index] &= ~ALARM_L1_UNDER_VOLTAGE;
  1193. }
  1194. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_UNDER_VOLTAGE) != (previousAlarmCode[gun_index] & ALARM_L2_UNDER_VOLTAGE))
  1195. {
  1196. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1197. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1198. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1199. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_UNDER_VOLTAGE)?"true":"false"));
  1200. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_UNDER_VOLTAGE)?OFF:ON);
  1201. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1202. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012204");
  1203. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "System L2 input UVP");
  1204. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Voltage");
  1205. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1206. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1207. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1208. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_UNDER_VOLTAGE)
  1209. previousAlarmCode[gun_index] |= ALARM_L2_UNDER_VOLTAGE;
  1210. else
  1211. previousAlarmCode[gun_index] &= ~ALARM_L2_UNDER_VOLTAGE;
  1212. }
  1213. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_UNDER_VOLTAGE) != (previousAlarmCode[gun_index] & ALARM_L3_UNDER_VOLTAGE))
  1214. {
  1215. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1216. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1217. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1218. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_UNDER_VOLTAGE)?"true":"false"));
  1219. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_UNDER_VOLTAGE)?OFF:ON);
  1220. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1221. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012205");
  1222. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "System L3 input UVP");
  1223. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Voltage");
  1224. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1225. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1226. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1227. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_UNDER_VOLTAGE)
  1228. previousAlarmCode[gun_index] |= ALARM_L3_UNDER_VOLTAGE;
  1229. else
  1230. previousAlarmCode[gun_index] &= ~ALARM_L3_UNDER_VOLTAGE;
  1231. }
  1232. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_CURRENT) != (previousAlarmCode[gun_index] & ALARM_L1_OVER_CURRENT))
  1233. {
  1234. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1235. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1236. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1237. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_CURRENT)?"true":"false"));
  1238. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_CURRENT)?OFF:ON);
  1239. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1240. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012216");
  1241. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "System AC output OCP L1");
  1242. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Current");
  1243. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1244. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1245. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1246. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_OVER_CURRENT)
  1247. previousAlarmCode[gun_index] |= ALARM_L1_OVER_CURRENT;
  1248. else
  1249. previousAlarmCode[gun_index] &= ~ALARM_L1_OVER_CURRENT;
  1250. }
  1251. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_CURRENT) != (previousAlarmCode[gun_index] & ALARM_L2_OVER_CURRENT))
  1252. {
  1253. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1254. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1255. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1256. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_CURRENT)?"true":"false"));
  1257. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_CURRENT)?OFF:ON);
  1258. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1259. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012299");
  1260. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "System AC output OCP L2");
  1261. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Current");
  1262. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1263. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1264. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1265. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_OVER_CURRENT)
  1266. previousAlarmCode[gun_index] |= ALARM_L2_OVER_CURRENT;
  1267. else
  1268. previousAlarmCode[gun_index] &= ~ALARM_L2_OVER_CURRENT;
  1269. }
  1270. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_CURRENT) != (previousAlarmCode[gun_index] & ALARM_L3_OVER_CURRENT))
  1271. {
  1272. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1273. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1274. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1275. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_CURRENT)?"true":"false"));
  1276. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_CURRENT)?OFF:ON);
  1277. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1278. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012300");
  1279. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "System AC output OCP L3");
  1280. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Current");
  1281. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1282. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1283. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1284. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_OVER_CURRENT)
  1285. previousAlarmCode[gun_index] |= ALARM_L3_OVER_CURRENT;
  1286. else
  1287. previousAlarmCode[gun_index] &= ~ALARM_L3_OVER_CURRENT;
  1288. }
  1289. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_OVER_TEMPERATURE) != (previousAlarmCode[gun_index] & ALARM_OVER_TEMPERATURE))
  1290. {
  1291. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1292. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1293. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1294. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_OVER_TEMPERATURE)?"true":"false"));
  1295. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_OVER_TEMPERATURE)?OFF:ON);
  1296. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1297. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012223");
  1298. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "System ambient/inlet OTP");
  1299. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Temperature");
  1300. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1301. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1302. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1303. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_OVER_TEMPERATURE)
  1304. previousAlarmCode[gun_index] |= ALARM_OVER_TEMPERATURE;
  1305. else
  1306. previousAlarmCode[gun_index] &= ~ALARM_OVER_TEMPERATURE;
  1307. }
  1308. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GROUND_FAIL) != (previousAlarmCode[gun_index] & ALARM_GROUND_FAIL))
  1309. {
  1310. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1311. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1312. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1313. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GROUND_FAIL)?"true":"false"));
  1314. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GROUND_FAIL)?OFF:ON);
  1315. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1316. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012256");
  1317. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "AC Ground Fault");
  1318. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Ground(PE)");
  1319. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1320. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1321. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1322. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_GROUND_FAIL)
  1323. previousAlarmCode[gun_index] |= ALARM_GROUND_FAIL;
  1324. else
  1325. previousAlarmCode[gun_index] &= ~ALARM_GROUND_FAIL;
  1326. }
  1327. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CP_ERROR) != (previousAlarmCode[gun_index] & ALARM_CP_ERROR))
  1328. {
  1329. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1330. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1331. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1332. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CP_ERROR)?"true":"false"));
  1333. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CP_ERROR)?OFF:ON);
  1334. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1335. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "023703");
  1336. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "pilot fault");
  1337. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Control pilot");
  1338. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1339. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1340. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1341. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CP_ERROR)
  1342. previousAlarmCode[gun_index] |= ALARM_CP_ERROR;
  1343. else
  1344. previousAlarmCode[gun_index] &= ~ALARM_CP_ERROR;
  1345. }
  1346. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_AC) != (previousAlarmCode[gun_index] & ALARM_CURRENT_LEAK_AC))
  1347. {
  1348. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1349. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1350. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1351. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_AC)?"true":"false"));
  1352. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_AC)?OFF:ON);
  1353. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1354. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012233");
  1355. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "RCD/CCID trip");
  1356. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "CCID");
  1357. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1358. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1359. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1360. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_AC)
  1361. previousAlarmCode[gun_index] |= ALARM_CURRENT_LEAK_AC;
  1362. else
  1363. previousAlarmCode[gun_index] &= ~ALARM_CURRENT_LEAK_AC;
  1364. }
  1365. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_DC) != (previousAlarmCode[gun_index] & ALARM_CURRENT_LEAK_DC))
  1366. {
  1367. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1368. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1369. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1370. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_DC)?"true":"false"));
  1371. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_DC)?OFF:ON);
  1372. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1373. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012233");
  1374. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "RCD/CCID trip");
  1375. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "CCID");
  1376. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1377. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1378. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1379. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_CURRENT_LEAK_DC)
  1380. previousAlarmCode[gun_index] |= ALARM_CURRENT_LEAK_DC;
  1381. else
  1382. previousAlarmCode[gun_index] &= ~ALARM_CURRENT_LEAK_DC;
  1383. }
  1384. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_MCU_TESTFAIL) != (previousAlarmCode[gun_index] & ALARM_MCU_TESTFAIL))
  1385. {
  1386. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1387. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1388. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1389. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_MCU_TESTFAIL)?"true":"false"));
  1390. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_MCU_TESTFAIL)?OFF:ON);
  1391. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1392. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012257");
  1393. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "MCU self-test Fault");
  1394. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "MCU");
  1395. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1396. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1397. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1398. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_MCU_TESTFAIL)
  1399. previousAlarmCode[gun_index] |= ALARM_MCU_TESTFAIL;
  1400. else
  1401. previousAlarmCode[gun_index] &= ~ALARM_MCU_TESTFAIL;
  1402. }
  1403. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT) != (previousAlarmCode[gun_index] & ALARM_HANDSHAKE_TIMEOUT))
  1404. {
  1405. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1406. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1407. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1408. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT)?"true":"false"));
  1409. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT)?OFF:ON);
  1410. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1411. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "HandshakeTimeout");
  1412. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "HandshakeTimeout");
  1413. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Operation");
  1414. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1415. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1416. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1417. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_HANDSHAKE_TIMEOUT)
  1418. previousAlarmCode[gun_index] |= ALARM_HANDSHAKE_TIMEOUT;
  1419. else
  1420. previousAlarmCode[gun_index] &= ~ALARM_HANDSHAKE_TIMEOUT;
  1421. }
  1422. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP) != (previousAlarmCode[gun_index] & ALARM_EMERGENCY_STOP))
  1423. {
  1424. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1425. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1426. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1427. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP)?"true":"false"));
  1428. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP)?OFF:ON);
  1429. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1430. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012251");
  1431. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "Emergency stop");
  1432. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Button");
  1433. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1434. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1435. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1436. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_EMERGENCY_STOP)
  1437. previousAlarmCode[gun_index] |= ALARM_EMERGENCY_STOP;
  1438. else
  1439. previousAlarmCode[gun_index] &= ~ALARM_EMERGENCY_STOP;
  1440. }
  1441. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_WELDING) != (previousAlarmCode[gun_index] & ALARM_RELAY_WELDING))
  1442. {
  1443. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1444. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1445. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1446. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_WELDING)?"true":"false"));
  1447. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_WELDING)?OFF:ON);
  1448. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1449. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "011009");
  1450. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "AC output relay welding");
  1451. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Relay");
  1452. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1453. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1454. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1455. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_WELDING)
  1456. previousAlarmCode[gun_index] |= ALARM_RELAY_WELDING;
  1457. else
  1458. previousAlarmCode[gun_index] &= ~ALARM_RELAY_WELDING;
  1459. }
  1460. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LEAK_MODULE_FAIL) != (previousAlarmCode[gun_index] & ALARM_LEAK_MODULE_FAIL))
  1461. {
  1462. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1463. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1464. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1465. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LEAK_MODULE_FAIL)?"true":"false"));
  1466. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LEAK_MODULE_FAIL)?OFF:ON);
  1467. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1468. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "011004");
  1469. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "RCD/CCID self-test fail");
  1470. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "CCID");
  1471. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1472. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1473. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1474. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LEAK_MODULE_FAIL)
  1475. previousAlarmCode[gun_index] |= ALARM_LEAK_MODULE_FAIL;
  1476. else
  1477. previousAlarmCode[gun_index] &= ~ALARM_LEAK_MODULE_FAIL;
  1478. }
  1479. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT) != (previousAlarmCode[gun_index] & ALARM_SHUTTER_FAULT))
  1480. {
  1481. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1482. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1483. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1484. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT)?"true":"false"));
  1485. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT)?OFF:ON);
  1486. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1487. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "011034");
  1488. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "Shutter fault");
  1489. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Shutter");
  1490. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1491. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1492. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1493. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_SHUTTER_FAULT)
  1494. previousAlarmCode[gun_index] |= ALARM_SHUTTER_FAULT;
  1495. else
  1496. previousAlarmCode[gun_index] &= ~ALARM_SHUTTER_FAULT;
  1497. }
  1498. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LOCKER_FAULT) != (previousAlarmCode[gun_index] & ALARM_LOCKER_FAULT))
  1499. {
  1500. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1501. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1502. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1503. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LOCKER_FAULT)?"true":"false"));
  1504. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LOCKER_FAULT)?OFF:ON);
  1505. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1506. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "011027");
  1507. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "AC connector lock fail");
  1508. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Locker");
  1509. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1510. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1511. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1512. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_LOCKER_FAULT)
  1513. previousAlarmCode[gun_index] |= ALARM_LOCKER_FAULT;
  1514. else
  1515. previousAlarmCode[gun_index] &= ~ALARM_LOCKER_FAULT;
  1516. }
  1517. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_POWER_DROP) != (previousAlarmCode[gun_index] & ALARM_POWER_DROP))
  1518. {
  1519. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1520. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1521. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1522. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_POWER_DROP)?"true":"false"));
  1523. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_POWER_DROP)?OFF:ON);
  1524. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1525. if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop == ON)
  1526. {
  1527. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012212");
  1528. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "System L1 input drop");
  1529. }
  1530. else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputDrop == ON)
  1531. {
  1532. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012213");
  1533. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "System L2 input drop");
  1534. }
  1535. else if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputDrop == ON)
  1536. {
  1537. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012214");
  1538. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "System L3 input drop");
  1539. }
  1540. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Voltage");
  1541. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1542. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1543. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1544. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_POWER_DROP)
  1545. previousAlarmCode[gun_index] |= ALARM_POWER_DROP;
  1546. else
  1547. previousAlarmCode[gun_index] &= ~ALARM_POWER_DROP;
  1548. }
  1549. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_CIRCUIT_SHORT) != (previousAlarmCode[gun_index] & ALARM_L1_CIRCUIT_SHORT))
  1550. {
  1551. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1552. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1553. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1554. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_CIRCUIT_SHORT)?"true":"false"));
  1555. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_CIRCUIT_SHORT)?OFF:ON);
  1556. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1557. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012262");
  1558. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "Circuit Short L1");
  1559. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Current");
  1560. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1561. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1562. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1563. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L1_CIRCUIT_SHORT)
  1564. previousAlarmCode[gun_index] |= ALARM_L1_CIRCUIT_SHORT;
  1565. else
  1566. previousAlarmCode[gun_index] &= ~ALARM_L1_CIRCUIT_SHORT;
  1567. }
  1568. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_CIRCUIT_SHORT) != (previousAlarmCode[gun_index] & ALARM_L2_CIRCUIT_SHORT))
  1569. {
  1570. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1571. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1572. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1573. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_CIRCUIT_SHORT)?"true":"false"));
  1574. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_CIRCUIT_SHORT)?OFF:ON);
  1575. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1576. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012301");
  1577. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "Circuit Short L2");
  1578. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Current");
  1579. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1580. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1581. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1582. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L2_CIRCUIT_SHORT)
  1583. previousAlarmCode[gun_index] |= ALARM_L2_CIRCUIT_SHORT;
  1584. else
  1585. previousAlarmCode[gun_index] &= ~ALARM_L2_CIRCUIT_SHORT;
  1586. }
  1587. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_CIRCUIT_SHORT) != (previousAlarmCode[gun_index] & ALARM_L3_CIRCUIT_SHORT))
  1588. {
  1589. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1590. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1591. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1592. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_CIRCUIT_SHORT)?"true":"false"));
  1593. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_CIRCUIT_SHORT)?OFF:ON);
  1594. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1595. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012302");
  1596. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "Circuit Short L3");
  1597. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Current");
  1598. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1599. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1600. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1601. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_L3_CIRCUIT_SHORT)
  1602. previousAlarmCode[gun_index] |= ALARM_L3_CIRCUIT_SHORT;
  1603. else
  1604. previousAlarmCode[gun_index] &= ~ALARM_L3_CIRCUIT_SHORT;
  1605. }
  1606. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_ROTATORY_SWITCH_FAULT) != (previousAlarmCode[gun_index] & ALARM_ROTATORY_SWITCH_FAULT))
  1607. {
  1608. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1609. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1610. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1611. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_ROTATORY_SWITCH_FAULT)?"true":"false"));
  1612. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_ROTATORY_SWITCH_FAULT)?OFF:ON);
  1613. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1614. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "011036");
  1615. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "Rotary switch fault");
  1616. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Rotary switch");
  1617. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1618. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1619. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1620. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_ROTATORY_SWITCH_FAULT)
  1621. previousAlarmCode[gun_index] |= ALARM_ROTATORY_SWITCH_FAULT;
  1622. else
  1623. previousAlarmCode[gun_index] &= ~ALARM_ROTATORY_SWITCH_FAULT;
  1624. }
  1625. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_DRIVE_FAULT) != (previousAlarmCode[gun_index] & ALARM_RELAY_DRIVE_FAULT))
  1626. {
  1627. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1628. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1629. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1630. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_DRIVE_FAULT)?"true":"false"));
  1631. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_DRIVE_FAULT)?OFF:ON);
  1632. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1633. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "011010");
  1634. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "AC output relay driving fault");
  1635. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Relay");
  1636. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1637. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1638. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1639. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_RELAY_DRIVE_FAULT)
  1640. previousAlarmCode[gun_index] |= ALARM_RELAY_DRIVE_FAULT;
  1641. else
  1642. previousAlarmCode[gun_index] &= ~ALARM_RELAY_DRIVE_FAULT;
  1643. }
  1644. if((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_METER_TIMEOUT) != (previousAlarmCode[gun_index] & ALARM_METER_TIMEOUT))
  1645. {
  1646. getNowDatetime(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp);
  1647. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId = idxEvent;
  1648. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger, "Alerting");
  1649. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue, ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_METER_TIMEOUT)?"true":"false"));
  1650. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared = ((ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_METER_TIMEOUT)?OFF:ON);
  1651. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType, "HardWiredNotification");
  1652. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode, "012305");
  1653. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo, "Meter communication timeout");
  1654. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name, "Meter");
  1655. ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId = (gun_index+1);
  1656. sprintf((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name, "Problem");
  1657. idxEvent += ((idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)-1)?1:0);
  1658. if(ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode & ALARM_METER_TIMEOUT)
  1659. previousAlarmCode[gun_index] |= ALARM_METER_TIMEOUT;
  1660. else
  1661. previousAlarmCode[gun_index] &= ~ALARM_METER_TIMEOUT;
  1662. }
  1663. if(idxEvent > 0)
  1664. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = ON;
  1665. }
  1666. //=====================================
  1667. // Latch alarm recover in state A
  1668. //=====================================
  1669. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == 1))
  1670. {
  1671. /*
  1672. TODO: Recover latch alarm here
  1673. */
  1674. }
  1675. //=====================================
  1676. // Latch alarm recover in state B1 and B2
  1677. //=====================================
  1678. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == 2) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == 3))
  1679. {
  1680. /*
  1681. TODO: Recover latch alarm here
  1682. */
  1683. }
  1684. //=====================================
  1685. // Latch alarm recover in state C
  1686. //=====================================
  1687. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == 4))
  1688. {
  1689. /*
  1690. TODO: Recover latch alarm here
  1691. */
  1692. }
  1693. ShmCharger->gun_info[gun_index].acCcsInfo.CSUAlarmStatusCode = ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode;
  1694. }
  1695. usleep(100000);
  1696. }
  1697. return FAIL;
  1698. }