Module_AlarmDetect.c 107 KB

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