Module_AlarmDetect.c 108 KB

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