Module_AlarmDetect.c 115 KB

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