Module_AlarmDetect.c 72 KB

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