Module_AlarmDetect.c 115 KB

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