Module_EvComm.c 208 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745
  1. #include <sys/time.h>
  2. #include <sys/timeb.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <sys/types.h>
  6. #include <sys/ioctl.h>
  7. #include <sys/socket.h>
  8. #include <sys/ipc.h>
  9. #include <sys/shm.h>
  10. #include <sys/mman.h>
  11. #include <linux/can.h>
  12. #include <linux/can/raw.h>
  13. #include <linux/wireless.h>
  14. #include <arpa/inet.h>
  15. #include <netinet/in.h>
  16. #include <unistd.h>
  17. #include <stdarg.h>
  18. #include <stdio.h> /*標準輸入輸出定義*/
  19. #include <stdlib.h> /*標準函數庫定義*/
  20. #include <unistd.h> /*Unix 標準函數定義*/
  21. #include <fcntl.h> /*檔控制定義*/
  22. #include <termios.h> /*PPSIX 終端控制定義*/
  23. #include <errno.h> /*錯誤號定義*/
  24. #include <string.h>
  25. #include <time.h>
  26. #include <ctype.h>
  27. #include <ifaddrs.h>
  28. #include "../../define.h"
  29. #include "Module_EvComm.h"
  30. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  31. #define PASS 1
  32. #define FAIL -1
  33. #define STOP 0
  34. #define START 1
  35. #define COMMUNICATION 2
  36. #define INITIALIZATION 3
  37. #define YES 1
  38. #define NO 0
  39. #define EQUAL 0
  40. #define CHK_VOL_RANGE 30
  41. #define CHK_CUR_RANGE 5
  42. #define PLUG 1
  43. #define UNPLUG 0
  44. #define UNDEFINED_TEMP 255
  45. #define ALLOW_COUNT_MAX 30
  46. #define VOUT_MIN_VOLTAGE 150
  47. #define CURR_MIN_CURRENT 0
  48. #define STAGE1_GUN_DERATING_TEMP 140 //LWADD
  49. #define STAGE2_GUN_DERATING_TEMP 145 //LWADD
  50. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  51. struct StatusCodeData *ShmStatusCodeData;
  52. struct FanModuleData *ShmFanModuleData;
  53. struct CHAdeMOData *ShmCHAdeMOData;
  54. struct GBTData *ShmGBTData;
  55. struct CcsData *ShmCcsData;
  56. struct PsuData *ShmPsuData;
  57. struct MeterInformation *ShmCsuMeterData;
  58. struct DcCommonInformation *ShmDcCommonData;
  59. struct SmartBoxData *ShmSmartBoxData;
  60. byte gun_count;
  61. int chargingTime[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  62. byte rtcChkCount = 0;
  63. bool printLogRecord;
  64. float LogInfo[2][10];
  65. bool _useOfflineNoCharging = false;
  66. byte sampleVolIndex[PSU_GROUP_COUNT];
  67. // 限制最大充電電壓,因應不同 type 槍線來限制
  68. double Chademo_Simple = 5000;
  69. double GB_Simple = 7500;
  70. double CCS_Simple = 7500;
  71. // ---------------------------------------
  72. double Chademo_Standard= 5000;
  73. double GB_Standard = 7500;
  74. double CCS_Standard = 9500;
  75. //float maxChargingVol[2] = { 0, 0 }; // 限制最大充電電壓,如依照模塊則填上 0
  76. // 限制最大充電電流與能量透過 Web
  77. //float maxChargingCur[2] = { 0, 0 }; // 限制最大充電電流,如依照模塊則填上 0
  78. int userLimitPwr = 0;
  79. // 允許當前輸出與需求落差超過 10A 的累積次數 (超過 ALLOW_COUNT_MAX 即給予當前值)
  80. byte curAllowCount[2] = { 0, 0 };
  81. float curTargetCur[2] = { 0, 0 };
  82. // 槍資訊
  83. struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  84. struct timespec _chk_ratingPower_timeout[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  85. struct timespec _chk_chademo_permission_timeout[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  86. bool chkChademoPermission[2] = { false, false };
  87. bool chkChademoPermissionSend[2] = { false, false };
  88. byte SendErrorCount[2] = { 0, 0};
  89. struct timespec delayToPrintLogTimeout;
  90. unsigned char mask_table[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
  91. void PRINTF_FUNC(char *string, ...);
  92. void GetMaxVolAndCurMethod(byte index, float *vol, float *cur);
  93. void GetMaxPowerMethod(byte index, float *pow);
  94. int GetTimeoutValue(struct timespec *startTime);
  95. #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  96. #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  97. #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  98. int GetTimeoutValue(struct timespec *startTime)
  99. {
  100. struct timespec endTime;
  101. clock_gettime(CLOCK_MONOTONIC_COARSE, &endTime);
  102. return endTime.tv_sec - startTime->tv_sec;
  103. }
  104. void GetTimespecFunc(struct timespec *time)
  105. {
  106. clock_gettime(CLOCK_MONOTONIC_COARSE, time);
  107. }
  108. int StoreLogMsg(const char *fmt, ...)
  109. {
  110. char Buf[4096+256];
  111. char buffer[4096];
  112. va_list args;
  113. struct timeb SeqEndTime;
  114. struct tm *tm;
  115. va_start(args, fmt);
  116. int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
  117. va_end(args);
  118. memset(Buf,0,sizeof(Buf));
  119. ftime(&SeqEndTime);
  120. SeqEndTime.time = time(NULL);
  121. tm=localtime(&SeqEndTime.time);
  122. if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
  123. {
  124. sprintf(Buf,"%02d:%02d:%02d:%03d - %s",
  125. tm->tm_hour,tm->tm_min,tm->tm_sec,SeqEndTime.millitm, buffer);
  126. printf("%s \n", Buf);
  127. }
  128. else
  129. {
  130. sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog_%s_Log",
  131. tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,SeqEndTime.millitm,
  132. buffer,
  133. tm->tm_year+1900,tm->tm_mon+1,
  134. ShmSysConfigAndInfo->SysConfig.SerialNumber);
  135. system(Buf);
  136. }
  137. return rc;
  138. }
  139. int DiffTimeb(struct timeb ST, struct timeb ET)
  140. {
  141. //return milli-second
  142. unsigned int StartTime,StopTime;
  143. StartTime=(unsigned int)ST.time;
  144. StopTime=(unsigned int)ET.time;
  145. return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
  146. }
  147. void PRINTF_FUNC(char *string, ...)
  148. {
  149. va_list args;
  150. char buffer[4096];
  151. va_start(args, string);
  152. vsnprintf(buffer, sizeof(buffer), string, args);
  153. va_end(args);
  154. DEBUG_INFO("%s ", buffer);
  155. }
  156. //=================================
  157. // Common routine
  158. //=================================
  159. void getTimeString(char *buff)
  160. {
  161. time_t timep;
  162. struct tm *p;
  163. time(&timep);
  164. p=gmtime(&timep);
  165. sprintf(buff, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
  166. }
  167. //bool CheckUniqNumber(byte value)
  168. //{
  169. // for (byte index = 0; index < gun_count; index++)
  170. // {
  171. // if (_chargingData[index]->Evboard_id == value)
  172. // {
  173. // struct timeval _end_time;
  174. // gettimeofday(&_end_time, NULL);
  175. // unsigned long diff = 1000000 * (_end_time.tv_sec - _id_assign_time.tv_sec) + _end_time.tv_usec - _id_assign_time.tv_usec;
  176. // if (diff >= 3000000)
  177. // {
  178. // gettimeofday(&_id_assign_time, NULL);
  179. // return true;
  180. // }
  181. // else
  182. // {
  183. // return false;
  184. // }
  185. // }
  186. // }
  187. //
  188. // gettimeofday(&_id_assign_time, NULL);
  189. // return true;
  190. //}
  191. //==========================================
  192. // Init all share memory
  193. //==========================================
  194. int InitShareMemory()
  195. {
  196. int result = PASS;
  197. int MeterSMId;
  198. //initial ShmSysConfigAndInfo
  199. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  200. {
  201. #ifdef SystemLogMessage
  202. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  203. #endif
  204. result = FAIL;
  205. }
  206. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  207. {
  208. #ifdef SystemLogMessage
  209. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  210. #endif
  211. result = FAIL;
  212. }
  213. //initial ShmStatusCodeData
  214. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  215. {
  216. #ifdef SystemLogMessage
  217. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  218. #endif
  219. result = FAIL;
  220. }
  221. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  222. {
  223. #ifdef SystemLogMessage
  224. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  225. #endif
  226. result = FAIL;
  227. }
  228. //creat ShmPsuData
  229. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  230. {
  231. #ifdef SystemLogMessage
  232. DEBUG_ERROR("shmget ShmPsuData NG \n");
  233. #endif
  234. result = FAIL;
  235. }
  236. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  237. {
  238. #ifdef SystemLogMessage
  239. DEBUG_ERROR("shmat ShmPsuData NG \n");
  240. #endif
  241. result = FAIL;
  242. }
  243. if(CHAdeMO_QUANTITY > 0)
  244. {
  245. if ((MeterSMId = shmget(ShmCHAdeMOCommKey, sizeof(struct CHAdeMOData), IPC_CREAT | 0777)) < 0)
  246. {
  247. #ifdef SystemLogMessage
  248. DEBUG_ERROR("[shmget ShmCHAdeMOData NG \n");
  249. #endif
  250. return FAIL;
  251. }
  252. else if ((ShmCHAdeMOData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  253. {
  254. #ifdef SystemLogMessage
  255. DEBUG_ERROR("shmat ShmCHAdeMOData NG \n");
  256. #endif
  257. return FAIL;
  258. }
  259. }
  260. if(GB_QUANTITY > 0)
  261. {
  262. if ((MeterSMId = shmget(ShmGBTCommKey, sizeof(struct GBTData), IPC_CREAT | 0777)) < 0)
  263. {
  264. #ifdef SystemLogMessage
  265. DEBUG_ERROR("[shmget ShmGBTData NG \n");
  266. #endif
  267. return FAIL;
  268. }
  269. else if ((ShmGBTData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  270. {
  271. #ifdef SystemLogMessage
  272. DEBUG_ERROR("shmat ShmGBTData NG \n");
  273. #endif
  274. return FAIL;
  275. }
  276. }
  277. if(CCS_QUANTITY > 0)
  278. {
  279. if ((MeterSMId = shmget(ShmCcsCommKey, sizeof(struct CcsData), IPC_CREAT | 0777)) < 0)
  280. {
  281. #ifdef SystemLogMessage
  282. DEBUG_ERROR("shmget ShmCcsData NG \n");
  283. #endif
  284. return FAIL;
  285. }
  286. else if ((ShmCcsData = shmat(MeterSMId, NULL, 0)) == (void *) -1) {
  287. #ifdef SystemLogMessage
  288. DEBUG_ERROR("shmat ShmCcsData NG \n");
  289. #endif
  290. return FAIL;
  291. }
  292. }
  293. if ((MeterSMId = shmget(ShmCsuMeterKey, sizeof(struct MeterInformation), IPC_CREAT | 0777)) < 0)
  294. {
  295. #ifdef SystemLogMessage
  296. DEBUG_ERROR("shmget ShmCsuMeterKey NG \n");
  297. #endif
  298. return 0;
  299. }
  300. else if ((ShmCsuMeterData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  301. {
  302. #ifdef SystemLogMessage
  303. DEBUG_ERROR("shmat ShmCsuMeterData NG \n");
  304. #endif
  305. return 0;
  306. }
  307. if ((MeterSMId = shmget(ShmCommonKey, sizeof(struct DcCommonInformation), IPC_CREAT | 0777)) < 0)
  308. {
  309. #ifdef SystemLogMessage
  310. DEBUG_ERROR("shmget ShmCommonKey NG \n");
  311. #endif
  312. return 0;
  313. }
  314. else if ((ShmDcCommonData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  315. {
  316. #ifdef SystemLogMessage
  317. DEBUG_ERROR("shmat ShmCommonKey NG \n");
  318. #endif
  319. return 0;
  320. }
  321. if ((MeterSMId = shmget ( ShmSmartBoxKey, sizeof(struct SmartBoxData), IPC_CREAT | 0777 )) < 0)
  322. {
  323. #ifdef SystemLogMessage
  324. DEBUG_ERROR("shmat ShmSmartBoxKey NG \n");
  325. #endif
  326. return 0;
  327. }
  328. else if ((ShmSmartBoxData = shmat ( MeterSMId, NULL, 0 )) == (void *) - 1)
  329. {
  330. #ifdef SystemLogMessage
  331. DEBUG_ERROR("shmat ShmSmartBoxData NG \n");
  332. #endif
  333. return 0;
  334. }
  335. return result;
  336. }
  337. //================================================
  338. // initial can-bus
  339. //================================================
  340. int InitCanBus()
  341. {
  342. int s0,nbytes;
  343. struct timeval tv;
  344. struct ifreq ifr0;
  345. struct sockaddr_can addr0;
  346. system("/sbin/ip link set can0 down");
  347. system("/sbin/ip link set can0 type can bitrate 500000 restart-ms 100");
  348. system("/sbin/ip link set can0 up");
  349. s0 = socket(PF_CAN, SOCK_RAW, CAN_RAW);
  350. tv.tv_sec = 0;
  351. tv.tv_usec = 10000;
  352. if (setsockopt(s0, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval)) < 0)
  353. {
  354. #ifdef SystemLogMessage
  355. DEBUG_ERROR("Set SO_RCVTIMEO NG");
  356. #endif
  357. }
  358. nbytes=40960;
  359. if (setsockopt(s0, SOL_SOCKET, SO_RCVBUF, &nbytes, sizeof(int)) < 0)
  360. {
  361. #ifdef SystemLogMessage
  362. DEBUG_ERROR("Set SO_RCVBUF NG");
  363. #endif
  364. }
  365. nbytes=40960;
  366. if (setsockopt(s0, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0)
  367. {
  368. #ifdef SystemLogMessage
  369. DEBUG_ERROR("Set SO_SNDBUF NG");
  370. #endif
  371. }
  372. strcpy(ifr0.ifr_name, "can0" );
  373. ioctl(s0, SIOCGIFINDEX, &ifr0); /* ifr.ifr_ifindex gets filled with that device's index */
  374. addr0.can_family = AF_CAN;
  375. addr0.can_ifindex = ifr0.ifr_ifindex;
  376. bind(s0, (struct sockaddr *)&addr0, sizeof(addr0));
  377. return s0;
  378. }
  379. //================================================
  380. //================================================
  381. // CANBUS receive task
  382. //================================================
  383. //================================================
  384. bool FindChargingInfoData(byte target, struct ChargingInfoData **chargingData)
  385. {
  386. for (byte index = 0; index < CHAdeMO_QUANTITY; index++)
  387. {
  388. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target)
  389. {
  390. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
  391. return true;
  392. }
  393. }
  394. for (byte index = 0; index < CCS_QUANTITY; index++)
  395. {
  396. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target)
  397. {
  398. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
  399. return true;
  400. }
  401. }
  402. for (byte index = 0; index < GB_QUANTITY; index++)
  403. {
  404. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target)
  405. {
  406. chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
  407. return true;
  408. }
  409. }
  410. return false;
  411. }
  412. void AddrAssignment(byte *data)
  413. {
  414. byte target_number[8];
  415. byte index = 0x00;
  416. memcpy(target_number, data, sizeof(target_number));
  417. index = *(data + 4);
  418. if (gun_count == 1)
  419. index = 0x01;
  420. // if (CheckUniqNumber(index))
  421. {
  422. if (_chargingData[index - 1]->Type == _Type_Chademo)
  423. PRINTF_FUNC("Set EV board info : (Chademo) TargetAddr = %d \n", index);
  424. else if (_chargingData[index - 1]->Type == _Type_CCS)
  425. PRINTF_FUNC("Set EV board info : (CCS) TargetAddr = %d \n", index);
  426. else if (_chargingData[index - 1]->Type == _Type_GB)
  427. PRINTF_FUNC("Set EV board info : (GB) TargetAddr = %d \n", index);
  428. SetTargetAddr(target_number, index);
  429. }
  430. }
  431. void ClearAbnormalStatus_Chademo(byte gun_index)
  432. {
  433. bool isCleanCheck = false;
  434. char code[7];
  435. if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "", 6) == EQUAL)
  436. return;
  437. if (true)
  438. {
  439. if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023700", 6) == EQUAL &&
  440. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvCommFail == YES)
  441. {
  442. memcpy(code, "023700", 6);
  443. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  444. isCleanCheck = true;
  445. }
  446. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023704", 6) == EQUAL &&
  447. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryMalfun == YES)
  448. {
  449. memcpy(code, "023704", 6);
  450. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  451. isCleanCheck = true;
  452. }
  453. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023705", 6) == EQUAL &&
  454. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoNoPermission == YES)
  455. {
  456. memcpy(code, "023705", 6);
  457. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  458. isCleanCheck = true;
  459. }
  460. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023706", 6) == EQUAL &&
  461. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryIncompatibility == YES)
  462. {
  463. memcpy(code, "023706", 6);
  464. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  465. isCleanCheck = true;
  466. }
  467. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023707", 6) == EQUAL &&
  468. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOVP == YES)
  469. {
  470. memcpy(code, "023707", 6);
  471. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  472. isCleanCheck = true;
  473. }
  474. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023708", 6) == EQUAL &&
  475. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryUVP == YES)
  476. {
  477. memcpy(code, "023708", 6);
  478. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  479. isCleanCheck = true;
  480. }
  481. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023709", 6) == EQUAL &&
  482. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOTP == YES)
  483. {
  484. memcpy(code, "023709", 6);
  485. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  486. isCleanCheck = true;
  487. }
  488. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023710", 6) == EQUAL &&
  489. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryCurrentDiff == YES)
  490. {
  491. memcpy(code, "023710", 6);
  492. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  493. isCleanCheck = true;
  494. }
  495. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023711", 6) == EQUAL &&
  496. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryVoltageDiff == YES)
  497. {
  498. memcpy(code, "023711", 6);
  499. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  500. isCleanCheck = true;
  501. }
  502. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023712", 6) == EQUAL &&
  503. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoShiftPosition == YES)
  504. {
  505. memcpy(code, "023712", 6);
  506. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  507. isCleanCheck = true;
  508. }
  509. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023713", 6) == EQUAL &&
  510. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOtherFault == YES)
  511. {
  512. memcpy(code, "023713", 6);
  513. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  514. isCleanCheck = true;
  515. }
  516. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023714", 6) == EQUAL &&
  517. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargingSystemError == YES)
  518. {
  519. memcpy(code, "023714", 6);
  520. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  521. isCleanCheck = true;
  522. }
  523. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023715", 6) == EQUAL &&
  524. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvNormalStop == YES)
  525. {
  526. memcpy(code, "023715", 6);
  527. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  528. isCleanCheck = true;
  529. }
  530. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023716", 6) == EQUAL &&
  531. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoTempSensorBroken == YES)
  532. {
  533. memcpy(code, "023716", 6);
  534. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  535. isCleanCheck = true;
  536. }
  537. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023717", 6) == EQUAL &&
  538. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoConnectorLockFail == YES)
  539. {
  540. memcpy(code, "023717", 6);
  541. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  542. isCleanCheck = true;
  543. }
  544. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023718", 6) == EQUAL &&
  545. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoD1OnNoReceive == YES)
  546. {
  547. memcpy(code, "023718", 6);
  548. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  549. isCleanCheck = true;
  550. }
  551. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023719", 6) == EQUAL &&
  552. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJTimeout == YES)
  553. {
  554. memcpy(code, "023719", 6);
  555. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  556. isCleanCheck = true;
  557. }
  558. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023720", 6) == EQUAL &&
  559. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeAllowTimeout == YES)
  560. {
  561. memcpy(code, "023720", 6);
  562. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  563. isCleanCheck = true;
  564. }
  565. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023721", 6) == EQUAL &&
  566. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoWaitGfdTimeout == YES)
  567. {
  568. memcpy(code, "023721", 6);
  569. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  570. isCleanCheck = true;
  571. }
  572. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023722", 6) == EQUAL &&
  573. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayTimeout == YES)
  574. {
  575. memcpy(code, "023722", 6);
  576. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  577. isCleanCheck = true;
  578. }
  579. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023723", 6) == EQUAL &&
  580. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsReqCurrentTimeout == YES)
  581. {
  582. memcpy(code, "023723", 6);
  583. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  584. isCleanCheck = true;
  585. }
  586. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023724", 6) == EQUAL &&
  587. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJOffTimeout == YES)
  588. {
  589. memcpy(code, "023724", 6);
  590. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  591. isCleanCheck = true;
  592. }
  593. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023725", 6) == EQUAL &&
  594. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayOffTimeout == YES)
  595. {
  596. memcpy(code, "023725", 6);
  597. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  598. isCleanCheck = true;
  599. }
  600. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023726", 6) == EQUAL &&
  601. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan10V == YES)
  602. {
  603. memcpy(code, "023726", 6);
  604. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  605. isCleanCheck = true;
  606. }
  607. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023727", 6) == EQUAL &&
  608. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan20V == YES)
  609. {
  610. memcpy(code, "023727", 6);
  611. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  612. isCleanCheck = true;
  613. }
  614. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023728", 6) == EQUAL &&
  615. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeBeforeStop == YES)
  616. {
  617. memcpy(code, "023728", 6);
  618. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  619. isCleanCheck = true;
  620. }
  621. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023729", 6) == EQUAL &&
  622. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetNormalStop == YES)
  623. {
  624. memcpy(code, "023729", 6);
  625. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  626. isCleanCheck = true;
  627. }
  628. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023730", 6) == EQUAL &&
  629. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetEmergencyStop == YES)
  630. {
  631. memcpy(code, "023730", 6);
  632. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  633. isCleanCheck = true;
  634. }
  635. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023731", 6) == EQUAL &&
  636. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoIsolationResultFail == YES)
  637. {
  638. memcpy(code, "023731", 6);
  639. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  640. isCleanCheck = true;
  641. }
  642. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023732", 6) == EQUAL &&
  643. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoMissLinkWithMotherBoard == YES)
  644. {
  645. memcpy(code, "023732", 6);
  646. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  647. isCleanCheck = true;
  648. }
  649. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023733", 6) == EQUAL &&
  650. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoOutputVolMoreThanLimit == YES)
  651. {
  652. memcpy(code, "023733", 6);
  653. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  654. isCleanCheck = true;
  655. }
  656. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023734", 6) == EQUAL &&
  657. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReqCurrentMoreThanLimit == YES)
  658. {
  659. memcpy(code, "023734", 6);
  660. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  661. isCleanCheck = true;
  662. }
  663. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023735", 6) == EQUAL &&
  664. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReCapBmsEqrCurrentExceed == YES)
  665. {
  666. memcpy(code, "023735", 6);
  667. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  668. isCleanCheck = true;
  669. }
  670. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023736", 6) == EQUAL &&
  671. ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargeRemainCountDown == YES)
  672. {
  673. memcpy(code, "023736", 6);
  674. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  675. isCleanCheck = true;
  676. }
  677. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023980", 6) == EQUAL &&
  678. ShmStatusCodeData->InfoCode.InfoEvents.bits.CHADEMO_BMS_CHARGE_ALLOW_ERROR == YES)
  679. {
  680. memcpy(code, "023980", 6);
  681. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  682. isCleanCheck = true;
  683. }
  684. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023981", 6) == EQUAL &&
  685. ShmStatusCodeData->InfoCode.InfoEvents.bits.CHADEMO_OUTPUT_VOLTAGE_MORE_THEN_10_PERCENT == YES)
  686. {
  687. memcpy(code, "023981", 6);
  688. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  689. isCleanCheck = true;
  690. }
  691. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023982", 6) == EQUAL &&
  692. ShmStatusCodeData->InfoCode.InfoEvents.bits.CHADEMO_ADC_LESS_THAN_10V == YES)
  693. {
  694. memcpy(code, "023982", 6);
  695. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  696. isCleanCheck = true;
  697. }
  698. }
  699. if (isCleanCheck)
  700. {
  701. for (byte index = 0; index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; index++)
  702. {
  703. if (index != gun_index || ShmSysConfigAndInfo->SysConfig.TotalConnectorCount == 1)
  704. {
  705. PRINTF_FUNC("CHA clean error : index = %d, EvConnAlarmCode = %s, code = %s \n", index, _chargingData[index]->EvConnAlarmCode, code);
  706. if (strncmp((char *)_chargingData[index]->EvConnAlarmCode, code, 6) != EQUAL)
  707. {
  708. if (strncmp(code, "023700", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvCommFail = NO;
  709. if (strncmp(code, "023704", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryMalfun = NO;
  710. if (strncmp(code, "023705", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoNoPermission = NO;
  711. if (strncmp(code, "023706", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryIncompatibility = NO;
  712. if (strncmp(code, "023707", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOVP = NO;
  713. if (strncmp(code, "023708", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryUVP = NO;
  714. if (strncmp(code, "023709", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOTP = NO;
  715. if (strncmp(code, "023710", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryCurrentDiff = NO;
  716. if (strncmp(code, "023711", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryVoltageDiff = NO;
  717. if (strncmp(code, "023712", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoShiftPosition = NO;
  718. if (strncmp(code, "023713", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOtherFault = NO;
  719. if (strncmp(code, "023714", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargingSystemError = NO;
  720. if (strncmp(code, "023715", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvNormalStop = NO;
  721. if (strncmp(code, "023716", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoTempSensorBroken = NO;
  722. if (strncmp(code, "023717", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoConnectorLockFail = NO;
  723. if (strncmp(code, "023718", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoD1OnNoReceive = NO;
  724. if (strncmp(code, "023719", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJTimeout = NO;
  725. if (strncmp(code, "023720", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeAllowTimeout = NO;
  726. if (strncmp(code, "023721", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoWaitGfdTimeout = NO;
  727. if (strncmp(code, "023722", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayTimeout = NO;
  728. if (strncmp(code, "023723", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsReqCurrentTimeout = NO;
  729. if (strncmp(code, "023724", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJOffTimeout = NO;
  730. if (strncmp(code, "023725", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayOffTimeout = NO;
  731. if (strncmp(code, "023726", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan10V = NO;
  732. if (strncmp(code, "023727", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan20V = NO;
  733. if (strncmp(code, "023728", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeBeforeStop = NO;
  734. if (strncmp(code, "023729", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetNormalStop = NO;
  735. if (strncmp(code, "023730", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetEmergencyStop = NO;
  736. if (strncmp(code, "023731", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoIsolationResultFail = NO;
  737. if (strncmp(code, "023732", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoMissLinkWithMotherBoard = NO;
  738. if (strncmp(code, "023733", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoOutputVolMoreThanLimit = NO;
  739. if (strncmp(code, "023734", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReqCurrentMoreThanLimit = NO;
  740. if (strncmp(code, "023735", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReCapBmsEqrCurrentExceed = NO;
  741. if (strncmp(code, "023736", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargeRemainCountDown = NO;
  742. if (strncmp(code, "023980", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CHADEMO_BMS_CHARGE_ALLOW_ERROR = NO;
  743. if (strncmp(code, "023981", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CHADEMO_OUTPUT_VOLTAGE_MORE_THEN_10_PERCENT = NO;
  744. if (strncmp(code, "023982", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CHADEMO_ADC_LESS_THAN_10V = NO;
  745. }
  746. }
  747. }
  748. }
  749. }
  750. void ClearAbnormalStatus_GB(byte gun_index)
  751. {
  752. bool isCleanCheck = false;
  753. char code[7];
  754. if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "", 6) == EQUAL)
  755. return;
  756. if (true)
  757. {
  758. if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023702", 6) == EQUAL &&
  759. ShmStatusCodeData->InfoCode.InfoEvents.bits.GbEvCommFail == YES)
  760. {
  761. memcpy(code, "023702", 6);
  762. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  763. isCleanCheck = true;
  764. }
  765. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023900", 6) == EQUAL &&
  766. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_LOS_CC1 == YES)
  767. {
  768. memcpy(code, "023900", 6);
  769. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  770. isCleanCheck = true;
  771. }
  772. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023901", 6) == EQUAL &&
  773. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CONNECTOR_LOCK_FAIL == YES)
  774. {
  775. memcpy(code, "023901", 6);
  776. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  777. isCleanCheck = true;
  778. }
  779. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023902", 6) == EQUAL &&
  780. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BATTERY_INCOMPATIBLE == YES)
  781. {
  782. memcpy(code, "023902", 6);
  783. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  784. isCleanCheck = true;
  785. }
  786. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023903", 6) == EQUAL &&
  787. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_BROAA_TIMEOUT == YES)
  788. {
  789. memcpy(code, "023903", 6);
  790. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  791. isCleanCheck = true;
  792. }
  793. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023904", 6) == EQUAL &&
  794. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CSU_PRECHARGE_TIMEOUT == YES)
  795. {
  796. memcpy(code, "023904", 6);
  797. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  798. isCleanCheck = true;
  799. }
  800. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023905", 6) == EQUAL &&
  801. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_PRESENT_VOLTAGE_FAULT == YES)
  802. {
  803. memcpy(code, "023905", 6);
  804. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  805. isCleanCheck = true;
  806. }
  807. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023906", 6) == EQUAL &&
  808. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_VOLTAGE_OVER_RANGE == YES)
  809. {
  810. memcpy(code, "023906", 6);
  811. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  812. isCleanCheck = true;
  813. }
  814. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023907", 6) == EQUAL &&
  815. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BSM_CHARGE_ALLOW_00_10MIN_COUUNTDONE == YES)
  816. {
  817. memcpy(code, "023907", 6);
  818. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  819. isCleanCheck = true;
  820. }
  821. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023908", 6) == EQUAL &&
  822. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_WAIT_GROUNDFAULT_TIMEOUT == YES)
  823. {
  824. memcpy(code, "023908", 6);
  825. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  826. isCleanCheck = true;
  827. }
  828. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023909", 6) == EQUAL &&
  829. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ADC_MORE_THAN_10V == YES)
  830. {
  831. memcpy(code, "023909", 6);
  832. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  833. isCleanCheck = true;
  834. }
  835. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023910", 6) == EQUAL &&
  836. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ADC_MORE_THAN_60V == YES)
  837. {
  838. memcpy(code, "023910", 6);
  839. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  840. isCleanCheck = true;
  841. }
  842. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023911", 6) == EQUAL &&
  843. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CHARGER_GET_NORMAL_STOP_CMD == YES)
  844. {
  845. memcpy(code, "023911", 6);
  846. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  847. isCleanCheck = true;
  848. }
  849. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023912", 6) == EQUAL &&
  850. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CHARGER_GET_EMERGENCY_STOP_CMD == YES)
  851. {
  852. memcpy(code, "023912", 6);
  853. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  854. isCleanCheck = true;
  855. }
  856. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023913", 6) == EQUAL &&
  857. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ISOLATION_RESULT_FAIL == YES)
  858. {
  859. memcpy(code, "023913", 6);
  860. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  861. isCleanCheck = true;
  862. }
  863. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023914", 6) == EQUAL &&
  864. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_MOTHER_BOARD_MISS_LINK == YES)
  865. {
  866. memcpy(code, "023914", 6);
  867. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  868. isCleanCheck = true;
  869. }
  870. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023915", 6) == EQUAL &&
  871. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_LIMIT == YES)
  872. {
  873. memcpy(code, "023915", 6);
  874. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  875. isCleanCheck = true;
  876. }
  877. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023916", 6) == EQUAL &&
  878. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_REQ_CURRENT_MORE_THAN_LIMIT == YES)
  879. {
  880. memcpy(code, "023916", 6);
  881. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  882. isCleanCheck = true;
  883. }
  884. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023917", 6) == EQUAL &&
  885. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_10_PERCENT == YES)
  886. {
  887. memcpy(code, "023917", 6);
  888. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  889. isCleanCheck = true;
  890. }
  891. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023918", 6) == EQUAL &&
  892. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_DIFF_BCS_5_PERCENT == YES)
  893. {
  894. memcpy(code, "023918", 6);
  895. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  896. isCleanCheck = true;
  897. }
  898. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023919", 6) == EQUAL &&
  899. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_STOP_ADC_MORE_THAN_10V == YES)
  900. {
  901. memcpy(code, "023919", 6);
  902. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  903. isCleanCheck = true;
  904. }
  905. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023930", 6) == EQUAL &&
  906. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BHM_TIMEOUT == YES)
  907. {
  908. memcpy(code, "023930", 6);
  909. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  910. isCleanCheck = true;
  911. }
  912. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023931", 6) == EQUAL &&
  913. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BRM_TIMEOUT == YES)
  914. {
  915. memcpy(code, "023931", 6);
  916. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  917. isCleanCheck = true;
  918. }
  919. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023932", 6) == EQUAL &&
  920. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCP_TIMEOUT == YES)
  921. {
  922. memcpy(code, "023932", 6);
  923. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  924. isCleanCheck = true;
  925. }
  926. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023933", 6) == EQUAL &&
  927. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BRO_TIMEOUT == YES)
  928. {
  929. memcpy(code, "023933", 6);
  930. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  931. isCleanCheck = true;
  932. }
  933. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023934", 6) == EQUAL &&
  934. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCL_TIMEOUT == YES)
  935. {
  936. memcpy(code, "023934", 6);
  937. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  938. isCleanCheck = true;
  939. }
  940. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023935", 6) == EQUAL &&
  941. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCS_TIMEOUT == YES)
  942. {
  943. memcpy(code, "023935", 6);
  944. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  945. isCleanCheck = true;
  946. }
  947. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023936", 6) == EQUAL &&
  948. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BSM_TIMEOUT == YES)
  949. {
  950. memcpy(code, "023936", 6);
  951. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  952. isCleanCheck = true;
  953. }
  954. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023937", 6) == EQUAL &&
  955. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BST_TIMEOUT == YES)
  956. {
  957. memcpy(code, "023937", 6);
  958. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  959. isCleanCheck = true;
  960. }
  961. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023938", 6) == EQUAL &&
  962. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BSD_TIMEOUT == YES)
  963. {
  964. memcpy(code, "023938", 6);
  965. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  966. isCleanCheck = true;
  967. }
  968. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023939", 6) == EQUAL &&
  969. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BEM_OTHER_TIMEOUT == YES)
  970. {
  971. memcpy(code, "023939", 6);
  972. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  973. isCleanCheck = true;
  974. }
  975. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023940", 6) == EQUAL &&
  976. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRM_TIMEOUT == YES)
  977. {
  978. memcpy(code, "023940", 6);
  979. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  980. isCleanCheck = true;
  981. }
  982. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023941", 6) == EQUAL &&
  983. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRMAA_TIMEOUT == YES)
  984. {
  985. memcpy(code, "023941", 6);
  986. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  987. isCleanCheck = true;
  988. }
  989. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023942", 6) == EQUAL &&
  990. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CTS_CML_TIMEOUT == YES)
  991. {
  992. memcpy(code, "023942", 6);
  993. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  994. isCleanCheck = true;
  995. }
  996. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023943", 6) == EQUAL &&
  997. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRO_TIMEOUT == YES)
  998. {
  999. memcpy(code, "023943", 6);
  1000. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1001. isCleanCheck = true;
  1002. }
  1003. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023944", 6) == EQUAL &&
  1004. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CCS_TIMEOUT == YES)
  1005. {
  1006. memcpy(code, "023944", 6);
  1007. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1008. isCleanCheck = true;
  1009. }
  1010. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023945", 6) == EQUAL &&
  1011. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CST_TIMEOUT == YES)
  1012. {
  1013. memcpy(code, "023945", 6);
  1014. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1015. isCleanCheck = true;
  1016. }
  1017. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023946", 6) == EQUAL &&
  1018. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CSD_TIMEOUT == YES)
  1019. {
  1020. memcpy(code, "023946", 6);
  1021. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1022. isCleanCheck = true;
  1023. }
  1024. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023947", 6) == EQUAL &&
  1025. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_BEM_OTHER_TIMEOUT == YES)
  1026. {
  1027. memcpy(code, "023947", 6);
  1028. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1029. isCleanCheck = true;
  1030. }
  1031. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023950", 6) == EQUAL &&
  1032. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_SOC_GOAL == YES)
  1033. {
  1034. memcpy(code, "023950", 6);
  1035. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1036. isCleanCheck = true;
  1037. }
  1038. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023951", 6) == EQUAL &&
  1039. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_TOTAL_VOLTAGE_GOAL == YES)
  1040. {
  1041. memcpy(code, "023951", 6);
  1042. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1043. isCleanCheck = true;
  1044. }
  1045. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023952", 6) == EQUAL &&
  1046. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CELL_VOLTAGE_GOAL == YES)
  1047. {
  1048. memcpy(code, "023952", 6);
  1049. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1050. isCleanCheck = true;
  1051. }
  1052. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023953", 6) == EQUAL &&
  1053. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_GET_CST == YES)
  1054. {
  1055. memcpy(code, "023953", 6);
  1056. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1057. isCleanCheck = true;
  1058. }
  1059. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023954", 6) == EQUAL &&
  1060. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_ISOLATION == YES)
  1061. {
  1062. memcpy(code, "023954", 6);
  1063. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1064. isCleanCheck = true;
  1065. }
  1066. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023955", 6) == EQUAL &&
  1067. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OUTPUT_CONNECTOR_OTP == YES)
  1068. {
  1069. memcpy(code, "023955", 6);
  1070. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1071. isCleanCheck = true;
  1072. }
  1073. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023956", 6) == EQUAL &&
  1074. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_COMPONENT == YES)
  1075. {
  1076. memcpy(code, "023956", 6);
  1077. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1078. isCleanCheck = true;
  1079. }
  1080. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023957", 6) == EQUAL &&
  1081. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CHARGE_CONNECTOR == YES)
  1082. {
  1083. memcpy(code, "023957", 6);
  1084. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1085. isCleanCheck = true;
  1086. }
  1087. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023958", 6) == EQUAL &&
  1088. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OTP == YES)
  1089. {
  1090. memcpy(code, "023958", 6);
  1091. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1092. isCleanCheck = true;
  1093. }
  1094. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023959", 6) == EQUAL &&
  1095. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OTHER == YES)
  1096. {
  1097. memcpy(code, "023959", 6);
  1098. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1099. isCleanCheck = true;
  1100. }
  1101. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023960", 6) == EQUAL &&
  1102. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_HIGH_V == YES)
  1103. {
  1104. memcpy(code, "023960", 6);
  1105. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1106. isCleanCheck = true;
  1107. }
  1108. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023961", 6) == EQUAL &&
  1109. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CC2 == YES)
  1110. {
  1111. memcpy(code, "023961", 6);
  1112. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1113. isCleanCheck = true;
  1114. }
  1115. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023962", 6) == EQUAL &&
  1116. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CURRENT == YES)
  1117. {
  1118. memcpy(code, "023962", 6);
  1119. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1120. isCleanCheck = true;
  1121. }
  1122. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023963", 6) == EQUAL &&
  1123. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_VOLTAGE == YES)
  1124. {
  1125. memcpy(code, "023963", 6);
  1126. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1127. isCleanCheck = true;
  1128. }
  1129. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023964", 6) == EQUAL &&
  1130. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GET_BST_NO_REASON == YES)
  1131. {
  1132. memcpy(code, "023964", 6);
  1133. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1134. isCleanCheck = true;
  1135. }
  1136. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023970", 6) == EQUAL &&
  1137. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CELL_OVER_VOLTAGE == YES)
  1138. {
  1139. memcpy(code, "023970", 6);
  1140. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1141. isCleanCheck = true;
  1142. }
  1143. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023971", 6) == EQUAL &&
  1144. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CELL_UNDER_VOLTAGE == YES)
  1145. {
  1146. memcpy(code, "023971", 6);
  1147. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1148. isCleanCheck = true;
  1149. }
  1150. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023972", 6) == EQUAL &&
  1151. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_OVER_SOC == YES)
  1152. {
  1153. memcpy(code, "023972", 6);
  1154. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1155. isCleanCheck = true;
  1156. }
  1157. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023973", 6) == EQUAL &&
  1158. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_UNDER_SOC == YES)
  1159. {
  1160. memcpy(code, "023973", 6);
  1161. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1162. isCleanCheck = true;
  1163. }
  1164. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023974", 6) == EQUAL &&
  1165. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CURRENT == YES)
  1166. {
  1167. memcpy(code, "023974", 6);
  1168. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1169. isCleanCheck = true;
  1170. }
  1171. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023975", 6) == EQUAL &&
  1172. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_TEMPERATURE == YES)
  1173. {
  1174. memcpy(code, "023975", 6);
  1175. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1176. isCleanCheck = true;
  1177. }
  1178. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023976", 6) == EQUAL &&
  1179. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_ISOLATE == YES)
  1180. {
  1181. memcpy(code, "023976", 6);
  1182. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1183. isCleanCheck = true;
  1184. }
  1185. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023977", 6) == EQUAL &&
  1186. ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_OUTPUT_CONNECTOR == YES)
  1187. {
  1188. memcpy(code, "023977", 6);
  1189. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1190. isCleanCheck = true;
  1191. }
  1192. }
  1193. if (isCleanCheck)
  1194. {
  1195. for (byte index = 0; index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; index++)
  1196. {
  1197. if (index != gun_index || ShmSysConfigAndInfo->SysConfig.TotalConnectorCount == 1)
  1198. {
  1199. PRINTF_FUNC("GBT clean error : index = %d, EvConnAlarmCode = %s, code = %s \n", index, _chargingData[index]->EvConnAlarmCode, code);
  1200. if (strncmp((char *)_chargingData[index]->EvConnAlarmCode, code, 6) != EQUAL)
  1201. {
  1202. if (strncmp(code, "023702", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.GbEvCommFail = NO;
  1203. if (strncmp(code, "023900", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_LOS_CC1 = NO;
  1204. if (strncmp(code, "023901", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CONNECTOR_LOCK_FAIL = NO;
  1205. if (strncmp(code, "023902", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BATTERY_INCOMPATIBLE = NO;
  1206. if (strncmp(code, "023903", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_BROAA_TIMEOUT = NO;
  1207. if (strncmp(code, "023904", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CSU_PRECHARGE_TIMEOUT = NO;
  1208. if (strncmp(code, "023905", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_PRESENT_VOLTAGE_FAULT = NO;
  1209. if (strncmp(code, "023906", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_VOLTAGE_OVER_RANGE = NO;
  1210. if (strncmp(code, "023907", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BSM_CHARGE_ALLOW_00_10MIN_COUUNTDONE = NO;
  1211. if (strncmp(code, "023908", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_WAIT_GROUNDFAULT_TIMEOUT = NO;
  1212. if (strncmp(code, "023909", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ADC_MORE_THAN_10V = NO;
  1213. if (strncmp(code, "023910", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ADC_MORE_THAN_60V = NO;
  1214. if (strncmp(code, "023911", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CHARGER_GET_NORMAL_STOP_CMD = NO;
  1215. if (strncmp(code, "023912", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CHARGER_GET_EMERGENCY_STOP_CMD = NO;
  1216. if (strncmp(code, "023913", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ISOLATION_RESULT_FAIL = NO;
  1217. if (strncmp(code, "023914", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_MOTHER_BOARD_MISS_LINK = NO;
  1218. if (strncmp(code, "023915", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_LIMIT = NO;
  1219. if (strncmp(code, "023916", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_REQ_CURRENT_MORE_THAN_LIMIT = NO;
  1220. if (strncmp(code, "023917", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_10_PERCENT = NO;
  1221. if (strncmp(code, "023918", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_DIFF_BCS_5_PERCENT = NO;
  1222. if (strncmp(code, "023919", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_STOP_ADC_MORE_THAN_10V = NO;
  1223. if (strncmp(code, "023930", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BHM_TIMEOUT = NO;
  1224. if (strncmp(code, "023931", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BRM_TIMEOUT = NO;
  1225. if (strncmp(code, "023932", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCP_TIMEOUT = NO;
  1226. if (strncmp(code, "023933", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BRO_TIMEOUT = NO;
  1227. if (strncmp(code, "023934", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCL_TIMEOUT = NO;
  1228. if (strncmp(code, "023935", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCS_TIMEOUT = NO;
  1229. if (strncmp(code, "023936", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BSM_TIMEOUT = NO;
  1230. if (strncmp(code, "023937", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BST_TIMEOUT = NO;
  1231. if (strncmp(code, "023938", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BSD_TIMEOUT = NO;
  1232. if (strncmp(code, "023939", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BEM_OTHER_TIMEOUT = NO;
  1233. if (strncmp(code, "023940", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRM_TIMEOUT = NO;
  1234. if (strncmp(code, "023941", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRMAA_TIMEOUT = NO;
  1235. if (strncmp(code, "023942", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CTS_CML_TIMEOUT = NO;
  1236. if (strncmp(code, "023943", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRO_TIMEOUT = NO;
  1237. if (strncmp(code, "023944", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CCS_TIMEOUT = NO;
  1238. if (strncmp(code, "023945", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CST_TIMEOUT = NO;
  1239. if (strncmp(code, "023946", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CSD_TIMEOUT = NO;
  1240. if (strncmp(code, "023947", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_BEM_OTHER_TIMEOUT = NO;
  1241. if (strncmp(code, "023950", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_SOC_GOAL = NO;
  1242. if (strncmp(code, "023951", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_TOTAL_VOLTAGE_GOAL = NO;
  1243. if (strncmp(code, "023952", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CELL_VOLTAGE_GOAL = NO;
  1244. if (strncmp(code, "023953", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_GET_CST = NO;
  1245. if (strncmp(code, "023954", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_ISOLATION = NO;
  1246. if (strncmp(code, "023955", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OUTPUT_CONNECTOR_OTP = NO;
  1247. if (strncmp(code, "023956", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_COMPONENT = NO;
  1248. if (strncmp(code, "023957", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CHARGE_CONNECTOR = NO;
  1249. if (strncmp(code, "023958", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OTP = NO;
  1250. if (strncmp(code, "023959", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OTHER = NO;
  1251. if (strncmp(code, "023960", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_HIGH_V = NO;
  1252. if (strncmp(code, "023961", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CC2 = NO;
  1253. if (strncmp(code, "023962", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CURRENT = NO;
  1254. if (strncmp(code, "023963", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_VOLTAGE = NO;
  1255. if (strncmp(code, "023964", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GET_BST_NO_REASON = NO;
  1256. if (strncmp(code, "023970", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CELL_OVER_VOLTAGE = NO;
  1257. if (strncmp(code, "023971", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CELL_UNDER_VOLTAGE = NO;
  1258. if (strncmp(code, "023972", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_OVER_SOC = NO;
  1259. if (strncmp(code, "023973", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_UNDER_SOC = NO;
  1260. if (strncmp(code, "023974", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CURRENT = NO;
  1261. if (strncmp(code, "023975", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_TEMPERATURE = NO;
  1262. if (strncmp(code, "023976", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_ISOLATE = NO;
  1263. if (strncmp(code, "023977", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_OUTPUT_CONNECTOR = NO;
  1264. }
  1265. }
  1266. }
  1267. }
  1268. }
  1269. void ClearAbnormalStatus_CCS(byte gun_index)
  1270. {
  1271. bool isCleanCheck = false;
  1272. char code[7];
  1273. if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "", 6) == EQUAL)
  1274. return;
  1275. if (true)
  1276. {
  1277. if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023701", 6) == EQUAL &&
  1278. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail == YES)
  1279. {
  1280. memcpy(code, "023701", 6);
  1281. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1282. isCleanCheck = true;
  1283. }
  1284. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023737", 6) == EQUAL &&
  1285. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsRESTemperatureInhibit == YES)
  1286. {
  1287. memcpy(code, "023737", 6);
  1288. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1289. isCleanCheck = true;
  1290. }
  1291. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023738", 6) == EQUAL &&
  1292. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVShiftPosition == YES)
  1293. {
  1294. memcpy(code, "023738", 6);
  1295. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1296. isCleanCheck = true;
  1297. }
  1298. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023739", 6) == EQUAL &&
  1299. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargerConnectorLockFault == YES)
  1300. {
  1301. memcpy(code, "023739", 6);
  1302. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1303. isCleanCheck = true;
  1304. }
  1305. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023740", 6) == EQUAL &&
  1306. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVRESSMalfunction == YES)
  1307. {
  1308. memcpy(code, "023740", 6);
  1309. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1310. isCleanCheck = true;
  1311. }
  1312. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023741", 6) == EQUAL &&
  1313. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingCurrentdifferential == YES)
  1314. {
  1315. memcpy(code, "023741", 6);
  1316. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1317. isCleanCheck = true;
  1318. }
  1319. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023742", 6) == EQUAL &&
  1320. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingVoltageOutOfRange == YES)
  1321. {
  1322. memcpy(code, "023742", 6);
  1323. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1324. isCleanCheck = true;
  1325. }
  1326. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023743", 6) == EQUAL &&
  1327. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingSystemIncompatibility == YES)
  1328. {
  1329. memcpy(code, "023743", 6);
  1330. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1331. isCleanCheck = true;
  1332. }
  1333. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023744", 6) == EQUAL &&
  1334. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEmergencyEvent == YES)
  1335. {
  1336. memcpy(code, "023744", 6);
  1337. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1338. isCleanCheck = true;
  1339. }
  1340. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023745", 6) == EQUAL &&
  1341. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsBreaker == YES)
  1342. {
  1343. memcpy(code, "023745", 6);
  1344. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1345. isCleanCheck = true;
  1346. }
  1347. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023746", 6) == EQUAL &&
  1348. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoData == YES)
  1349. {
  1350. memcpy(code, "023746", 6);
  1351. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1352. isCleanCheck = true;
  1353. }
  1354. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023747", 6) == EQUAL &&
  1355. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_A == YES)
  1356. {
  1357. memcpy(code, "023747", 6);
  1358. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1359. isCleanCheck = true;
  1360. }
  1361. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023748", 6) == EQUAL &&
  1362. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_B == YES)
  1363. {
  1364. memcpy(code, "023748", 6);
  1365. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1366. isCleanCheck = true;
  1367. }
  1368. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023749", 6) == EQUAL &&
  1369. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_C == YES)
  1370. {
  1371. memcpy(code, "023749", 6);
  1372. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1373. isCleanCheck = true;
  1374. }
  1375. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023750", 6) == EQUAL &&
  1376. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_1 == YES)
  1377. {
  1378. memcpy(code, "023750", 6);
  1379. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1380. isCleanCheck = true;
  1381. }
  1382. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023751", 6) == EQUAL &&
  1383. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_2 == YES)
  1384. {
  1385. memcpy(code, "023751", 6);
  1386. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1387. isCleanCheck = true;
  1388. }
  1389. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023752", 6) == EQUAL &&
  1390. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_3 == YES)
  1391. {
  1392. memcpy(code, "023752", 6);
  1393. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1394. isCleanCheck = true;
  1395. }
  1396. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023753", 6) == EQUAL &&
  1397. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_1 == YES)
  1398. {
  1399. memcpy(code, "023753", 6);
  1400. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1401. isCleanCheck = true;
  1402. }
  1403. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023754", 6) == EQUAL &&
  1404. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_2 == YES)
  1405. {
  1406. memcpy(code, "023754", 6);
  1407. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1408. isCleanCheck = true;
  1409. }
  1410. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023755", 6) == EQUAL &&
  1411. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_3 == YES)
  1412. {
  1413. memcpy(code, "023755", 6);
  1414. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1415. isCleanCheck = true;
  1416. }
  1417. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023756", 6) == EQUAL &&
  1418. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_4 == YES)
  1419. {
  1420. memcpy(code, "023756", 6);
  1421. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1422. isCleanCheck = true;
  1423. }
  1424. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023757", 6) == EQUAL &&
  1425. ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_5 == YES)
  1426. {
  1427. memcpy(code, "023757", 6);
  1428. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1429. isCleanCheck = true;
  1430. }
  1431. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023758", 6) == EQUAL &&
  1432. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequenceError == YES)
  1433. {
  1434. memcpy(code, "023758", 6);
  1435. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1436. isCleanCheck = true;
  1437. }
  1438. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023759", 6) == EQUAL &&
  1439. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSignatureError == YES)
  1440. {
  1441. memcpy(code, "023759", 6);
  1442. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1443. isCleanCheck = true;
  1444. }
  1445. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023760", 6) == EQUAL &&
  1446. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUnknownSession == YES)
  1447. {
  1448. memcpy(code, "023760", 6);
  1449. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1450. isCleanCheck = true;
  1451. }
  1452. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023761", 6) == EQUAL &&
  1453. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceIDInvalid == YES)
  1454. {
  1455. memcpy(code, "023761", 6);
  1456. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1457. isCleanCheck = true;
  1458. }
  1459. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023762", 6) == EQUAL &&
  1460. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPaymentSelectionInvalid == YES)
  1461. {
  1462. memcpy(code, "023762", 6);
  1463. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1464. isCleanCheck = true;
  1465. }
  1466. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023763", 6) == EQUAL &&
  1467. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsIdentificationSelectionInvalid == YES)
  1468. {
  1469. memcpy(code, "023763", 6);
  1470. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1471. isCleanCheck = true;
  1472. }
  1473. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023764", 6) == EQUAL &&
  1474. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceSelectionInvalid == YES)
  1475. {
  1476. memcpy(code, "023764", 6);
  1477. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1478. isCleanCheck = true;
  1479. }
  1480. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023765", 6) == EQUAL &&
  1481. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateExpired == YES)
  1482. {
  1483. memcpy(code, "023765", 6);
  1484. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1485. isCleanCheck = true;
  1486. }
  1487. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023766", 6) == EQUAL &&
  1488. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotYetValid == YES)
  1489. {
  1490. memcpy(code, "023766", 6);
  1491. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1492. isCleanCheck = true;
  1493. }
  1494. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023767", 6) == EQUAL &&
  1495. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateRevoked == YES)
  1496. {
  1497. memcpy(code, "023767", 6);
  1498. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1499. isCleanCheck = true;
  1500. }
  1501. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023768", 6) == EQUAL &&
  1502. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoCertificateAvailable == YES)
  1503. {
  1504. memcpy(code, "023768", 6);
  1505. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1506. isCleanCheck = true;
  1507. }
  1508. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023769", 6) == EQUAL &&
  1509. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertChainError == YES)
  1510. {
  1511. memcpy(code, "023769", 6);
  1512. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1513. isCleanCheck = true;
  1514. }
  1515. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023770", 6) == EQUAL &&
  1516. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertValidationError == YES)
  1517. {
  1518. memcpy(code, "023770", 6);
  1519. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1520. isCleanCheck = true;
  1521. }
  1522. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023771", 6) == EQUAL &&
  1523. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertVerificationError == YES)
  1524. {
  1525. memcpy(code, "023771", 6);
  1526. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1527. isCleanCheck = true;
  1528. }
  1529. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023772", 6) == EQUAL &&
  1530. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractCanceled == YES)
  1531. {
  1532. memcpy(code, "023772", 6);
  1533. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1534. isCleanCheck = true;
  1535. }
  1536. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023773", 6) == EQUAL &&
  1537. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChallengeInvalid == YES)
  1538. {
  1539. memcpy(code, "023773", 6);
  1540. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1541. isCleanCheck = true;
  1542. }
  1543. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023774", 6) == EQUAL &&
  1544. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongEnergyTransferMode == YES)
  1545. {
  1546. memcpy(code, "023774", 6);
  1547. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1548. isCleanCheck = true;
  1549. }
  1550. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023775", 6) == EQUAL &&
  1551. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongChargeParameter == YES)
  1552. {
  1553. memcpy(code, "023775", 6);
  1554. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1555. isCleanCheck = true;
  1556. }
  1557. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023776", 6) == EQUAL &&
  1558. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingProfileInvalid == YES)
  1559. {
  1560. memcpy(code, "023776", 6);
  1561. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1562. isCleanCheck = true;
  1563. }
  1564. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023777", 6) == EQUAL &&
  1565. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTariffSelectionInvalid == YES)
  1566. {
  1567. memcpy(code, "023777", 6);
  1568. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1569. isCleanCheck = true;
  1570. }
  1571. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023778", 6) == EQUAL &&
  1572. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEPresentVoltageToLow == YES)
  1573. {
  1574. memcpy(code, "023778", 6);
  1575. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1576. isCleanCheck = true;
  1577. }
  1578. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023779", 6) == EQUAL &&
  1579. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryNotApplied == YES)
  1580. {
  1581. memcpy(code, "023779", 6);
  1582. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1583. isCleanCheck = true;
  1584. }
  1585. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023780", 6) == EQUAL &&
  1586. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMeteringSignatureNotValid == YES)
  1587. {
  1588. memcpy(code, "023780", 6);
  1589. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1590. isCleanCheck = true;
  1591. }
  1592. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023781", 6) == EQUAL &&
  1593. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoChargeServiceSelected == YES)
  1594. {
  1595. memcpy(code, "023781", 6);
  1596. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1597. isCleanCheck = true;
  1598. }
  1599. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023782", 6) == EQUAL &&
  1600. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContactorError == YES)
  1601. {
  1602. memcpy(code, "023782", 6);
  1603. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1604. isCleanCheck = true;
  1605. }
  1606. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023783", 6) == EQUAL &&
  1607. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotAllowedAtThisEVSE == YES)
  1608. {
  1609. memcpy(code, "023783", 6);
  1610. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1611. isCleanCheck = true;
  1612. }
  1613. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023784", 6) == EQUAL &&
  1614. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsGAChargeStop == YES)
  1615. {
  1616. memcpy(code, "023784", 6);
  1617. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1618. isCleanCheck = true;
  1619. }
  1620. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023785", 6) == EQUAL &&
  1621. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAlignmentError == YES)
  1622. {
  1623. memcpy(code, "023785", 6);
  1624. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1625. isCleanCheck = true;
  1626. }
  1627. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023786", 6) == EQUAL &&
  1628. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsACDError == YES)
  1629. {
  1630. memcpy(code, "023786", 6);
  1631. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1632. isCleanCheck = true;
  1633. }
  1634. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023787", 6) == EQUAL &&
  1635. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAssociationError == YES)
  1636. {
  1637. memcpy(code, "023787", 6);
  1638. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1639. isCleanCheck = true;
  1640. }
  1641. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023788", 6) == EQUAL &&
  1642. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEChargeAbort == YES)
  1643. {
  1644. memcpy(code, "023788", 6);
  1645. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1646. isCleanCheck = true;
  1647. }
  1648. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023789", 6) == EQUAL &&
  1649. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoSupportedAppProtocol == YES)
  1650. {
  1651. memcpy(code, "023789", 6);
  1652. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1653. isCleanCheck = true;
  1654. }
  1655. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023790", 6) == EQUAL &&
  1656. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractNotAccepted == YES)
  1657. {
  1658. memcpy(code, "023790", 6);
  1659. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1660. isCleanCheck = true;
  1661. }
  1662. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023791", 6) == EQUAL &&
  1663. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMOUnknown == YES)
  1664. {
  1665. memcpy(code, "023791", 6);
  1666. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1667. isCleanCheck = true;
  1668. }
  1669. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023792", 6) == EQUAL &&
  1670. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_Prov_CertificateRevoke == YES)
  1671. {
  1672. memcpy(code, "023792", 6);
  1673. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1674. isCleanCheck = true;
  1675. }
  1676. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023793", 6) == EQUAL &&
  1677. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA1_CertificateRevoked == YES)
  1678. {
  1679. memcpy(code, "023793", 6);
  1680. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1681. isCleanCheck = true;
  1682. }
  1683. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023794", 6) == EQUAL &&
  1684. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA2_CertificateRevoked == YES)
  1685. {
  1686. memcpy(code, "023794", 6);
  1687. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1688. isCleanCheck = true;
  1689. }
  1690. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023795", 6) == EQUAL &&
  1691. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_RootCA_CertificateRevoked == YES)
  1692. {
  1693. memcpy(code, "023795", 6);
  1694. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1695. isCleanCheck = true;
  1696. }
  1697. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023796", 6) == EQUAL &&
  1698. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_Prov_CertificateRevoked == YES)
  1699. {
  1700. memcpy(code, "023796", 6);
  1701. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1702. isCleanCheck = true;
  1703. }
  1704. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023797", 6) == EQUAL &&
  1705. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA1_CertificateRevoked == YES)
  1706. {
  1707. memcpy(code, "023797", 6);
  1708. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1709. isCleanCheck = true;
  1710. }
  1711. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023798", 6) == EQUAL &&
  1712. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA2_CertificateRevoked == YES)
  1713. {
  1714. memcpy(code, "023798", 6);
  1715. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1716. isCleanCheck = true;
  1717. }
  1718. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023799", 6) == EQUAL &&
  1719. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_RootCA_CertificateRevoked == YES)
  1720. {
  1721. memcpy(code, "023799", 6);
  1722. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1723. isCleanCheck = true;
  1724. }
  1725. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023800", 6) == EQUAL &&
  1726. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_Prov_CertificateRevoked == YES)
  1727. {
  1728. memcpy(code, "023800", 6);
  1729. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1730. isCleanCheck = true;
  1731. }
  1732. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023801", 6) == EQUAL &&
  1733. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA1_CertificateRevoked == YES)
  1734. {
  1735. memcpy(code, "023801", 6);
  1736. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1737. isCleanCheck = true;
  1738. }
  1739. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023802", 6) == EQUAL &&
  1740. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA2_CertificateRevoked == YES)
  1741. {
  1742. memcpy(code, "023802", 6);
  1743. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1744. isCleanCheck = true;
  1745. }
  1746. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023803", 6) == EQUAL &&
  1747. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_RootCA_CertificateRevoked == YES)
  1748. {
  1749. memcpy(code, "023803", 6);
  1750. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1751. isCleanCheck = true;
  1752. }
  1753. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023809", 6) == EQUAL &&
  1754. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_SLAC_init == YES)
  1755. {
  1756. memcpy(code, "023809", 6);
  1757. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1758. isCleanCheck = true;
  1759. }
  1760. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023810", 6) == EQUAL &&
  1761. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_match_response == YES)
  1762. {
  1763. memcpy(code, "023810", 6);
  1764. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1765. isCleanCheck = true;
  1766. }
  1767. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023811", 6) == EQUAL &&
  1768. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_sequence == YES)
  1769. {
  1770. memcpy(code, "023811", 6);
  1771. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1772. isCleanCheck = true;
  1773. }
  1774. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023812", 6) == EQUAL &&
  1775. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_match_MNBC == YES)
  1776. {
  1777. memcpy(code, "023812", 6);
  1778. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1779. isCleanCheck = true;
  1780. }
  1781. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023813", 6) == EQUAL &&
  1782. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_avg_atten_calc == YES)
  1783. {
  1784. memcpy(code, "023813", 6);
  1785. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1786. isCleanCheck = true;
  1787. }
  1788. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023814", 6) == EQUAL &&
  1789. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_response == YES)
  1790. {
  1791. memcpy(code, "023814", 6);
  1792. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1793. isCleanCheck = true;
  1794. }
  1795. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023815", 6) == EQUAL &&
  1796. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_match_session == YES)
  1797. {
  1798. memcpy(code, "023815", 6);
  1799. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1800. isCleanCheck = true;
  1801. }
  1802. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023816", 6) == EQUAL &&
  1803. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_assoc_session == YES)
  1804. {
  1805. memcpy(code, "023816", 6);
  1806. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1807. isCleanCheck = true;
  1808. }
  1809. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023817", 6) == EQUAL &&
  1810. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_vald_toggle == YES)
  1811. {
  1812. memcpy(code, "023817", 6);
  1813. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1814. isCleanCheck = true;
  1815. }
  1816. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023818", 6) == EQUAL &&
  1817. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccSlacTimeoutCmMnbcSound == YES)
  1818. {
  1819. memcpy(code, "023818", 6);
  1820. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1821. isCleanCheck = true;
  1822. }
  1823. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023819", 6) == EQUAL &&
  1824. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccSlacTimeoutCmValidateReq == YES)
  1825. {
  1826. memcpy(code, "023819", 6);
  1827. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1828. isCleanCheck = true;
  1829. }
  1830. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023823", 6) == EQUAL &&
  1831. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUDP_TT_match_join == YES)
  1832. {
  1833. memcpy(code, "023823", 6);
  1834. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1835. isCleanCheck = true;
  1836. }
  1837. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023824", 6) == EQUAL &&
  1838. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTCP_TT_match_join == YES)
  1839. {
  1840. memcpy(code, "023824", 6);
  1841. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1842. isCleanCheck = true;
  1843. }
  1844. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023825", 6) == EQUAL &&
  1845. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_amp_map_exchange == YES)
  1846. {
  1847. memcpy(code, "023825", 6);
  1848. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1849. isCleanCheck = true;
  1850. }
  1851. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023826", 6) == EQUAL &&
  1852. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_link_ready_notification == YES)
  1853. {
  1854. memcpy(code, "023826", 6);
  1855. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1856. isCleanCheck = true;
  1857. }
  1858. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023832", 6) == EQUAL &&
  1859. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSupportedAppProtocolRes == YES)
  1860. {
  1861. memcpy(code, "023832", 6);
  1862. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1863. isCleanCheck = true;
  1864. }
  1865. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023833", 6) == EQUAL &&
  1866. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionSetupRes == YES)
  1867. {
  1868. memcpy(code, "023833", 6);
  1869. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1870. isCleanCheck = true;
  1871. }
  1872. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023834", 6) == EQUAL &&
  1873. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceDiscoveryRes == YES)
  1874. {
  1875. memcpy(code, "023834", 6);
  1876. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1877. isCleanCheck = true;
  1878. }
  1879. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023835", 6) == EQUAL &&
  1880. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServicePaymentSelectionRes == YES)
  1881. {
  1882. memcpy(code, "023835", 6);
  1883. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1884. isCleanCheck = true;
  1885. }
  1886. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023836", 6) == EQUAL &&
  1887. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractAuthenticationRes == YES)
  1888. {
  1889. memcpy(code, "023836", 6);
  1890. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1891. isCleanCheck = true;
  1892. }
  1893. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023837", 6) == EQUAL &&
  1894. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargeParameterDiscoveryRes == YES)
  1895. {
  1896. memcpy(code, "023837", 6);
  1897. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1898. isCleanCheck = true;
  1899. }
  1900. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023838", 6) == EQUAL &&
  1901. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryRes == YES)
  1902. {
  1903. memcpy(code, "023838", 6);
  1904. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1905. isCleanCheck = true;
  1906. }
  1907. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023839", 6) == EQUAL &&
  1908. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheckRes == YES)
  1909. {
  1910. memcpy(code, "023839", 6);
  1911. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1912. isCleanCheck = true;
  1913. }
  1914. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023840", 6) == EQUAL &&
  1915. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPreChargeRes == YES)
  1916. {
  1917. memcpy(code, "023840", 6);
  1918. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1919. isCleanCheck = true;
  1920. }
  1921. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023841", 6) == EQUAL &&
  1922. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCurrentDemandRes == YES)
  1923. {
  1924. memcpy(code, "023841", 6);
  1925. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1926. isCleanCheck = true;
  1927. }
  1928. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023842", 6) == EQUAL &&
  1929. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWeldingDetectionRes == YES)
  1930. {
  1931. memcpy(code, "023842", 6);
  1932. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1933. isCleanCheck = true;
  1934. }
  1935. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023843", 6) == EQUAL &&
  1936. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionStopRes == YES)
  1937. {
  1938. memcpy(code, "023843", 6);
  1939. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1940. isCleanCheck = true;
  1941. }
  1942. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023844", 6) == EQUAL &&
  1943. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequence_Time == YES)
  1944. {
  1945. memcpy(code, "023844", 6);
  1946. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1947. isCleanCheck = true;
  1948. }
  1949. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023845", 6) == EQUAL &&
  1950. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsReadyToCharge_Performance_Time == YES)
  1951. {
  1952. memcpy(code, "023845", 6);
  1953. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1954. isCleanCheck = true;
  1955. }
  1956. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023846", 6) == EQUAL &&
  1957. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCommunicationSetup_Performance_Time == YES)
  1958. {
  1959. memcpy(code, "023846", 6);
  1960. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1961. isCleanCheck = true;
  1962. }
  1963. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023847", 6) == EQUAL &&
  1964. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheck_Performance_Time == YES)
  1965. {
  1966. memcpy(code, "023847", 6);
  1967. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1968. isCleanCheck = true;
  1969. }
  1970. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023848", 6) == EQUAL &&
  1971. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPState_Detection_Time == YES)
  1972. {
  1973. memcpy(code, "023848", 6);
  1974. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1975. isCleanCheck = true;
  1976. }
  1977. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023849", 6) == EQUAL &&
  1978. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPOscillator_Retain_Time == YES)
  1979. {
  1980. memcpy(code, "023849", 6);
  1981. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1982. isCleanCheck = true;
  1983. }
  1984. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023850", 6) == EQUAL &&
  1985. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccTimeoutV2GPreChargePerformaceTime == YES)
  1986. {
  1987. memcpy(code, "023850", 6);
  1988. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1989. isCleanCheck = true;
  1990. }
  1991. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023855", 6) == EQUAL &&
  1992. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_TARGET_INFO == YES)
  1993. {
  1994. memcpy(code, "023855", 6);
  1995. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  1996. isCleanCheck = true;
  1997. }
  1998. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023856", 6) == EQUAL &&
  1999. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_TARGET_INFO == YES)
  2000. {
  2001. memcpy(code, "023856", 6);
  2002. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2003. isCleanCheck = true;
  2004. }
  2005. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023857", 6) == EQUAL &&
  2006. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_BATTERY_INFO == YES)
  2007. {
  2008. memcpy(code, "023857", 6);
  2009. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2010. isCleanCheck = true;
  2011. }
  2012. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023858", 6) == EQUAL &&
  2013. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_BATTERY_INFO == YES)
  2014. {
  2015. memcpy(code, "023858", 6);
  2016. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2017. isCleanCheck = true;
  2018. }
  2019. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023859", 6) == EQUAL &&
  2020. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EV_STOP_EVENT == YES)
  2021. {
  2022. memcpy(code, "023859", 6);
  2023. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2024. isCleanCheck = true;
  2025. }
  2026. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023860", 6) == EQUAL &&
  2027. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EV_STOP_EVENT == YES)
  2028. {
  2029. memcpy(code, "023860", 6);
  2030. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2031. isCleanCheck = true;
  2032. }
  2033. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023861", 6) == EQUAL &&
  2034. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_STOP_EVENT == YES)
  2035. {
  2036. memcpy(code, "023861", 6);
  2037. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2038. isCleanCheck = true;
  2039. }
  2040. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023862", 6) == EQUAL &&
  2041. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_STOP_EVENT == YES)
  2042. {
  2043. memcpy(code, "023862", 6);
  2044. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2045. isCleanCheck = true;
  2046. }
  2047. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023863", 6) == EQUAL &&
  2048. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_MISC_INFO == YES)
  2049. {
  2050. memcpy(code, "023863", 6);
  2051. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2052. isCleanCheck = true;
  2053. }
  2054. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023864", 6) == EQUAL &&
  2055. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_MISC_INFO == YES)
  2056. {
  2057. memcpy(code, "023864", 6);
  2058. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2059. isCleanCheck = true;
  2060. }
  2061. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023865", 6) == EQUAL &&
  2062. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_REQUEST == YES)
  2063. {
  2064. memcpy(code, "023865", 6);
  2065. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2066. isCleanCheck = true;
  2067. }
  2068. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023866", 6) == EQUAL &&
  2069. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_REQUEST == YES)
  2070. {
  2071. memcpy(code, "023866", 6);
  2072. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2073. isCleanCheck = true;
  2074. }
  2075. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023867", 6) == EQUAL &&
  2076. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_START_BLOCK_TRANSFER == YES)
  2077. {
  2078. memcpy(code, "023867", 6);
  2079. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2080. isCleanCheck = true;
  2081. }
  2082. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023868", 6) == EQUAL &&
  2083. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_START_BLOCK_TRANSFER == YES)
  2084. {
  2085. memcpy(code, "023868", 6);
  2086. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2087. isCleanCheck = true;
  2088. }
  2089. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023869", 6) == EQUAL &&
  2090. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DATA_TRANSFER == YES)
  2091. {
  2092. memcpy(code, "023869", 6);
  2093. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2094. isCleanCheck = true;
  2095. }
  2096. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023870", 6) == EQUAL &&
  2097. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DATA_TRANSFER == YES)
  2098. {
  2099. memcpy(code, "023870", 6);
  2100. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2101. isCleanCheck = true;
  2102. }
  2103. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023871", 6) == EQUAL &&
  2104. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_FINISH == YES)
  2105. {
  2106. memcpy(code, "023871", 6);
  2107. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2108. isCleanCheck = true;
  2109. }
  2110. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023872", 6) == EQUAL &&
  2111. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_FINISH == YES)
  2112. {
  2113. memcpy(code, "023872", 6);
  2114. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2115. isCleanCheck = true;
  2116. }
  2117. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023873", 6) == EQUAL &&
  2118. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_ISOLATION_STATUS == YES)
  2119. {
  2120. memcpy(code, "023873", 6);
  2121. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2122. isCleanCheck = true;
  2123. }
  2124. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023874", 6) == EQUAL &&
  2125. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_ISOLATION_STATUS == YES)
  2126. {
  2127. memcpy(code, "023874", 6);
  2128. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2129. isCleanCheck = true;
  2130. }
  2131. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023875", 6) == EQUAL &&
  2132. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_CONNECTOR_INFO == YES)
  2133. {
  2134. memcpy(code, "023875", 6);
  2135. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2136. isCleanCheck = true;
  2137. }
  2138. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023876", 6) == EQUAL &&
  2139. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_CONNECTOR_INFO == YES)
  2140. {
  2141. memcpy(code, "023876", 6);
  2142. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2143. isCleanCheck = true;
  2144. }
  2145. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023877", 6) == EQUAL &&
  2146. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_RTC_INFO == YES)
  2147. {
  2148. memcpy(code, "023877", 6);
  2149. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2150. isCleanCheck = true;
  2151. }
  2152. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023878", 6) == EQUAL &&
  2153. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_RTC_INFO == YES)
  2154. {
  2155. memcpy(code, "023878", 6);
  2156. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2157. isCleanCheck = true;
  2158. }
  2159. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023879", 6) == EQUAL &&
  2160. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_PRECHARGE_INFO == YES)
  2161. {
  2162. memcpy(code, "023879", 6);
  2163. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2164. isCleanCheck = true;
  2165. }
  2166. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023880", 6) == EQUAL &&
  2167. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_PRECHARGE_INFO == YES)
  2168. {
  2169. memcpy(code, "023880", 6);
  2170. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2171. isCleanCheck = true;
  2172. }
  2173. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023881", 6) == EQUAL &&
  2174. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMSG_Sequence == YES)
  2175. {
  2176. memcpy(code, "023881", 6);
  2177. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2178. isCleanCheck = true;
  2179. }
  2180. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023882", 6) == EQUAL &&
  2181. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCAN_MSG_Unrecognized_CMD_ID == YES)
  2182. {
  2183. memcpy(code, "023882", 6);
  2184. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2185. isCleanCheck = true;
  2186. }
  2187. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023883", 6) == EQUAL &&
  2188. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Decode_Error == YES)
  2189. {
  2190. memcpy(code, "023883", 6);
  2191. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2192. isCleanCheck = true;
  2193. }
  2194. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023884", 6) == EQUAL &&
  2195. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Encode_Error == YES)
  2196. {
  2197. memcpy(code, "023884", 6);
  2198. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2199. isCleanCheck = true;
  2200. }
  2201. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023885", 6) == EQUAL &&
  2202. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Decode_Error == YES)
  2203. {
  2204. memcpy(code, "023885", 6);
  2205. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2206. isCleanCheck = true;
  2207. }
  2208. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023886", 6) == EQUAL &&
  2209. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Encode_Error == YES)
  2210. {
  2211. memcpy(code, "023886", 6);
  2212. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2213. isCleanCheck = true;
  2214. }
  2215. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023887", 6) == EQUAL &&
  2216. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Decode_Error == YES)
  2217. {
  2218. memcpy(code, "023887", 6);
  2219. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2220. isCleanCheck = true;
  2221. }
  2222. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023888", 6) == EQUAL &&
  2223. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Encode_Error == YES)
  2224. {
  2225. memcpy(code, "023888", 6);
  2226. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2227. isCleanCheck = true;
  2228. }
  2229. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023889", 6) == EQUAL &&
  2230. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCpStatus_Error == YES)
  2231. {
  2232. memcpy(code, "023889", 6);
  2233. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2234. isCleanCheck = true;
  2235. }
  2236. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023890", 6) == EQUAL &&
  2237. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUnexpectVolBeforeCharing_Error == YES)
  2238. {
  2239. memcpy(code, "023890", 6);
  2240. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2241. isCleanCheck = true;
  2242. }
  2243. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023891", 6) == EQUAL &&
  2244. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccNotReadyForCharging == YES)
  2245. {
  2246. memcpy(code, "023891", 6);
  2247. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2248. isCleanCheck = true;
  2249. }
  2250. // else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023892", 6) == EQUAL &&
  2251. // ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccTimeoutQCA7000Comm == YES)
  2252. // {
  2253. // memcpy(code, "023892", 6);
  2254. // memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2255. // isCleanCheck = true;
  2256. // }
  2257. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023893", 6) == EQUAL &&
  2258. ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccFailForQCA7000SetKey == YES)
  2259. {
  2260. memcpy(code, "023893", 6);
  2261. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2262. isCleanCheck = true;
  2263. }
  2264. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023979", 6) == EQUAL &&
  2265. ShmStatusCodeData->InfoCode.InfoEvents.bits.EV_Full_Charging == YES)
  2266. {
  2267. memcpy(code, "023979", 6);
  2268. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2269. isCleanCheck = true;
  2270. }
  2271. else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023983", 6) == EQUAL &&
  2272. ShmStatusCodeData->InfoCode.InfoEvents.bits.Stop_by_EV_with_unknow_reason == YES)
  2273. {
  2274. memcpy(code, "023983", 6);
  2275. memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
  2276. isCleanCheck = true;
  2277. }
  2278. }
  2279. if (isCleanCheck)
  2280. {
  2281. for (byte index = 0; index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; index++)
  2282. {
  2283. if (index != gun_index || ShmSysConfigAndInfo->SysConfig.TotalConnectorCount == 1)
  2284. {
  2285. PRINTF_FUNC("CCS clean error : index = %d, EvConnAlarmCode = %s, code = %s \n", index, _chargingData[index]->EvConnAlarmCode, code);
  2286. if (strncmp((char *)_chargingData[index]->EvConnAlarmCode, code, 6) != EQUAL)
  2287. {
  2288. if (strncmp(code, "023701", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = NO;
  2289. if (strncmp(code, "023737", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsRESTemperatureInhibit = NO;
  2290. if (strncmp(code, "023738", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVShiftPosition = NO;
  2291. if (strncmp(code, "023739", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargerConnectorLockFault = NO;
  2292. if (strncmp(code, "023740", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVRESSMalfunction = NO;
  2293. if (strncmp(code, "023741", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingCurrentdifferential = NO;
  2294. if (strncmp(code, "023742", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingVoltageOutOfRange = NO;
  2295. if (strncmp(code, "023743", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingSystemIncompatibility = NO;
  2296. if (strncmp(code, "023744", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEmergencyEvent = NO;
  2297. if (strncmp(code, "023745", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsBreaker = NO;
  2298. if (strncmp(code, "023746", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoData = NO;
  2299. if (strncmp(code, "023747", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_A = NO;
  2300. if (strncmp(code, "023748", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_B = NO;
  2301. if (strncmp(code, "023749", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_C = NO;
  2302. if (strncmp(code, "023750", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_1 = NO;
  2303. if (strncmp(code, "023751", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_2 = NO;
  2304. if (strncmp(code, "023752", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_3 = NO;
  2305. if (strncmp(code, "023753", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_1 = NO;
  2306. if (strncmp(code, "023754", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_2 = NO;
  2307. if (strncmp(code, "023755", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_3 = NO;
  2308. if (strncmp(code, "023756", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_4 = NO;
  2309. if (strncmp(code, "023757", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_5 = NO;
  2310. if (strncmp(code, "023758", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequenceError = NO;
  2311. if (strncmp(code, "023759", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSignatureError = NO;
  2312. if (strncmp(code, "023760", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUnknownSession = NO;
  2313. if (strncmp(code, "023761", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceIDInvalid = NO;
  2314. if (strncmp(code, "023762", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPaymentSelectionInvalid = NO;
  2315. if (strncmp(code, "023763", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsIdentificationSelectionInvalid = NO;
  2316. if (strncmp(code, "023764", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceSelectionInvalid = NO;
  2317. if (strncmp(code, "023765", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateExpired = NO;
  2318. if (strncmp(code, "023766", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotYetValid = NO;
  2319. if (strncmp(code, "023767", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateRevoked = NO;
  2320. if (strncmp(code, "023768", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoCertificateAvailable = NO;
  2321. if (strncmp(code, "023769", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertChainError = NO;
  2322. if (strncmp(code, "023770", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertValidationError = NO;
  2323. if (strncmp(code, "023771", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertVerificationError = NO;
  2324. if (strncmp(code, "023772", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractCanceled = NO;
  2325. if (strncmp(code, "023773", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChallengeInvalid = NO;
  2326. if (strncmp(code, "023774", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongEnergyTransferMode = NO;
  2327. if (strncmp(code, "023775", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongChargeParameter = NO;
  2328. if (strncmp(code, "023776", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingProfileInvalid = NO;
  2329. if (strncmp(code, "023777", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTariffSelectionInvalid = NO;
  2330. if (strncmp(code, "023778", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEPresentVoltageToLow = NO;
  2331. if (strncmp(code, "023779", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryNotApplied = NO;
  2332. if (strncmp(code, "023780", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMeteringSignatureNotValid = NO;
  2333. if (strncmp(code, "023781", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoChargeServiceSelected = NO;
  2334. if (strncmp(code, "023782", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContactorError = NO;
  2335. if (strncmp(code, "023783", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotAllowedAtThisEVSE = NO;
  2336. if (strncmp(code, "023784", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsGAChargeStop = NO;
  2337. if (strncmp(code, "023785", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAlignmentError = NO;
  2338. if (strncmp(code, "023786", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsACDError = NO;
  2339. if (strncmp(code, "023787", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAssociationError = NO;
  2340. if (strncmp(code, "023788", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEChargeAbort = NO;
  2341. if (strncmp(code, "023789", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoSupportedAppProtocol = NO;
  2342. if (strncmp(code, "023790", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractNotAccepted = NO;
  2343. if (strncmp(code, "023791", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMOUnknown = NO;
  2344. if (strncmp(code, "023792", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_Prov_CertificateRevoke = NO;
  2345. if (strncmp(code, "023793", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA1_CertificateRevoked = NO;
  2346. if (strncmp(code, "023794", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA2_CertificateRevoked = NO;
  2347. if (strncmp(code, "023795", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_RootCA_CertificateRevoked = NO;
  2348. if (strncmp(code, "023796", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_Prov_CertificateRevoked = NO;
  2349. if (strncmp(code, "023797", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA1_CertificateRevoked = NO;
  2350. if (strncmp(code, "023798", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA2_CertificateRevoked = NO;
  2351. if (strncmp(code, "023799", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_RootCA_CertificateRevoked = NO;
  2352. if (strncmp(code, "023800", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_Prov_CertificateRevoked = NO;
  2353. if (strncmp(code, "023801", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA1_CertificateRevoked = NO;
  2354. if (strncmp(code, "023802", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA2_CertificateRevoked = NO;
  2355. if (strncmp(code, "023803", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_RootCA_CertificateRevoked = NO;
  2356. if (strncmp(code, "023809", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_SLAC_init = NO;
  2357. if (strncmp(code, "023810", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_match_response = NO;
  2358. if (strncmp(code, "023811", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_sequence = NO;
  2359. if (strncmp(code, "023812", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_match_MNBC = NO;
  2360. if (strncmp(code, "023813", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_avg_atten_calc = NO;
  2361. if (strncmp(code, "023814", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_response = NO;
  2362. if (strncmp(code, "023815", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_match_session = NO;
  2363. if (strncmp(code, "023816", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_assoc_session = NO;
  2364. if (strncmp(code, "023817", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_vald_toggle = NO;
  2365. if (strncmp(code, "023818", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccSlacTimeoutCmMnbcSound = NO;
  2366. if (strncmp(code, "023819", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccSlacTimeoutCmValidateReq = NO;
  2367. if (strncmp(code, "023823", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUDP_TT_match_join = NO;
  2368. if (strncmp(code, "023824", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTCP_TT_match_join = NO;
  2369. if (strncmp(code, "023825", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_amp_map_exchange = NO;
  2370. if (strncmp(code, "023826", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_link_ready_notification = NO;
  2371. if (strncmp(code, "023832", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSupportedAppProtocolRes = NO;
  2372. if (strncmp(code, "023833", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionSetupRes = NO;
  2373. if (strncmp(code, "023834", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceDiscoveryRes = NO;
  2374. if (strncmp(code, "023835", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServicePaymentSelectionRes = NO;
  2375. if (strncmp(code, "023836", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractAuthenticationRes = NO;
  2376. if (strncmp(code, "023837", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargeParameterDiscoveryRes = NO;
  2377. if (strncmp(code, "023838", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryRes = NO;
  2378. if (strncmp(code, "023839", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheckRes = NO;
  2379. if (strncmp(code, "023840", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPreChargeRes = NO;
  2380. if (strncmp(code, "023841", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCurrentDemandRes = NO;
  2381. if (strncmp(code, "023842", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWeldingDetectionRes = NO;
  2382. if (strncmp(code, "023843", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionStopRes = NO;
  2383. if (strncmp(code, "023844", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequence_Time = NO;
  2384. if (strncmp(code, "023845", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsReadyToCharge_Performance_Time = NO;
  2385. if (strncmp(code, "023846", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCommunicationSetup_Performance_Time = NO;
  2386. if (strncmp(code, "023847", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheck_Performance_Time = NO;
  2387. if (strncmp(code, "023848", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPState_Detection_Time = NO;
  2388. if (strncmp(code, "023849", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPOscillator_Retain_Time = NO;
  2389. if (strncmp(code, "023850", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccTimeoutV2GPreChargePerformaceTime = NO;
  2390. if (strncmp(code, "023855", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_TARGET_INFO = NO;
  2391. if (strncmp(code, "023856", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_TARGET_INFO = NO;
  2392. if (strncmp(code, "023857", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_BATTERY_INFO = NO;
  2393. if (strncmp(code, "023858", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_BATTERY_INFO = NO;
  2394. if (strncmp(code, "023859", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EV_STOP_EVENT = NO;
  2395. if (strncmp(code, "023860", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EV_STOP_EVENT = NO;
  2396. if (strncmp(code, "023861", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_STOP_EVENT = NO;
  2397. if (strncmp(code, "023862", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_STOP_EVENT = NO;
  2398. if (strncmp(code, "023863", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_MISC_INFO = NO;
  2399. if (strncmp(code, "023864", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_MISC_INFO = NO;
  2400. if (strncmp(code, "023865", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_REQUEST = NO;
  2401. if (strncmp(code, "023866", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_REQUEST = NO;
  2402. if (strncmp(code, "023867", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_START_BLOCK_TRANSFER = NO;
  2403. if (strncmp(code, "023868", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_START_BLOCK_TRANSFER = NO;
  2404. if (strncmp(code, "023869", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DATA_TRANSFER = NO;
  2405. if (strncmp(code, "023870", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DATA_TRANSFER = NO;
  2406. if (strncmp(code, "023871", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_FINISH = NO;
  2407. if (strncmp(code, "023872", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_FINISH = NO;
  2408. if (strncmp(code, "023873", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_ISOLATION_STATUS = NO;
  2409. if (strncmp(code, "023874", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_ISOLATION_STATUS = NO;
  2410. if (strncmp(code, "023875", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_CONNECTOR_INFO = NO;
  2411. if (strncmp(code, "023876", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_CONNECTOR_INFO = NO;
  2412. if (strncmp(code, "023877", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_RTC_INFO = NO;
  2413. if (strncmp(code, "023878", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_RTC_INFO = NO;
  2414. if (strncmp(code, "023879", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_PRECHARGE_INFO = NO;
  2415. if (strncmp(code, "023880", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_PRECHARGE_INFO = NO;
  2416. if (strncmp(code, "023881", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMSG_Sequence = NO;
  2417. if (strncmp(code, "023882", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCAN_MSG_Unrecognized_CMD_ID = NO;
  2418. if (strncmp(code, "023883", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Decode_Error = NO;
  2419. if (strncmp(code, "023884", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Encode_Error = NO;
  2420. if (strncmp(code, "023885", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Decode_Error = NO;
  2421. if (strncmp(code, "023886", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Encode_Error = NO;
  2422. if (strncmp(code, "023887", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Decode_Error = NO;
  2423. if (strncmp(code, "023888", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Encode_Error = NO;
  2424. if (strncmp(code, "023889", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCpStatus_Error = NO;
  2425. if (strncmp(code, "023890", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUnexpectVolBeforeCharing_Error = NO;
  2426. if (strncmp(code, "023891", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccNotReadyForCharging = NO;
  2427. //if (strncmp(code, "023892", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccTimeoutQCA7000Comm = NO;
  2428. if (strncmp(code, "023893", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccFailForQCA7000SetKey = NO;
  2429. if (strncmp(code, "023979", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.EV_Full_Charging = NO;
  2430. if (strncmp(code, "023983", 6) == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Stop_by_EV_with_unknow_reason = NO;
  2431. }
  2432. }
  2433. }
  2434. }
  2435. }
  2436. bool AbnormalStopAnalysis(byte gun_index, byte *errCode)
  2437. {
  2438. char string[7];
  2439. sprintf(string, "%d%d%d%d%d%d", *(errCode + 0), *(errCode + 1), *(errCode + 2), *(errCode + 3), *(errCode + 4), *(errCode + 5));
  2440. PRINTF_FUNC("NOTIFICATION_EV_STOP : Err Code = %s \n", string);
  2441. if (strncmp(string, "000000", 6) == EQUAL || strncmp(string, "012219", 6) == EQUAL)
  2442. return false;
  2443. if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "", 6) != EQUAL)
  2444. return true;
  2445. memcpy(_chargingData[gun_index]->EvConnAlarmCode, string, 6);
  2446. PRINTF_FUNC("NOTIFICATION_EV_STOP : EvConnAlarmCode = %s \n", _chargingData[gun_index]->EvConnAlarmCode);
  2447. if (strcmp(string, "023700") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvCommFail = YES;
  2448. if (strcmp(string, "023704") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryMalfun = YES;
  2449. if (strcmp(string, "023705") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoNoPermission = YES;
  2450. if (strcmp(string, "023706") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryIncompatibility = YES;
  2451. if (strcmp(string, "023707") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOVP = YES;
  2452. if (strcmp(string, "023708") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryUVP = YES;
  2453. if (strcmp(string, "023709") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOTP = YES;
  2454. if (strcmp(string, "023710") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryCurrentDiff = YES;
  2455. if (strcmp(string, "023711") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryVoltageDiff = YES;
  2456. if (strcmp(string, "023712") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoShiftPosition = YES;
  2457. if (strcmp(string, "023713") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryOtherFault = YES;
  2458. if (strcmp(string, "023714") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargingSystemError = YES;
  2459. if (strcmp(string, "023715") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvNormalStop = YES;
  2460. if (strcmp(string, "023716") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoTempSensorBroken = YES;
  2461. if (strcmp(string, "023717") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoConnectorLockFail = YES;
  2462. if (strcmp(string, "023718") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoD1OnNoReceive = YES;
  2463. if (strcmp(string, "023719") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJTimeout = YES;
  2464. if (strcmp(string, "023720") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeAllowTimeout = YES;
  2465. if (strcmp(string, "023721") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoWaitGfdTimeout = YES;
  2466. if (strcmp(string, "023722") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayTimeout = YES;
  2467. if (strcmp(string, "023723") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsReqCurrentTimeout = YES;
  2468. if (strcmp(string, "023724") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsKtoJOffTimeout = YES;
  2469. if (strcmp(string, "023725") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsEvRelayOffTimeout = YES;
  2470. if (strcmp(string, "023726") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan10V = YES;
  2471. if (strcmp(string, "023727") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoAdcMoreThan20V = YES;
  2472. if (strcmp(string, "023728") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBmsChargeBeforeStop = YES;
  2473. if (strcmp(string, "023729") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetNormalStop = YES;
  2474. if (strcmp(string, "023730") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargerGetEmergencyStop = YES;
  2475. if (strcmp(string, "023731") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoIsolationResultFail = YES;
  2476. if (strcmp(string, "023732") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoMissLinkWithMotherBoard = YES;
  2477. if (strcmp(string, "023733") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoOutputVolMoreThanLimit = YES;
  2478. if (strcmp(string, "023734") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReqCurrentMoreThanLimit = YES;
  2479. if (strcmp(string, "023735") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoReCapBmsEqrCurrentExceed = YES;
  2480. if (strcmp(string, "023736") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoChargeRemainCountDown = YES;
  2481. if (strcmp(string, "023980") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CHADEMO_BMS_CHARGE_ALLOW_ERROR = YES;
  2482. if (strcmp(string, "023981") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CHADEMO_OUTPUT_VOLTAGE_MORE_THEN_10_PERCENT = YES;
  2483. if (strcmp(string, "023982") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CHADEMO_ADC_LESS_THAN_10V = YES;
  2484. if (strcmp(string, "012288") == EQUAL) ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsOutputUVPFail = YES;
  2485. if (strcmp(string, "023701") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = YES;
  2486. if (strcmp(string, "023737") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsRESTemperatureInhibit = YES;
  2487. if (strcmp(string, "023738") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVShiftPosition = YES;
  2488. if (strcmp(string, "023739") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargerConnectorLockFault = YES;
  2489. if (strcmp(string, "023740") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVRESSMalfunction = YES;
  2490. if (strcmp(string, "023741") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingCurrentdifferential = YES;
  2491. if (strcmp(string, "023742") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingVoltageOutOfRange = YES;
  2492. if (strcmp(string, "023743") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingSystemIncompatibility = YES;
  2493. if (strcmp(string, "023744") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEmergencyEvent = YES;
  2494. if (strcmp(string, "023745") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsBreaker = YES;
  2495. if (strcmp(string, "023746") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoData = YES;
  2496. if (strcmp(string, "023747") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_A = YES;
  2497. if (strcmp(string, "023748") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_B = YES;
  2498. if (strcmp(string, "023749") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_DIN_C = YES;
  2499. if (strcmp(string, "023750") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_1 = YES;
  2500. if (strcmp(string, "023751") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_2 = YES;
  2501. if (strcmp(string, "023752") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_ISO_3 = YES;
  2502. if (strcmp(string, "023753") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_1 = YES;
  2503. if (strcmp(string, "023754") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_2 = YES;
  2504. if (strcmp(string, "023755") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_3 = YES;
  2505. if (strcmp(string, "023756") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_4 = YES;
  2506. if (strcmp(string, "023757") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Ccsreserved_by_OEM_5 = YES;
  2507. if (strcmp(string, "023758") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequenceError = YES;
  2508. if (strcmp(string, "023759") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSignatureError = YES;
  2509. if (strcmp(string, "023760") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUnknownSession = YES;
  2510. if (strcmp(string, "023761") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceIDInvalid = YES;
  2511. if (strcmp(string, "023762") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPaymentSelectionInvalid = YES;
  2512. if (strcmp(string, "023763") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsIdentificationSelectionInvalid = YES;
  2513. if (strcmp(string, "023764") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceSelectionInvalid = YES;
  2514. if (strcmp(string, "023765") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateExpired = YES;
  2515. if (strcmp(string, "023766") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotYetValid = YES;
  2516. if (strcmp(string, "023767") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateRevoked = YES;
  2517. if (strcmp(string, "023768") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoCertificateAvailable = YES;
  2518. if (strcmp(string, "023769") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertChainError = YES;
  2519. if (strcmp(string, "023770") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertValidationError = YES;
  2520. if (strcmp(string, "023771") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertVerificationError = YES;
  2521. if (strcmp(string, "023772") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractCanceled = YES;
  2522. if (strcmp(string, "023773") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChallengeInvalid = YES;
  2523. if (strcmp(string, "023774") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongEnergyTransferMode = YES;
  2524. if (strcmp(string, "023775") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWrongChargeParameter = YES;
  2525. if (strcmp(string, "023776") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargingProfileInvalid = YES;
  2526. if (strcmp(string, "023777") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTariffSelectionInvalid = YES;
  2527. if (strcmp(string, "023778") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEPresentVoltageToLow = YES;
  2528. if (strcmp(string, "023779") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryNotApplied = YES;
  2529. if (strcmp(string, "023780") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMeteringSignatureNotValid = YES;
  2530. if (strcmp(string, "023781") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoChargeServiceSelected = YES;
  2531. if (strcmp(string, "023782") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContactorError = YES;
  2532. if (strcmp(string, "023783") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCertificateNotAllowedAtThisEVSE = YES;
  2533. if (strcmp(string, "023784") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsGAChargeStop = YES;
  2534. if (strcmp(string, "023785") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAlignmentError = YES;
  2535. if (strcmp(string, "023786") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsACDError = YES;
  2536. if (strcmp(string, "023787") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsAssociationError = YES;
  2537. if (strcmp(string, "023788") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVSEChargeAbort = YES;
  2538. if (strcmp(string, "023789") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsNoSupportedAppProtocol = YES;
  2539. if (strcmp(string, "023790") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractNotAccepted = YES;
  2540. if (strcmp(string, "023791") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMOUnknown = YES;
  2541. if (strcmp(string, "023792") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_Prov_CertificateRevoke = YES;
  2542. if (strcmp(string, "023793") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA1_CertificateRevoked = YES;
  2543. if (strcmp(string, "023794") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_SubCA2_CertificateRevoked = YES;
  2544. if (strcmp(string, "023795") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsOEM_RootCA_CertificateRevoked = YES;
  2545. if (strcmp(string, "023796") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_Prov_CertificateRevoked = YES;
  2546. if (strcmp(string, "023797") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA1_CertificateRevoked = YES;
  2547. if (strcmp(string, "023798") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_SubCA2_CertificateRevoked = YES;
  2548. if (strcmp(string, "023799") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMO_RootCA_CertificateRevoked = YES;
  2549. if (strcmp(string, "023800") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_Prov_CertificateRevoked = YES;
  2550. if (strcmp(string, "023801") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA1_CertificateRevoked = YES;
  2551. if (strcmp(string, "023802") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_SubCA2_CertificateRevoked = YES;
  2552. if (strcmp(string, "023803") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPS_RootCA_CertificateRevoked = YES;
  2553. if (strcmp(string, "023809") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_SLAC_init = YES;
  2554. if (strcmp(string, "023810") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_match_response = YES;
  2555. if (strcmp(string, "023811") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_sequence = YES;
  2556. if (strcmp(string, "023812") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_match_MNBC = YES;
  2557. if (strcmp(string, "023813") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_avg_atten_calc = YES;
  2558. if (strcmp(string, "023814") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_match_response = YES;
  2559. if (strcmp(string, "023815") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_match_session = YES;
  2560. if (strcmp(string, "023816") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_assoc_session = YES;
  2561. if (strcmp(string, "023817") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_vald_toggle = YES;
  2562. if (strcmp(string, "023818") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccSlacTimeoutCmMnbcSound = YES;
  2563. if (strcmp(string, "023819") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccSlacTimeoutCmValidateReq = YES;
  2564. if (strcmp(string, "023823") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUDP_TT_match_join = YES;
  2565. if (strcmp(string, "023824") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTCP_TT_match_join = YES;
  2566. if (strcmp(string, "023825") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_amp_map_exchange = YES;
  2567. if (strcmp(string, "023826") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_link_ready_notification = YES;
  2568. if (strcmp(string, "023832") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSupportedAppProtocolRes = YES;
  2569. if (strcmp(string, "023833") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionSetupRes = YES;
  2570. if (strcmp(string, "023834") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServiceDiscoveryRes = YES;
  2571. if (strcmp(string, "023835") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsServicePaymentSelectionRes = YES;
  2572. if (strcmp(string, "023836") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsContractAuthenticationRes = YES;
  2573. if (strcmp(string, "023837") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsChargeParameterDiscoveryRes = YES;
  2574. if (strcmp(string, "023838") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPowerDeliveryRes = YES;
  2575. if (strcmp(string, "023839") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheckRes = YES;
  2576. if (strcmp(string, "023840") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsPreChargeRes = YES;
  2577. if (strcmp(string, "023841") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCurrentDemandRes = YES;
  2578. if (strcmp(string, "023842") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsWeldingDetectionRes = YES;
  2579. if (strcmp(string, "023843") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSessionStopRes = YES;
  2580. if (strcmp(string, "023844") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSequence_Time = YES;
  2581. if (strcmp(string, "023845") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsReadyToCharge_Performance_Time = YES;
  2582. if (strcmp(string, "023846") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCommunicationSetup_Performance_Time = YES;
  2583. if (strcmp(string, "023847") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCableCheck_Performance_Time = YES;
  2584. if (strcmp(string, "023848") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPState_Detection_Time = YES;
  2585. if (strcmp(string, "023849") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCPOscillator_Retain_Time = YES;
  2586. if (strcmp(string, "023850") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccTimeoutV2GPreChargePerformaceTime = YES;
  2587. if (strcmp(string, "023855") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_TARGET_INFO = YES;
  2588. if (strcmp(string, "023856") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_TARGET_INFO = YES;
  2589. if (strcmp(string, "023857") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_EV_BATTERY_INFO = YES;
  2590. if (strcmp(string, "023858") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_EV_BATTERY_INFO = YES;
  2591. if (strcmp(string, "023859") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EV_STOP_EVENT = YES;
  2592. if (strcmp(string, "023860") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EV_STOP_EVENT = YES;
  2593. if (strcmp(string, "023861") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_STOP_EVENT = YES;
  2594. if (strcmp(string, "023862") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_STOP_EVENT = YES;
  2595. if (strcmp(string, "023863") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_GET_MISC_INFO = YES;
  2596. if (strcmp(string, "023864") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_GET_MISC_INFO = YES;
  2597. if (strcmp(string, "023865") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_REQUEST = YES;
  2598. if (strcmp(string, "023866") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_REQUEST = YES;
  2599. if (strcmp(string, "023867") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_START_BLOCK_TRANSFER = YES;
  2600. if (strcmp(string, "023868") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_START_BLOCK_TRANSFER = YES;
  2601. if (strcmp(string, "023869") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DATA_TRANSFER = YES;
  2602. if (strcmp(string, "023870") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DATA_TRANSFER = YES;
  2603. if (strcmp(string, "023871") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_DOWNLOAD_FINISH = YES;
  2604. if (strcmp(string, "023872") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_DOWNLOAD_FINISH = YES;
  2605. if (strcmp(string, "023873") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_ISOLATION_STATUS = YES;
  2606. if (strcmp(string, "023874") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_ISOLATION_STATUS = YES;
  2607. if (strcmp(string, "023875") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_CONNECTOR_INFO = YES;
  2608. if (strcmp(string, "023876") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_CONNECTOR_INFO = YES;
  2609. if (strcmp(string, "023877") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_RTC_INFO = YES;
  2610. if (strcmp(string, "023878") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_RTC_INFO = YES;
  2611. if (strcmp(string, "023879") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTP_EVSE_PRECHARGE_INFO = YES;
  2612. if (strcmp(string, "023880") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsTT_EVSE_PRECHARGE_INFO = YES;
  2613. if (strcmp(string, "023881") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsMSG_Sequence = YES;
  2614. if (strcmp(string, "023882") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCAN_MSG_Unrecognized_CMD_ID = YES;
  2615. if (strcmp(string, "023883") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Decode_Error = YES;
  2616. if (strcmp(string, "023884") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsDIN_Msg_Encode_Error = YES;
  2617. if (strcmp(string, "023885") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Decode_Error = YES;
  2618. if (strcmp(string, "023886") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO1_Msg_Encode_Error = YES;
  2619. if (strcmp(string, "023887") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Decode_Error = YES;
  2620. if (strcmp(string, "023888") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsISO2_Msg_Encode_Error = YES;
  2621. if (strcmp(string, "023889") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsCpStatus_Error = YES;
  2622. if (strcmp(string, "023890") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsUnexpectVolBeforeCharing_Error = YES;
  2623. if (strcmp(string, "023891") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccNotReadyForCharging = YES;
  2624. if (strcmp(string, "023892") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccTimeoutQCA7000Comm = YES;
  2625. if (strcmp(string, "023893") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsSeccFailForQCA7000SetKey = YES;
  2626. if (strcmp(string, "023979") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.EV_Full_Charging = YES;
  2627. if (strcmp(string, "023983") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.Stop_by_EV_with_unknow_reason = YES;
  2628. if (strcmp(string, "023702") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.GbEvCommFail = YES;
  2629. if (strcmp(string, "023900") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_LOS_CC1 = YES;
  2630. if (strcmp(string, "023901") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CONNECTOR_LOCK_FAIL = YES;
  2631. if (strcmp(string, "023902") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BATTERY_INCOMPATIBLE = YES;
  2632. if (strcmp(string, "023903") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_BROAA_TIMEOUT = YES;
  2633. if (strcmp(string, "023904") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CSU_PRECHARGE_TIMEOUT = YES;
  2634. if (strcmp(string, "023905") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_PRESENT_VOLTAGE_FAULT = YES;
  2635. if (strcmp(string, "023906") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BMS_VOLTAGE_OVER_RANGE = YES;
  2636. if (strcmp(string, "023907") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_BSM_CHARGE_ALLOW_00_10MIN_COUUNTDONE = YES;
  2637. if (strcmp(string, "023908") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_WAIT_GROUNDFAULT_TIMEOUT = YES;
  2638. if (strcmp(string, "023909") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ADC_MORE_THAN_10V = YES;
  2639. if (strcmp(string, "023910") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ADC_MORE_THAN_60V = YES;
  2640. if (strcmp(string, "023911") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CHARGER_GET_NORMAL_STOP_CMD = YES;
  2641. if (strcmp(string, "023912") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_CHARGER_GET_EMERGENCY_STOP_CMD = YES;
  2642. if (strcmp(string, "023913") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_ISOLATION_RESULT_FAIL = YES;
  2643. if (strcmp(string, "023914") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_MOTHER_BOARD_MISS_LINK = YES;
  2644. if (strcmp(string, "023915") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_LIMIT = YES;
  2645. if (strcmp(string, "023916") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_REQ_CURRENT_MORE_THAN_LIMIT = YES;
  2646. if (strcmp(string, "023917") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_10_PERCENT = YES;
  2647. if (strcmp(string, "023918") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_OUTPUT_VOLTAGE_DIFF_BCS_5_PERCENT = YES;
  2648. if (strcmp(string, "023919") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GBT_STOP_ADC_MORE_THAN_10V = YES;
  2649. if (strcmp(string, "023930") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BHM_TIMEOUT = YES;
  2650. if (strcmp(string, "023931") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BRM_TIMEOUT = YES;
  2651. if (strcmp(string, "023932") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCP_TIMEOUT = YES;
  2652. if (strcmp(string, "023933") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BRO_TIMEOUT = YES;
  2653. if (strcmp(string, "023934") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCL_TIMEOUT = YES;
  2654. if (strcmp(string, "023935") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BCS_TIMEOUT = YES;
  2655. if (strcmp(string, "023936") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BSM_TIMEOUT = YES;
  2656. if (strcmp(string, "023937") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BST_TIMEOUT = YES;
  2657. if (strcmp(string, "023938") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BSD_TIMEOUT = YES;
  2658. if (strcmp(string, "023939") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_CEM_BEM_OTHER_TIMEOUT = YES;
  2659. if (strcmp(string, "023940") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRM_TIMEOUT = YES;
  2660. if (strcmp(string, "023941") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRMAA_TIMEOUT = YES;
  2661. if (strcmp(string, "023942") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CTS_CML_TIMEOUT = YES;
  2662. if (strcmp(string, "023943") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CRO_TIMEOUT = YES;
  2663. if (strcmp(string, "023944") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CCS_TIMEOUT = YES;
  2664. if (strcmp(string, "023945") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CST_TIMEOUT = YES;
  2665. if (strcmp(string, "023946") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_CSD_TIMEOUT = YES;
  2666. if (strcmp(string, "023947") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BEM_BEM_OTHER_TIMEOUT = YES;
  2667. if (strcmp(string, "023950") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_SOC_GOAL = YES;
  2668. if (strcmp(string, "023951") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_TOTAL_VOLTAGE_GOAL = YES;
  2669. if (strcmp(string, "023952") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CELL_VOLTAGE_GOAL = YES;
  2670. if (strcmp(string, "023953") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_GET_CST = YES;
  2671. if (strcmp(string, "023954") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_ISOLATION = YES;
  2672. if (strcmp(string, "023955") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OUTPUT_CONNECTOR_OTP = YES;
  2673. if (strcmp(string, "023956") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_COMPONENT = YES;
  2674. if (strcmp(string, "023957") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CHARGE_CONNECTOR = YES;
  2675. if (strcmp(string, "023958") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OTP = YES;
  2676. if (strcmp(string, "023959") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_OTHER = YES;
  2677. if (strcmp(string, "023960") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_HIGH_V = YES;
  2678. if (strcmp(string, "023961") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CC2 = YES;
  2679. if (strcmp(string, "023962") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_CURRENT = YES;
  2680. if (strcmp(string, "023963") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BST_VOLTAGE = YES;
  2681. if (strcmp(string, "023964") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_GET_BST_NO_REASON = YES;
  2682. if (strcmp(string, "023970") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CELL_OVER_VOLTAGE = YES;
  2683. if (strcmp(string, "023971") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CELL_UNDER_VOLTAGE = YES;
  2684. if (strcmp(string, "023972") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_OVER_SOC = YES;
  2685. if (strcmp(string, "023973") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_UNDER_SOC = YES;
  2686. if (strcmp(string, "023974") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_CURRENT = YES;
  2687. if (strcmp(string, "023975") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_TEMPERATURE = YES;
  2688. if (strcmp(string, "023976") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_ISOLATE = YES;
  2689. if (strcmp(string, "023977") == EQUAL) ShmStatusCodeData->InfoCode.InfoEvents.bits.ERROR_CODE_BSM_OUTPUT_CONNECTOR = YES;
  2690. return true;
  2691. }
  2692. byte ReturnConnectTemp(byte temp1, byte temp2)
  2693. {
  2694. byte result = 0;
  2695. if (temp1 == UNDEFINED_TEMP && temp2 == UNDEFINED_TEMP)
  2696. return UNDEFINED_TEMP;
  2697. if (temp1 != UNDEFINED_TEMP)
  2698. result = temp1;
  2699. else
  2700. temp1 = 0;
  2701. if (temp2 != UNDEFINED_TEMP)
  2702. {
  2703. if (temp2 > temp1)
  2704. result = temp2;
  2705. }
  2706. return result;
  2707. }
  2708. void CANReceiver()
  2709. {
  2710. pid_t canRecPid;
  2711. canRecPid = fork();
  2712. if(canRecPid > 0)
  2713. {
  2714. int nbytes;
  2715. struct can_frame frame;
  2716. int intCmd;
  2717. bool isClearBuf = false;
  2718. // 槍資訊
  2719. struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
  2720. bool isPass = false;
  2721. gun_count = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
  2722. while(!isPass)
  2723. {
  2724. isPass = true;
  2725. for (byte _index = 0; _index < gun_count; _index++)
  2726. {
  2727. if (!FindChargingInfoData(_index, &_chargingData[0]))
  2728. {
  2729. DEBUG_ERROR("EvComm (main) : FindChargingInfoData false \n");
  2730. isPass = false;
  2731. break;
  2732. }
  2733. }
  2734. sleep(1);
  2735. }
  2736. while (1)
  2737. {
  2738. memset(&frame, 0, sizeof(struct can_frame));
  2739. nbytes = read(CanFd, &frame, sizeof(struct can_frame));
  2740. if (nbytes > 0)
  2741. {
  2742. byte target;
  2743. byte targetGun = 0x00;
  2744. byte findIndex = 0x00;
  2745. EvFrame *EvFrameMsg;
  2746. EvFrameMsg = (EvFrame *)&frame.can_id;
  2747. intCmd = EvFrameMsg->EvBdBits.MessageID;
  2748. if (!isClearBuf)
  2749. {
  2750. continue;
  2751. }
  2752. if (intCmd == EV_Command_AddressReq)
  2753. {
  2754. ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V013S0;
  2755. AddrAssignment(frame.data);
  2756. continue;
  2757. }
  2758. target = EvFrameMsg->EvBdBits.SlaveAddress; // 0x01 or 0x02
  2759. for (byte _index = 0; _index < gun_count; _index++)
  2760. {
  2761. // 假設有找到回應的 Index
  2762. findIndex = target;
  2763. if (gun_count == 1 &&
  2764. _chargingData[_index]->Type == _Type_CCS &&
  2765. ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0)
  2766. {
  2767. target -= 1;
  2768. }
  2769. if (_chargingData[_index]->Evboard_id == target)
  2770. {
  2771. targetGun = _index;
  2772. break;
  2773. }
  2774. }
  2775. if(targetGun < 0 || targetGun >= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)
  2776. {
  2777. PRINTF_FUNC("EvComm (CANReceiver) : Target index = %x is < 0 or > QUANTITY \n", targetGun);
  2778. continue;
  2779. }
  2780. if (gun_count == 1)
  2781. {
  2782. if (findIndex == 1)
  2783. ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V013S0;
  2784. else
  2785. ShmDcCommonData->CcsVersion = _CCS_VERSION_CHECK_TAG_V015S0;
  2786. }
  2787. if(intCmd == 256) { continue; }
  2788. switch (intCmd)
  2789. {
  2790. case EV_Command_EvStatusNotification:
  2791. {
  2792. if (_chargingData[targetGun]->ConnectorPlugIn != frame.data[0])
  2793. {
  2794. if (frame.data[0] == PLUG)
  2795. PRINTF_FUNC("Conn %d, Plugin. \n", targetGun);
  2796. else if (frame.data[0] == UNPLUG)
  2797. PRINTF_FUNC("Conn %d, Unplug. \n", targetGun);
  2798. else
  2799. PRINTF_FUNC("Conn %d, Plug None Check. (%d) \n", targetGun, frame.data[0]);
  2800. }
  2801. // for using ccid to authoriz.
  2802. if (ShmDcCommonData->_authWithCcidFlag[targetGun] == _CCID_AUTHFAIL &&
  2803. _chargingData[targetGun]->ConnectorPlugIn == UNPLUG)
  2804. {
  2805. ShmDcCommonData->_authWithCcidFlag[targetGun] = _CCID_NONE;
  2806. }
  2807. _chargingData[targetGun]->ConnectorPlugIn = frame.data[0];
  2808. _chargingData[targetGun]->PilotVoltage = frame.data[1];
  2809. //PRINTF_FUNC("index = %d, ConnectorPlugIn = %x, data[0] = %x \n", targetGun, _chargingData[targetGun]->ConnectorPlugIn, frame.data[0]);
  2810. //PRINTF_FUNC("ConnectorPlugIn = %x \n", (-120 + frame.data[1]) / 10);
  2811. }
  2812. break;
  2813. case EV_Command_GetFwVersion:
  2814. {
  2815. byte ver[16];
  2816. memset(ver, 0, sizeof(ver));
  2817. if (_chargingData[targetGun]->Type == _Type_Chademo)
  2818. {
  2819. memcpy(ver, frame.data, frame.can_dlc);
  2820. memcpy(ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].version, ver, ARRAY_SIZE(ver));
  2821. ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
  2822. // PRINTF_FUNC("Connector %d, Chadmoe Ver. : %s\n",
  2823. // targetGun, ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].version);
  2824. }
  2825. else if (_chargingData[targetGun]->Type == _Type_GB)
  2826. {
  2827. memcpy(ver, frame.data, frame.can_dlc);
  2828. memcpy(ShmGBTData->evse[_chargingData[targetGun]->type_index].version, ver, ARRAY_SIZE(ver));
  2829. ShmGBTData->evse[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
  2830. // PRINTF_FUNC("Connector %d, GBT Ver. : %s\n",
  2831. // targetGun, ShmGBTData->evse[_chargingData[targetGun]->type_index].version);
  2832. }
  2833. else if (_chargingData[targetGun]->Type == _Type_CCS)
  2834. {
  2835. if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121)
  2836. {
  2837. memcpy(ver, frame.data, frame.can_dlc);
  2838. memcpy(&ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version, ver, ARRAY_SIZE(ver));
  2839. ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].SelfTest_Comp = PASS;
  2840. // PRINTF_FUNC("Connector %d, CCS Ver. = %s \n",
  2841. // targetGun, ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].version);
  2842. }
  2843. }
  2844. if (targetGun == 0)
  2845. {
  2846. memset(ShmSysConfigAndInfo->SysInfo.Connector1FwRev, 0, sizeof(ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  2847. memcpy(ShmSysConfigAndInfo->SysInfo.Connector1FwRev, ver, ARRAY_SIZE(ver));
  2848. }
  2849. else
  2850. {
  2851. memset(ShmSysConfigAndInfo->SysInfo.Connector2FwRev, 0, sizeof(ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  2852. memcpy(ShmSysConfigAndInfo->SysInfo.Connector2FwRev, ver, ARRAY_SIZE(ver));
  2853. }
  2854. }
  2855. break;
  2856. case EV_Command_GetHwVersion:
  2857. {
  2858. //PRINTF_FUNC("Get EV HW = %s \n", frame.data);
  2859. }
  2860. break;
  2861. case EV_Command_GetOutputReq:
  2862. {
  2863. if ((_chargingData[targetGun]->SystemStatus >= SYS_MODE_PREPARE_FOR_EVSE &&
  2864. _chargingData[targetGun]->SystemStatus <= SYS_MODE_CHARGING) ||
  2865. (_chargingData[targetGun]->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 &&
  2866. _chargingData[targetGun]->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
  2867. {
  2868. if (frame.data[1] > _chargingData[targetGun]->EvBatterySoc ||
  2869. _chargingData[targetGun]->SystemStatus == SYS_MODE_CHARGING)
  2870. _chargingData[targetGun]->EvBatterySoc = frame.data[1];
  2871. }
  2872. _chargingData[targetGun]->EvBatterytargetVoltage = (float)((frame.data[3] << 8) + frame.data[2]) / 10;
  2873. _chargingData[targetGun]->EvBatterytargetCurrent = (float)((frame.data[5] << 8) + frame.data[4]) / 10;
  2874. _chargingData[targetGun]->RemainChargingDuration = ((short) frame.data[7] << 8) + (short) frame.data[6];
  2875. if (_chargingData[targetGun]->Type == _Type_Chademo)
  2876. {
  2877. //if (ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].EvDetection != frame.data[0])
  2878. {
  2879. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].PresentMsgFlowStatus = frame.data[0];
  2880. }
  2881. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].EvDetection = frame.data[0];
  2882. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].SOC = _chargingData[targetGun]->EvBatterySoc;
  2883. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].TargetBatteryVoltage = (_chargingData[targetGun]->EvBatterytargetVoltage * 10);
  2884. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].ChargingCurrentRequest = (_chargingData[targetGun]->EvBatterytargetCurrent * 10);
  2885. }
  2886. else if (_chargingData[targetGun]->Type == _Type_GB)
  2887. {
  2888. //if (ShmGBTData->ev[_chargingData[targetGun]->type_index].EvDetection != frame.data[0])
  2889. {
  2890. ShmGBTData->ev[_chargingData[targetGun]->type_index].PresentMsgFlowStatus = frame.data[0];
  2891. }
  2892. ShmGBTData->ev[_chargingData[targetGun]->type_index].EvDetection = frame.data[0];
  2893. ShmGBTData->ev[_chargingData[targetGun]->type_index].SOC = _chargingData[targetGun]->EvBatterySoc;
  2894. ShmGBTData->ev[_chargingData[targetGun]->type_index].TargetBatteryVoltage = (_chargingData[targetGun]->EvBatterytargetVoltage * 10);
  2895. ShmGBTData->ev[_chargingData[targetGun]->type_index].ChargingCurrentRequest = (_chargingData[targetGun]->EvBatterytargetCurrent * 10);
  2896. }
  2897. else if (_chargingData[targetGun]->Type == _Type_CCS)
  2898. {
  2899. if(ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121)
  2900. {
  2901. ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].PresentMsgFlowStatus = frame.data[0];
  2902. }
  2903. }
  2904. //PRINTF_FUNC("EvBatterytargetVoltage = %f \n", _chargingData[targetGun]->EvBatterytargetVoltage);
  2905. //PRINTF_FUNC("EvBatterytargetCurrent = %f \n", _chargingData[targetGun]->EvBatterytargetCurrent);
  2906. //PRINTF_FUNC("BatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TargetBatteryVoltage);
  2907. //PRINTF_FUNC("CurrentRequest = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].ChargingCurrentRequest);
  2908. }
  2909. break;
  2910. case EV_Command_GetBetteryInfo:
  2911. {
  2912. //_chargingData[target].EvACorDCcharging = frame.data[0];
  2913. //_chargingData[target]->TotalBatteryCap = ((float) frame.data[4] << 8) + (short) frame.data[3];
  2914. _chargingData[targetGun]->EvBatteryMaxVoltage = (((short) frame.data[4] << 8) + (short) frame.data[3]) / 10;
  2915. //_chargingData[target]->EvBatteryMaxCurrent = ((float) frame.data[4] << 8) + (short) frame.data[3];
  2916. //_chargingData[target].MaxiBatteryCurrent = ((short) frame.data[6] << 8) + (short) frame.data[5];
  2917. if (_chargingData[targetGun]->Type == _Type_Chademo)
  2918. {
  2919. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].TotalBatteryCapacity = ((short) frame.data[2] << 8) + (short) frame.data[1];
  2920. ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].MaxiBatteryVoltage = _chargingData[targetGun]->EvBatteryMaxVoltage;
  2921. //PRINTF_FUNC("EvBatteryMaxVoltage = %f \n", _chargingData[target]->EvBatteryMaxVoltage);
  2922. //PRINTF_FUNC("TotalBatteryCapacity = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TotalBatteryCapacity);
  2923. //PRINTF_FUNC("MaxiBatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].MaxiBatteryVoltage);
  2924. }
  2925. else if (_chargingData[targetGun]->Type == _Type_GB)
  2926. {
  2927. ShmGBTData->ev[_chargingData[targetGun]->type_index].TotalBatteryCapacity = ((short) frame.data[2] << 8) + (short) frame.data[1];
  2928. ShmGBTData->ev[_chargingData[targetGun]->type_index].MaxiBatteryVoltage = _chargingData[targetGun]->EvBatteryMaxVoltage;
  2929. }
  2930. else if (_chargingData[targetGun]->Type == _Type_CCS)
  2931. {
  2932. }
  2933. }
  2934. break;
  2935. case EV_Command_GetMiscellaneous:
  2936. {
  2937. _chargingData[targetGun]->GunLocked = frame.data[0];
  2938. _chargingData[targetGun]->PilotVoltage = (float)(-120 + frame.data[3]) / 10;
  2939. ShmDcCommonData->ConnectorTemp1[targetGun] = frame.data[1];
  2940. ShmDcCommonData->ConnectorTemp2[targetGun] = frame.data[2];
  2941. if (_chargingData[targetGun]->Type == _Type_Chademo)
  2942. {
  2943. // 200A 以上的槍才會有 cha 槍溫
  2944. _chargingData[targetGun]->ConnectorTemp = ReturnConnectTemp(frame.data[1], frame.data[2]);
  2945. ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureP = frame.data[1];
  2946. ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureN = frame.data[2];
  2947. ShmCHAdeMOData->evse[_chargingData[targetGun]->type_index].EvboardStatus = frame.data[7];
  2948. }
  2949. else if (_chargingData[targetGun]->Type == _Type_GB)
  2950. {
  2951. _chargingData[targetGun]->ConnectorTemp = ReturnConnectTemp(frame.data[1], frame.data[2]);
  2952. ShmGBTData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureP = frame.data[1];
  2953. ShmGBTData->evse[_chargingData[targetGun]->type_index].ConnectorTemperatureN = frame.data[2];
  2954. ShmGBTData->evse[_chargingData[targetGun]->type_index].EvboardStatus = frame.data[7];
  2955. }
  2956. else if (_chargingData[targetGun]->Type == _Type_CCS)
  2957. {
  2958. _chargingData[targetGun]->ConnectorTemp = ReturnConnectTemp(frame.data[1], frame.data[2]);
  2959. if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121)
  2960. {
  2961. //ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index]. .ConnectorTemperatureP = frame.data[1];
  2962. //ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index]. .ConnectorTemperatureN = frame.data[2];
  2963. }
  2964. }
  2965. //PRINTF_FUNC("EvboardStatus = %x \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].EvboardStatus);
  2966. //PRINTF_FUNC("ConnectorPlug locked = %x \n", frame.data[0]);
  2967. //PRINTF_FUNC("ConnectorTemp 0= %d \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].ConnectorTemperatureP);
  2968. //PRINTF_FUNC("ConnectorTemp 1= %d \n", ShmCHAdeMOData->evse[_chargingData[target]->type_index].ConnectorTemperatureN);
  2969. //PRINTF_FUNC("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
  2970. }
  2971. break;
  2972. case EV_Command_IsolationStatus:{}
  2973. break;
  2974. case EV_Command_EvccidReq:
  2975. {
  2976. if (frame.can_dlc > 0 &&
  2977. strcmp((char *)_chargingData[targetGun]->EVCCID, "") == EQUAL)
  2978. {
  2979. if (_chargingData[targetGun]->Type == _Type_CCS)
  2980. {
  2981. if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121)
  2982. {
  2983. memset(ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].SessionSetupRequest.EVCCID, 0, sizeof(ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].SessionSetupRequest.EVCCID));
  2984. memcpy(ShmCcsData->V2GMessage_DIN70121[_chargingData[targetGun]->type_index].SessionSetupRequest.EVCCID, frame.data, frame.can_dlc);
  2985. }
  2986. }
  2987. sprintf((char *)_chargingData[targetGun]->EVCCID, "%.2x%.2x%.2x%.2x%.2x%.2x",
  2988. frame.data[0], frame.data[1], frame.data[2], frame.data[3],
  2989. frame.data[4], frame.data[5]);
  2990. PRINTF_FUNC("*******Gun %d->EVCCID = %s \n", targetGun, _chargingData[targetGun]->EVCCID);
  2991. }
  2992. }
  2993. break;
  2994. case EV_Command_EvsePrechargeInfo:
  2995. {
  2996. _chargingData[targetGun]->PrechargeStatus = frame.data[0];
  2997. }
  2998. break;
  2999. case EV_Command_EvStopNotification:
  3000. {
  3001. // 車端要求停止
  3002. if ((_chargingData[targetGun]->SystemStatus >= SYS_MODE_MODE_REASSIGN_CHECK &&
  3003. _chargingData[targetGun]->SystemStatus <= SYS_MODE_CHARGING) ||
  3004. (_chargingData[targetGun]->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 &&
  3005. _chargingData[targetGun]->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
  3006. {
  3007. // frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
  3008. if (frame.data[0] == 0x02)
  3009. {
  3010. PRINTF_FUNC("Gun_%d, ** Emc Level **, Stop charging by EV. \n", targetGun);
  3011. if (AbnormalStopAnalysis(targetGun, frame.data + 1))
  3012. {
  3013. _chargingData[targetGun]->StopChargeFlag = YES;
  3014. }
  3015. else
  3016. {
  3017. // 六個蛋
  3018. _chargingData[targetGun]->NormalStopChargeFlag = YES;
  3019. }
  3020. }
  3021. else
  3022. {
  3023. AbnormalStopAnalysis(targetGun, frame.data + 1);
  3024. PRINTF_FUNC("Gun_%d, ** Normal Level **, Stop charging by EV. \n", targetGun);
  3025. _chargingData[targetGun]->NormalStopChargeFlag = YES;
  3026. }
  3027. }
  3028. }
  3029. break;
  3030. case EV_Command_SyncRtcInfo:
  3031. {} break;
  3032. default:
  3033. PRINTF_FUNC("EV board = %d, Ack none defined. intCmd = %d \n", targetGun, intCmd);
  3034. break;
  3035. }
  3036. }
  3037. else
  3038. {
  3039. isClearBuf = true;
  3040. usleep(10000);
  3041. }
  3042. }
  3043. }
  3044. }
  3045. //================================================
  3046. // Main process
  3047. //================================================
  3048. // 檢查 Byte 中某個 Bit 的值
  3049. // _byte : 欲改變的 byte
  3050. // _bit : 該 byte 的第幾個 bit
  3051. unsigned char EvDetectionStatus(unsigned char _byte, unsigned char _bit)
  3052. {
  3053. return ( _byte & mask_table[_bit] ) != 0x00;
  3054. }
  3055. bool IsConnectorPlugIn(struct ChargingInfoData *chargingData)
  3056. {
  3057. return (chargingData->ConnectorPlugIn == 0x01) ? true : false;
  3058. }
  3059. void SetPresentChargingOutputPower(struct ChargingInfoData *chargingData_1, struct ChargingInfoData *chargingData_2)
  3060. {
  3061. float vol1 = 0, cur1 = 0;
  3062. float vol2 = 0, cur2 = 0;
  3063. // if (ShmGBTData->ev[chargingData_1->type_index].PresentMsgFlowStatus == 10)
  3064. // vol1 = ShmPsuData->PsuGroup[0].GroupTargetOutputVoltage;
  3065. // else
  3066. vol1 = chargingData_1->FireChargingVoltage;
  3067. cur1 = (chargingData_1->PresentChargingCurrent * 10);
  3068. float targetCur = chargingData_1->EvBatterytargetCurrent * 10;
  3069. if (curTargetCur[GUN_LEFT] != chargingData_1->EvBatterytargetCurrent * 10)
  3070. {
  3071. curTargetCur[GUN_LEFT] = chargingData_1->EvBatterytargetCurrent * 10;
  3072. curAllowCount[GUN_LEFT] = 0;
  3073. }
  3074. if (curAllowCount[GUN_LEFT] < ALLOW_COUNT_MAX &&
  3075. chargingData_1->Type == _Type_CCS)
  3076. {
  3077. if (cur1 > targetCur + 100 || cur1 < targetCur - 100)
  3078. {
  3079. cur1 = targetCur;
  3080. curAllowCount[GUN_LEFT]++;
  3081. }
  3082. else
  3083. curAllowCount[GUN_LEFT] = 0;
  3084. }
  3085. // if (ShmGBTData->ev[chargingData_2->type_index].PresentMsgFlowStatus == 10)
  3086. // vol2 = ShmPsuData->PsuGroup[1].GroupTargetOutputVoltage;
  3087. // else
  3088. vol2 = chargingData_2->FireChargingVoltage;
  3089. cur2 = (chargingData_2->PresentChargingCurrent * 10);
  3090. if ((chargingData_1->SystemStatus >= SYS_MODE_PREPARING && chargingData_1->SystemStatus <= SYS_MODE_CHARGING) ||
  3091. (chargingData_1->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && chargingData_1->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
  3092. {
  3093. if ((LogInfo[GUN_LEFT][EV_LOG_NOW_OUTPUT_VOL] >= vol1 + CHK_VOL_RANGE) || (LogInfo[GUN_LEFT][EV_LOG_NOW_OUTPUT_VOL] <= vol1 - CHK_VOL_RANGE) ||
  3094. (LogInfo[GUN_LEFT][EV_LOG_NOW_OUTPUT_CUR] >= cur1 + CHK_CUR_RANGE) || (LogInfo[GUN_LEFT][EV_LOG_NOW_OUTPUT_CUR] <= cur1 - CHK_CUR_RANGE))
  3095. {
  3096. PRINTF_FUNC("G_0 -> Output Vol = %.1f (V), Output Cur = %.1f (A) \n", vol1 / 10, cur1 / 10);
  3097. LogInfo [GUN_LEFT] [EV_LOG_NOW_OUTPUT_VOL] = vol1;
  3098. LogInfo [GUN_LEFT] [EV_LOG_NOW_OUTPUT_CUR] = cur1;
  3099. }
  3100. }
  3101. targetCur = chargingData_2->EvBatterytargetCurrent * 10;
  3102. if (curTargetCur[GUN_RIGHT] != chargingData_2->EvBatterytargetCurrent * 10)
  3103. {
  3104. curTargetCur[GUN_RIGHT] = chargingData_2->EvBatterytargetCurrent * 10;
  3105. curAllowCount[GUN_RIGHT] = 0;
  3106. }
  3107. if (curAllowCount[GUN_RIGHT] < ALLOW_COUNT_MAX &&
  3108. chargingData_2->Type == _Type_CCS)
  3109. {
  3110. if (cur2 > targetCur + 100 || cur2 < targetCur - 100)
  3111. {
  3112. cur2 = targetCur;
  3113. curAllowCount[GUN_RIGHT]++;
  3114. }
  3115. else
  3116. curAllowCount[GUN_RIGHT] = 0;
  3117. }
  3118. if ((chargingData_2->SystemStatus >= SYS_MODE_PREPARING && chargingData_2->SystemStatus <= SYS_MODE_CHARGING) ||
  3119. (chargingData_2->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && chargingData_2->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
  3120. {
  3121. if ((LogInfo[GUN_RIGHT][EV_LOG_NOW_OUTPUT_VOL] >= vol2 + CHK_VOL_RANGE) || (LogInfo[GUN_RIGHT][EV_LOG_NOW_OUTPUT_VOL] <= vol2 - CHK_VOL_RANGE) ||
  3122. (LogInfo[GUN_RIGHT][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) || (LogInfo[GUN_RIGHT][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE))
  3123. {
  3124. PRINTF_FUNC("G_1 -> Output Vol = %.1f (V), Output Cur = %.1f (A) \n", vol2 / 10, cur2 / 10);
  3125. LogInfo[GUN_RIGHT][EV_LOG_NOW_OUTPUT_VOL] = vol2;
  3126. LogInfo[GUN_RIGHT][EV_LOG_NOW_OUTPUT_CUR] = cur2;
  3127. }
  3128. }
  3129. if (!_useOfflineNoCharging)
  3130. {
  3131. if (ShmSysConfigAndInfo->SysInfo.OcppConnStatus == NO &&
  3132. ShmSysConfigAndInfo->SysConfig.OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING)
  3133. {
  3134. PRINTF_FUNC("Offline Policy : No Charing... \n");
  3135. _useOfflineNoCharging = true;
  3136. cur1 = cur2 = 0;
  3137. }
  3138. }
  3139. else
  3140. {
  3141. if (ShmSysConfigAndInfo->SysInfo.OcppConnStatus == YES)
  3142. _useOfflineNoCharging = false;
  3143. }
  3144. SetPresentOutputPower(vol1, cur1, vol2, cur2);
  3145. }
  3146. // LWADD
  3147. void GetOtpPwrOrCurMethod(struct ChargingInfoData *chargingData, float *pow, float *cur)
  3148. {
  3149. if (chargingData->ConnectorTemp >= STAGE1_GUN_DERATING_TEMP &&
  3150. chargingData->ConnectorTemp < STAGE2_GUN_DERATING_TEMP &&
  3151. chargingData->deratingByConnOtp.deratingIndex < 1)
  3152. {
  3153. chargingData->deratingByConnOtp.deratingIndex = 1;
  3154. }
  3155. else if (chargingData->ConnectorTemp >= STAGE2_GUN_DERATING_TEMP &&
  3156. chargingData->ConnectorTemp != UNDEFINED_TEMP &&
  3157. chargingData->deratingByConnOtp.deratingIndex < 2)
  3158. {
  3159. chargingData->deratingByConnOtp.deratingIndex = 2;
  3160. }
  3161. if (chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex] != 0)
  3162. {
  3163. *pow *= chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex];
  3164. }
  3165. else if (chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex] != 0)
  3166. {
  3167. if (*cur > chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex])
  3168. *cur = chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex];
  3169. }
  3170. }
  3171. void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct ChargingInfoData *chargingData_2)
  3172. {
  3173. float pow1 = 0, cur1 = 0;
  3174. float pow2 = 0, cur2 = 0;
  3175. float vol = 0;
  3176. pow1 = chargingData_1->AvailableChargingPower;
  3177. cur1 = chargingData_1->AvailableChargingCurrent;
  3178. vol = chargingData_1->MaximumChargingVoltage;
  3179. if ((chargingData_1->SystemStatus >= SYS_MODE_PREPARING && chargingData_1->SystemStatus <= SYS_MODE_CHARGING) ||
  3180. (chargingData_1->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && chargingData_1->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
  3181. {
  3182. GetMaxVolAndCurMethod(chargingData_1->Index, &vol, &cur1);
  3183. GetMaxPowerMethod(chargingData_1->Index, &pow1);
  3184. if (pow1 <= 0)
  3185. cur1 = 0;
  3186. else
  3187. {
  3188. if (chargingData_1->SystemStatus == SYS_MODE_CHARGING &&
  3189. chargingData_1->FireChargingVoltage > 1500)
  3190. {
  3191. float maxCur = 0;
  3192. maxCur = (pow1 * 1000) / chargingData_1->FireChargingVoltage;
  3193. if (maxCur * 10 <= cur1)
  3194. {
  3195. cur1 = maxCur * 10;
  3196. }
  3197. }
  3198. }
  3199. }
  3200. else
  3201. {
  3202. cur1 = chargingData_1->ConnectorMaxCurrent;
  3203. }
  3204. //LWADD
  3205. if (chargingData_1->deratingByConnOtp.isNeedDerating)
  3206. GetOtpPwrOrCurMethod(chargingData_1, &pow1, &cur1);
  3207. pow2 = chargingData_2->AvailableChargingPower;
  3208. cur2 = chargingData_2->AvailableChargingCurrent;
  3209. vol = chargingData_2->MaximumChargingVoltage;
  3210. if ((chargingData_2->SystemStatus >= SYS_MODE_PREPARING && chargingData_2->SystemStatus <= SYS_MODE_CHARGING) ||
  3211. (chargingData_2->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && chargingData_2->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1))
  3212. {
  3213. GetMaxVolAndCurMethod(chargingData_2->Index, &vol, &cur2);
  3214. GetMaxPowerMethod(chargingData_2->Index, &pow2);
  3215. if (pow2 <= 0)
  3216. cur2 = 0;
  3217. else
  3218. {
  3219. if (chargingData_2->SystemStatus == SYS_MODE_CHARGING &&
  3220. chargingData_2->FireChargingVoltage > 1500)
  3221. {
  3222. float maxCur = 0;
  3223. maxCur = (pow2 * 1000) / chargingData_2->FireChargingVoltage;
  3224. if (maxCur * 10 <= cur2)
  3225. {
  3226. cur2 = maxCur * 10;
  3227. }
  3228. }
  3229. }
  3230. }
  3231. else
  3232. {
  3233. cur2 = chargingData_2->ConnectorMaxCurrent;
  3234. }
  3235. //LWADD
  3236. if (chargingData_2->deratingByConnOtp.isNeedDerating)
  3237. GetOtpPwrOrCurMethod(chargingData_2, &pow2, &cur2);
  3238. if (ShmSmartBoxData->Dynamic4Release[GUN_LEFT].LimitCurCap > 0 &&
  3239. ShmSmartBoxData->Dynamic4Release[GUN_LEFT].LimitCurCap < cur1)
  3240. cur1 = ShmSmartBoxData->Dynamic4Release[GUN_LEFT].LimitCurCap;
  3241. if (ShmSmartBoxData->Dynamic4Release[GUN_LEFT].LimitPwrCap > 0 &&
  3242. ShmSmartBoxData->Dynamic4Release[GUN_LEFT].LimitPwrCap < pow1)
  3243. pow1 = ShmSmartBoxData->Dynamic4Release[GUN_LEFT].LimitPwrCap;
  3244. if (ShmSmartBoxData->Dynamic4Release[GUN_RIGHT].LimitCurCap > 0 &&
  3245. ShmSmartBoxData->Dynamic4Release[GUN_RIGHT].LimitCurCap < cur2)
  3246. cur2 = ShmSmartBoxData->Dynamic4Release[GUN_RIGHT].LimitCurCap;
  3247. if (ShmSmartBoxData->Dynamic4Release[GUN_RIGHT].LimitPwrCap > 0 &&
  3248. ShmSmartBoxData->Dynamic4Release[GUN_RIGHT].LimitPwrCap < pow2)
  3249. pow2 = ShmSmartBoxData->Dynamic4Release[GUN_RIGHT].LimitPwrCap;
  3250. ShmSmartBoxData->Dynamic4Release[GUN_LEFT].LimitCur = cur1;
  3251. ShmSmartBoxData->Dynamic4Release[GUN_LEFT].LimitPwr = pow1;
  3252. ShmSmartBoxData->Dynamic4Release[GUN_RIGHT].LimitCur = cur2;
  3253. ShmSmartBoxData->Dynamic4Release[GUN_RIGHT].LimitPwr = pow2;
  3254. if (ShmDcCommonData->_psuProtocol == _PSU_PROTOCOL_UU)
  3255. {
  3256. if (pow1 > userLimitPwr)
  3257. pow1 = userLimitPwr;
  3258. if (pow2 > userLimitPwr)
  3259. pow2 = userLimitPwr;
  3260. }
  3261. if ((LogInfo[GUN_LEFT][EV_LOG_OUTPUT_CAP_POW] <= pow1 - 5 || LogInfo[GUN_LEFT][EV_LOG_OUTPUT_CAP_POW] >= pow1 + 5) ||
  3262. (LogInfo[GUN_LEFT][EV_LOG_OUTPUT_CAP_CUR] <= cur1 - 5 || LogInfo[GUN_LEFT][EV_LOG_OUTPUT_CAP_CUR] >= cur1 + 5) ||
  3263. (LogInfo[GUN_RIGHT][EV_LOG_OUTPUT_CAP_POW] <= pow2 - 5 || LogInfo[GUN_RIGHT][EV_LOG_OUTPUT_CAP_POW] >= pow2 + 5) ||
  3264. (LogInfo[GUN_RIGHT][EV_LOG_OUTPUT_CAP_CUR] <= cur2 - 5 || LogInfo[GUN_RIGHT][EV_LOG_OUTPUT_CAP_CUR] >= cur2 + 5))
  3265. {
  3266. PRINTF_FUNC("----------------------------------------------------- \n");
  3267. PRINTF_FUNC("To EV (Real) Power_1 = %.1f (kw), Cur_1 = %.1f (A), Power_2 = %.1f (kw), Cur_2 = %.1f (A) \n",
  3268. pow1 / 10, cur1 / 10, pow2 / 10, cur2 / 10);
  3269. PRINTF_FUNC("----------------------------------------------------- \n");
  3270. LogInfo[GUN_LEFT][EV_LOG_OUTPUT_CAP_POW] = pow1;
  3271. LogInfo[GUN_LEFT][EV_LOG_OUTPUT_CAP_CUR] = cur1;
  3272. LogInfo[GUN_RIGHT][EV_LOG_OUTPUT_CAP_POW] = pow2;
  3273. LogInfo[GUN_RIGHT][EV_LOG_OUTPUT_CAP_CUR] = cur2;
  3274. chargingData_1->RealMaxCurrent = cur1;
  3275. chargingData_1->RealMaxPower = pow1;
  3276. if (gun_count == 2)
  3277. {
  3278. chargingData_2->RealMaxCurrent = cur2;
  3279. chargingData_2->RealMaxPower = pow2;
  3280. }
  3281. }
  3282. SetPresentOutputCapacity(pow1, cur1, pow2, cur2);
  3283. }
  3284. void Initialization()
  3285. {
  3286. bool isPass = false;
  3287. while(!isPass)
  3288. {
  3289. isPass = true;
  3290. for (byte _index = 0; _index < gun_count; _index++)
  3291. {
  3292. if (!FindChargingInfoData(_index, &_chargingData[0]))
  3293. {
  3294. DEBUG_ERROR("EvComm (main) : FindChargingInfoData false \n");
  3295. isPass = false;
  3296. break;
  3297. }
  3298. }
  3299. sleep(1);
  3300. }
  3301. GetTimespecFunc(&delayToPrintLogTimeout);
  3302. }
  3303. void GetMaxVolAndCurMethod(byte index, float *vol, float *cur)
  3304. {
  3305. unsigned short configCurrent = ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10;
  3306. if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_BOTH)
  3307. configCurrent /= 2;
  3308. if (configCurrent != 0 && configCurrent < *cur)
  3309. *cur = configCurrent;
  3310. if (_chargingData[index]->ConnectorMaxVoltage != 0 &&
  3311. _chargingData[index]->ConnectorMaxVoltage <= *vol)
  3312. *vol = _chargingData[index]->ConnectorMaxVoltage;
  3313. if (_chargingData[index]->ConnectorMaxCurrent != 0 &&
  3314. _chargingData[index]->ConnectorMaxCurrent <= *cur)
  3315. *cur = _chargingData[index]->ConnectorMaxCurrent;
  3316. _chargingData [index]->CurrentOffered = *cur ;
  3317. if (((_chargingData[index]->SystemStatus >= SYS_MODE_PREPARE_FOR_EVSE && _chargingData[index]->SystemStatus <= SYS_MODE_CHARGING) ||
  3318. (_chargingData[index]->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && _chargingData[index]->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1)) &&
  3319. _chargingData[index]->ChargingProfileCurrent >= 0 &&
  3320. _chargingData[index]->ChargingProfileCurrent <= *cur)
  3321. {
  3322. *cur = _chargingData[index]->ChargingProfileCurrent;
  3323. }
  3324. }
  3325. void GetMaxPowerMethod(byte index, float *pow)
  3326. {
  3327. unsigned short configPower = ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10;
  3328. //LW_OfflinePower
  3329. if (ShmSysConfigAndInfo->SysInfo.OcppConnStatus == NO)
  3330. {
  3331. if ((ShmDcCommonData->_offlinePower > 0 &&
  3332. (configPower * 100 > ShmDcCommonData->_offlinePower)) || configPower == 0) //Unit: W
  3333. {
  3334. configPower = (unsigned short) ShmDcCommonData->_offlinePower / 100; //Unit:0.1kw
  3335. }
  3336. }
  3337. if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_BOTH)
  3338. configPower /= 2;
  3339. if (configPower != 0 && configPower < *pow)
  3340. *pow = configPower;
  3341. if (_chargingData[index]->RealRatingPower != 0 && _chargingData[index]->RealRatingPower <= *pow)
  3342. *pow = _chargingData[index]->RealRatingPower;
  3343. _chargingData [index]->PowerOffered = *pow;
  3344. // 100 = (/ 1000 * 10)
  3345. if (((_chargingData[index]->SystemStatus >= SYS_MODE_PREPARE_FOR_EVSE && _chargingData[index]->SystemStatus <= SYS_MODE_CHARGING) ||
  3346. (_chargingData[index]->SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0 && _chargingData[index]->SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1)) &&
  3347. (_chargingData[index]->ChargingProfilePower / 100) >= 0 &&
  3348. (_chargingData[index]->ChargingProfilePower / 100) <= *pow)
  3349. {
  3350. *pow = (float)(_chargingData[index]->ChargingProfilePower / 100);
  3351. }
  3352. }
  3353. time_t GetRtcInfoForEpoch()
  3354. {
  3355. struct timeb csuTime;
  3356. struct tm *tmCSU;
  3357. struct tm t;
  3358. time_t result;
  3359. ftime(&csuTime);
  3360. tmCSU = localtime(&csuTime.time);
  3361. t.tm_year = tmCSU->tm_year;
  3362. t.tm_mon = tmCSU->tm_mon;
  3363. t.tm_mday = tmCSU->tm_mday;
  3364. t.tm_hour = tmCSU->tm_hour;
  3365. t.tm_min = tmCSU->tm_min;
  3366. t.tm_sec = tmCSU->tm_sec;
  3367. t.tm_isdst = -1;
  3368. result = mktime(&t);
  3369. return result;
  3370. }
  3371. byte GetStopChargingReasonByEvse(byte gunIndex, byte *reason)
  3372. {
  3373. byte result = NO;
  3374. if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == 0x01)
  3375. {
  3376. // 012251
  3377. * (reason + 0) = 0x00;
  3378. * (reason + 1) = 0x01;
  3379. * (reason + 2) = 0x02;
  3380. * (reason + 3) = 0x02;
  3381. * (reason + 4) = 0x05;
  3382. * (reason + 5) = 0x01;
  3383. result = YES;
  3384. }
  3385. else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DoorOpen == 0x01)
  3386. {
  3387. // 012252
  3388. * (reason + 0) = 0x00;
  3389. * (reason + 1) = 0x01;
  3390. * (reason + 2) = 0x02;
  3391. * (reason + 3) = 0x02;
  3392. * (reason + 4) = 0x05;
  3393. * (reason + 5) = 0x02;
  3394. result = YES;
  3395. }
  3396. if (_chargingData[gunIndex]->Type == _Type_Chademo)
  3397. {
  3398. if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaRelayDrivingFault == YES)
  3399. {
  3400. // 011012
  3401. * (reason + 0) = 0x00;
  3402. * (reason + 1) = 0x01;
  3403. * (reason + 2) = 0x01;
  3404. * (reason + 3) = 0x00;
  3405. * (reason + 4) = 0x01;
  3406. * (reason + 5) = 0x02;
  3407. result = YES;
  3408. }
  3409. else if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaUvpFail == YES)
  3410. {
  3411. // 012289
  3412. * (reason + 0) = 0x00;
  3413. * (reason + 1) = 0x01;
  3414. * (reason + 2) = 0x02;
  3415. * (reason + 3) = 0x02;
  3416. * (reason + 4) = 0x08;
  3417. * (reason + 5) = 0x09;
  3418. result = YES;
  3419. }
  3420. else if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaGfdTrip == YES)
  3421. {
  3422. // 012234
  3423. * (reason + 0) = 0x00;
  3424. * (reason + 1) = 0x01;
  3425. * (reason + 2) = 0x02;
  3426. * (reason + 3) = 0x02;
  3427. * (reason + 4) = 0x03;
  3428. * (reason + 5) = 0x04;
  3429. result = YES;
  3430. }
  3431. else if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectOTP == YES)
  3432. {
  3433. // 012229
  3434. * (reason + 0) = 0x00;
  3435. * (reason + 1) = 0x01;
  3436. * (reason + 2) = 0x02;
  3437. * (reason + 3) = 0x02;
  3438. * (reason + 4) = 0x02;
  3439. * (reason + 5) = 0x09;
  3440. result = YES;
  3441. }
  3442. else if (ShmSysConfigAndInfo->SysConfig.PhaseLossPolicy == YES &&
  3443. (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == YES ||
  3444. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == YES ||
  3445. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == YES))
  3446. {
  3447. // 012203-012204-012205
  3448. * (reason + 0) = 0x00;
  3449. * (reason + 1) = 0x01;
  3450. * (reason + 2) = 0x02;
  3451. * (reason + 3) = 0x02;
  3452. * (reason + 4) = 0x00;
  3453. * (reason + 5) = 0x03;
  3454. result = YES;
  3455. }
  3456. }
  3457. else if (_chargingData[gunIndex]->Type == _Type_GB)
  3458. {
  3459. if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTRelayDrivingFault == YES)
  3460. {
  3461. // 012290
  3462. * (reason + 0) = 0x00;
  3463. * (reason + 1) = 0x01;
  3464. * (reason + 2) = 0x02;
  3465. * (reason + 3) = 0x02;
  3466. * (reason + 4) = 0x09;
  3467. * (reason + 5) = 0x00;
  3468. result = YES;
  3469. }
  3470. else if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTUvpFail == YES)
  3471. {
  3472. // 012290
  3473. * (reason + 0) = 0x00;
  3474. * (reason + 1) = 0x01;
  3475. * (reason + 2) = 0x02;
  3476. * (reason + 3) = 0x02;
  3477. * (reason + 4) = 0x09;
  3478. * (reason + 5) = 0x00;
  3479. result = YES;
  3480. }
  3481. else if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTGfdTrip == YES)
  3482. {
  3483. // 012236
  3484. * (reason + 0) = 0x00;
  3485. * (reason + 1) = 0x01;
  3486. * (reason + 2) = 0x02;
  3487. * (reason + 3) = 0x02;
  3488. * (reason + 4) = 0x03;
  3489. * (reason + 5) = 0x06;
  3490. result = YES;
  3491. }
  3492. }
  3493. else if (_chargingData[gunIndex]->Type == _Type_CCS)
  3494. {
  3495. if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSRelayDrivingFault == YES)
  3496. {
  3497. // 011014
  3498. * (reason + 0) = 0x00;
  3499. * (reason + 1) = 0x01;
  3500. * (reason + 2) = 0x01;
  3501. * (reason + 3) = 0x00;
  3502. * (reason + 4) = 0x01;
  3503. * (reason + 5) = 0x04;
  3504. result = YES;
  3505. }
  3506. else if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSUvpFail == YES)
  3507. {
  3508. // 012288
  3509. * (reason + 0) = 0x00;
  3510. * (reason + 1) = 0x01;
  3511. * (reason + 2) = 0x02;
  3512. * (reason + 3) = 0x02;
  3513. * (reason + 4) = 0x08;
  3514. * (reason + 5) = 0x08;
  3515. result = YES;
  3516. }
  3517. else if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSGfdTrip == YES)
  3518. {
  3519. // 012235
  3520. * (reason + 0) = 0x00;
  3521. * (reason + 1) = 0x01;
  3522. * (reason + 2) = 0x02;
  3523. * (reason + 3) = 0x02;
  3524. * (reason + 4) = 0x03;
  3525. * (reason + 5) = 0x05;
  3526. result = YES;
  3527. }
  3528. }
  3529. return result;
  3530. }
  3531. void SendCommunicationOnly(byte index)
  3532. {
  3533. byte targetID = _chargingData[index]->Evboard_id;
  3534. if (gun_count == 1 &&
  3535. _chargingData[index]->Type == _Type_CCS &&
  3536. ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0)
  3537. {
  3538. targetID += 1;
  3539. }
  3540. SetChargingPermission(index, COMMUNICATION,
  3541. _chargingData[index]->AvailableChargingPower,
  3542. 0,
  3543. 0,
  3544. targetID);
  3545. }
  3546. void SendStopOnly(byte index)
  3547. {
  3548. byte targetID = _chargingData[index]->Evboard_id;
  3549. if (gun_count == 1 &&
  3550. _chargingData[index]->Type == _Type_CCS &&
  3551. ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0)
  3552. {
  3553. targetID += 1;
  3554. }
  3555. SetChargingPermission(index, STOP,
  3556. _chargingData[index]->AvailableChargingPower,
  3557. 0,
  3558. 0,
  3559. targetID);
  3560. }
  3561. void InitialConnectorStatus(byte index)
  3562. {
  3563. SetChargingPermission(index, INITIALIZATION,
  3564. 0,
  3565. 0,
  3566. 0,
  3567. _chargingData[index]->Evboard_id);
  3568. }
  3569. void SetDertingInfo(byte _index)
  3570. {
  3571. switch(_chargingData[_index]->ModelType)
  3572. {
  3573. case 'S':
  3574. {
  3575. _chargingData [_index]->deratingByConnOtp.isNeedDerating = YES;
  3576. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [0] = 0;
  3577. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [1] = 0;
  3578. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [2] = 0;
  3579. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [3] = 0;
  3580. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [4] = 0;
  3581. _chargingData [_index]->deratingByConnOtp.deratingTargetCurrent [0] = 2000;
  3582. _chargingData [_index]->deratingByConnOtp.deratingTargetCurrent [1] = 1250;
  3583. _chargingData [_index]->deratingByConnOtp.deratingTargetCurrent [2] = 1250;
  3584. _chargingData [_index]->deratingByConnOtp.deratingTargetCurrent [3] = 0;
  3585. _chargingData [_index]->deratingByConnOtp.deratingTargetCurrent [4] = 0;
  3586. _chargingData [_index]->deratingByConnOtp.deratingIndex = 0;
  3587. }
  3588. break;
  3589. case 'K':
  3590. {
  3591. _chargingData [_index]->deratingByConnOtp.isNeedDerating = YES;
  3592. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [0] = 1;
  3593. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [1] = 0.8;
  3594. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [2] = 0.8;
  3595. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [3] = 0;
  3596. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [4] = 0;
  3597. _chargingData [_index]->deratingByConnOtp.deratingIndex = 0;
  3598. }
  3599. break;
  3600. case 'T' :
  3601. case 'D' :
  3602. {
  3603. _chargingData [_index]->deratingByConnOtp.isNeedDerating = YES;
  3604. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [0] = 0;
  3605. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [1] = 0;
  3606. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [2] = 0;
  3607. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [3] = 0;
  3608. _chargingData [_index]->deratingByConnOtp.deratingTargetRate [4] = 0;
  3609. _chargingData [_index]->deratingByConnOtp.deratingTargetCurrent [0] = 5000;
  3610. _chargingData [_index]->deratingByConnOtp.deratingTargetCurrent [1] = 3000;
  3611. _chargingData [_index]->deratingByConnOtp.deratingTargetCurrent [2] = 1000;
  3612. _chargingData [_index]->deratingByConnOtp.deratingTargetCurrent [3] = 0;
  3613. _chargingData [_index]->deratingByConnOtp.deratingTargetCurrent [4] = 0;
  3614. _chargingData [_index]->deratingByConnOtp.deratingIndex = 0;
  3615. }
  3616. break;
  3617. default :
  3618. {
  3619. _chargingData [_index]->deratingByConnOtp.isNeedDerating = NO;
  3620. }
  3621. break;
  3622. }
  3623. if (_chargingData [_index]->deratingByConnOtp.isNeedDerating)
  3624. {
  3625. PRINTF_FUNC("------------Derating info (OTP)----------- \n" );
  3626. PRINTF_FUNC(" Gun-%d (%c) \n", _index, _chargingData[_index]->ModelType);
  3627. if (_chargingData [_index]->deratingByConnOtp.deratingTargetRate [0] != 0)
  3628. {
  3629. for(byte count = 0;
  3630. count < ARRAY_SIZE(_chargingData [_index]->deratingByConnOtp.deratingTargetRate);
  3631. count++)
  3632. {
  3633. if (_chargingData [_index]->deratingByConnOtp.deratingTargetRate [count] != 0)
  3634. {
  3635. PRINTF_FUNC(" (Pwr) count = %d, valut = %.1f \n", count,
  3636. _chargingData [_index]->deratingByConnOtp.deratingTargetRate[count]);
  3637. }
  3638. else
  3639. break;
  3640. }
  3641. }
  3642. else if (_chargingData [_index]->deratingByConnOtp.deratingTargetCurrent [0] != 0)
  3643. {
  3644. for(byte count = 0;
  3645. count < ARRAY_SIZE(_chargingData [_index]->deratingByConnOtp.deratingTargetCurrent);
  3646. count++)
  3647. {
  3648. if (_chargingData [_index]->deratingByConnOtp.deratingTargetCurrent [count] != 0)
  3649. {
  3650. PRINTF_FUNC(" (Cur) count = %d, valut = %.1f \n", count,
  3651. _chargingData [_index]->deratingByConnOtp.deratingTargetCurrent[count]);
  3652. }
  3653. else
  3654. break;
  3655. }
  3656. }
  3657. PRINTF_FUNC("------------------------------------ \n" );
  3658. }
  3659. }
  3660. void FormatVoltageAndCurrent()
  3661. {
  3662. char isLowCur = 0x00;
  3663. char EvsePower[2];
  3664. EvsePower[2] = '\0';
  3665. if (strlen((char *) ShmSysConfigAndInfo->SysConfig.ModelName) >= 6)
  3666. {
  3667. strncpy(EvsePower, (char *)(ShmSysConfigAndInfo->SysConfig.ModelName + 4), 2);
  3668. if (strcmp(EvsePower, "30") == EQUAL)
  3669. {
  3670. isLowCur = 0x00;
  3671. }
  3672. else if (strcmp(EvsePower, "60") == EQUAL ||
  3673. strcmp(EvsePower, "50") == EQUAL)
  3674. {
  3675. isLowCur = 0x01;
  3676. // 日規 - UU 模塊 => 限制 50KW 輸出
  3677. userLimitPwr = 500;
  3678. }
  3679. else
  3680. {
  3681. // 60KW 以上的系統
  3682. isLowCur = 0x02;
  3683. }
  3684. }
  3685. for (byte _index = 0; _index < gun_count; _index++)
  3686. {
  3687. if (_chargingData[_index]->Type == _Type_Chademo)
  3688. {
  3689. if (ShmDcCommonData->chargerType == CHARGER_TYPE_STANDARD)
  3690. _chargingData[_index]->ConnectorMaxVoltage = Chademo_Standard;
  3691. else
  3692. _chargingData[_index]->ConnectorMaxVoltage = Chademo_Simple;
  3693. }
  3694. else if (_chargingData[_index]->Type == _Type_CCS)
  3695. {
  3696. if (ShmDcCommonData->chargerType == CHARGER_TYPE_STANDARD)
  3697. _chargingData[_index]->ConnectorMaxVoltage = CCS_Standard;
  3698. else
  3699. _chargingData[_index]->ConnectorMaxVoltage = CCS_Simple;
  3700. }
  3701. else if (_chargingData[_index]->Type == _Type_GB)
  3702. {
  3703. if (ShmDcCommonData->chargerType == CHARGER_TYPE_STANDARD)
  3704. _chargingData[_index]->ConnectorMaxVoltage = GB_Standard;
  3705. else
  3706. _chargingData[_index]->ConnectorMaxVoltage = GB_Simple;
  3707. }
  3708. if (isLowCur == 0x00)
  3709. {
  3710. if (_chargingData[_index]->Type == _Type_Chademo)
  3711. {
  3712. if (_chargingData[_index]->ModelType == 'L')
  3713. _chargingData[_index]->ConnectorMaxCurrent = 800;
  3714. else
  3715. _chargingData[_index]->ConnectorMaxCurrent = 600;
  3716. }
  3717. else if (_chargingData[_index]->Type == _Type_CCS)
  3718. {
  3719. if (_chargingData[_index]->ModelType == 'M' ||
  3720. _chargingData[_index]->ModelType == 'N')
  3721. _chargingData[_index]->ConnectorMaxCurrent = 800;
  3722. else
  3723. _chargingData[_index]->ConnectorMaxCurrent = 600;
  3724. }
  3725. else if (_chargingData[_index]->Type == _Type_GB)
  3726. {
  3727. _chargingData[_index]->ConnectorMaxCurrent = 800;
  3728. }
  3729. }
  3730. else if (isLowCur == 0x01)
  3731. {
  3732. if (_chargingData[_index]->Type == _Type_Chademo)
  3733. {
  3734. if (_chargingData[_index]->ModelType == 'J' &&
  3735. ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_JARI)
  3736. _chargingData[_index]->ConnectorMaxCurrent = 1250;
  3737. else
  3738. _chargingData[_index]->ConnectorMaxCurrent = 1200;
  3739. }
  3740. else if (_chargingData[_index]->Type == _Type_CCS)
  3741. {
  3742. if (_chargingData [_index]->ModelType == 'Y' ||
  3743. _chargingData [_index]->ModelType == 'Z')
  3744. _chargingData[_index]->ConnectorMaxCurrent = 1500;
  3745. else
  3746. _chargingData[_index]->ConnectorMaxCurrent = 1200;
  3747. }
  3748. else if (_chargingData[_index]->Type == _Type_GB)
  3749. {
  3750. _chargingData[_index]->ConnectorMaxCurrent = 1200;
  3751. }
  3752. }
  3753. else
  3754. {
  3755. if (_chargingData[_index]->Type == _Type_Chademo)
  3756. {
  3757. if (_chargingData[_index]->ModelType == 'K' ||
  3758. _chargingData[_index]->ModelType == 'S')
  3759. _chargingData[_index]->ConnectorMaxCurrent = 2000;
  3760. else if (_chargingData[_index]->ModelType == 'J' &&
  3761. ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_JARI)
  3762. _chargingData[_index]->ConnectorMaxCurrent = 1250;
  3763. else
  3764. _chargingData[_index]->ConnectorMaxCurrent = 1200;
  3765. }
  3766. else if (_chargingData[_index]->Type == _Type_CCS)
  3767. {
  3768. if (_chargingData [_index]->ModelType == 'V' ||
  3769. _chargingData [_index]->ModelType == 'F')
  3770. _chargingData[_index]->ConnectorMaxCurrent = 5000;
  3771. if (_chargingData[_index]->ModelType == 'T' ||
  3772. _chargingData[_index]->ModelType == 'D')
  3773. _chargingData[_index]->ConnectorMaxCurrent = 5000;
  3774. else if (_chargingData[_index]->ModelType == 'R')
  3775. _chargingData[_index]->ConnectorMaxCurrent = 2500;
  3776. else
  3777. _chargingData[_index]->ConnectorMaxCurrent = 2000;
  3778. }
  3779. else if (_chargingData[_index]->Type == _Type_GB)
  3780. {
  3781. _chargingData[_index]->ConnectorMaxCurrent = 2500;
  3782. }
  3783. }
  3784. SetDertingInfo(_index);
  3785. }
  3786. // 簡易版 (180), 會有最小輸出電流限制
  3787. if (ShmDcCommonData->chargerType == CHARGER_TYPE_SIMPLE &&
  3788. strcmp(EvsePower, "18") == EQUAL)
  3789. {
  3790. // 簡易版且180KW -> 限制最小輸出電流 50A
  3791. ShmDcCommonData->minOutputCur = 50;
  3792. }
  3793. }
  3794. // 如果是使用 Meter 計算的話
  3795. void CalOutputPowerAndEnergy(int _index)
  3796. {
  3797. if(ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
  3798. ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L')
  3799. {
  3800. // AC Meter
  3801. //printf("(%d), totalChargingValue = %f \n", _index, ShmCsuMeterData->_meter[_index]._curTotalCharging / 100);
  3802. float totalChargingValue = ShmCsuMeterData->_meter[_index]._curTotalCharging / 100;
  3803. if (totalChargingValue > _chargingData[_index]->PresentChargedEnergy)
  3804. {
  3805. ShmDcCommonData->energy_time_period[_index][ShmDcCommonData->_hour_index] += totalChargingValue - _chargingData[_index]->PresentChargedEnergy;
  3806. _chargingData[_index]->presentChargedEnergyPeriod[ShmDcCommonData->_hour_index] += totalChargingValue - _chargingData[_index]->PresentChargedEnergy;
  3807. }
  3808. _chargingData[_index]->PresentChargedEnergy = totalChargingValue;
  3809. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
  3810. {
  3811. if(strcmp((char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL, "") == EQUAL ||
  3812. strcmp((char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId, "") == EQUAL)
  3813. _chargingData[_index]->ChargingFee = totalChargingValue * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
  3814. }
  3815. }
  3816. else if (ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'P')
  3817. {
  3818. // DC Meter
  3819. if (ShmCsuMeterData->_meter[_index].curMeterValue == 0)
  3820. ShmCsuMeterData->_meter[_index].curMeterValue = ShmSysConfigAndInfo->SysInfo.DcMeterInfo[_index].totlizeImportEnergy;
  3821. else
  3822. {
  3823. if (ShmSysConfigAndInfo->SysInfo.DcMeterInfo[_index].totlizeImportEnergy > ShmCsuMeterData->_meter[_index].curMeterValue)
  3824. {
  3825. ShmCsuMeterData->_meter[_index]._curTotalCharging += ShmSysConfigAndInfo->SysInfo.DcMeterInfo[_index].totlizeImportEnergy - ShmCsuMeterData->_meter[_index].curMeterValue;
  3826. float totalChargingValue = ShmCsuMeterData->_meter[_index]._curTotalCharging;
  3827. if (totalChargingValue > _chargingData[_index]->PresentChargedEnergy)
  3828. {
  3829. ShmDcCommonData->energy_time_period[_index][ShmDcCommonData->_hour_index] += totalChargingValue - _chargingData[_index]->PresentChargedEnergy;
  3830. _chargingData[_index]->presentChargedEnergyPeriod[ShmDcCommonData->_hour_index] += totalChargingValue - _chargingData[_index]->PresentChargedEnergy;
  3831. }
  3832. _chargingData[_index]->PresentChargedEnergy = totalChargingValue;
  3833. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
  3834. {
  3835. if(strcmp((char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL, "") == EQUAL ||
  3836. strcmp((char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId, "") == EQUAL)
  3837. _chargingData[_index]->ChargingFee = totalChargingValue * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
  3838. }
  3839. ShmCsuMeterData->_meter[_index].curMeterValue = ShmSysConfigAndInfo->SysInfo.DcMeterInfo[_index].totlizeImportEnergy;
  3840. }
  3841. }
  3842. }
  3843. else
  3844. {
  3845. if (chargingTime[_index] == 0 ||
  3846. chargingTime[_index] > _chargingData[_index]->PresentChargedDuration)
  3847. {
  3848. chargingTime[_index] = _chargingData[_index]->PresentChargedDuration;
  3849. }
  3850. else
  3851. {
  3852. int passTime = _chargingData[_index]->PresentChargedDuration - chargingTime[_index];
  3853. if (passTime > 0)
  3854. {
  3855. float changingPow = (_chargingData[_index]->PresentChargingPower) * passTime / 3600;
  3856. if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
  3857. {
  3858. ShmDcCommonData->energy_time_period[_index][ShmDcCommonData->_hour_index] += changingPow;
  3859. _chargingData[_index]->presentChargedEnergyPeriod[ShmDcCommonData->_hour_index] += changingPow;
  3860. if(strcmp((char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL, "") == EQUAL ||
  3861. strcmp((char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId, "") == EQUAL)
  3862. _chargingData[_index]->ChargingFee += changingPow * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
  3863. }
  3864. _chargingData[_index]->PowerConsumption += changingPow;
  3865. _chargingData[_index]->PresentChargedEnergy += changingPow;
  3866. chargingTime[_index] = _chargingData[_index]->PresentChargedDuration;
  3867. }
  3868. }
  3869. }
  3870. }
  3871. void OfferCurrentAndPowerRecord(byte _index)
  3872. {
  3873. if (_index == 1 && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf)
  3874. {
  3875. _chargingData [GUN_RIGHT]->PowerOffered = _chargingData [GUN_LEFT]->PowerOffered;
  3876. _chargingData [GUN_RIGHT]->CurrentOffered = _chargingData [GUN_LEFT]->CurrentOffered;
  3877. }
  3878. }
  3879. bool IsTimeToPrintLog()
  3880. {
  3881. bool result = false;
  3882. int _timebuf = GetTimeoutValue(&delayToPrintLogTimeout);
  3883. if (_timebuf < 0)
  3884. GetTimespecFunc (&delayToPrintLogTimeout);
  3885. else
  3886. {
  3887. if (_timebuf >= 5)
  3888. result = true;
  3889. }
  3890. return result;
  3891. }
  3892. void InitTimeToPrintLog()
  3893. {
  3894. GetTimespecFunc (&delayToPrintLogTimeout);
  3895. }
  3896. void AuthorizeByCcid(byte _index)
  3897. {
  3898. if (_chargingData[_index]->Type == _Type_CCS &&
  3899. _chargingData [_index]->IsAvailable &&
  3900. ShmDcCommonData->enObtainAuthorizbyCCID &&
  3901. strcmp ( (char *) _chargingData[_index]->StartUserId, "") == EQUAL)
  3902. {
  3903. if (_chargingData [_index]->ConnectorPlugIn)
  3904. {
  3905. byte targetID = _chargingData [_index]->Evboard_id;
  3906. if (gun_count == 1 &&
  3907. _chargingData [_index]->Type == _Type_CCS &&
  3908. ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0)
  3909. {
  3910. targetID += 1;
  3911. }
  3912. if (ShmDcCommonData->_authWithCcidFlag [_index] == _CCID_NONE)
  3913. {
  3914. if (printLogRecord)
  3915. PRINTF_FUNC ( "index = %d, Wait for CCID. \n", _index );
  3916. if (strcmp ( (char *) _chargingData [_index]->EVCCID, "" ) == EQUAL)
  3917. {
  3918. SendCommunicationOnly ( _index );
  3919. GetEvccIdReq ( _index, targetID);
  3920. }
  3921. else
  3922. ShmDcCommonData->_authWithCcidFlag [_index] = _CCID_GET;
  3923. }
  3924. else if (ShmDcCommonData->_authWithCcidFlag [_index] == _CCID_AUTHFAIL)
  3925. {
  3926. SendStopOnly ( _index );
  3927. strcpy ( (char *) _chargingData [_index]->EVCCID, "" );
  3928. }
  3929. }
  3930. else
  3931. {
  3932. SendStopOnly ( _index );
  3933. }
  3934. }
  3935. }
  3936. void SampleOutputVoltage()
  3937. {
  3938. for (byte group = 0; group < ShmPsuData->GroupCount; group++)
  3939. {
  3940. if (ShmPsuData->PsuGroup[group].GroupPresentOutputVoltage >= VOUT_MIN_VOLTAGE)
  3941. {
  3942. ShmDcCommonData->_outputVoltageSapmle[group][sampleVolIndex[group]] = ShmPsuData->PsuGroup[group].GroupPresentOutputVoltage;
  3943. sampleVolIndex[group]++;
  3944. if (sampleVolIndex[group] >= VOLTAGE_SAMPLE_COUNT)
  3945. sampleVolIndex[group] = 0;
  3946. }
  3947. }
  3948. }
  3949. int main(int argc, char *argv[])
  3950. {
  3951. if(InitShareMemory() == FAIL)
  3952. {
  3953. #ifdef SystemLogMessage
  3954. DEBUG_ERROR("InitShareMemory NG\n");
  3955. #endif
  3956. if(ShmStatusCodeData != NULL)
  3957. {
  3958. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  3959. }
  3960. sleep(5);
  3961. return 0;
  3962. }
  3963. gun_count = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
  3964. Initialization();
  3965. // 根據輸出能量與槍別給予當前最大耐壓耐流
  3966. FormatVoltageAndCurrent();
  3967. CanFd = InitCanBus();
  3968. CANReceiver();
  3969. byte priorityLow = 1;
  3970. time_t rtc = GetRtcInfoForEpoch();
  3971. for (byte _index = 0; _index < gun_count; _index++)
  3972. {
  3973. if (_chargingData[_index]->Type == _Type_Chademo)
  3974. {
  3975. PRINTF_FUNC("Conn %d (Chademo), MaxVol = %.1f (V), MaxCur = %.1f (A) \n",
  3976. _index,
  3977. _chargingData[_index]->ConnectorMaxVoltage / 10,
  3978. _chargingData[_index]->ConnectorMaxCurrent / 10);
  3979. }
  3980. else if (_chargingData[_index]->Type == _Type_CCS)
  3981. {
  3982. PRINTF_FUNC("Conn %d (CCS), MaxVol = %.1f (V), MaxCur = %.1f (A) \n",
  3983. _index,
  3984. _chargingData[_index]->ConnectorMaxVoltage / 10,
  3985. _chargingData[_index]->ConnectorMaxCurrent / 10);
  3986. }
  3987. else if (_chargingData[_index]->Type == _Type_GB)
  3988. {
  3989. PRINTF_FUNC("Conn %d (GBT), MaxVol = %.1f (V), MaxCur = %.1f (A) \n",
  3990. _index,
  3991. _chargingData[_index]->ConnectorMaxVoltage / 10,
  3992. _chargingData[_index]->ConnectorMaxCurrent / 10);
  3993. }
  3994. }
  3995. int _timeBuf = 0;
  3996. while(CanFd)
  3997. {
  3998. printLogRecord = IsTimeToPrintLog();
  3999. for(byte _index = 0; _index < gun_count; _index++)
  4000. {
  4001. byte targetID = _chargingData[_index]->Evboard_id;
  4002. if (gun_count == 1 &&
  4003. _chargingData[_index]->Type == _Type_CCS &&
  4004. ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0)
  4005. {
  4006. targetID += 1;
  4007. }
  4008. if (priorityLow == 1)
  4009. {
  4010. // 優先權較低 - 只要有回應即不會再詢問
  4011. if (_chargingData[_index]->Type == _Type_Chademo)
  4012. {
  4013. if (ShmCHAdeMOData->evse[_chargingData[_index]->type_index].SelfTest_Comp != PASS)
  4014. {
  4015. if (rtcChkCount == 0)
  4016. SyncRtcInfo(_index, _chargingData[_index]->Evboard_id, (int)rtc);
  4017. GetFirmwareVersion(_index, _chargingData[_index]->Evboard_id);
  4018. }
  4019. if (ShmDcCommonData->evBoardResetFlag)
  4020. InitialConnectorStatus(_index);
  4021. }
  4022. else if (_chargingData[_index]->Type == _Type_GB)
  4023. {
  4024. if (ShmGBTData->evse[_chargingData[_index]->type_index].SelfTest_Comp != PASS)
  4025. {
  4026. if (rtcChkCount == 0)
  4027. SyncRtcInfo(_index, _chargingData[_index]->Evboard_id, (int)rtc);
  4028. GetFirmwareVersion(_index, _chargingData[_index]->Evboard_id);
  4029. }
  4030. if (ShmDcCommonData->evBoardResetFlag)
  4031. InitialConnectorStatus(_index);
  4032. }
  4033. else if (_chargingData[_index]->Type == _Type_CCS)
  4034. {
  4035. if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121 &&
  4036. ShmCcsData->V2GMessage_DIN70121[_chargingData[_index]->type_index].SelfTest_Comp != PASS)
  4037. {
  4038. if (rtcChkCount == 0)
  4039. SyncRtcInfo(_index, targetID, (int)rtc);
  4040. GetFirmwareVersion(_index, targetID);
  4041. SetConnectInfo(ShmDcCommonData->CcsTypeSaved[_index], targetID);
  4042. }
  4043. }
  4044. if (rtcChkCount >= 2)
  4045. rtcChkCount = 0;
  4046. else
  4047. rtcChkCount++;
  4048. // 固定要取得的資訊 : 1.槍鎖狀態, 2."Connector 1" 溫度, 3."Connector 2" 溫度, 4.Pilot Voltage
  4049. //PRINTF_FUNC("GetMiscellaneousInfo. index = %d, Eid = %d \n", _index, _chargingData[_index]->Evboard_id);
  4050. GetMiscellaneousInfo(_index,
  4051. _chargingData[_index]->RelayK1K2Status,
  4052. _chargingData[_index]->PresentChargedEnergy,
  4053. (_chargingData[_index]->PresentChargingVoltage * 10),
  4054. targetID);
  4055. OfferCurrentAndPowerRecord(_index);
  4056. SampleOutputVoltage();
  4057. }
  4058. switch (_chargingData[_index]->SystemStatus)
  4059. {
  4060. case SYS_MODE_IDLE:
  4061. case SYS_MODE_RESERVATION:
  4062. if (_chargingData[_index]->Type == _Type_Chademo)
  4063. {
  4064. ClearAbnormalStatus_Chademo(_index);
  4065. if (ShmSysConfigAndInfo->SysInfo.PageIndex == _LCM_WAIT_FOR_PLUG ||
  4066. ShmDcCommonData->_cha_try_communication[_index].try2CommunicationFlag ||
  4067. (ShmDcCommonData->TpcDetectFunction == YES &&
  4068. ShmDcCommonData->_tpcPlugDetectState == _TPC_PLUG_DETECT_STATUS_WAIT))//LW_tpc plug detect
  4069. {
  4070. if (!chkChademoPermission[_index])
  4071. {
  4072. chkChademoPermission[_index] = true;
  4073. GetTimespecFunc(&_chk_chademo_permission_timeout[_index]);
  4074. SendStopOnly(_index);
  4075. chkChademoPermissionSend[_index] = NO;
  4076. }
  4077. else
  4078. {
  4079. _timeBuf = GetTimeoutValue(&_chk_chademo_permission_timeout[_index]);
  4080. if (_timeBuf < 0)
  4081. GetTimespecFunc(&_chk_chademo_permission_timeout[_index]);
  4082. else
  4083. {
  4084. if (_timeBuf > 2)
  4085. {
  4086. if (chkChademoPermissionSend[_index] == NO)
  4087. {
  4088. chkChademoPermissionSend[_index] = YES;
  4089. SendCommunicationOnly(_index);
  4090. }
  4091. if (_timeBuf > 10)
  4092. {
  4093. chkChademoPermissionSend[_index] = NO;
  4094. GetTimespecFunc(&_chk_chademo_permission_timeout[_index]);
  4095. }
  4096. }
  4097. }
  4098. }
  4099. }
  4100. else if (chkChademoPermission[_index])
  4101. {
  4102. chkChademoPermission[_index] = false;
  4103. //SendStopOnly(_index);
  4104. }
  4105. if (ShmDcCommonData->ConnectErrList[_index].GunBits.ChaConnectOTP == NO)
  4106. _chargingData[_index]->StopChargeFlag = NO;
  4107. }
  4108. else if (_chargingData[_index]->Type == _Type_GB)
  4109. {
  4110. ClearAbnormalStatus_GB(_index);
  4111. if (ShmDcCommonData->ConnectErrList[_index].GunBits.GBTConnectOTP == NO)
  4112. _chargingData[_index]->StopChargeFlag = NO;
  4113. }
  4114. else if (_chargingData[_index]->Type == _Type_CCS)
  4115. {
  4116. ClearAbnormalStatus_CCS(_index);
  4117. if (ShmDcCommonData->ConnectErrList[_index].GunBits.CCSConnectOTP == NO)
  4118. _chargingData[_index]->StopChargeFlag = NO;
  4119. }
  4120. if (priorityLow == 1 || printLogRecord)
  4121. {
  4122. _chargingData[_index]->PresentChargedEnergy = 0;
  4123. _chargingData[_index]->PresentChargingPower = 0;
  4124. _chargingData[_index]->GroundFaultStatus = GFD_WAIT;
  4125. _chargingData[_index]->RealRatingPower = 0;
  4126. _chargingData[_index]->NormalStopChargeFlag = NO;
  4127. _chargingData[_index]->ChargingFee = 0.0;
  4128. _chargingData[_index]->EvBatterySoc = 0;
  4129. _chargingData[_index]->EvBatteryStartSoc = 0;
  4130. _chargingData[_index]->EvBatteryMaxVoltage = 0;
  4131. _chargingData[_index]->ChargingProfilePower = -1;
  4132. _chargingData[_index]->ChargingProfileCurrent = -1;
  4133. curAllowCount[_index] = 0;
  4134. curTargetCur[_index] = 0;
  4135. if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_NORMAL)
  4136. {
  4137. _chargingData[_index]->PresentChargingVoltage = 0;
  4138. _chargingData[_index]->PresentChargingCurrent = 0;
  4139. }
  4140. chargingTime[_index] = 0;
  4141. SendErrorCount[_index] = 0;
  4142. // 使用 Meter 狀況
  4143. if(ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'M' ||
  4144. ShmSysConfigAndInfo->SysConfig.ModelName[3] == 'L')
  4145. {
  4146. if (ShmCsuMeterData->_meter[_index].isCalculation == NO)
  4147. {
  4148. if (ShmCsuMeterData->_meter[_index].curMeterValue != 0 ||
  4149. ShmCsuMeterData->_meter[_index]._chargingValue != 0 ||
  4150. ShmCsuMeterData->_meter[_index]._curTotalCharging != 0 )
  4151. {
  4152. ShmCsuMeterData->_meter[_index].curMeterValue = 0;
  4153. ShmCsuMeterData->_meter[_index]._chargingValue = 0;
  4154. ShmCsuMeterData->_meter[_index]._curTotalCharging = 0;
  4155. }
  4156. }
  4157. }
  4158. LogInfo[_index][EV_LOG_EVSE_MAX_VOL] = 0;
  4159. LogInfo[_index][EV_LOG_EVSE_MAX_CUR] = 0;
  4160. LogInfo[_index][EV_LOG_MAX_BATT_VOL] = 0;
  4161. LogInfo[_index][EV_LOG_REAL_CAP_POW] = 0;
  4162. LogInfo[_index][EV_LOG_SOC] = 0;
  4163. if (gun_count == 1)
  4164. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_LEFT]);
  4165. else if (gun_count == 2)
  4166. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_RIGHT]);
  4167. GetOutputReq(_index, targetID);
  4168. }
  4169. break;
  4170. case SYS_MODE_PREPARING:
  4171. {
  4172. chkChademoPermission[_index] = false;
  4173. // 設定當前輸出
  4174. if (gun_count == 1)
  4175. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_LEFT]);
  4176. else if (gun_count == 2)
  4177. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_RIGHT]);
  4178. }
  4179. break;
  4180. case SYS_MODE_PREPARE_FOR_EV:
  4181. {
  4182. AuthorizeByCcid(_index);
  4183. if (ShmDcCommonData->startTransactionFlag[_index] == START_TRANSATION_STATUS_WAIT)
  4184. continue;
  4185. if (_chargingData[_index]->Type == _Type_CCS)
  4186. GetEvccIdReq(_index, targetID);
  4187. // 開始確認車端是否同意開始充電 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
  4188. GetOutputReq(_index, targetID);
  4189. // 設定當前輸出
  4190. if (gun_count == 1)
  4191. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_LEFT]);
  4192. else if (gun_count == 2)
  4193. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_RIGHT]);
  4194. if (priorityLow == 1)
  4195. {
  4196. float maxVol, maxCur;
  4197. // 樁端輸出能力
  4198. maxVol = _chargingData[_index]->MaximumChargingVoltage;
  4199. maxCur = _chargingData[_index]->AvailableChargingCurrent;
  4200. GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
  4201. if (LogInfo[_index][EV_LOG_EVSE_MAX_VOL] != maxVol ||
  4202. LogInfo[_index][EV_LOG_EVSE_MAX_CUR] != ShmPsuData->SystemAvailableCurrent)
  4203. {
  4204. LogInfo[_index][EV_LOG_EVSE_MAX_VOL] = maxVol;
  4205. LogInfo[_index][EV_LOG_EVSE_MAX_CUR] = ShmPsuData->SystemAvailableCurrent;
  4206. PRINTF_FUNC("To EV_%d Max_Vol = %.1f, Cap_Cur = %d (A), Cap_Pow = %d (KW) \n",
  4207. _index, maxVol / 10, ShmPsuData->SystemAvailableCurrent / 10, ShmPsuData->SystemAvailablePower / 10);
  4208. }
  4209. _chargingData[_index]->RealMaxVoltage = maxVol;
  4210. SetChargingPermission ( _index, START,
  4211. ShmPsuData->SystemAvailablePower,
  4212. ShmPsuData->SystemAvailableCurrent,
  4213. maxVol, targetID);
  4214. // 取得車端電池資訊 : 1.AC or DC ? 2.Total battery cap, 3.Max battery vol, 4.Max battery cur
  4215. GetEvBatteryInfo(_index, targetID);
  4216. }
  4217. GetTimespecFunc(&_chk_ratingPower_timeout[_index]);
  4218. }
  4219. break;
  4220. case SYS_MODE_PREPARE_FOR_EVSE:
  4221. case SYS_MODE_CCS_PRECHARGE_STEP0:
  4222. case SYS_MODE_CCS_PRECHARGE_STEP1:
  4223. {
  4224. // 開始確認車端是否同意開始充電
  4225. GetOutputReq(_index, targetID);
  4226. // 設定當前輸出
  4227. if (gun_count == 1)
  4228. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_LEFT]);
  4229. else if (gun_count == 2)
  4230. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_RIGHT]);
  4231. if (priorityLow % 5 == 1)
  4232. {
  4233. if (_chargingData[_index]->Type == _Type_CCS)
  4234. GetEvccIdReq(_index, targetID);
  4235. // 取得車端電池資訊 : 1.AC or DC ? 2.Total battery cap, 3.Max battery vol, 4.Max battery cur
  4236. GetEvBatteryInfo(_index, targetID);
  4237. // 樁端輸出能力改變
  4238. if (gun_count == 1)
  4239. SetPresentChargingOutputCap(_chargingData[GUN_LEFT], _chargingData[GUN_LEFT]);
  4240. else if (gun_count == 2)
  4241. SetPresentChargingOutputCap(_chargingData[GUN_LEFT], _chargingData[GUN_RIGHT]);
  4242. }
  4243. if (LogInfo[_index][EV_LOG_MAX_BATT_VOL] != _chargingData[_index]->EvBatteryMaxVoltage)
  4244. {
  4245. LogInfo[_index][EV_LOG_MAX_BATT_VOL] = _chargingData[_index]->EvBatteryMaxVoltage;
  4246. PRINTF_FUNC("index = %d, Ev Maximum Battery Voltage = %f \n", _index, _chargingData[_index]->EvBatteryMaxVoltage);
  4247. }
  4248. if (LogInfo[_index][EV_LOG_SOC] != _chargingData[_index]->EvBatterySoc)
  4249. {
  4250. LogInfo[_index][EV_LOG_SOC] = _chargingData[_index]->EvBatterySoc;
  4251. PRINTF_FUNC("index = %d, SOC = %d \n", _index, _chargingData[_index]->EvBatterySoc);
  4252. }
  4253. // 持續通知 Isolation 測試狀態
  4254. if (priorityLow == 1)
  4255. {
  4256. // 拉 500 V 如果在一秒鐘內 GFD 都符合則 PASS
  4257. // if (_chargingData[_index]->FireChargingVoltage >= 3500)
  4258. // _chargingData[_index]->GroundFaultStatus = GFD_PASS;
  4259. //PRINTF_FUNC("To EV_%d GFD = %d \n", _index, _chargingData[_index]->GroundFaultStatus);
  4260. //if(_chargingData[_index]->GroundFaultStatus != GFD_WAIT)
  4261. {
  4262. //if ((GetTimeoutValue(_derating_time) / 1000) > 1000)
  4263. unsigned char _result = _chargingData[_index]->GroundFaultStatus;
  4264. // GB & Chademo ~ Warning 也先算 Pass,因為 CCS 認證會驗 Warning 故不可更動
  4265. if(_chargingData[_index]->Type == _Type_Chademo ||
  4266. _chargingData[_index]->Type == _Type_GB)
  4267. {
  4268. if (_result == GFD_WARNING)
  4269. {
  4270. _result = GFD_PASS;
  4271. }
  4272. }
  4273. if (_result == GFD_WARNING || _result == GFD_PASS)
  4274. {
  4275. _timeBuf = GetTimeoutValue(&_chk_ratingPower_timeout[_index]);
  4276. if (_timeBuf < 0)
  4277. {
  4278. GetTimespecFunc(&_chk_ratingPower_timeout[_index]);
  4279. }
  4280. else
  4281. {
  4282. if ((_timeBuf > 6 &&
  4283. _chargingData[_index]->RealRatingPower > 0) ||
  4284. _timeBuf > 14)
  4285. {
  4286. PRINTF_FUNC("Conn %d, RealRatingPower = %d (KW) \n",
  4287. _index, _chargingData[_index]->RealRatingPower / 10);
  4288. }
  4289. else
  4290. _result = GFD_WAIT;
  4291. }
  4292. }
  4293. if (_result != GFD_WAIT)
  4294. SetIsolationStatus(_index, _result, targetID);
  4295. }
  4296. if(_chargingData[_index]->SystemStatus == SYS_MODE_CCS_PRECHARGE_STEP0 &&
  4297. _chargingData[_index]->PrechargeStatus == PRECHARGE_READY)
  4298. {
  4299. SetEvsePrechargeInfo(_index, PRECHARGE_PRERELAY_PASS, targetID);
  4300. }
  4301. }
  4302. }
  4303. break;
  4304. case SYS_MODE_CHARGING:
  4305. {
  4306. // 當前 Power
  4307. _chargingData[_index]->PresentChargingPower = ((float)((_chargingData[_index]->PresentChargingVoltage) * (_chargingData[_index]->PresentChargingCurrent)) / 1000);
  4308. CalOutputPowerAndEnergy(_index);
  4309. // 開始確認車端是否同意開始充電
  4310. GetOutputReq(_index, targetID);
  4311. if (LogInfo[_index][EV_LOG_MAX_BATT_VOL] != _chargingData[_index]->EvBatteryMaxVoltage)
  4312. {
  4313. LogInfo[_index][EV_LOG_MAX_BATT_VOL] = _chargingData[_index]->EvBatteryMaxVoltage;
  4314. PRINTF_FUNC("index = %d, Ev Maximum Battery Voltage = %f \n", _index, _chargingData[_index]->EvBatteryMaxVoltage);
  4315. }
  4316. if (LogInfo[_index][EV_LOG_SOC] != _chargingData[_index]->EvBatterySoc)
  4317. {
  4318. LogInfo[_index][EV_LOG_SOC] = _chargingData[_index]->EvBatterySoc;
  4319. PRINTF_FUNC("index = %d, SOC = %d \n", _index, _chargingData[_index]->EvBatterySoc);
  4320. }
  4321. // 設定當前輸出
  4322. if (gun_count == 1)
  4323. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_LEFT]);
  4324. else if (gun_count == 2)
  4325. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_RIGHT]);
  4326. // for test end
  4327. if (priorityLow % 5 == 0)
  4328. {
  4329. // 樁端輸出能力改變
  4330. if (gun_count == 1)
  4331. SetPresentChargingOutputCap(_chargingData[GUN_LEFT], _chargingData[GUN_LEFT]);
  4332. else if (gun_count == 2)
  4333. SetPresentChargingOutputCap(_chargingData[GUN_LEFT], _chargingData[GUN_RIGHT]);
  4334. }
  4335. // GFD 失敗再通知
  4336. if(_chargingData[_index]->GroundFaultStatus == GFD_FAIL ||
  4337. _chargingData[_index]->Type == _Type_CCS)
  4338. {
  4339. SetIsolationStatus(_index, _chargingData[_index]->GroundFaultStatus, targetID);
  4340. }
  4341. if (priorityLow == 1)
  4342. {
  4343. if(_chargingData[_index]->Type == _Type_CCS &&
  4344. _chargingData[_index]->PrechargeStatus == PRECHARGE_READY)
  4345. {
  4346. SetEvsePrechargeInfo(_index, PRECHARGE_CHARELAY_PASS, targetID);
  4347. }
  4348. // 取得車端電池資訊 : 1.AC or DC ? 2.Total battery cap, 3.Max battery vol, 4.Max battery cur
  4349. GetEvBatteryInfo(_index, targetID);
  4350. }
  4351. }
  4352. break;
  4353. case SYS_MODE_ALARM:
  4354. case SYS_MODE_TERMINATING:
  4355. {
  4356. // 當前 Power
  4357. _chargingData[_index]->PresentChargingPower = ((float)((_chargingData[_index]->PresentChargingVoltage) * (_chargingData[_index]->PresentChargingCurrent)) / 1000);
  4358. CalOutputPowerAndEnergy(_index);
  4359. // 設定當前輸出
  4360. if (gun_count == 1)
  4361. {
  4362. if (_chargingData[GUN_LEFT]->FireChargingVoltage <= VOUT_MIN_VOLTAGE)
  4363. _chargingData[GUN_LEFT]->PresentChargingCurrent = CURR_MIN_CURRENT;
  4364. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_LEFT]);
  4365. }
  4366. else if (gun_count == 2)
  4367. {
  4368. if (_chargingData[GUN_LEFT]->FireChargingVoltage <= VOUT_MIN_VOLTAGE)
  4369. _chargingData[GUN_LEFT]->PresentChargingCurrent = CURR_MIN_CURRENT;
  4370. if (_chargingData[GUN_RIGHT]->FireChargingVoltage <= VOUT_MIN_VOLTAGE)
  4371. _chargingData[GUN_RIGHT]->PresentChargingCurrent = CURR_MIN_CURRENT;
  4372. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_RIGHT]);
  4373. }
  4374. // 槍鎖還在,則代表是樁端要求的停止
  4375. if (SendErrorCount[_index] < 3 &&
  4376. (_chargingData[_index]->GunLocked == START ||
  4377. _chargingData[_index]->Type == _Type_CCS ||
  4378. _chargingData[_index]->SystemStatus == SYS_MODE_ALARM))
  4379. {
  4380. byte normalStop = 0x01;
  4381. byte stopReason[7] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
  4382. if (GetStopChargingReasonByEvse(_index, stopReason))
  4383. {
  4384. normalStop = 0x02;
  4385. }
  4386. if (SendErrorCount[_index] == 0)
  4387. {
  4388. if (normalStop == 0x01)
  4389. PRINTF_FUNC("EVSE : Normal Stop (%d). \n", _index);
  4390. else
  4391. PRINTF_FUNC("EVSE : EMC Stop : (%d) - (%s) \n", _index, stopReason);
  4392. }
  4393. EvseStopChargingEvent(normalStop, stopReason, targetID);
  4394. SendErrorCount[_index] += 1;
  4395. }
  4396. if(_chargingData[_index]->Type == _Type_CCS)
  4397. {
  4398. SetIsolationStatus(_index, _chargingData[_index]->GroundFaultStatus, targetID);
  4399. }
  4400. GetOutputReq(_index, targetID);
  4401. if (_chargingData[_index]->SystemStatus == SYS_MODE_ALARM)
  4402. {
  4403. if (priorityLow == 1)
  4404. {
  4405. float maxVol, maxCur;
  4406. // 樁端輸出能力
  4407. maxVol = _chargingData[_index]->MaximumChargingVoltage;
  4408. maxCur = _chargingData[_index]->AvailableChargingCurrent;
  4409. GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
  4410. SetChargingPermission(_index, STOP,
  4411. _chargingData[_index]->AvailableChargingPower,
  4412. maxCur,
  4413. maxVol,
  4414. targetID);
  4415. }
  4416. }
  4417. }
  4418. break;
  4419. case SYS_MODE_COMPLETE:
  4420. {
  4421. // 設定當前輸出
  4422. if (gun_count == 1)
  4423. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_LEFT]);
  4424. else if (gun_count == 2)
  4425. SetPresentChargingOutputPower(_chargingData[GUN_LEFT], _chargingData[GUN_RIGHT]);
  4426. if (priorityLow == 1)
  4427. {
  4428. float maxVol, maxCur;
  4429. // 樁端輸出能力
  4430. maxVol = _chargingData[_index]->MaximumChargingVoltage;
  4431. maxCur = _chargingData[_index]->AvailableChargingCurrent;
  4432. GetMaxVolAndCurMethod(_index, &maxVol, &maxCur);
  4433. SetChargingPermission(_index, STOP,
  4434. _chargingData[_index]->AvailableChargingPower,
  4435. maxCur,
  4436. maxVol,
  4437. targetID);
  4438. }
  4439. }
  4440. break;
  4441. }
  4442. }
  4443. if (printLogRecord)
  4444. InitTimeToPrintLog();
  4445. priorityLow >= 20 ? priorityLow = 1 : priorityLow++;
  4446. usleep(45000); //EV 小板通訊 (50 ms)
  4447. }
  4448. DEBUG_INFO("Module_EvComm : Can-bus port = %d \n", CanFd);
  4449. return FAIL;
  4450. }