Module_AlarmDetect.c 111 KB

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