MessageHandler.c 1.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180
  1. #include "Module_OcppBackend20.h"
  2. #include "define.h"
  3. static char *APNAuthenticationEnumTypeStr[] = {
  4. MACROSTR(CHAP),
  5. MACROSTR(NONE),
  6. MACROSTR(PAP),
  7. MACROSTR(AUTO)
  8. };
  9. static char *AttributeEnumTypeStr[] = {
  10. MACROSTR(Actual),
  11. MACROSTR(Target),
  12. MACROSTR(MinSet),
  13. MACROSTR(MaxSet)
  14. };
  15. static char *AuthorizationStatusEnumTypeStr[] = {
  16. MACROSTR(Accepted),
  17. MACROSTR(Blocked),
  18. MACROSTR(ConcurrentTx),
  19. MACROSTR(Expired),
  20. MACROSTR(Invalid),
  21. MACROSTR(NoCredit),
  22. MACROSTR(NotAllowedTypeEVSE),
  23. MACROSTR(NotAtThisLocation),
  24. MACROSTR(NotAtThisTime),
  25. MACROSTR(Unknown)
  26. };
  27. #if 0
  28. static char *AuthorizeCertificateStatusEnumTypeStr[] = {
  29. MACROSTR(Accepted),
  30. MACROSTR(SignatureError),
  31. MACROSTR(CertificateExpired),
  32. MACROSTR(CertificateRevoked),
  33. MACROSTR(NoCertificateAvailable),
  34. MACROSTR(CertChainError),
  35. MACROSTR(ContractCancelled)
  36. };
  37. #endif
  38. static char *BootReasonEnumTypeStr[] = {
  39. MACROSTR(ApplicationReset),
  40. MACROSTR(FirmwareUpdate),
  41. MACROSTR(LocalReset),
  42. MACROSTR(PowerUp),
  43. MACROSTR(RemoteReset),
  44. MACROSTR(ScheduledReset),
  45. MACROSTR(Triggered),
  46. MACROSTR(Unknown),
  47. MACROSTR(Watchdog)
  48. };
  49. static char *SecurityEventEnumTypeStr[] = {
  50. MACROSTR(FirmwareUpdated),
  51. MACROSTR(FailedToAuthenticateAtCsms),
  52. MACROSTR(CsmsFailedToAuthenticate),
  53. MACROSTR(SettingSystemTime),
  54. MACROSTR(StartupOfTheDevice),
  55. MACROSTR(ResetOrReboot),
  56. MACROSTR(SecurityLogWasCleared),
  57. MACROSTR(ReconfigurationOfSecurityParameters),
  58. MACROSTR(MemoryExhaustion),
  59. MACROSTR(InvalidMessages),
  60. MACROSTR(AttemptedReplayAttacks),
  61. MACROSTR(TamperDetectionActivated),
  62. MACROSTR(InvalidFirmwareSignature),
  63. MACROSTR(InvalidFirmwareSigningCertificate),
  64. MACROSTR(InvalidCsmsCertificate),
  65. MACROSTR(InvalidChargingStationCertificate),
  66. MACROSTR(InvalidTLSVersion),
  67. MACROSTR(InvalidTLSCipherSuite)
  68. };
  69. static char *CancelReservationStatusEnumTypeStr[] = {
  70. MACROSTR(Accepted),
  71. MACROSTR(Rejected)
  72. };
  73. static char *CertificateActionEnumTypeStr[] = {
  74. MACROSTR(Install),
  75. MACROSTR(Update)
  76. };
  77. static char *CertificateSignedStatusEnumTypeStr[] = {
  78. MACROSTR(Accepted),
  79. MACROSTR(Rejected)
  80. };
  81. static char *CertificateSigningUseEnumTypeStr[] = {
  82. MACROSTR(ChargingStationCertificate),
  83. MACROSTR(V2GCertificate)
  84. };
  85. static char *ChangeAvailabilityStatusEnumTypeStr[] = {
  86. MACROSTR(Accepted),
  87. MACROSTR(Rejected),
  88. MACROSTR(Scheduled)
  89. };
  90. #if 0
  91. static char *ChargingLimitSourceEnumTypeStr[] = {
  92. MACROSTR(EMS),
  93. MACROSTR(Other),
  94. MACROSTR(SO),
  95. MACROSTR(CSO)
  96. };
  97. #endif
  98. static char *ChargingProfileKindEnumTypeStr[] = {
  99. MACROSTR(Absolute),
  100. MACROSTR(Recurring),
  101. MACROSTR(Relative)
  102. };
  103. static char *ChargingProfilePurposeEnumTypeStr[] = {
  104. MACROSTR(ChargingStationExternalConstraints),
  105. MACROSTR(ChargingStationMaxProfile),
  106. MACROSTR(TxDefaultProfile),
  107. MACROSTR(TxProfile)
  108. };
  109. static char *ChargingProfileStatusEnumTypeStr[] = {
  110. MACROSTR(Accepted),
  111. MACROSTR(Rejected)
  112. };
  113. static char *ChargingRateUnitEnumTypeStr[] = {
  114. MACROSTR(W),
  115. MACROSTR(A)
  116. };
  117. static char *ChargingStateEnumTypeStr[] = {
  118. MACROSTR(Charging),
  119. MACROSTR(EVConnected),
  120. MACROSTR(SuspendedEV),
  121. MACROSTR(SuspendedEVSE),
  122. MACROSTR(Idle)
  123. };
  124. static char *ClearCacheStatusEnumTypeStr[] = {
  125. MACROSTR(Accepted),
  126. MACROSTR(Rejected)
  127. };
  128. static char *ClearChargingProfileStatusEnumTypeStr[] = {
  129. MACROSTR(Accepted),
  130. MACROSTR(Unknown)
  131. };
  132. static char *ClearMessageStatusEnumTypeStr[] = {
  133. MACROSTR(Accepted),
  134. MACROSTR(Unknown)
  135. };
  136. static char *ClearMonitoringStatusEnumTypeStr[] = {
  137. MACROSTR(Accepted),
  138. MACROSTR(Rejected),
  139. MACROSTR(NotFound)
  140. };
  141. static char *ComponentCriterionEnumTypeStr[] = {
  142. MACROSTR(Active),
  143. MACROSTR(Available),
  144. MACROSTR(Enabled),
  145. MACROSTR(Problem)
  146. };
  147. #if 0
  148. static char *ConnectorEnumTypeStr[] = {
  149. MACROSTR(cCCS1),
  150. MACROSTR(cCCS2),
  151. MACROSTR(cG105),
  152. MACROSTR(cTesla),
  153. MACROSTR(cType1),
  154. MACROSTR(cType2),
  155. MACROSTR(s309-1P-16A),
  156. MACROSTR(s309-1P-32A),
  157. MACROSTR(s309-3P-16A),
  158. MACROSTR(s309-3P-32A),
  159. MACROSTR(sBS1361),
  160. MACROSTR(sCEE-7-7),
  161. MACROSTR(sType2),
  162. MACROSTR(sType3),
  163. MACROSTR(Other1PhMax16A),
  164. MACROSTR(Other1PhOver16A),
  165. MACROSTR(Other3Ph),
  166. MACROSTR(Pan),
  167. MACROSTR(wInductive),
  168. MACROSTR(wResonant),
  169. MACROSTR(Undetermined),
  170. MACROSTR(Unknown)
  171. };
  172. #endif
  173. static char *ConnectorStatusEnumTypeStr[] = {
  174. MACROSTR(Available),
  175. MACROSTR(Occupied),
  176. MACROSTR(Reserved),
  177. MACROSTR(Unavailable),
  178. MACROSTR(Faulted)
  179. };
  180. #if 0
  181. static char *CostKindEnumTypeStr[] = {
  182. MACROSTR(CarbonDioxideEmission),
  183. MACROSTR(RelativePricePercentage),
  184. MACROSTR(RenewableGenerationPercentage)
  185. };
  186. #endif
  187. static char *CustomerInformationStatusEnumTypeStr[] = {
  188. MACROSTR(Accepted),
  189. MACROSTR(Rejected),
  190. MACROSTR(Invalid)
  191. };
  192. static char *DataEnumTypeStr[] = {
  193. MACROSTR(string),
  194. MACROSTR(decimal),
  195. MACROSTR(integer),
  196. MACROSTR(dateTime),
  197. MACROSTR(boolean),
  198. MACROSTR(OptionList),
  199. MACROSTR(SequenceList),
  200. MACROSTR(MemberList)
  201. };
  202. static char *DataTransferStatusEnumTypeStr[] = {
  203. MACROSTR(Accepted),
  204. MACROSTR(Rejected),
  205. MACROSTR(UnknownMessageId),
  206. MACROSTR(UnknownVendorId)
  207. };
  208. static char *DeleteCertificateStatusEnumTypeStr[] = {
  209. MACROSTR(Accepted),
  210. MACROSTR(Failed),
  211. MACROSTR(NotFound)
  212. };
  213. static char *DisplayMessageStatusEnumTypeStr[] = {
  214. MACROSTR(Accepted),
  215. MACROSTR(NotSupportedMessageFormat),
  216. MACROSTR(Rejected),
  217. MACROSTR(NotSupportedPriority),
  218. MACROSTR(NotSupportedState),
  219. MACROSTR(UnknownTransaction)
  220. };
  221. #if 0
  222. static char *EnergyTransferModeEnumTypeStr[] = {
  223. MACROSTR(DC),
  224. MACROSTR(AC_single_phase),
  225. MACROSTR(AC_two_phase),
  226. MACROSTR(AC_three_phase)
  227. };
  228. #endif
  229. static char *EventNotificationEnumTypeStr[] = {
  230. MACROSTR(HardWiredNotification),
  231. MACROSTR(HardWiredMonitor),
  232. MACROSTR(PreconfiguredMonitor),
  233. MACROSTR(CustomMonitor)
  234. };
  235. static char *EventTriggerEnumTypeStr[] = {
  236. MACROSTR(Alerting),
  237. MACROSTR(Delta),
  238. MACROSTR(Periodic)
  239. };
  240. static char *FirmwareStatusEnumTypeStr[] = {
  241. MACROSTR(Downloaded),
  242. MACROSTR(DownloadFailed),
  243. MACROSTR(Downloading),
  244. MACROSTR(DownloadScheduled),
  245. MACROSTR(DownloadPaused),
  246. MACROSTR(Idle),
  247. MACROSTR(InstallationFailed),
  248. MACROSTR(Installing),
  249. MACROSTR(Installed),
  250. MACROSTR(InstallRebooting),
  251. MACROSTR(InstallScheduled),
  252. MACROSTR(InstallVerificationFailed),
  253. MACROSTR(InvalidSignature),
  254. MACROSTR(SignatureVerified)
  255. };
  256. static char *GenericDeviceModelStatusEnumTypeStr[] = {
  257. MACROSTR(Accepted),
  258. MACROSTR(Rejected),
  259. MACROSTR(NotSupported),
  260. MACROSTR(EmptyResultSet)
  261. };
  262. static char *GenericStatusEnumTypeStr[] = {
  263. MACROSTR(Accepted),
  264. MACROSTR(Rejected)
  265. };
  266. static char *GetCertificateIdUseEnumTypeStr[] = {
  267. MACROSTR(V2GRootCertificate),
  268. MACROSTR(MORootCertificate),
  269. MACROSTR(CSMSRootCertificate),
  270. MACROSTR(V2GCertificateChain),
  271. MACROSTR(ManufacturerRootCertificate)
  272. };
  273. static char *GetCertificateStatusEnumTypeStr[] = {
  274. MACROSTR(Accepted),
  275. MACROSTR(Failed)
  276. };
  277. static char *GetChargingProfileStatusEnumTypeStr[] = {
  278. MACROSTR(Accepted),
  279. MACROSTR(NoProfiles)
  280. };
  281. static char *GetDisplayMessagesStatusEnumTypeStr[] = {
  282. MACROSTR(Accepted),
  283. MACROSTR(Unknown)
  284. };
  285. static char *GetInstalledCertificateStatusEnumTypeStr[] = {
  286. MACROSTR(Accepted),
  287. MACROSTR(NotFound)
  288. };
  289. static char *GetVariableStatusEnumTypeStr[] = {
  290. MACROSTR(Accepted),
  291. MACROSTR(Rejected),
  292. MACROSTR(UnknownComponent),
  293. MACROSTR(UnknownVariable),
  294. MACROSTR(NotSupportedAttributeType)
  295. };
  296. static char *HashAlgorithmEnumTypeStr[] = {
  297. MACROSTR(SHA256),
  298. MACROSTR(SHA384),
  299. MACROSTR(SHA512)
  300. };
  301. static char *IdTokenEnumTypeStr[] = {
  302. MACROSTR(Central),
  303. MACROSTR(eMAID),
  304. MACROSTR(ISO14443),
  305. MACROSTR(KeyCode),
  306. MACROSTR(Local),
  307. MACROSTR(NoAuthorization),
  308. MACROSTR(ISO15693)
  309. };
  310. static char *InstallCertificateUseEnumTypeStr[] = {
  311. MACROSTR(V2GRootCertificate),
  312. MACROSTR(MORootCertificate),
  313. MACROSTR(CSMSRootCertificate),
  314. MACROSTR(ManufacturerRootCertificate)
  315. };
  316. static char *InstallCertificateStatusEnumTypeStr[]={
  317. MACROSTR(Accepted),
  318. MACROSTR(Failed),
  319. MACROSTR(Rejected)
  320. };
  321. static char *Iso15118EVCertificateStatusEnumTypeStr[] = {
  322. MACROSTR(Accepted),
  323. MACROSTR(Failed)
  324. };
  325. static char *LocationEnumTypeStr[] = {
  326. MACROSTR(Body),
  327. MACROSTR(Cable),
  328. MACROSTR(EV),
  329. MACROSTR(Inlet),
  330. MACROSTR(Outlet)
  331. };
  332. static char *LogEnumTypeStr[] = {
  333. MACROSTR(DiagnosticsLog),
  334. MACROSTR(SecurityLog)
  335. };
  336. static char *LogStatusEnumTypeStr[] = {
  337. MACROSTR(Accepted),
  338. MACROSTR(Rejected),
  339. MACROSTR(AcceptedCanceled)
  340. };
  341. static char *MeasurandEnumTypeStr[] = {
  342. MACROSTR(Current.Export),
  343. MACROSTR(Current.Import),
  344. MACROSTR(Current.Offered),
  345. MACROSTR(Energy.Active.Export.Register),
  346. MACROSTR(Energy.Active.Import.Register),
  347. MACROSTR(Energy.Reactive.Export.Register),
  348. MACROSTR(Energy.Reactive.Import.Register),
  349. MACROSTR(Energy.Active.Export.Interval),
  350. MACROSTR(Energy.Active.Import.Interval),
  351. MACROSTR(Energy.Active.Net),
  352. MACROSTR(Energy.Reactive.Export.Interval),
  353. MACROSTR(Energy.Reactive.Import.Interval),
  354. MACROSTR(Energy.Reactive.Net),
  355. MACROSTR(Energy.Apparent.Net),
  356. MACROSTR(Energy.Apparent.Import),
  357. MACROSTR(Energy.Apparent.Export),
  358. MACROSTR(Frequency),
  359. MACROSTR(Power.Active.Export),
  360. MACROSTR(Power.Active.Import),
  361. MACROSTR(Power.Factor),
  362. MACROSTR(Power.Offered),
  363. MACROSTR(Power.Reactive.Export),
  364. MACROSTR(Power.Reactive.Import),
  365. MACROSTR(SoC),
  366. MACROSTR(Voltage)
  367. };
  368. static char *MessageFormatEnumTypeStr[] = {
  369. MACROSTR(ASCII),
  370. MACROSTR(HTML),
  371. MACROSTR(URI),
  372. MACROSTR(UTF8)
  373. };
  374. static char *MessagePriorityEnumTypeStr[] = {
  375. MACROSTR(AlwaysFront),
  376. MACROSTR(InFront),
  377. MACROSTR(NormalCycle)
  378. };
  379. static char *MessageStateEnumTypeStr[] = {
  380. MACROSTR(Charging),
  381. MACROSTR(Faulted),
  382. MACROSTR(Idle),
  383. MACROSTR(Unavailable)
  384. };
  385. static char *MessageTriggerEnumTypeStr[] = {
  386. MACROSTR(BootNotification),
  387. MACROSTR(LogStatusNotification),
  388. MACROSTR(FirmwareStatusNotification),
  389. MACROSTR(Heartbeat),
  390. MACROSTR(MeterValues),
  391. MACROSTR(SignChargingStationCertificate),
  392. MACROSTR(SignV2GCertificate),
  393. MACROSTR(StatusNotification),
  394. MACROSTR(TransactionEvent),
  395. MACROSTR(SignCombinedCertificate),
  396. MACROSTR(PublishFirmwareStatusNotification)
  397. };
  398. static char *MonitorEnumTypeStr[] = {
  399. MACROSTR(UpperThreshold),
  400. MACROSTR(LowerThreshold),
  401. MACROSTR(Delta),
  402. MACROSTR(Periodic),
  403. MACROSTR(PeriodicClockAligned)
  404. };
  405. static char *MonitoringBaseEnumTypeStr[] = {
  406. MACROSTR(All),
  407. MACROSTR(FactoryDefault),
  408. MACROSTR(HardWiredOnly)
  409. };
  410. static char *MonitoringCriterionEnumTypeStr[] = {
  411. MACROSTR(ThresholdMonitoring),
  412. MACROSTR(DeltaMonitoring),
  413. MACROSTR(PeriodicMonitoring)
  414. };
  415. static char *MutabilityEnumTypeStr[] = {
  416. MACROSTR(ReadOnly),
  417. MACROSTR(WriteOnly),
  418. MACROSTR(ReadWrite)
  419. };
  420. static char *NotifyEVChargingNeedsStatusEnumTypeStr[] = {
  421. MACROSTR(Accepted),
  422. MACROSTR(Rejected),
  423. MACROSTR(Processing)
  424. };
  425. static char *OCPPInterfaceEnumTypeStr[] = {
  426. MACROSTR(Wired0),
  427. MACROSTR(Wired1),
  428. MACROSTR(Wired2),
  429. MACROSTR(Wired3),
  430. MACROSTR(Wireless0),
  431. MACROSTR(Wireless1),
  432. MACROSTR(Wireless2),
  433. MACROSTR(Wireless3)
  434. };
  435. static char *OCPPTransportEnumTypeStr[] = {
  436. MACROSTR(JSON),
  437. MACROSTR(SOAP)
  438. };
  439. static char *OCPPVersionEnumTypeStr[] = {
  440. MACROSTR(OCPP12),
  441. MACROSTR(OCPP15),
  442. MACROSTR(OCPP16),
  443. MACROSTR(OCPP20)
  444. };
  445. static char *OperationalStatusEnumTypeStr[] = {
  446. MACROSTR(Inoperative),
  447. MACROSTR(Operative)
  448. };
  449. static char *PhaseEnumTypeStr[] = {
  450. MACROSTR(L1),
  451. MACROSTR(L2),
  452. MACROSTR(L3),
  453. MACROSTR(N),
  454. MACROSTR(L1-N),
  455. MACROSTR(L2-N),
  456. MACROSTR(L3-N),
  457. MACROSTR(L1-L2),
  458. MACROSTR(L2-L3),
  459. MACROSTR(L3-L1)
  460. };
  461. static char *PublishFirmwareStatusEnumTypeStr[] = {
  462. MACROSTR(Downloaded),
  463. MACROSTR(DownloadFailed),
  464. MACROSTR(Downloading),
  465. MACROSTR(DownloadScheduled),
  466. MACROSTR(DownloadPaused),
  467. MACROSTR(PublishFailed),
  468. MACROSTR(Published),
  469. MACROSTR(InvalidChecksum),
  470. MACROSTR(ChecksumVerified)
  471. };
  472. static char *ReadingContextEnumTypeStr[] = {
  473. MACROSTR(Interruption.Begin),
  474. MACROSTR(Interruption.End),
  475. MACROSTR(Other),
  476. MACROSTR(Sample.Clock),
  477. MACROSTR(Sample.Periodic),
  478. MACROSTR(Transaction.Begin),
  479. MACROSTR(Transaction.End),
  480. MACROSTR(Trigger)
  481. };
  482. #if 0
  483. static char *ReasonEnumTypeStr[] = {
  484. MACROSTR(DeAuthorized),
  485. MACROSTR(EmergencyStop),
  486. MACROSTR(EnergyLimitReached),
  487. MACROSTR(EVDisconnected),
  488. MACROSTR(GroundFault),
  489. MACROSTR(ImmediateReset),
  490. MACROSTR(Local),
  491. MACROSTR(LocalOutOfCredit),
  492. MACROSTR(MasterPass),
  493. MACROSTR(Other),
  494. MACROSTR(OvercurrentFault),
  495. MACROSTR(PowerLoss),
  496. MACROSTR(PowerQuality),
  497. MACROSTR(Reboot),
  498. MACROSTR(Remote),
  499. MACROSTR(SOCLimitReached),
  500. MACROSTR(StoppedByEV),
  501. MACROSTR(TimeLimitReached),
  502. MACROSTR(TimeLimitReached)
  503. };
  504. #endif
  505. static char *RecurrencyKindEnumTypeStr[] = {
  506. MACROSTR(Daily),
  507. MACROSTR(Weekly)
  508. };
  509. static char *RegistrationStatusEnumTypeStr[] = {
  510. MACROSTR(Accepted),
  511. MACROSTR(Pending),
  512. MACROSTR(Rejected)
  513. };
  514. static char *ReportBaseEnumTypeStr[] = {
  515. MACROSTR(ConfigurationInventory),
  516. MACROSTR(FullInventory),
  517. MACROSTR(SummaryInventory)
  518. };
  519. static char *RequestStartStopStatusEnumTypeStr[] = {
  520. MACROSTR(Accepted),
  521. MACROSTR(Rejected)
  522. };
  523. static char *ReservationUpdateStatusEnumTypeStr[] = {
  524. MACROSTR(Expired),
  525. MACROSTR(Removed)
  526. };
  527. static char *ReserveNowStatusEnumTypeStr[] = {
  528. MACROSTR(Accepted),
  529. MACROSTR(Faulted),
  530. MACROSTR(Occupied),
  531. MACROSTR(Rejected),
  532. MACROSTR(Unavailable)
  533. };
  534. static char *ResetEnumTypeStr[] = {
  535. MACROSTR(Immediate),
  536. MACROSTR(OnIdle)
  537. };
  538. static char *ResetStatusEnumTypeStr[] = {
  539. MACROSTR(Accepted),
  540. MACROSTR(Rejected),
  541. MACROSTR(Scheduled)
  542. };
  543. static char *SetMonitoringStatusEnumTypeStr[] = {
  544. MACROSTR(Accepted),
  545. MACROSTR(UnknownComponent),
  546. MACROSTR(UnknownVariable),
  547. MACROSTR(UnsupportedMonitorType),
  548. MACROSTR(Rejected),
  549. MACROSTR(OutOfRange),
  550. MACROSTR(Duplicate)
  551. };
  552. static char *SetNetworkProfileStatusEnumTypeStr[] = {
  553. MACROSTR(Accepted),
  554. MACROSTR(Rejected),
  555. MACROSTR(Failed)
  556. };
  557. static char *SetVariableStatusEnumTypeStr[] = {
  558. MACROSTR(Accepted),
  559. MACROSTR(Rejected),
  560. MACROSTR(InvalidValue),
  561. MACROSTR(UnknownComponent),
  562. MACROSTR(UnknownVariable),
  563. MACROSTR(NotSupportedAttributeType),
  564. MACROSTR(OutOfRange),
  565. MACROSTR(RebootRequired)
  566. };
  567. static char *TransactionEventEnumTypeStr[] = {
  568. MACROSTR(Ended),
  569. MACROSTR(Started),
  570. MACROSTR(Updated)
  571. };
  572. static char *TriggerMessageStatusEnumTypeStr[] = {
  573. MACROSTR(Accepted),
  574. MACROSTR(Rejected),
  575. MACROSTR(NotImplemented)
  576. };
  577. static char *TriggerReasonEnumTypeStr[] = {
  578. MACROSTR(Authorized),
  579. MACROSTR(CablePluggedIn),
  580. MACROSTR(ChargingRateChanged),
  581. MACROSTR(ChargingStateChanged),
  582. MACROSTR(Deauthorized),
  583. MACROSTR(EnergyLimitReached),
  584. MACROSTR(EVCommunicationLost),
  585. MACROSTR(EVConnectTimeout),
  586. MACROSTR(MeterValueClock),
  587. MACROSTR(MeterValuePeriodic),
  588. MACROSTR(TimeLimitReached),
  589. MACROSTR(Trigger),
  590. MACROSTR(UnlockCommand),
  591. MACROSTR(StopAuthorized),
  592. MACROSTR(EVDeparted),
  593. MACROSTR(EVDetected),
  594. MACROSTR(RemoteStop),
  595. MACROSTR(RemoteStart),
  596. MACROSTR(AbnormalCondition),
  597. MACROSTR(SignedDataReceived),
  598. MACROSTR(ResetCommand)
  599. };
  600. static char *UnlockStatusEnumTypeStr[] = {
  601. MACROSTR(Unlocked),
  602. MACROSTR(UnlockFailed),
  603. MACROSTR(OngoingAuthorizedTransaction),
  604. MACROSTR(UnknownConnector)
  605. };
  606. static char *UnpublishFirmwareStatusEnumTypeStr[] = {
  607. MACROSTR(DownloadOngoing),
  608. MACROSTR(NoFirmware),
  609. MACROSTR(Unpublished)
  610. };
  611. static char *UpdateEnumTypeStr[] = {
  612. MACROSTR(Differential),
  613. MACROSTR(Full)
  614. };
  615. static char *UpdateFirmwareStatusEnumTypeStr[] = {
  616. MACROSTR(Accepted),
  617. MACROSTR(Rejected),
  618. MACROSTR(AcceptedCanceled),
  619. MACROSTR(InvalidCertificate),
  620. MACROSTR(RevokedCertificate)
  621. };
  622. static char *UpdateStatusEnumTypeStr[] = {
  623. MACROSTR(Accepted),
  624. MACROSTR(Failed),
  625. MACROSTR(VersionMismatch)
  626. };
  627. static char *UploadLogStatusEnumTypeStr[] = {
  628. MACROSTR(BadMessage),
  629. MACROSTR(Idle),
  630. MACROSTR(NotSupportedOperation),
  631. MACROSTR(PermissionDenied),
  632. MACROSTR(Uploaded),
  633. MACROSTR(UploadFailure),
  634. MACROSTR(Uploading)
  635. };
  636. static char *VPNEnumTypeStr[] = {
  637. MACROSTR(IKEv2),
  638. MACROSTR(IPSec),
  639. MACROSTR(L2TP),
  640. MACROSTR(PPTP)
  641. };
  642. #if 0
  643. static char *ChargePointErrorCodeEnumTypeStr[] = {
  644. MACROSTR(ConnectorLockFailure),
  645. MACROSTR(EVCommunicationError),
  646. MACROSTR(GroundFailure),
  647. MACROSTR(HighTemperature),
  648. MACROSTR(InternalError),
  649. MACROSTR(LocalListConflict),
  650. MACROSTR(NoError),
  651. MACROSTR(OtherError),
  652. MACROSTR(OverCurrentFailure),
  653. MACROSTR(OverVoltage),
  654. MACROSTR(PowerMeterFailure),
  655. MACROSTR(PowerSwitchFailure),
  656. MACROSTR(ReaderFailure),
  657. MACROSTR(ResetFailure),
  658. MACROSTR(UnderVoltage),
  659. MACROSTR(WeakSignal)
  660. };
  661. #endif
  662. static char *GetCompositeScheduleStatusEnumTypeStr[] = {
  663. MACROSTR(Accepted),
  664. MACROSTR(Rejected)
  665. };
  666. static char *RemoteStartStopStatusEnumTypeStr[] = {
  667. MACROSTR(Accepted),
  668. MACROSTR(Rejected)
  669. };
  670. #if 0
  671. static char * StopTransactionReasonEnumTypeStr[] = {
  672. MACROSTR(EmergencyStop),
  673. MACROSTR(EVDisconnected),
  674. MACROSTR(HardReset),
  675. MACROSTR(Local),
  676. MACROSTR(Other),
  677. MACROSTR(PowerLoss),
  678. MACROSTR(Reboot),
  679. MACROSTR(Remote),
  680. MACROSTR(SoftReset),
  681. MACROSTR(UnlockCommand),
  682. MACROSTR(DeAuthorized)
  683. };
  684. #endif
  685. //ChargePointMaxProfile
  686. #define ChargingStationMaxProfile_JSON "/Storage/OCPP/ChargingStationMaxProfile_OCPP20.json"
  687. //TxDefaultProfile
  688. #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0_OCPP20.json"
  689. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  690. struct StatusCodeData *ShmStatusCodeData;
  691. struct PsuData *ShmPsuData ;
  692. struct OCPP20Data *ShmOCPP20Data;
  693. pthread_mutex_t lock_send = PTHREAD_MUTEX_INITIALIZER;
  694. char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
  695. //===============================
  696. // Gun Total Numbers
  697. //===============================
  698. static ParsingRatedCur modelnameInfo = {0};
  699. static int gunTotalNumber = 0;
  700. static uint8_t gunType[4] = {0};
  701. //===============================
  702. // Local List Version
  703. //===============================
  704. static int localversion=0;
  705. //===============================
  706. // Variable Version
  707. //===============================
  708. static int variableVersion=6;
  709. //===============================
  710. // OCPP sign variable
  711. //===============================
  712. static int server_sign = FALSE;
  713. int server_pending = FALSE;
  714. static int BootNotificationInterval = 10;
  715. //===============================
  716. // OCPP auth variable
  717. //===============================
  718. static int authorizeRetryTimes = 0; //number of Retry times
  719. //===============================
  720. // OCPP other variables
  721. //===============================
  722. static int HeartBeatWaitTime = 10;
  723. static int FirstHeartBeat = 0;
  724. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  725. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  726. static char CurrentChargingProfileScheduleStr[30] = {0};
  727. //========================================
  728. // OCPP status/previous related variables
  729. //========================================
  730. static int GunStatusInterval = 10;
  731. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  732. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  733. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  734. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  735. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  736. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  737. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  738. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  739. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  740. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  741. static int TransactionMessageAttemptsValue = 0;
  742. static int TransactionMessageRetryIntervalValue = 0;
  743. static struct AuthorizationData idTagQuery;
  744. //=============================================
  745. // OCPP HeartBeat Response Not Receive Counts
  746. //============================================
  747. static int HeartBeatWithNOResponse = 0;
  748. static int HeartBeatCountPerHour = 0;
  749. sqlite3 *db;
  750. int TransactionMessageAttemptsGet(void);
  751. int TransactionMessageRetryIntervalGet(void);
  752. int GetOcppConnStatus(void);
  753. void SetOcppConnStatus(uint8_t status);
  754. int setKeyValue(char *key, char *value);
  755. void OCPP_get_TableAuthlocalAllData(void);
  756. void processUnkownKey(void);
  757. struct InterLock
  758. {
  759. unsigned char isGetLogGoing:1;
  760. unsigned char isUpdateFirmwareGoing:1;
  761. }interLock;
  762. struct ClientTime
  763. {
  764. struct timespec Heartbeat;
  765. struct timespec StatusNotification[CONNECTOR_QUANTITY];
  766. struct timespec StartTransaction;
  767. struct timespec StopTransaction;
  768. struct timespec MeterValues[CONNECTOR_QUANTITY];
  769. struct timespec RemoteStartWait;
  770. }clientTime;
  771. typedef union
  772. {
  773. //Operations Initiated by Central System
  774. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  775. struct
  776. {
  777. //CsMsgValue[0]
  778. unsigned char StatusNotificationReq:1; //bit 0,
  779. unsigned char StatusNotificationConf:1; //bit 1,
  780. unsigned char TriggerMeterValueReq:1; //bit 2,
  781. unsigned char SampleMeterReq:1; //bit 3,
  782. unsigned char ClockAlignMeterReq:1; //bit 4,
  783. unsigned char TriggerStatusNotificationReq:1; //bit 5,
  784. unsigned char isOnCharging:1; //bit6,
  785. unsigned char :1; //bit7
  786. }bits[CONNECTOR_QUANTITY];
  787. }CpinitiateMsg;
  788. CpinitiateMsg cpinitateMsg;
  789. //=========================================
  790. // Save configuration
  791. //=========================================
  792. int runShellCmd(const char*cmd)
  793. {
  794. int result = FAIL;
  795. char buf[256];
  796. FILE *fp;
  797. fp = popen(cmd, "r");
  798. if(fp != NULL)
  799. {
  800. while(fgets(buf, sizeof(buf), fp) != NULL)
  801. {
  802. DEBUG_INFO("%s\n", buf);
  803. }
  804. result = PASS;
  805. }
  806. pclose(fp);
  807. return result;
  808. }
  809. int StoreUsrConfigData(struct SysConfigData *UsrData)
  810. {
  811. int result = PASS;
  812. int fd,wrd;
  813. unsigned int i,Chk;
  814. unsigned char *ptr, *BufTmp;
  815. int MtdBlockSize = 0x300000;
  816. Chk=0;
  817. ptr=(unsigned char *)UsrData;
  818. if((BufTmp=malloc(MtdBlockSize))!=NULL)
  819. {
  820. memset(BufTmp,0,MtdBlockSize);
  821. memcpy(BufTmp,ptr,sizeof(struct SysConfigData));
  822. for(i=ARRAY_SIZE(UsrData->CsuBootLoadFwRev);i<MtdBlockSize-4;i++)
  823. Chk+=*(BufTmp+i);
  824. memcpy(BufTmp+MtdBlockSize-4, &Chk, 4);
  825. // Output configuration to file.
  826. fd = open("/mnt/EvseConfig.bin", O_RDWR|O_CREAT);
  827. if (fd < 0)
  828. {
  829. DEBUG_ERROR("open /mnt/EvseConfig.bin NG\n");
  830. free(BufTmp);
  831. return 0;
  832. }
  833. wrd=write(fd, BufTmp, MtdBlockSize);
  834. close(fd);
  835. if(wrd<MtdBlockSize)
  836. {
  837. DEBUG_ERROR("write /mnt/EvseConfig.bin NG\n");
  838. free(BufTmp);
  839. return 0;
  840. }
  841. DEBUG_INFO("EvseConfig write to file in /mnt OK.\n");
  842. DEBUG_INFO("Erase /dev/mtd10.\n");
  843. runShellCmd("flash_erase /dev/mtd10 0 0");
  844. DEBUG_INFO("Write /dev/mtd10.\n");
  845. runShellCmd("nandwrite -p /dev/mtd10 /mnt/EvseConfig.bin");
  846. DEBUG_INFO("Erase /dev/mtd11.\n");
  847. runShellCmd("flash_erase /dev/mtd11 0 0");
  848. DEBUG_INFO("Write /dev/mtd11.\n");
  849. runShellCmd("nandwrite -p /dev/mtd11 /mnt/EvseConfig.bin");
  850. system("rm -f /mnt/EvseConfig.bin");
  851. DEBUG_INFO("EvseConfig write to flash OK\n");
  852. }
  853. else
  854. {
  855. DEBUG_ERROR("alloc BlockSize NG\r\n");
  856. result = FAIL;
  857. }
  858. if(BufTmp!=NULL)
  859. free(BufTmp);
  860. return result;
  861. }
  862. //=========================================
  863. // Date time related function
  864. //=========================================
  865. void getNowDatetime(uint8_t *data)
  866. {
  867. time_t t = time(NULL);
  868. struct tm tm = *localtime(&t);
  869. sprintf((char*)data, "%04d-%02d-%02dT%02d:%02d:%02dZ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  870. }
  871. //=========================================
  872. // Sqlite3 related function
  873. //=========================================
  874. int DB_Initial()
  875. {
  876. int result = PASS;
  877. char* errMsg = NULL;
  878. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  879. "idToken text UNIQUE,"
  880. "type text,"
  881. "status text,"
  882. "cacheExpiryDateTime text,"
  883. "chargingPriority integer,"
  884. "language1 text,"
  885. "evseId text,"
  886. "language2 text,"
  887. "groupIdToken_idToken text,"
  888. "groupIdToken_type text,"
  889. "personalMessage text);";
  890. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  891. "idToken text UNIQUE,"
  892. "type text,"
  893. "status text,"
  894. "cacheExpiryDateTime text,"
  895. "chargingPriority integer,"
  896. "language1 text,"
  897. "evseId text,"
  898. "language2 text,"
  899. "groupIdToken_idToken text,"
  900. "groupIdToken_type text,"
  901. "personalMessage text,"
  902. "version text);";
  903. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  904. "componentName text NOT NULL ,"
  905. "componentInstance text, "
  906. "variableName text NOT NULL, "
  907. "variableInstance text, "
  908. "variableCharacteristicsDataType integer, "
  909. "variableCharacteristicsUnit text, "
  910. "variableCharacteristicsMaxLimit real,"
  911. "variableAttributesType text, "
  912. "variableAttributesTypeMutability text, "
  913. "variableAttributesTypeValue text, "
  914. "variableCharacteristicsMinLimit real,"
  915. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  916. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  917. "type text);";
  918. char *sqlSecurityEventType = "create table if not exists ocpp20_securityevent_type (idx integer primary key,"
  919. "type text);";
  920. char *sqlNetworkProfile = "create table if not exists ocpp20_networkprofile (idx integer primary key,"
  921. "slot integer UNIQUE, connectionData text);";
  922. char *sqlTransaction = "create table if not exists ocpp20_transaction_record (idx integer primary key,"
  923. "occurDatetime text,"
  924. "message_type text,"
  925. "message_content text)";
  926. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  927. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  928. {
  929. result = FAIL;
  930. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  931. sqlite3_close(db);
  932. }
  933. else
  934. {
  935. DEBUG_INFO( "OCPP local database open successfully.\n");
  936. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  937. {
  938. result = FAIL;
  939. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  940. }
  941. else
  942. {
  943. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  944. }
  945. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  946. {
  947. result = FAIL;
  948. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  949. }
  950. else
  951. {
  952. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  953. }
  954. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  955. {
  956. result = FAIL;
  957. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  958. }
  959. else
  960. {
  961. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  962. }
  963. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  964. {
  965. result = FAIL;
  966. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  967. }
  968. else
  969. {
  970. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  971. }
  972. if (sqlite3_exec(db, sqlSecurityEventType, 0, 0, &errMsg) != SQLITE_OK)
  973. {
  974. result = FAIL;
  975. DEBUG_ERROR( "Create OCPP 2.0 securityevent_type table error message: %s\n", errMsg);
  976. }
  977. else
  978. {
  979. DEBUG_INFO( "Create OCPP 2.0 securityevent_type table successfully\n");
  980. }
  981. if (sqlite3_exec(db, sqlNetworkProfile, 0, 0, &errMsg) != SQLITE_OK)
  982. {
  983. result = FAIL;
  984. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_networkprofile table error message: %s\n", errMsg);
  985. }
  986. else
  987. {
  988. DEBUG_INFO( "Create OCPP 2.0 ocpp20_networkprofile table successfully\n");
  989. }
  990. if (sqlite3_exec(db, sqlTransaction, 0, 0, &errMsg) != SQLITE_OK)
  991. {
  992. result = FAIL;
  993. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_transaction_record table error message: %s\n", errMsg);
  994. }
  995. else
  996. {
  997. DEBUG_INFO( "Create OCPP 2.0 ocpp20_transaction_record table successfully\n");
  998. }
  999. //sqlite3_close(db);
  1000. }
  1001. return result;
  1002. }
  1003. int DB_cbGetVersion(void *para, int columnCount, char **columnValue, char **columnName)
  1004. {
  1005. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  1006. return 0;
  1007. }
  1008. void DB_getListVerion()
  1009. {
  1010. char sql[256];
  1011. char* errMsg = NULL;
  1012. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  1013. /* Execute SQL statement */
  1014. if( sqlite3_exec(db, sql, DB_cbGetVersion, 0, &errMsg) != SQLITE_OK )
  1015. {
  1016. DEBUG_INFO("SQL error: %s", errMsg);
  1017. }
  1018. }
  1019. int DB_cbGetIdTag(void *para, int columnCount, char **columnValue, char **columnName)
  1020. {
  1021. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  1022. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  1023. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  1024. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  1025. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  1026. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  1027. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  1028. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  1029. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  1030. return 0;
  1031. }
  1032. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  1033. {
  1034. char sql[256];
  1035. char* errMsg = NULL;
  1036. memset(&idTagQuery, 0, sizeof(idTagQuery));
  1037. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  1038. if(isQueryFromCache)
  1039. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  1040. else
  1041. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  1042. /* Execute SQL statement */
  1043. if(sqlite3_exec(db, sql, DB_cbGetIdTag, 0, &errMsg) != SQLITE_OK )
  1044. {
  1045. DEBUG_INFO("SQL error: %s", errMsg);
  1046. }
  1047. }
  1048. int DB_cbTableAuthlocalAllData(void *para, int columnCount, char **columnValue, char **columnName)
  1049. {
  1050. for (int i = 0; i < columnCount; i++)
  1051. {
  1052. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  1053. }
  1054. return 0;
  1055. }
  1056. void DB_get_TableAuthlocalAllData(void)
  1057. {
  1058. char sql[256];
  1059. char* errMsg = NULL;
  1060. sprintf(sql,"select * from ocpp20_auth_local;");
  1061. /* Execute SQL statement */
  1062. if(sqlite3_exec(db, sql, DB_cbTableAuthlocalAllData, 0,&errMsg) != SQLITE_OK)
  1063. {
  1064. DEBUG_INFO("SQL error: %s", errMsg);
  1065. }
  1066. }
  1067. int DB_cbAddLocalListCache(void *para, int columnCount, char **columnValue, char **columnName)
  1068. {
  1069. for(int i = 0; i<columnCount; i++)
  1070. {
  1071. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1072. }
  1073. return 0;
  1074. }
  1075. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  1076. {
  1077. int result = PASS;
  1078. char sql[512];
  1079. char* errMsg = NULL;
  1080. sprintf(sql,"insert or replace into ocpp20_auth_local (idToken, type, status, cacheExpiryDateTime, chargingPriority, language1, language2, groupIdToken_idToken, groupIdToken_type, version) VALUES('%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', %d ); SELECT * from ocpp20_auth_local;",
  1081. data->idToken.idToken,
  1082. data->idToken.type,
  1083. data->idTokenInfo.status,
  1084. data->idTokenInfo.cacheExpiryDateTime,
  1085. data->idTokenInfo.chargingPriority,
  1086. data->idTokenInfo.language1,
  1087. data->idTokenInfo.language2,
  1088. data->idTokenInfo.groupIdToken.idToken,
  1089. data->idTokenInfo.groupIdToken.type,
  1090. listVersion);
  1091. //* Execute SQL statement */
  1092. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  1093. {
  1094. DEBUG_INFO("SQL error: %s\n", errMsg);
  1095. result = FAIL;
  1096. }
  1097. else
  1098. {
  1099. memset(sql, 0, ARRAY_SIZE(sql));
  1100. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  1101. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  1102. {
  1103. DEBUG_INFO("SQL error: %s\n", errMsg);
  1104. result = FAIL;
  1105. }
  1106. }
  1107. return result;
  1108. }
  1109. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  1110. {
  1111. int result = PASS;
  1112. char sql[512];
  1113. char* errMsg = NULL;
  1114. sprintf(sql,"insert or replace into ocpp20_auth_cache (idToken, type, status, cacheExpiryDateTime, chargingPriority, language1, language2, groupIdToken_idToken, groupIdToken_type) VALUES('%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s'); SELECT * from ocpp20_auth_cache;",
  1115. idToken->idToken,
  1116. idToken->type,
  1117. idTokenInfo->status,
  1118. idTokenInfo->cacheExpiryDateTime,
  1119. idTokenInfo->chargingPriority,
  1120. idTokenInfo->language1,
  1121. idTokenInfo->language2,
  1122. idTokenInfo->groupIdToken.idToken,
  1123. idTokenInfo->groupIdToken.type);
  1124. //* Execute SQL statement */
  1125. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  1126. {
  1127. DEBUG_INFO("SQL error: %s\n", errMsg);
  1128. result = FAIL;
  1129. }
  1130. return result;
  1131. }
  1132. int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  1133. {
  1134. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  1135. // printf("localversion=%d\n", localversion);
  1136. return 0;
  1137. }
  1138. void DB_deleteIdTag(char idTag[])
  1139. {
  1140. char sql[512];
  1141. char* errMsg = NULL;
  1142. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1143. //* Execute SQL statement */
  1144. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1145. {
  1146. DEBUG_INFO("SQL error: %s", errMsg);
  1147. }
  1148. }
  1149. int DB_cleanLocalList()
  1150. {
  1151. int result = PASS;
  1152. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1153. char *errMsg = 0;
  1154. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1155. {
  1156. DEBUG_INFO("%s\n", errMsg);
  1157. result = FAIL;
  1158. }
  1159. return result;
  1160. }
  1161. int DB_cleanLocalCache()
  1162. {
  1163. int result = PASS;
  1164. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1165. char *errMsg = 0;
  1166. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1167. {
  1168. DEBUG_INFO("%s\n", errMsg);
  1169. result = FAIL;
  1170. }
  1171. return result;
  1172. }
  1173. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1174. {
  1175. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1176. return 0;
  1177. }
  1178. void DB_getBooType()
  1179. {
  1180. char sql[256];
  1181. char* errMsg = NULL;
  1182. sprintf(sql,"select * from ocpp20_boot_type;");
  1183. /* Execute SQL statement */
  1184. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1185. {
  1186. DEBUG_INFO("SQL error: %s\n", errMsg);
  1187. }
  1188. }
  1189. int DB_cbUpdateBootType(void *para, int columnCount, char **columnValue, char **columnName)
  1190. {
  1191. for(int i = 0; i<columnCount; i++)
  1192. {
  1193. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1194. }
  1195. return 0;
  1196. }
  1197. int DB_updateBootType(BootReasonEnumType reason)
  1198. {
  1199. int result = PASS;
  1200. char sql[512];
  1201. char* errMsg = NULL;
  1202. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1203. //* Execute SQL statement */
  1204. if(sqlite3_exec(db, sql, DB_cbUpdateBootType, 0, &errMsg) != SQLITE_OK)
  1205. {
  1206. DEBUG_INFO("SQL error: %s\n", errMsg);
  1207. result = FAIL;
  1208. }
  1209. return result;
  1210. }
  1211. int SecurityEventTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1212. {
  1213. sprintf((char*)ShmOCPP20Data->SecurityEventNotification.type,"%s", columnValue[1] ? columnValue[1] : SecurityEventEnumTypeStr[SecurityEventEnumType_ResetOrReboot]);
  1214. return 0;
  1215. }
  1216. void DB_getSecurityEventType()
  1217. {
  1218. char sql[256];
  1219. char* errMsg = NULL;
  1220. sprintf(sql,"select * from ocpp20_securityevent_type;");
  1221. /* Execute SQL statement */
  1222. if(sqlite3_exec(db, sql, SecurityEventTypecallback, 0, &errMsg) != SQLITE_OK )
  1223. {
  1224. DEBUG_INFO("SQL error: %s\n", errMsg);
  1225. }
  1226. }
  1227. int DB_cbUpdateSecurityEventType(void *para, int columnCount, char **columnValue, char **columnName)
  1228. {
  1229. for(int i = 0; i<columnCount; i++)
  1230. {
  1231. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1232. }
  1233. return 0;
  1234. }
  1235. int DB_updateSecurityEventType(SecurityEventEnumType reason)
  1236. {
  1237. int result = PASS;
  1238. char sql[512];
  1239. char* errMsg = NULL;
  1240. sprintf(sql,"insert or replace into ocpp20_securityevent_type (idx, type) VALUES(1, '%s');", SecurityEventEnumTypeStr[reason]);
  1241. //* Execute SQL statement */
  1242. if(sqlite3_exec(db, sql, DB_cbUpdateSecurityEventType, 0, &errMsg) != SQLITE_OK)
  1243. {
  1244. DEBUG_INFO("SQL error: %s\n", errMsg);
  1245. result = FAIL;
  1246. }
  1247. return result;
  1248. }
  1249. int DB_variableClear()
  1250. {
  1251. int result = PASS;
  1252. char * sqlcleanLocalList = "delete from ocpp20_variable";
  1253. char *errMsg = 0;
  1254. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1255. {
  1256. DEBUG_INFO("%s\n", errMsg);
  1257. result = FAIL;
  1258. }
  1259. return result;
  1260. }
  1261. int DB_cbVariableSaveToDb(void *para, int columnCount, char **columnValue, char **columnName)
  1262. {
  1263. for(int i = 0; i<columnCount; i++)
  1264. {
  1265. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1266. }
  1267. return 0;
  1268. }
  1269. int DB_variableSaveToDb(struct ReportDataType *variable)
  1270. {
  1271. int result = FAIL;
  1272. char sql[4096];
  1273. char* errMsg = NULL;
  1274. sprintf(sql,"insert or replace into ocpp20_variable (componentName, componentInstance, variableName, variableInstance, variableCharacteristicsDataType, variableCharacteristicsUnit, variableCharacteristicsMaxLimit, variableAttributesType, variableAttributesTypeMutability, variableAttributesTypeValue, variableCharacteristicsMinLimit) VALUES('%s', '%s', '%s', '%s', '%s', '%s', %f, '%s', '%s', '%s', '%f'); SELECT * from ocpp20_variable;",
  1275. variable->component.name,
  1276. variable->component.instance,
  1277. variable->variable.name,
  1278. variable->variable.instance,
  1279. variable->variableCharacteristics.dataType,
  1280. variable->variableCharacteristics.unit,
  1281. variable->variableCharacteristics.maxLimit,
  1282. variable->variableAttribute[0].type,
  1283. variable->variableAttribute[0].mutability,
  1284. variable->variableAttribute[0].value,
  1285. variable->variableCharacteristics.minLimit);
  1286. //* Execute SQL statement */
  1287. if(sqlite3_exec(db, sql, DB_cbVariableSaveToDb, 0, &errMsg) != SQLITE_OK)
  1288. {
  1289. DEBUG_INFO("SQL error: %s\n", errMsg);
  1290. result = FAIL;
  1291. }
  1292. return result;
  1293. }
  1294. int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1295. {
  1296. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1297. if(atoi(columnValue[0]) == 0)
  1298. {
  1299. DB_updateBootType(BootReasonEnumType_PowerUp);
  1300. // Create variable table content
  1301. /* AlignedDataCtrlr Required item */
  1302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1308. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1315. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1319. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.maxLimit = 20;
  1320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1322. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,"
  1324. "Energy.Active.Import.Register,"
  1325. "Energy.Active.Import.Interval,"
  1326. "Power.Active.Import,"
  1327. "Voltage,"
  1328. "SoC,"
  1329. "Current.Offered,"
  1330. "Power.Offered");
  1331. else
  1332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,"
  1333. "Energy.Active.Import.Register,"
  1334. "Energy.Active.Import.Interval,"
  1335. "Power.Active.Import,"
  1336. "Voltage,"
  1337. "Current.Offered");
  1338. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1340. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1343. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.minLimit = 5;
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1347. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1354. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1361. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1365. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.maxLimit = 10;
  1366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1368. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  1370. "Energy.Active.Import.Register,"
  1371. "Energy.Active.Import.Interval,"
  1372. "Power.Active.Import,"
  1373. "Voltage,"
  1374. "SoC");
  1375. else
  1376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  1377. "Energy.Active.Import.Register,"
  1378. "Energy.Active.Import.Interval,"
  1379. "Power.Active.Import,"
  1380. "Voltage");
  1381. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1384. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1385. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1389. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1390. /* AuthCtrlrVariable Required item */
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1393. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1397. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1404. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1411. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1416. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1418. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1425. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1432. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1436. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1440. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1441. /* AuthCacheCtrlr Variable Required item*/
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1448. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1455. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1463. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1467. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*10);
  1468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1471. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1478. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1479. /* ClockCtrlr Variable Required item */
  1480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1485. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1486. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1493. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1498. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1501. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1508. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1515. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1522. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1523. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1530. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1535. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1536. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1537. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1538. /* ChargingStation Required item */
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1543. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1545. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1551. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1552. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1559. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].component.name, "ChargingStation");
  1561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variable.name, "SystemUptimeSec");
  1562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].value, "0");
  1566. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec]);
  1567. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].component.name, "ChargingStation");
  1568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variable.name, "FreeVend");
  1569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableAttribute[0].value, (ShmSysConfigAndInfo->SysConfig.AuthorisationMode?"TRUE":"FALSE"));
  1573. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend]);
  1574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].component.name, "ChargingStation");
  1575. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variable.name, "FreeVendIdtag");
  1576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableAttribute[0].value, "FreeVendIdtag");
  1580. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag]);
  1581. /* Connector Required item */
  1582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1583. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1588. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1590. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1591. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1595. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1598. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1602. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1603. /* CustomizationCtrlr Required item */
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1606. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1607. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1610. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1611. /* DeviceDataCtrlr Required item */
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1613. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1614. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1615. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1619. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1621. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1622. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1627. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1635. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1643. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1645. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1646. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1651. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1653. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1654. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1655. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1657. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1658. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1659. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1660. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1661. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1666. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1667. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1668. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1673. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1674. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1675. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1676. /* DisplayMessageCtrlr Required item */
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1682. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1683. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1684. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1688. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1690. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1691. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1692. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1693. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1694. ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.maxLimit = 1;
  1695. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1696. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1697. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "1");
  1698. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1699. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1700. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1702. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1704. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1705. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1706. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1707. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1708. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1710. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1712. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1713. /* EVSE Required item */
  1714. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1715. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1716. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1717. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1719. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1720. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1721. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1722. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1723. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1724. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1725. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1727. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1728. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1729. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1730. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1732. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1734. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1735. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1737. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1739. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1741. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1742. /* LocalAuthListCtrlr Required item */
  1743. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1744. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1745. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1746. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1749. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1750. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1751. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1752. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1753. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.maxLimit = 5000;
  1754. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1757. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1758. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1759. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1761. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1764. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1765. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1766. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1767. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1768. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "500");
  1772. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1773. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1774. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1775. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1776. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1779. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "20480");
  1780. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1781. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1782. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1783. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1784. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = (1024*10);
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1787. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "100000");
  1788. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1789. /* MonitoringCtrlr Required item */
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1791. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1792. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1793. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1795. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1796. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1800. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1801. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1802. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1803. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1804. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1805. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1807. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1808. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1809. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1810. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1811. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1812. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1813. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1814. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1815. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1816. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1817. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1819. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1820. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1821. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1822. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1823. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1824. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1825. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1827. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1828. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1829. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1831. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1833. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1835. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1836. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1839. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1842. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1843. /* OCPPCommCtrlr Required item */
  1844. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1845. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1847. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1848. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1849. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1850. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1851. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1854. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1855. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1857. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1858. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1859. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1862. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1864. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1865. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1866. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1869. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1870. ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.minLimit = 10;
  1871. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1872. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1873. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1874. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1875. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1876. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1877. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1878. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1879. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1880. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "[0]");
  1882. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1884. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1885. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1886. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1887. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1888. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1889. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1891. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1892. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1893. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1894. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1895. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1897. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1898. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1899. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1900. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1901. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1902. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1903. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1904. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1906. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1907. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1908. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1909. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1911. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1912. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1913. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1914. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1916. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1918. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1919. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1920. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1921. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "30");
  1922. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1923. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1925. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1926. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1927. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1928. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1929. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1933. ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.minLimit = 10;
  1934. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1935. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1936. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1937. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1938. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1940. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1941. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1942. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1943. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1944. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1945. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1946. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1947. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1948. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1949. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1950. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1951. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1952. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].component.name, "OCPPCommCtrlr");
  1954. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variable.name, "VariableVersion");
  1955. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1956. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1957. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1958. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].value, "%d", variableVersion);
  1959. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion]);
  1960. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].component.name, "OCPPCommCtrlr");
  1961. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variable.name, "StatusNotificationPeriodically");
  1962. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1963. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1964. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1965. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].value, "FALSE");
  1966. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically]);
  1967. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].component.name, "OCPPCommCtrlr");
  1968. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variable.name, "StatusNotificationInterval");
  1969. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableCharacteristics.unit, "Seconds");
  1970. ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableCharacteristics.minLimit = 10;
  1971. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1972. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1973. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1974. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].value, "120");
  1975. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval]);
  1976. /* ReservationCtrlr Required item */
  1977. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1978. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1979. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1980. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1981. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1982. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1983. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1984. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1985. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1986. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1987. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1988. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1990. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1991. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1992. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1993. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1994. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1995. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1996. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1997. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1998. /* SampledDataCtrlr Required item */
  1999. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2000. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2001. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2002. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2003. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  2005. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2007. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2008. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2009. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2010. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  2012. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2014. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2015. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2016. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2017. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2018. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  2019. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  2020. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2021. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2022. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  2023. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.maxLimit = 10;
  2024. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2026. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  2027. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  2028. "Energy.Active.Import.Register,"
  2029. "Energy.Active.Import.Interval,"
  2030. "Power.Active.Import,"
  2031. "Voltage,"
  2032. "SoC");
  2033. else
  2034. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  2035. "Energy.Active.Import.Register,"
  2036. "Energy.Active.Import.Interval,"
  2037. "Power.Active.Import,"
  2038. "Voltage");
  2039. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  2040. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2041. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2042. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  2043. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2044. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2045. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2046. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  2047. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  2048. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2049. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2050. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  2051. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.maxLimit = 10;
  2052. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2053. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2054. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  2055. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  2056. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  2059. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.maxLimit = 10;
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2062. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  2063. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, "Current.Import,"
  2064. "Energy.Active.Import.Register,"
  2065. "Energy.Active.Import.Interval,"
  2066. "Power.Active.Import,"
  2067. "Voltage,"
  2068. "SoC,"
  2069. "Current.Offered,"
  2070. "Power.Offered");
  2071. else
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, "Current.Import,"
  2073. "Energy.Active.Import.Register,"
  2074. "Energy.Active.Import.Interval,"
  2075. "Power.Active.Import,"
  2076. "Voltage,"
  2077. "Current.Offered");
  2078. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2080. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2081. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  2082. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2083. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.minLimit = 3;
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2085. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2086. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "30");
  2087. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  2088. /* SecurityCtrlr Required item */
  2089. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2090. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2091. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2092. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_WriteOnly]);
  2095. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, "%s", (strlen((char*)ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword)>0?(char*)ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword:"00000000"));
  2096. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2100. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  2104. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2110. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  2111. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2115. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.maxLimit = 1;
  2116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2117. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  2119. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "%d", ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile);
  2126. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  2127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  2133. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].component.name, "SecurityCtrlr");
  2135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variable.name, "MaxCertificateChainSize");
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2137. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableCharacteristics.maxLimit = 10000;
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].value, "10000");
  2141. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize]);
  2142. /* SmartChargingCtrlr Required item */
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  2149. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  2156. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  2157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  2163. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "3");
  2170. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  2177. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  2184. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  2185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  2191. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  2198. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  2205. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2209. ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.maxLimit = 10;
  2210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "10");
  2213. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  2217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  2220. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  2221. /* TariffCostCtrlr Required item */
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  2229. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  2237. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2241. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  2242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  2245. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  2253. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  2261. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2265. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  2269. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  2270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2273. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  2277. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  2278. /* TxCtrlr Required item */
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2285. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  2293. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  2300. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2307. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  2308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "PowerPathClosed");
  2314. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  2315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "PowerPathClosed");
  2321. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "0");
  2329. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2336. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2337. }
  2338. else
  2339. {
  2340. // Variable name init
  2341. /* AlignedDataCtrlr Required item */
  2342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2358. /* AuthCtrlrVariable Required item */
  2359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2373. /* AuthCacheCtrlr Variable Required item */
  2374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2377. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2384. /* ClockCtrlr Variable Required item */
  2385. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2393. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2403. /* ChargingStation Required item */
  2404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].component.name, "ChargingStation");
  2411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variable.name, "SystemUptimeSec");
  2412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].component.name, "ChargingStation");
  2413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variable.name, "FreeVend");
  2414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].component.name, "ChargingStation");
  2415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variable.name, "FreeVendIdtag");
  2416. /* Connector Required item */
  2417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2423. /* CustomizationCtrlr Required item */
  2424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  2425. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  2426. /* DeviceDataCtrlr Required item */
  2427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2440. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2449. /* DisplayMessageCtrlr Required item */
  2450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2460. /* EVSE Required item */
  2461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2469. /* LocalAuthListCtrlr Required item */
  2470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2484. /* MonitoringCtrlr Required item */
  2485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2498. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2503. /* OCPPCommCtrlr Required item */
  2504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2522. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2535. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].component.name, "OCPPCommCtrlr");
  2536. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variable.name, "VariableVersion");
  2537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].component.name, "OCPPCommCtrlr");
  2538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variable.name, "StatusNotificationPeriodically");
  2539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].component.name, "OCPPCommCtrlr");
  2540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variable.name, "StatusNotificationInterval");
  2541. /* ReservationCtrlr Required item */
  2542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2543. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2548. /* SampledDataCtrlr Required item */
  2549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2551. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2559. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2565. /* SecurityCtrlr Required item */
  2566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2567. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2575. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].component.name, "SecurityCtrlr");
  2579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variable.name, "MaxCertificateChainSize");
  2580. /* SmartChargingCtrlr Required item */
  2581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2583. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2590. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2591. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2598. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2603. /* TariffCostCtrlr Required item */
  2604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2606. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2607. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2613. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2614. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2615. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2621. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2622. /* TxCtrlr Required item */
  2623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2635. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2639. }
  2640. return 0;
  2641. }
  2642. void DB_variableIsCreate()
  2643. {
  2644. char sql[512];
  2645. char* errMsg = NULL;
  2646. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2647. /* Execute SQL statement */
  2648. if(sqlite3_exec(db, sql, DB_cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2649. {
  2650. DEBUG_INFO("SQL error: %s\n", errMsg);
  2651. }
  2652. }
  2653. int DB_cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2654. {
  2655. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2656. {
  2657. if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) == 0) &&
  2658. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) == 0) &&
  2659. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) == 0) &&
  2660. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) == 0))
  2661. {
  2662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2664. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2666. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2667. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2668. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.minLimit = strlen(columnValue[11])>=0?atoi(columnValue[11]):0;
  2669. }
  2670. }
  2671. return 0;
  2672. }
  2673. void DB_variableLoadFromDb()
  2674. {
  2675. char sql[512];
  2676. char* errMsg = NULL;
  2677. sprintf(sql,"select * from ocpp20_variable order by idx;");
  2678. /* Execute SQL statement */
  2679. if(sqlite3_exec(db, sql, DB_cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2680. {
  2681. DEBUG_INFO("SQL error: %s\n", errMsg);
  2682. }
  2683. }
  2684. int DB_cbGetNetworkProfileFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2685. {
  2686. memset(&ShmOCPP20Data->NetworkConnectionProfile[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile));
  2687. if(columnCount > 0)
  2688. {
  2689. for(int idx=0;idx<columnCount;idx++)
  2690. {
  2691. json_object *SetNetworkProfile;
  2692. SetNetworkProfile = json_tokener_parse(columnValue[2]);
  2693. if(!is_error(SetNetworkProfile))
  2694. {
  2695. // Required data
  2696. if(json_object_object_get(SetNetworkProfile, "ocppVersion") != NULL)
  2697. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppVersion")));
  2698. if(json_object_object_get(SetNetworkProfile, "ocppTransport") != NULL)
  2699. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppTransport")));
  2700. if(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl") != NULL)
  2701. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl")));
  2702. if(json_object_object_get(SetNetworkProfile, "messageTimeout") != NULL)
  2703. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.messageTimeout = json_object_get_int(json_object_object_get(SetNetworkProfile, "messageTimeout"));
  2704. if(json_object_object_get(SetNetworkProfile, "ocppInterface") != NULL)
  2705. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppInterface")));
  2706. if(json_object_object_get(SetNetworkProfile, "vpn") != NULL)
  2707. {
  2708. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server") != NULL)
  2709. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server")));
  2710. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user") != NULL)
  2711. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user")));
  2712. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group") != NULL)
  2713. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group")));
  2714. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password") != NULL)
  2715. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password")));
  2716. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key") != NULL)
  2717. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key")));
  2718. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type") != NULL)
  2719. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type")));
  2720. }
  2721. if(json_object_object_get(SetNetworkProfile, "apn") != NULL)
  2722. {
  2723. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn") != NULL)
  2724. {
  2725. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn));
  2726. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn")));
  2727. }
  2728. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName") != NULL)
  2729. {
  2730. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName));
  2731. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName")));
  2732. }
  2733. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword") != NULL)
  2734. {
  2735. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword));
  2736. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword")));
  2737. }
  2738. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin") != NULL)
  2739. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin"));
  2740. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork") != NULL)
  2741. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork")));
  2742. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork") != NULL)
  2743. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork"));
  2744. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication") != NULL)
  2745. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication")));
  2746. }
  2747. }
  2748. json_object_put(SetNetworkProfile);
  2749. ShmOCPP20Data->NetworkConnectionProfile[idx].slot = atoi(columnValue[1]);
  2750. }
  2751. }
  2752. return 0;
  2753. }
  2754. void DB_getNetworkProfileFromDb()
  2755. {
  2756. char sql[512];
  2757. char* errMsg = NULL;
  2758. sprintf(sql,"select * from ocpp20_networkprofile order by slot;");
  2759. /* Execute SQL statement */
  2760. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2761. {
  2762. DEBUG_INFO("SQL error: %s\n", errMsg);
  2763. }
  2764. }
  2765. int DB_addNetworkProfile(int slot, char *data)
  2766. {
  2767. int result = PASS;
  2768. char sql[512];
  2769. char* errMsg = NULL;
  2770. sprintf(sql,"insert or replace into ocpp20_networkprofile (slot, connectionData) VALUES('%d', '%s'); SELECT * from ocpp20_networkprofile order by slot;",
  2771. slot,
  2772. data);
  2773. //* Execute SQL statement */
  2774. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK)
  2775. {
  2776. DEBUG_INFO("SQL error: %s\n", errMsg);
  2777. result = FAIL;
  2778. }
  2779. return result;
  2780. }
  2781. int DB_deleteNetworkProfile(int slot)
  2782. {
  2783. int result = PASS;
  2784. char sql[512];
  2785. char* errMsg = NULL;
  2786. sprintf(sql,"DELETE from ocpp20_networkprofile where slot=%d; SELECT * from ocpp20_networkprofile order by slot;", slot);
  2787. //* Execute SQL statement */
  2788. if( sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2789. {
  2790. DEBUG_INFO("SQL error: %s", errMsg);
  2791. result = FAIL;
  2792. }
  2793. return result;
  2794. }
  2795. int getCurrentYear()
  2796. {
  2797. int result = 0;
  2798. time_t CurrentTime;
  2799. struct tm *tm;
  2800. CurrentTime = time(NULL);
  2801. tm=localtime(&CurrentTime);
  2802. result = (tm->tm_year + 1900);
  2803. return result;
  2804. }
  2805. int OCPP_insert_transaction_msg(uint8_t isStartTransaction, char *transactionMsg)
  2806. {
  2807. int result = PASS;
  2808. char* errMsg = NULL;
  2809. char sqlStr[8192];
  2810. sprintf(sqlStr, "insert into ocpp20_transaction_record(occurDatetime, message_type, message_content) values(CURRENT_TIMESTAMP, '%s', '%s');", (isStartTransaction?"startTransaction":"stopTransaction"), transactionMsg);
  2811. if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
  2812. {
  2813. result = FAIL;
  2814. DEBUG_WARN( "Insert local transaction record error message: %s\n", errMsg);
  2815. }
  2816. sprintf(sqlStr, "delete from ocpp20_transaction_record where (idx < (select idx from ocpp_transaction_record order by idx desc limit 1)-2000) and (occurDatetime < '%04d-01-01 00:00:00');", (getCurrentYear()-3));
  2817. if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
  2818. {
  2819. result = FAIL;
  2820. DEBUG_WARN( "delete local transaction record error message: %s\n", errMsg);
  2821. }
  2822. return result;
  2823. }
  2824. //==========================================
  2825. // Check time passed since today
  2826. //==========================================
  2827. long long DiffTimebWithNow(struct timeb ST)
  2828. {
  2829. //return milli-second
  2830. struct timeb ET;
  2831. long long StartTime,StopTime;
  2832. ftime(&ET);
  2833. StartTime=(long long)ST.time;
  2834. StopTime=(long long)ET.time;
  2835. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2836. }
  2837. int getTimePassSinceToday(uint8_t gun_index)
  2838. {
  2839. int result = -1;
  2840. static time_t lastTime[4];
  2841. time_t t;
  2842. struct tm *tmStartToday;
  2843. struct timeb tbStartToday;
  2844. t=time(NULL);
  2845. if(difftime(t, lastTime[gun_index])>0)
  2846. {
  2847. tmStartToday=localtime(&t);
  2848. tmStartToday->tm_hour = 0;
  2849. tmStartToday->tm_min = 0;
  2850. tmStartToday->tm_sec = 0;
  2851. tbStartToday.time = mktime(tmStartToday);
  2852. tbStartToday.millitm = 0;
  2853. result = DiffTimebWithNow(tbStartToday)/1000;
  2854. lastTime[gun_index] = t;
  2855. }
  2856. return result;
  2857. }
  2858. int syncDateTimeRTC(uint8_t *data)
  2859. {
  2860. struct ParsingResult
  2861. {
  2862. int result;
  2863. int scanedElement;
  2864. int year;
  2865. int month;
  2866. int mday;
  2867. int hour;
  2868. int min;
  2869. int sec;
  2870. int tz_hour;
  2871. int tz_min;
  2872. float minSec;
  2873. }result;
  2874. struct tm tmOrg;
  2875. struct tm *tmTarget;
  2876. struct timeb tbTarget;
  2877. char buf[128];
  2878. memset(&result, 0x00, sizeof(struct ParsingResult));
  2879. result.result = PASS;
  2880. if(strstr((char*)data, ".") != NULL)
  2881. {
  2882. // Original data with mini second
  2883. if(strstr((char*)data, "Z") != NULL)
  2884. {
  2885. // Original data with Z
  2886. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%fZ",
  2887. &result.year,
  2888. &result.month,
  2889. &result.mday,
  2890. &result.hour,
  2891. &result.min,
  2892. &result.sec,
  2893. &result.minSec);
  2894. }
  2895. else
  2896. {
  2897. // Original data without Z
  2898. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  2899. &result.year,
  2900. &result.month,
  2901. &result.mday,
  2902. &result.hour,
  2903. &result.min,
  2904. &result.sec,
  2905. &result.minSec,
  2906. &result.tz_hour,
  2907. &result.tz_min);
  2908. }
  2909. }
  2910. else
  2911. {
  2912. // Original data without mini second
  2913. if(strstr((char*)data, "Z") != NULL)
  2914. {
  2915. // Original data with Z
  2916. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%dZ",
  2917. &result.year,
  2918. &result.month,
  2919. &result.mday,
  2920. &result.hour,
  2921. &result.min,
  2922. &result.sec);
  2923. }
  2924. else
  2925. {
  2926. // Original data without Z
  2927. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d%d:%d",
  2928. &result.year,
  2929. &result.month,
  2930. &result.mday,
  2931. &result.hour,
  2932. &result.min,
  2933. &result.sec,
  2934. &result.tz_hour,
  2935. &result.tz_min);
  2936. }
  2937. }
  2938. tmOrg.tm_year = result.year - 1900;
  2939. tmOrg.tm_mon = result.month - 1;
  2940. tmOrg.tm_mday = result.mday;
  2941. tmOrg.tm_hour = result.hour;
  2942. tmOrg.tm_min = result.min;
  2943. tmOrg.tm_sec = result.sec;
  2944. tmOrg.tm_gmtoff = 0;
  2945. tbTarget.time = mktime(&tmOrg);
  2946. tbTarget.timezone = 0;
  2947. tbTarget.time -= (result.tz_hour*3600) + (result.tz_min*60*(result.tz_hour>=0?1:-1));
  2948. tmTarget = gmtime(&tbTarget.time);
  2949. sprintf(buf, "date -s '%04d-%02d-%02d %02d:%02d:%02d'", (tmTarget->tm_year+1900), (tmTarget->tm_mon+1), tmTarget->tm_mday, tmTarget->tm_hour, tmTarget->tm_min, tmTarget->tm_sec);
  2950. //DEBUG_INFO(" org date time: %s\n", data);
  2951. //DEBUG_INFO("parse date time: %s\n", buf);
  2952. system(buf);
  2953. system("/sbin/hwclock -w --systohc");
  2954. if(result.scanedElement < 6)
  2955. result.result = FAIL;
  2956. return result.result;
  2957. }
  2958. //==========================================
  2959. // GetCompositeSchedule logic related function
  2960. //==========================================
  2961. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2962. {
  2963. //return milli-second
  2964. unsigned int StartTime,StopTime;
  2965. StartTime=(unsigned int)ST.time;
  2966. StopTime=(unsigned int)ET.time;
  2967. return (StopTime-StartTime);
  2968. }
  2969. int DiffTimebWithNowSec(struct timeb ST)
  2970. {
  2971. //return milli-second
  2972. struct timeb ET;
  2973. unsigned int StartTime,StopTime;
  2974. ftime(&ET);
  2975. StartTime=(unsigned int)ST.time;
  2976. StopTime=(unsigned int)ET.time;
  2977. return (StopTime-StartTime);
  2978. }
  2979. int getStartStop(uint8_t *start, uint8_t *stop)
  2980. {
  2981. struct ParsingResult
  2982. {
  2983. int result;
  2984. int scanedElement;
  2985. int year;
  2986. int month;
  2987. int mday;
  2988. int hour;
  2989. int min;
  2990. int sec;
  2991. int tz_hour;
  2992. int tz_min;
  2993. float minSec;
  2994. };
  2995. struct ParsingResult parseStart;
  2996. struct ParsingResult parseStop;
  2997. int result = -1;
  2998. struct tm tmStart;
  2999. struct timeb tbStart;
  3000. struct tm tmStop;
  3001. struct timeb tbStop;
  3002. memset(&parseStart, 0x00, sizeof(struct ParsingResult));
  3003. memset(&parseStop, 0x00, sizeof(struct ParsingResult));
  3004. // Scan start & stop date time
  3005. if(strstr((char*)start, ".") != NULL)
  3006. {
  3007. // Original data with mini second
  3008. if(strstr((char*)start, "Z") != NULL)
  3009. {
  3010. // Original data with Z
  3011. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%fZ",
  3012. &parseStart.year,
  3013. &parseStart.month,
  3014. &parseStart.mday,
  3015. &parseStart.hour,
  3016. &parseStart.min,
  3017. &parseStart.sec,
  3018. &parseStart.minSec);
  3019. }
  3020. else
  3021. {
  3022. // Original data without Z
  3023. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  3024. &parseStart.year,
  3025. &parseStart.month,
  3026. &parseStart.mday,
  3027. &parseStart.hour,
  3028. &parseStart.min,
  3029. &parseStart.sec,
  3030. &parseStart.minSec,
  3031. &parseStart.tz_hour,
  3032. &parseStart.tz_min);
  3033. }
  3034. }
  3035. else
  3036. {
  3037. // Original data without mini second
  3038. if(strstr((char*)start, "Z") != NULL)
  3039. {
  3040. // Original data with Z
  3041. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%dZ",
  3042. &parseStart.year,
  3043. &parseStart.month,
  3044. &parseStart.mday,
  3045. &parseStart.hour,
  3046. &parseStart.min,
  3047. &parseStart.sec);
  3048. }
  3049. else
  3050. {
  3051. // Original data without Z
  3052. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d%d:%d",
  3053. &parseStart.year,
  3054. &parseStart.month,
  3055. &parseStart.mday,
  3056. &parseStart.hour,
  3057. &parseStart.min,
  3058. &parseStart.sec,
  3059. &parseStart.tz_hour,
  3060. &parseStart.tz_min);
  3061. }
  3062. }
  3063. if(strstr((char*)stop, ".") != NULL)
  3064. {
  3065. // Original data with mini second
  3066. if(strstr((char*)stop, "Z") != NULL)
  3067. {
  3068. // Original data with Z
  3069. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d.%fZ",
  3070. &parseStop.year,
  3071. &parseStop.month,
  3072. &parseStop.mday,
  3073. &parseStop.hour,
  3074. &parseStop.min,
  3075. &parseStop.sec,
  3076. &parseStop.minSec);
  3077. }
  3078. else
  3079. {
  3080. // Original data without Z
  3081. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  3082. &parseStop.year,
  3083. &parseStop.month,
  3084. &parseStop.mday,
  3085. &parseStop.hour,
  3086. &parseStop.min,
  3087. &parseStop.sec,
  3088. &parseStop.minSec,
  3089. &parseStop.tz_hour,
  3090. &parseStop.tz_min);
  3091. }
  3092. }
  3093. else
  3094. {
  3095. // Original data without mini second
  3096. if(strstr((char*)stop, "Z") != NULL)
  3097. {
  3098. // Original data with Z
  3099. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%dZ",
  3100. &parseStop.year,
  3101. &parseStop.month,
  3102. &parseStop.mday,
  3103. &parseStop.hour,
  3104. &parseStop.min,
  3105. &parseStop.sec);
  3106. }
  3107. else
  3108. {
  3109. // Original data without Z
  3110. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d%d:%d",
  3111. &parseStop.year,
  3112. &parseStop.month,
  3113. &parseStop.mday,
  3114. &parseStop.hour,
  3115. &parseStop.min,
  3116. &parseStop.sec,
  3117. &parseStop.tz_hour,
  3118. &parseStop.tz_min);
  3119. }
  3120. }
  3121. // Calculate date time difference
  3122. if((parseStart.scanedElement >=6) &&
  3123. (parseStop.scanedElement >=6))
  3124. {
  3125. //DEBUG_INFO("Start: %04d-%02d-%02d %02d:%02d:%02d(%02d:%02d)\n", parseStart.year, parseStart.month, parseStart.mday, parseStart.hour, parseStart.min, parseStart.sec, parseStart.tz_hour, parseStart.tz_min);
  3126. //DEBUG_INFO("Stop: %04d-%02d-%02d %02d:%02d:%02d(%02d:%02d)\n", parseStop.year, parseStop.month, parseStop.mday, parseStop.hour, parseStop.min, parseStop.sec, parseStop.tz_hour, parseStop.tz_min);
  3127. tmStart.tm_year = parseStart.year - 1900;
  3128. tmStart.tm_mon = parseStart.month - 1;
  3129. tmStart.tm_mday = parseStart.mday;
  3130. tmStart.tm_hour = parseStart.hour;
  3131. tmStart.tm_min = parseStart.min;
  3132. tmStart.tm_sec = parseStart.sec;
  3133. tmStart.tm_gmtoff = 0;
  3134. tbStart.time = mktime(&tmStart);
  3135. tbStart.timezone = 0;
  3136. tbStart.time -= (parseStart.tz_hour*3600) + (parseStart.tz_min*60*(parseStart.tz_hour>=0?1:-1));
  3137. tmStop.tm_year = parseStop.year - 1900;
  3138. tmStop.tm_mon = parseStop.month - 1;
  3139. tmStop.tm_mday = parseStop.mday;
  3140. tmStop.tm_hour = parseStop.hour;
  3141. tmStop.tm_min = parseStop.min;
  3142. tmStop.tm_sec = parseStop.sec;
  3143. tmStop.tm_gmtoff = 0;
  3144. tbStop.time = mktime(&tmStop);
  3145. tbStop.timezone = 0;
  3146. tbStop.time -= (parseStop.tz_hour*3600) + (parseStop.tz_min*60*(parseStop.tz_hour>=0?1:-1));
  3147. result = DiffTimebSec(tbStart, tbStop);
  3148. //DEBUG_INFO("getStartStop(): %d\n", result);
  3149. }
  3150. else
  3151. {
  3152. DEBUG_WARN("Start or stop date parsing error.\r\n");
  3153. }
  3154. return result;
  3155. }
  3156. int isOvertNow(uint8_t *start)
  3157. {
  3158. int result = NO;
  3159. struct ParsingResult
  3160. {
  3161. int result;
  3162. int scanedElement;
  3163. int year;
  3164. int month;
  3165. int mday;
  3166. int hour;
  3167. int min;
  3168. int sec;
  3169. int tz_hour;
  3170. int tz_min;
  3171. float minSec;
  3172. }parsingResult;
  3173. struct tm tmStart;
  3174. struct timeb tbStart;
  3175. memset(&parsingResult, 0x00, sizeof(struct ParsingResult));
  3176. if(strstr((char*)start, ".") != NULL)
  3177. {
  3178. // Original data with mini second
  3179. if(strstr((char*)start, "Z") != NULL)
  3180. {
  3181. // Original data with Z
  3182. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%fZ",
  3183. &parsingResult.year,
  3184. &parsingResult.month,
  3185. &parsingResult.mday,
  3186. &parsingResult.hour,
  3187. &parsingResult.min,
  3188. &parsingResult.sec,
  3189. &parsingResult.minSec);
  3190. }
  3191. else
  3192. {
  3193. // Original data without Z
  3194. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  3195. &parsingResult.year,
  3196. &parsingResult.month,
  3197. &parsingResult.mday,
  3198. &parsingResult.hour,
  3199. &parsingResult.min,
  3200. &parsingResult.sec,
  3201. &parsingResult.minSec,
  3202. &parsingResult.tz_hour,
  3203. &parsingResult.tz_min);
  3204. }
  3205. }
  3206. else
  3207. {
  3208. // Original data without mini second
  3209. if(strstr((char*)start, "Z") != NULL)
  3210. {
  3211. // Original data with Z
  3212. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%dZ",
  3213. &parsingResult.year,
  3214. &parsingResult.month,
  3215. &parsingResult.mday,
  3216. &parsingResult.hour,
  3217. &parsingResult.min,
  3218. &parsingResult.sec);
  3219. }
  3220. else
  3221. {
  3222. // Original data without Z
  3223. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d%d:%d",
  3224. &parsingResult.year,
  3225. &parsingResult.month,
  3226. &parsingResult.mday,
  3227. &parsingResult.hour,
  3228. &parsingResult.min,
  3229. &parsingResult.sec,
  3230. &parsingResult.tz_hour,
  3231. &parsingResult.tz_min);
  3232. }
  3233. }
  3234. if(parsingResult.scanedElement >= 6)
  3235. {
  3236. tmStart.tm_year = parsingResult.year - 1900;
  3237. tmStart.tm_mon = parsingResult.month - 1;
  3238. tmStart.tm_mday = parsingResult.mday;
  3239. tmStart.tm_hour = parsingResult.hour;
  3240. tmStart.tm_min = parsingResult.min;
  3241. tmStart.tm_sec = parsingResult.sec;
  3242. tmStart.tm_gmtoff = 0;
  3243. tbStart.time = mktime(&tmStart);
  3244. tbStart.timezone = 0;
  3245. tbStart.millitm = 0;
  3246. tbStart.time -= (parsingResult.tz_hour*3600) + (parsingResult.tz_min*60*(parsingResult.tz_hour>=0?1:-1));
  3247. if(DiffTimebWithNowSec(tbStart) <= 0)
  3248. result = NO;
  3249. else
  3250. result = YES;
  3251. }
  3252. else
  3253. {
  3254. DEBUG_WARN("Start date parsing error.\n");
  3255. }
  3256. return result;
  3257. }
  3258. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  3259. {
  3260. struct ParsingResult
  3261. {
  3262. int result;
  3263. int scanedElement;
  3264. int year;
  3265. int month;
  3266. int mday;
  3267. int hour;
  3268. int min;
  3269. int sec;
  3270. int tz_hour;
  3271. int tz_min;
  3272. float minSec;
  3273. };
  3274. struct ParsingResult parseStart;
  3275. struct ParsingResult parseStop;
  3276. int result = -1;
  3277. struct tm tmStart;
  3278. struct timeb tbStart;
  3279. struct tm tmStop;
  3280. struct timeb tbStop;
  3281. memset(&parseStart, 0x00, sizeof(struct ParsingResult));
  3282. memset(&parseStop, 0x00, sizeof(struct ParsingResult));
  3283. // Scan start & stop date time
  3284. if(strstr((char*)start, ".") != NULL)
  3285. {
  3286. // Original data with mini second
  3287. if(strstr((char*)start, "Z") != NULL)
  3288. {
  3289. // Original data with Z
  3290. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%fZ",
  3291. &parseStart.year,
  3292. &parseStart.month,
  3293. &parseStart.mday,
  3294. &parseStart.hour,
  3295. &parseStart.min,
  3296. &parseStart.sec,
  3297. &parseStart.minSec);
  3298. }
  3299. else
  3300. {
  3301. // Original data without Z
  3302. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  3303. &parseStart.year,
  3304. &parseStart.month,
  3305. &parseStart.mday,
  3306. &parseStart.hour,
  3307. &parseStart.min,
  3308. &parseStart.sec,
  3309. &parseStart.minSec,
  3310. &parseStart.tz_hour,
  3311. &parseStart.tz_min);
  3312. }
  3313. }
  3314. else
  3315. {
  3316. // Original data without mini second
  3317. if(strstr((char*)start, "Z") != NULL)
  3318. {
  3319. // Original data with Z
  3320. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%dZ",
  3321. &parseStart.year,
  3322. &parseStart.month,
  3323. &parseStart.mday,
  3324. &parseStart.hour,
  3325. &parseStart.min,
  3326. &parseStart.sec);
  3327. }
  3328. else
  3329. {
  3330. // Original data without Z
  3331. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d%d:%d",
  3332. &parseStart.year,
  3333. &parseStart.month,
  3334. &parseStart.mday,
  3335. &parseStart.hour,
  3336. &parseStart.min,
  3337. &parseStart.sec,
  3338. &parseStart.tz_hour,
  3339. &parseStart.tz_min);
  3340. }
  3341. }
  3342. if(strstr((char*)stop, ".") != NULL)
  3343. {
  3344. // Original data with mini second
  3345. if(strstr((char*)stop, "Z") != NULL)
  3346. {
  3347. // Original data with Z
  3348. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d.%fZ",
  3349. &parseStop.year,
  3350. &parseStop.month,
  3351. &parseStop.mday,
  3352. &parseStop.hour,
  3353. &parseStop.min,
  3354. &parseStop.sec,
  3355. &parseStop.minSec);
  3356. }
  3357. else
  3358. {
  3359. // Original data without Z
  3360. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  3361. &parseStop.year,
  3362. &parseStop.month,
  3363. &parseStop.mday,
  3364. &parseStop.hour,
  3365. &parseStop.min,
  3366. &parseStop.sec,
  3367. &parseStop.minSec,
  3368. &parseStop.tz_hour,
  3369. &parseStop.tz_min);
  3370. }
  3371. }
  3372. else
  3373. {
  3374. // Original data without mini second
  3375. if(strstr((char*)stop, "Z") != NULL)
  3376. {
  3377. // Original data with Z
  3378. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%dZ",
  3379. &parseStop.year,
  3380. &parseStop.month,
  3381. &parseStop.mday,
  3382. &parseStop.hour,
  3383. &parseStop.min,
  3384. &parseStop.sec);
  3385. }
  3386. else
  3387. {
  3388. // Original data without Z
  3389. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d%d:%d",
  3390. &parseStop.year,
  3391. &parseStop.month,
  3392. &parseStop.mday,
  3393. &parseStop.hour,
  3394. &parseStop.min,
  3395. &parseStop.sec,
  3396. &parseStop.tz_hour,
  3397. &parseStop.tz_min);
  3398. }
  3399. }
  3400. // Calculate date time difference
  3401. if((parseStart.scanedElement >=6) &&
  3402. (parseStop.scanedElement >=6))
  3403. {
  3404. //DEBUG_INFO("Start: %04d-%02d-%02d %02d:%02d:%02d(%02d:%02d)\n", parseStart.year, parseStart.month, parseStart.mday, parseStart.hour, parseStart.min, parseStart.sec, parseStart.tz_hour, parseStart.tz_min);
  3405. //DEBUG_INFO("Stop: %04d-%02d-%02d %02d:%02d:%02d(%02d:%02d)\n", parseStop.year, parseStop.month, parseStop.mday, parseStop.hour, parseStop.min, parseStop.sec, parseStop.tz_hour, parseStop.tz_min);
  3406. tmStart.tm_year = parseStart.year - 1900;
  3407. tmStart.tm_mon = parseStart.month - 1;
  3408. tmStart.tm_mday = parseStart.mday;
  3409. tmStart.tm_hour = parseStart.hour;
  3410. tmStart.tm_min = parseStart.min;
  3411. tmStart.tm_sec = parseStart.sec;
  3412. tmStart.tm_gmtoff = 0;
  3413. tbStart.time = mktime(&tmStart);
  3414. tbStart.timezone = 0;
  3415. tbStart.time -= (parseStart.tz_hour*3600) + (parseStart.tz_min*60*(parseStart.tz_hour>=0?1:-1));
  3416. tmStop.tm_year = parseStop.year - 1900;
  3417. tmStop.tm_mon = parseStop.month - 1;
  3418. tmStop.tm_mday = parseStop.mday;
  3419. tmStop.tm_hour = parseStop.hour;
  3420. tmStop.tm_min = parseStop.min;
  3421. tmStop.tm_sec = parseStop.sec;
  3422. tmStop.tm_gmtoff = 0;
  3423. tbStop.time = mktime(&tmStop);
  3424. tbStop.timezone = 0;
  3425. tbStop.time -= (parseStop.tz_hour*3600) + (parseStop.tz_min*60*(parseStop.tz_hour>=0?1:-1));
  3426. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  3427. //DEBUG_INFO("getStartStop(): %d\n", result);
  3428. }
  3429. else
  3430. {
  3431. DEBUG_WARN("Start or stop date parsing error.\r\n");
  3432. }
  3433. return result;
  3434. }
  3435. void checkChargingStationMaxProfile(uint32_t durationReq, struct ChargingProfileType *targetCompositeProfile, uint8_t idxSchedule, uint8_t isUnitA)
  3436. {
  3437. FILE *fp;
  3438. char profileFileName[128];
  3439. char *line = NULL;
  3440. size_t len = 0;
  3441. time_t CurrentTime;
  3442. struct tm *tmComposite;
  3443. struct ChargingProfileType maxProfile;
  3444. struct ChargingProfileType compositeProfile;
  3445. uint8_t limitMax=0;
  3446. int compositePeriodIdx = 0;
  3447. CurrentTime = time(NULL);
  3448. tmComposite=localtime(&CurrentTime);
  3449. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].startSchedule, "%04d-%02d-%02dT%02d:%02d:%02dZ", tmComposite->tm_year+1900, tmComposite->tm_mon+1, tmComposite->tm_mday, tmComposite->tm_hour, tmComposite->tm_min, tmComposite->tm_sec);
  3450. if(isUnitA)
  3451. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3452. else
  3453. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3454. compositeProfile.chargingSchedule[idxSchedule].duration = durationReq;
  3455. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3456. {
  3457. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3458. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3459. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3460. }
  3461. compositeProfile.id = 0;
  3462. compositeProfile.stackLevel = 99 ;
  3463. sprintf((char*)compositeProfile.chargingProfileKind ,"Absolute");
  3464. maxProfile.id = -1;
  3465. maxProfile.chargingSchedule[idxSchedule].duration = -1;
  3466. system("rm -f /tmp/*.json");
  3467. system("cp /Storage/OCPP/*.json /tmp 2>/dev/null");
  3468. // Search max profile
  3469. sprintf(profileFileName, "/tmp/ChargingStationMaxProfile_OCPP20.json");
  3470. if((access(profileFileName, F_OK))!=-1)
  3471. {
  3472. fp = fopen(profileFileName, "r");
  3473. while(getline(&line, &len, fp) != -1)
  3474. {
  3475. json_object *obj = NULL;
  3476. obj = json_tokener_parse(line);
  3477. if(is_error(obj))
  3478. {
  3479. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  3480. }
  3481. else
  3482. {
  3483. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != maxProfile.id) &&
  3484. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= maxProfile.stackLevel)
  3485. )
  3486. {
  3487. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  3488. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3489. )
  3490. {
  3491. struct tm tmFrom, tmTo;
  3492. struct timeb tbFrom, tbTo;
  3493. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmFrom.tm_year, &tmFrom.tm_mon, &tmFrom.tm_mday, &tmFrom.tm_hour, &tmFrom.tm_min, &tmFrom.tm_sec) == 6) &&
  3494. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmTo.tm_year, &tmTo.tm_mon, &tmTo.tm_mday, &tmTo.tm_hour, &tmTo.tm_min, &tmTo.tm_sec) == 6))
  3495. {
  3496. tmFrom.tm_year -= 1900;
  3497. tmFrom.tm_mon -= 1;
  3498. tbFrom.time = mktime(&tmFrom);
  3499. tmTo.tm_year -= 1900;
  3500. tmTo.tm_mon -= 1;
  3501. tbTo.time = mktime(&tmTo);
  3502. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3503. {
  3504. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3505. {
  3506. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3507. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3508. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3509. }
  3510. if(maxProfile.id == -1)
  3511. DEBUG_INFO("MaxProfile found.\n");
  3512. else
  3513. DEBUG_INFO("MaxProfile updated.\n");
  3514. // Required item
  3515. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3516. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3517. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3518. if(isUnitA)
  3519. {
  3520. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3521. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  3522. {
  3523. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3524. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0 ), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3525. 3:
  3526. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3527. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3528. }
  3529. }
  3530. else
  3531. {
  3532. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3533. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  3534. {
  3535. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3536. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3537. 3:
  3538. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3539. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3540. }
  3541. }
  3542. // Optional item
  3543. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3544. {
  3545. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3546. }
  3547. else
  3548. {
  3549. sprintf((char*)maxProfile.validFrom, " ");
  3550. }
  3551. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3552. {
  3553. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3554. }
  3555. else
  3556. {
  3557. sprintf((char*)maxProfile.validTo, " ");
  3558. }
  3559. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3560. {
  3561. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3562. }
  3563. else
  3564. {
  3565. sprintf((char*)maxProfile.recurrencyKind, " ");
  3566. }
  3567. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3568. {
  3569. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3570. }
  3571. else
  3572. {
  3573. sprintf((char*)maxProfile.transactionId, " ");
  3574. }
  3575. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  3576. {
  3577. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
  3578. }
  3579. else
  3580. {
  3581. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3582. }
  3583. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  3584. {
  3585. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
  3586. }
  3587. else
  3588. {
  3589. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
  3590. }
  3591. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  3592. {
  3593. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
  3594. }
  3595. else
  3596. {
  3597. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3598. }
  3599. }
  3600. }
  3601. }
  3602. else
  3603. {
  3604. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3605. {
  3606. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3607. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3608. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3609. }
  3610. if(maxProfile.id == -1)
  3611. DEBUG_INFO("MaxProfile found.\n");
  3612. else
  3613. DEBUG_INFO("MaxProfile updated.\n");
  3614. // Required item
  3615. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3616. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3617. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3618. if(isUnitA)
  3619. {
  3620. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3621. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  3622. {
  3623. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3624. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3625. 3:
  3626. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3627. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3628. }
  3629. }
  3630. else
  3631. {
  3632. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3633. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  3634. {
  3635. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3636. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3637. 3:
  3638. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3639. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  3640. }
  3641. }
  3642. // Optional item
  3643. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3644. {
  3645. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3646. }
  3647. else
  3648. {
  3649. sprintf((char*)maxProfile.validFrom, " ");
  3650. }
  3651. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3652. {
  3653. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3654. }
  3655. else
  3656. {
  3657. sprintf((char*)maxProfile.validTo, " ");
  3658. }
  3659. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3660. {
  3661. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3662. }
  3663. else
  3664. {
  3665. sprintf((char*)maxProfile.recurrencyKind, " ");
  3666. }
  3667. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3668. {
  3669. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3670. }
  3671. else
  3672. {
  3673. sprintf((char*)maxProfile.transactionId, " ");
  3674. }
  3675. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  3676. {
  3677. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
  3678. }
  3679. else
  3680. {
  3681. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3682. }
  3683. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  3684. {
  3685. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
  3686. }
  3687. else
  3688. {
  3689. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
  3690. }
  3691. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  3692. {
  3693. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
  3694. }
  3695. else
  3696. {
  3697. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3698. }
  3699. }
  3700. }
  3701. }
  3702. json_object_put(obj);
  3703. }
  3704. fclose(fp);
  3705. /*
  3706. if(maxProfile.id !=-1)
  3707. {
  3708. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  3709. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3710. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3711. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3712. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3713. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3714. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  3715. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[idxSchedule].StartSchedule);
  3716. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  3717. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3718. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3719. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3720. {
  3721. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3722. {
  3723. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3724. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3725. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3726. }
  3727. }
  3728. }
  3729. else
  3730. DEBUG_INFO("MaxProfile not found.\n");
  3731. DEBUG_INFO("------------------------------------\n");*/
  3732. }
  3733. if(maxProfile.id != -1)
  3734. {
  3735. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3736. {
  3737. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3738. {
  3739. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  3740. 0:
  3741. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  3742. }
  3743. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3744. {
  3745. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3746. {
  3747. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  3748. 0:
  3749. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  3750. if(idxPeriod > 0)
  3751. {
  3752. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3753. {
  3754. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3755. }
  3756. }
  3757. }
  3758. }
  3759. }
  3760. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3761. {
  3762. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3763. {
  3764. maxProfile.chargingSchedule[idxSchedule].duration = maxProfile.chargingSchedule[idxSchedule].duration;
  3765. }
  3766. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3767. {
  3768. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3769. {
  3770. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod;
  3771. if(idxPeriod > 0)
  3772. {
  3773. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3774. {
  3775. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3776. }
  3777. }
  3778. }
  3779. }
  3780. }
  3781. else
  3782. {
  3783. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3784. {
  3785. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3786. {
  3787. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3788. 0:
  3789. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3790. }
  3791. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3792. {
  3793. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3794. {
  3795. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3796. 0:
  3797. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3798. if(idxPeriod > 0)
  3799. {
  3800. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3801. {
  3802. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3803. }
  3804. }
  3805. }
  3806. }
  3807. }
  3808. else
  3809. {
  3810. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3811. {
  3812. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3813. 0:
  3814. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3815. }
  3816. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3817. {
  3818. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3819. {
  3820. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3821. 0:
  3822. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3823. if(idxPeriod > 0)
  3824. {
  3825. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3826. {
  3827. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3828. }
  3829. }
  3830. }
  3831. }
  3832. }
  3833. }
  3834. /*
  3835. DEBUG_INFO("MaxProfile after align.\n");
  3836. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  3837. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3838. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3839. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3840. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3841. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3842. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  3843. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile.ChargingSchedule.StartSchedule);
  3844. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  3845. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3846. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3847. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3848. {
  3849. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3850. {
  3851. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3852. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3853. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3854. }
  3855. }
  3856. DEBUG_INFO("------------------------------------\n");*/
  3857. }
  3858. // Find each profile period quantity
  3859. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  3860. {
  3861. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  3862. limitMax = idx+1;
  3863. }
  3864. if(maxProfile.id != -1)
  3865. {
  3866. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3867. {
  3868. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3869. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3870. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  3871. {
  3872. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3873. {
  3874. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3875. compositePeriodIdx++;
  3876. }
  3877. else
  3878. {
  3879. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3880. }
  3881. }
  3882. }
  3883. }
  3884. DEBUG_INFO("ChargePointMaxProfile ready.\n");
  3885. DEBUG_INFO("Schedule start: %s\n", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
  3886. DEBUG_INFO("Schedule duration: %d\n", compositeProfile.chargingSchedule[idxSchedule].duration);
  3887. DEBUG_INFO("Rate unit: %s\n", compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit);
  3888. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3889. {
  3890. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  3891. {
  3892. compositeProfile.id = 1;
  3893. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  3894. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
  3895. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
  3896. }
  3897. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit == -1)
  3898. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit =0;
  3899. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  3900. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  3901. }
  3902. memcpy(targetCompositeProfile, &compositeProfile, sizeof(struct StructChargingProfile));
  3903. if(line)
  3904. free(line);
  3905. }
  3906. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *targetCompositeProfile, uint8_t idxSchedule, uint8_t isUnitA)
  3907. {
  3908. FILE *fp;
  3909. char profileFileName[128];
  3910. char *line = NULL;
  3911. size_t len = 0;
  3912. time_t CurrentTime;
  3913. struct tm *tmComposite;
  3914. struct ChargingProfileType maxProfile;
  3915. struct ChargingProfileType defaultTxProfile;
  3916. struct ChargingProfileType txProfile;
  3917. struct ChargingProfileType compositeProfile;
  3918. struct ChargingSchedulePeriodType tmpPeriod;
  3919. uint8_t limitMax=0;
  3920. uint8_t limitDef=0;
  3921. uint8_t limitTx=0;
  3922. int compositePeriodIdx = 0;
  3923. CurrentTime = time(NULL);
  3924. tmComposite=localtime(&CurrentTime);
  3925. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].startSchedule, "%04d-%02d-%02dT%02d:%02d:%02dZ", tmComposite->tm_year+1900, tmComposite->tm_mon+1, tmComposite->tm_mday, tmComposite->tm_hour, tmComposite->tm_min, tmComposite->tm_sec);
  3926. if(isUnitA)
  3927. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3928. else
  3929. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3930. compositeProfile.chargingSchedule[idxSchedule].duration = durationReq;
  3931. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3932. {
  3933. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3934. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3935. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3936. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  3937. }
  3938. compositeProfile.id = 0;
  3939. compositeProfile.stackLevel = 99 ;
  3940. sprintf((char*)compositeProfile.chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  3941. maxProfile.id = -1;
  3942. defaultTxProfile.id = -1;
  3943. txProfile.id = -1;
  3944. maxProfile.chargingSchedule[idxSchedule].duration = -1;
  3945. defaultTxProfile.chargingSchedule[idxSchedule].duration = -1;
  3946. txProfile.chargingSchedule[idxSchedule].duration = -1;
  3947. system("rm -f /tmp/*.json");
  3948. system("cp /Storage/OCPP/*.json /tmp 2>/dev/null");
  3949. /*
  3950. * Search valid charging profile
  3951. */
  3952. //DEBUG_INFO("====================================\n");
  3953. // Search tx profile
  3954. sprintf(profileFileName, "/tmp/TxProfile_%d_OCPP20.json", connectorId);
  3955. if((access(profileFileName, F_OK))!=-1)
  3956. {
  3957. fp = fopen(profileFileName, "r");
  3958. while(getline(&line, &len, fp) != -1)
  3959. {
  3960. json_object *obj = NULL;
  3961. obj = json_tokener_parse(line);
  3962. if(is_error(obj))
  3963. {
  3964. DEBUG_ERROR("Parse txProfile from file error.\n");
  3965. }
  3966. else
  3967. {
  3968. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != txProfile.id) &&
  3969. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= txProfile.stackLevel)
  3970. )
  3971. {
  3972. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  3973. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3974. )
  3975. {
  3976. struct tm tmFrom, tmTo;
  3977. struct timeb tbFrom, tbTo;
  3978. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmFrom.tm_year, &tmFrom.tm_mon, &tmFrom.tm_mday, &tmFrom.tm_hour, &tmFrom.tm_min, &tmFrom.tm_sec) == 6) &&
  3979. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmTo.tm_year, &tmTo.tm_mon, &tmTo.tm_mday, &tmTo.tm_hour, &tmTo.tm_min, &tmTo.tm_sec) == 6))
  3980. {
  3981. tmFrom.tm_year -= 1900;
  3982. tmFrom.tm_mon -= 1;
  3983. tbFrom.time = mktime(&tmFrom);
  3984. tmTo.tm_year -= 1900;
  3985. tmTo.tm_mon -= 1;
  3986. tbTo.time = mktime(&tmTo);
  3987. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3988. {
  3989. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3990. {
  3991. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3992. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3993. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3994. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  3995. }
  3996. if(txProfile.id == -1)
  3997. DEBUG_INFO("TxProfile found.\n");
  3998. else
  3999. DEBUG_INFO("TxProfile updated.\n");
  4000. // Required item
  4001. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4002. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4003. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4004. if(isUnitA)
  4005. {
  4006. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4007. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  4008. {
  4009. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4010. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4011. 3:
  4012. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4013. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
  4014. }
  4015. }
  4016. else
  4017. {
  4018. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4019. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  4020. {
  4021. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4022. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4023. 3:
  4024. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4025. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  4026. }
  4027. }
  4028. // Optional item
  4029. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4030. {
  4031. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4032. }
  4033. else
  4034. {
  4035. sprintf((char*)txProfile.validFrom, " ");
  4036. }
  4037. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4038. {
  4039. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4040. }
  4041. else
  4042. {
  4043. sprintf((char*)txProfile.validTo, " ");
  4044. }
  4045. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4046. {
  4047. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4048. }
  4049. else
  4050. {
  4051. sprintf((char*)txProfile.recurrencyKind, " ");
  4052. }
  4053. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4054. {
  4055. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4056. }
  4057. else
  4058. {
  4059. sprintf((char*)txProfile.transactionId, " ");
  4060. }
  4061. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  4062. {
  4063. txProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
  4064. }
  4065. else
  4066. {
  4067. txProfile.chargingSchedule[idxSchedule].duration = 86400;
  4068. }
  4069. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  4070. {
  4071. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
  4072. }
  4073. else
  4074. {
  4075. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging ? compositeProfile.chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  4076. }
  4077. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  4078. {
  4079. txProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
  4080. }
  4081. else
  4082. {
  4083. txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4084. }
  4085. }
  4086. }
  4087. }
  4088. else
  4089. {
  4090. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4091. {
  4092. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4093. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4094. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4095. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  4096. }
  4097. if(txProfile.id == -1)
  4098. DEBUG_INFO("TxProfile found.\n");
  4099. else
  4100. DEBUG_INFO("TxProfile updated.\n");
  4101. // Required item
  4102. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4103. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4104. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4105. if(isUnitA)
  4106. {
  4107. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4108. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  4109. {
  4110. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4111. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4112. 3:
  4113. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4114. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
  4115. }
  4116. }
  4117. else
  4118. {
  4119. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4120. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  4121. {
  4122. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4123. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4124. 3:
  4125. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4126. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  4127. }
  4128. }
  4129. // Optional item
  4130. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4131. {
  4132. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4133. }
  4134. else
  4135. {
  4136. sprintf((char*)txProfile.validFrom, " ");
  4137. }
  4138. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4139. {
  4140. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4141. }
  4142. else
  4143. {
  4144. sprintf((char*)txProfile.validTo, " ");
  4145. }
  4146. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4147. {
  4148. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4149. }
  4150. else
  4151. {
  4152. sprintf((char*)txProfile.recurrencyKind, " ");
  4153. }
  4154. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4155. {
  4156. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4157. }
  4158. else
  4159. {
  4160. sprintf((char*)txProfile.transactionId, " ");
  4161. }
  4162. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  4163. {
  4164. txProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
  4165. }
  4166. else
  4167. {
  4168. txProfile.chargingSchedule[idxSchedule].duration = 86400;
  4169. }
  4170. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  4171. {
  4172. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
  4173. }
  4174. else
  4175. {
  4176. sprintf((char*)txProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging ? compositeProfile.chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  4177. }
  4178. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  4179. {
  4180. txProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
  4181. }
  4182. else
  4183. {
  4184. txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4185. }
  4186. }
  4187. }
  4188. }
  4189. json_object_put(obj);
  4190. }
  4191. fclose(fp);
  4192. /*
  4193. if(txProfile.id != -1)
  4194. {
  4195. DEBUG_INFO("Profile ID: %d\n", txProfile.id);
  4196. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  4197. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  4198. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  4199. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  4200. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  4201. DEBUG_INFO("Profile recurrencyKind: %s\n", txProfile.recurrencyKind);
  4202. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[idxSchedule].StartSchedule);
  4203. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
  4204. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4205. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4206. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4207. {
  4208. if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4209. {
  4210. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4211. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4212. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4213. }
  4214. }
  4215. }
  4216. else
  4217. DEBUG_INFO("TxProfile not found.\n");*/
  4218. }
  4219. // Search default tx profile
  4220. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d_OCPP20.json", connectorId);
  4221. if((access(profileFileName, F_OK))==-1)
  4222. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  4223. if((access(profileFileName, F_OK))!=-1)
  4224. {
  4225. fp = fopen(profileFileName, "r");
  4226. while(getline(&line, &len, fp) != -1)
  4227. {
  4228. json_object *obj = NULL;
  4229. obj = json_tokener_parse(line);
  4230. if(is_error(obj))
  4231. {
  4232. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  4233. }
  4234. else
  4235. {
  4236. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != defaultTxProfile.id) &&
  4237. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= defaultTxProfile.stackLevel)
  4238. )
  4239. {
  4240. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  4241. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4242. )
  4243. {
  4244. struct tm tmFrom, tmTo;
  4245. struct timeb tbFrom, tbTo;
  4246. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmFrom.tm_year, &tmFrom.tm_mon, &tmFrom.tm_mday, &tmFrom.tm_hour, &tmFrom.tm_min, &tmFrom.tm_sec) == 6) &&
  4247. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmTo.tm_year, &tmTo.tm_mon, &tmTo.tm_mday, &tmTo.tm_hour, &tmTo.tm_min, &tmTo.tm_sec) == 6))
  4248. {
  4249. tmFrom.tm_year -= 1900;
  4250. tmFrom.tm_mon -= 1;
  4251. tbFrom.time = mktime(&tmFrom);
  4252. tmTo.tm_year -= 1900;
  4253. tmTo.tm_mon -= 1;
  4254. tbTo.time = mktime(&tmTo);
  4255. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  4256. {
  4257. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4258. {
  4259. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4260. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4261. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4262. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  4263. }
  4264. if(defaultTxProfile.id == -1)
  4265. DEBUG_INFO("TxDefaultProfile found.\n");
  4266. else
  4267. DEBUG_INFO("TxDefaultProfile updated.\n");
  4268. // Required item
  4269. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4270. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4271. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4272. if(isUnitA)
  4273. {
  4274. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4275. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  4276. {
  4277. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4278. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4279. 3:
  4280. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4281. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
  4282. }
  4283. }
  4284. else
  4285. {
  4286. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4287. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  4288. {
  4289. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4290. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4291. 3:
  4292. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4293. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  4294. }
  4295. }
  4296. // Optional item
  4297. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4298. {
  4299. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4300. }
  4301. else
  4302. {
  4303. sprintf((char*)defaultTxProfile.validFrom, " ");
  4304. }
  4305. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4306. {
  4307. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4308. }
  4309. else
  4310. {
  4311. sprintf((char*)defaultTxProfile.validTo, " ");
  4312. }
  4313. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4314. {
  4315. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4316. }
  4317. else
  4318. {
  4319. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  4320. }
  4321. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4322. {
  4323. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4324. }
  4325. else
  4326. {
  4327. sprintf((char*)defaultTxProfile.transactionId, " ");
  4328. }
  4329. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  4330. {
  4331. defaultTxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
  4332. }
  4333. else
  4334. {
  4335. defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4336. }
  4337. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  4338. {
  4339. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
  4340. }
  4341. else
  4342. {
  4343. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging ? compositeProfile.chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  4344. }
  4345. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  4346. {
  4347. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
  4348. }
  4349. else
  4350. {
  4351. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4352. }
  4353. }
  4354. }
  4355. }
  4356. else
  4357. {
  4358. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4359. {
  4360. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4361. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4362. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4363. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  4364. }
  4365. if(defaultTxProfile.id == -1)
  4366. DEBUG_INFO("TxDefaultProfile found.\n");
  4367. else
  4368. DEBUG_INFO("TxDefaultProfile updated.\n");
  4369. // Required item
  4370. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4371. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4372. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4373. if(isUnitA)
  4374. {
  4375. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4376. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  4377. {
  4378. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4379. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4380. 3:
  4381. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4382. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
  4383. }
  4384. }
  4385. else
  4386. {
  4387. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4388. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  4389. {
  4390. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4391. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4392. 3:
  4393. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4394. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  4395. }
  4396. }
  4397. // Optional item
  4398. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4399. {
  4400. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4401. }
  4402. else
  4403. {
  4404. sprintf((char*)defaultTxProfile.validFrom, " ");
  4405. }
  4406. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4407. {
  4408. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4409. }
  4410. else
  4411. {
  4412. sprintf((char*)defaultTxProfile.validTo, " ");
  4413. }
  4414. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4415. {
  4416. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4417. }
  4418. else
  4419. {
  4420. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  4421. }
  4422. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4423. {
  4424. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4425. }
  4426. else
  4427. {
  4428. sprintf((char*)defaultTxProfile.transactionId, " ");
  4429. }
  4430. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  4431. {
  4432. defaultTxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
  4433. }
  4434. else
  4435. {
  4436. defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4437. }
  4438. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  4439. {
  4440. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
  4441. }
  4442. else
  4443. {
  4444. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging ? compositeProfile.chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  4445. }
  4446. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  4447. {
  4448. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
  4449. }
  4450. else
  4451. {
  4452. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4453. }
  4454. }
  4455. }
  4456. }
  4457. json_object_put(obj);
  4458. }
  4459. fclose(fp);
  4460. /*
  4461. if(defaultTxProfile.id != -1)
  4462. {
  4463. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.id);
  4464. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  4465. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  4466. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  4467. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  4468. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  4469. DEBUG_INFO("Profile recurrencyKind: %s\n", defaultTxProfile.recurrencyKind);
  4470. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].StartSchedule);
  4471. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
  4472. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4473. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4474. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4475. {
  4476. if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4477. {
  4478. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4479. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4480. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4481. }
  4482. }
  4483. }
  4484. else
  4485. DEBUG_INFO("TxDefaultProfile not found.\n");
  4486. DEBUG_INFO("------------------------------------\n");*/
  4487. }
  4488. // Search max profile
  4489. sprintf(profileFileName, "/tmp/ChargingStationMaxProfile_OCPP20.json");
  4490. if((access(profileFileName, F_OK))!=-1)
  4491. {
  4492. fp = fopen(profileFileName, "r");
  4493. while(getline(&line, &len, fp) != -1)
  4494. {
  4495. json_object *obj = NULL;
  4496. obj = json_tokener_parse(line);
  4497. if(is_error(obj))
  4498. {
  4499. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  4500. }
  4501. else
  4502. {
  4503. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != maxProfile.id) &&
  4504. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= maxProfile.stackLevel)
  4505. )
  4506. {
  4507. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  4508. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4509. )
  4510. {
  4511. struct tm tmFrom, tmTo;
  4512. struct timeb tbFrom, tbTo;
  4513. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmFrom.tm_year, &tmFrom.tm_mon, &tmFrom.tm_mday, &tmFrom.tm_hour, &tmFrom.tm_min, &tmFrom.tm_sec) == 6) &&
  4514. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")), "%4d-%2d-%2dT%2d:%2d:%2d", &tmTo.tm_year, &tmTo.tm_mon, &tmTo.tm_mday, &tmTo.tm_hour, &tmTo.tm_min, &tmTo.tm_sec) == 6))
  4515. {
  4516. tmFrom.tm_year -= 1900;
  4517. tmFrom.tm_mon -= 1;
  4518. tbFrom.time = mktime(&tmFrom);
  4519. tmTo.tm_year -= 1900;
  4520. tmTo.tm_mon -= 1;
  4521. tbTo.time = mktime(&tmTo);
  4522. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  4523. {
  4524. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4525. {
  4526. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4527. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4528. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4529. }
  4530. if(maxProfile.id == -1)
  4531. DEBUG_INFO("MaxProfile found.\n");
  4532. else
  4533. DEBUG_INFO("MaxProfile updated.\n");
  4534. // Required item
  4535. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4536. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4537. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4538. if(isUnitA)
  4539. {
  4540. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4541. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  4542. {
  4543. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4544. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4545. 3:
  4546. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4547. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
  4548. }
  4549. }
  4550. else
  4551. {
  4552. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4553. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  4554. {
  4555. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4556. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4557. 3:
  4558. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4559. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  4560. }
  4561. }
  4562. // Optional item
  4563. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4564. {
  4565. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4566. }
  4567. else
  4568. {
  4569. sprintf((char*)maxProfile.validFrom, " ");
  4570. }
  4571. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4572. {
  4573. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4574. }
  4575. else
  4576. {
  4577. sprintf((char*)maxProfile.validTo, " ");
  4578. }
  4579. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4580. {
  4581. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4582. }
  4583. else
  4584. {
  4585. sprintf((char*)maxProfile.recurrencyKind, " ");
  4586. }
  4587. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4588. {
  4589. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4590. }
  4591. else
  4592. {
  4593. sprintf((char*)maxProfile.transactionId, " ");
  4594. }
  4595. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  4596. {
  4597. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
  4598. }
  4599. else
  4600. {
  4601. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4602. }
  4603. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  4604. {
  4605. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
  4606. }
  4607. else
  4608. {
  4609. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging ? compositeProfile.chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  4610. }
  4611. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  4612. {
  4613. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
  4614. }
  4615. else
  4616. {
  4617. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4618. }
  4619. }
  4620. }
  4621. }
  4622. else
  4623. {
  4624. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4625. {
  4626. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4627. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4628. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4629. }
  4630. if(maxProfile.id == -1)
  4631. DEBUG_INFO("MaxProfile found.\n");
  4632. else
  4633. DEBUG_INFO("MaxProfile updated.\n");
  4634. // Required item
  4635. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4636. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4637. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4638. if(isUnitA)
  4639. {
  4640. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4641. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  4642. {
  4643. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4644. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4645. 3:
  4646. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4647. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))/(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")));
  4648. }
  4649. }
  4650. else
  4651. {
  4652. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4653. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"));idxPeriod++)
  4654. {
  4655. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  4656. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  4657. 3:
  4658. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  4659. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit")):json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "chargingSchedulePeriod"), idxPeriod), "limit"))*(220*maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  4660. }
  4661. }
  4662. // Optional item
  4663. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4664. {
  4665. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4666. }
  4667. else
  4668. {
  4669. sprintf((char*)maxProfile.validFrom, " ");
  4670. }
  4671. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4672. {
  4673. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4674. }
  4675. else
  4676. {
  4677. sprintf((char*)maxProfile.validTo, " ");
  4678. }
  4679. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4680. {
  4681. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4682. }
  4683. else
  4684. {
  4685. sprintf((char*)maxProfile.recurrencyKind, " ");
  4686. }
  4687. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4688. {
  4689. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4690. }
  4691. else
  4692. {
  4693. sprintf((char*)maxProfile.transactionId, " ");
  4694. }
  4695. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  4696. {
  4697. maxProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration"));
  4698. }
  4699. else
  4700. {
  4701. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4702. }
  4703. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  4704. {
  4705. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule")));
  4706. }
  4707. else
  4708. {
  4709. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", (!cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging ? compositeProfile.chargingSchedule[idxSchedule].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  4710. }
  4711. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  4712. {
  4713. maxProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate"));
  4714. }
  4715. else
  4716. {
  4717. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4718. }
  4719. }
  4720. }
  4721. }
  4722. json_object_put(obj);
  4723. }
  4724. fclose(fp);
  4725. /*
  4726. if(maxProfile.id !=-1)
  4727. {
  4728. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  4729. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  4730. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  4731. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  4732. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  4733. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  4734. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  4735. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[idxSchedule].StartSchedule);
  4736. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  4737. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4738. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4739. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4740. {
  4741. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4742. {
  4743. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4744. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4745. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4746. }
  4747. }
  4748. }
  4749. else
  4750. DEBUG_INFO("MaxProfile not found.\n");
  4751. DEBUG_INFO("------------------------------------\n");*/
  4752. }
  4753. /*
  4754. * Align found profile start schedule & periods
  4755. */
  4756. //DEBUG_INFO("====================================\n");
  4757. /*
  4758. // For local test usage, force modify found profile start schedule info
  4759. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].StartSchedule, "%04d-%02d-%02dT%02d:%02d:%02dZ", tmComposite->tm_year+1900, tmComposite->tm_mon+1, tmComposite->tm_mday, tmComposite->tm_hour, tmComposite->tm_min, tmComposite->tm_sec-10);
  4760. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].StartSchedule, "%04d-%02d-%02dT%02d:%02d:%02dZ", tmComposite->tm_year+1900, tmComposite->tm_mon+1, tmComposite->tm_mday, tmComposite->tm_hour, tmComposite->tm_min, tmComposite->tm_sec-5);
  4761. sprintf((char*)txProfile.chargingSchedule[idxSchedule].StartSchedule, "%04d-%02d-%02dT%02d:%02d:%02dZ", tmComposite->tm_year+1900, tmComposite->tm_mon+1, tmComposite->tm_mday, tmComposite->tm_hour, tmComposite->tm_min, tmComposite->tm_sec-3);
  4762. */
  4763. if(txProfile.id != -1)
  4764. {
  4765. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  4766. {
  4767. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4768. {
  4769. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4770. 0:
  4771. (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4772. }
  4773. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4774. {
  4775. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4776. {
  4777. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4778. 0:
  4779. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4780. if(idxPeriod > 0)
  4781. {
  4782. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4783. {
  4784. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4785. }
  4786. }
  4787. }
  4788. }
  4789. }
  4790. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  4791. {
  4792. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4793. {
  4794. txProfile.chargingSchedule[idxSchedule].duration = !cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging?txProfile.chargingSchedule[idxSchedule].duration:((txProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4795. 0:
  4796. (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4797. }
  4798. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4799. {
  4800. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4801. {
  4802. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = !cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging?txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod:((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4803. 0:
  4804. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4805. if(idxPeriod > 0)
  4806. {
  4807. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4808. {
  4809. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4810. }
  4811. }
  4812. }
  4813. }
  4814. }
  4815. else
  4816. {
  4817. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  4818. {
  4819. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4820. {
  4821. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4822. 0:
  4823. (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4824. }
  4825. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4826. {
  4827. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4828. {
  4829. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4830. 0:
  4831. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4832. if(idxPeriod > 0)
  4833. {
  4834. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4835. {
  4836. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4837. }
  4838. }
  4839. }
  4840. }
  4841. }
  4842. else
  4843. {
  4844. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4845. {
  4846. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4847. 0:
  4848. (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4849. }
  4850. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4851. {
  4852. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4853. {
  4854. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4855. 0:
  4856. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4857. if(idxPeriod > 0)
  4858. {
  4859. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4860. {
  4861. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4862. }
  4863. }
  4864. }
  4865. }
  4866. }
  4867. }
  4868. /*
  4869. DEBUG_INFO("txProfile after align.\n");
  4870. DEBUG_INFO("Profile ID: %d\n", txProfile.id);
  4871. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  4872. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  4873. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  4874. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  4875. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  4876. DEBUG_INFO("Profile recurrencyKind: %s\n", txProfile.recurrencyKind);
  4877. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile.ChargingSchedule.StartSchedule);
  4878. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
  4879. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4880. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4881. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4882. {
  4883. if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4884. {
  4885. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4886. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4887. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4888. }
  4889. }*/
  4890. }
  4891. if(defaultTxProfile.id != -1)
  4892. {
  4893. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  4894. {
  4895. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4896. {
  4897. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4898. 0:
  4899. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4900. }
  4901. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4902. {
  4903. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4904. {
  4905. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4906. 0:
  4907. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4908. if(idxPeriod > 0)
  4909. {
  4910. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4911. {
  4912. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4913. }
  4914. }
  4915. }
  4916. }
  4917. }
  4918. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  4919. {
  4920. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4921. {
  4922. defaultTxProfile.chargingSchedule[idxSchedule].duration = !cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging?defaultTxProfile.chargingSchedule[idxSchedule].duration:((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4923. 0:
  4924. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4925. }
  4926. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4927. {
  4928. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4929. {
  4930. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = !cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging?defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod:((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4931. 0:
  4932. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4933. if(idxPeriod > 0)
  4934. {
  4935. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4936. {
  4937. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4938. }
  4939. }
  4940. }
  4941. }
  4942. }
  4943. else
  4944. {
  4945. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  4946. {
  4947. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4948. {
  4949. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4950. 0:
  4951. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4952. }
  4953. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4954. {
  4955. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4956. {
  4957. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4958. 0:
  4959. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4960. if(idxPeriod > 0)
  4961. {
  4962. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4963. {
  4964. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4965. }
  4966. }
  4967. }
  4968. }
  4969. }
  4970. else
  4971. {
  4972. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4973. {
  4974. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4975. 0:
  4976. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4977. }
  4978. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4979. {
  4980. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4981. {
  4982. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4983. 0:
  4984. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4985. if(idxPeriod > 0)
  4986. {
  4987. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4988. {
  4989. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4990. }
  4991. }
  4992. }
  4993. }
  4994. }
  4995. }
  4996. /*
  4997. DEBUG_INFO("defaultTxProfile after align.\n");
  4998. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.id);
  4999. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  5000. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  5001. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  5002. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  5003. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  5004. DEBUG_INFO("Profile recurrencyKind: %s\n", defaultTxProfile.recurrencyKind);
  5005. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile.ChargingSchedule.StartSchedule);
  5006. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
  5007. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  5008. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  5009. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  5010. {
  5011. if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  5012. {
  5013. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  5014. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  5015. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  5016. }
  5017. }
  5018. DEBUG_INFO("------------------------------------\n");*/
  5019. }
  5020. if(maxProfile.id != -1)
  5021. {
  5022. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  5023. {
  5024. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  5025. {
  5026. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  5027. 0:
  5028. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  5029. }
  5030. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  5031. {
  5032. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  5033. {
  5034. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  5035. 0:
  5036. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  5037. if(idxPeriod > 0)
  5038. {
  5039. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  5040. {
  5041. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  5042. }
  5043. }
  5044. }
  5045. }
  5046. }
  5047. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  5048. {
  5049. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  5050. {
  5051. maxProfile.chargingSchedule[idxSchedule].duration = !cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging?maxProfile.chargingSchedule[idxSchedule].duration:((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  5052. 0:
  5053. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[9].startSchedule)));
  5054. }
  5055. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  5056. {
  5057. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  5058. {
  5059. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = !cpinitateMsg.bits[(connectorId==0?0:connectorId-1)].isOnCharging?maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod:((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  5060. 0:
  5061. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  5062. if(idxPeriod > 0)
  5063. {
  5064. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  5065. {
  5066. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  5067. }
  5068. }
  5069. }
  5070. }
  5071. }
  5072. else
  5073. {
  5074. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  5075. {
  5076. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  5077. {
  5078. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  5079. 0:
  5080. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  5081. }
  5082. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  5083. {
  5084. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  5085. {
  5086. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  5087. 0:
  5088. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  5089. if(idxPeriod > 0)
  5090. {
  5091. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  5092. {
  5093. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  5094. }
  5095. }
  5096. }
  5097. }
  5098. }
  5099. else
  5100. {
  5101. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  5102. {
  5103. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  5104. 0:
  5105. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  5106. }
  5107. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  5108. {
  5109. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  5110. {
  5111. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  5112. 0:
  5113. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  5114. if(idxPeriod > 0)
  5115. {
  5116. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  5117. {
  5118. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  5119. }
  5120. }
  5121. }
  5122. }
  5123. }
  5124. }
  5125. /*
  5126. DEBUG_INFO("MaxProfile after align.\n");
  5127. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  5128. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  5129. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  5130. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  5131. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  5132. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  5133. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  5134. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile.ChargingSchedule.StartSchedule);
  5135. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  5136. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  5137. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  5138. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  5139. {
  5140. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  5141. {
  5142. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  5143. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  5144. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  5145. }
  5146. }
  5147. DEBUG_INFO("------------------------------------\n");*/
  5148. }
  5149. /*
  5150. * Merge to conposite schedule
  5151. */
  5152. //DEBUG_INFO("====================================\n");
  5153. // Find each profile period quantity
  5154. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  5155. {
  5156. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  5157. limitMax = idx+1;
  5158. }
  5159. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  5160. {
  5161. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  5162. limitDef = idx+1;
  5163. }
  5164. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  5165. {
  5166. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  5167. limitTx = idx+1;
  5168. }
  5169. // TxProfile found, composite schedule based on it
  5170. if(txProfile.id != -1)
  5171. {
  5172. compositeProfile.chargingSchedule[idxSchedule].duration = txProfile.chargingSchedule[idxSchedule].duration;
  5173. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  5174. {
  5175. if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  5176. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  5177. (txProfile.chargingSchedule[idxSchedule].duration > 0))
  5178. {
  5179. if(maxProfile.id != -1)
  5180. {
  5181. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  5182. {
  5183. if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  5184. {
  5185. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5186. {
  5187. tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  5188. tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  5189. tmpPeriod.limit = (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit>maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit?maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit:txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit);
  5190. }
  5191. else
  5192. {
  5193. tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  5194. tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  5195. tmpPeriod.limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit;
  5196. }
  5197. }
  5198. if(idxMaxPeriod == (limitMax-1))
  5199. {
  5200. if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  5201. {
  5202. if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5203. {
  5204. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5205. compositePeriodIdx++;
  5206. }
  5207. else
  5208. {
  5209. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5210. }
  5211. }
  5212. }
  5213. }
  5214. }
  5215. else
  5216. {
  5217. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5218. {
  5219. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  5220. compositePeriodIdx++;
  5221. }
  5222. else
  5223. {
  5224. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  5225. }
  5226. }
  5227. }
  5228. if(idxTxPeriod == (limitTx-1))
  5229. {
  5230. if(defaultTxProfile.id != -1)
  5231. {
  5232. compositeProfile.chargingSchedule[idxSchedule].duration = (defaultTxProfile.chargingSchedule[idxSchedule].duration>compositeProfile.chargingSchedule[idxSchedule].duration)?defaultTxProfile.chargingSchedule[idxSchedule].duration:compositeProfile.chargingSchedule[idxSchedule].duration;
  5233. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  5234. {
  5235. if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  5236. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  5237. (defaultTxProfile.chargingSchedule[idxSchedule].duration>0))
  5238. {
  5239. if(maxProfile.id != -1)
  5240. {
  5241. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  5242. {
  5243. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  5244. {
  5245. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5246. {
  5247. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  5248. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  5249. tmpPeriod.limit = (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit>maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit?maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit:defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit);
  5250. }
  5251. else
  5252. {
  5253. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  5254. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  5255. tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
  5256. }
  5257. if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  5258. {
  5259. if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5260. {
  5261. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5262. compositePeriodIdx++;
  5263. }
  5264. else
  5265. {
  5266. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5267. }
  5268. }
  5269. // Delete duplicate period
  5270. if(compositePeriodIdx > 1)
  5271. {
  5272. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  5273. {
  5274. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  5275. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  5276. compositePeriodIdx -= 1;
  5277. }
  5278. }
  5279. }
  5280. else
  5281. {
  5282. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5283. {
  5284. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5285. compositePeriodIdx++;
  5286. }
  5287. else
  5288. {
  5289. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5290. }
  5291. break;
  5292. }
  5293. }
  5294. }
  5295. else
  5296. {
  5297. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5298. {
  5299. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5300. compositePeriodIdx++;
  5301. }
  5302. else
  5303. {
  5304. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5305. }
  5306. }
  5307. }
  5308. }
  5309. }
  5310. }
  5311. }
  5312. }
  5313. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  5314. else if(defaultTxProfile.id != -1)
  5315. {
  5316. compositeProfile.chargingSchedule[idxSchedule].duration = defaultTxProfile.chargingSchedule[idxSchedule].duration;
  5317. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  5318. {
  5319. if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  5320. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  5321. (defaultTxProfile.chargingSchedule[idxSchedule].duration > 0))
  5322. {
  5323. if(maxProfile.id != -1)
  5324. {
  5325. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  5326. {
  5327. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  5328. {
  5329. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  5330. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  5331. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5332. {
  5333. tmpPeriod.limit = (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit>maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit?maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit:defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit);
  5334. }
  5335. else
  5336. {
  5337. tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
  5338. }
  5339. if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  5340. {
  5341. if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5342. {
  5343. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5344. compositePeriodIdx++;
  5345. }
  5346. else
  5347. {
  5348. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5349. }
  5350. }
  5351. // Delete duplicate period
  5352. if(compositePeriodIdx > 1)
  5353. {
  5354. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  5355. {
  5356. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  5357. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  5358. compositePeriodIdx -= 1;
  5359. }
  5360. }
  5361. }
  5362. else
  5363. {
  5364. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5365. {
  5366. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5367. compositePeriodIdx++;
  5368. }
  5369. else
  5370. {
  5371. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5372. }
  5373. break;
  5374. }
  5375. }
  5376. }
  5377. else
  5378. {
  5379. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5380. {
  5381. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5382. compositePeriodIdx++;
  5383. }
  5384. else
  5385. {
  5386. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5387. }
  5388. }
  5389. }
  5390. }
  5391. }
  5392. // Fill other period by MaxProfile
  5393. if(maxProfile.id != -1)
  5394. {
  5395. if(compositePeriodIdx==0)
  5396. {
  5397. compositeProfile.chargingSchedule[idxSchedule].duration = maxProfile.chargingSchedule[idxSchedule].duration;
  5398. for(int idxMaxPeriod=0;idxMaxPeriod<limitDef;idxMaxPeriod++)
  5399. {
  5400. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  5401. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  5402. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5403. {
  5404. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5405. {
  5406. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct StructChargingSchedulePeriod));
  5407. compositePeriodIdx++;
  5408. }
  5409. else
  5410. {
  5411. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct StructChargingSchedulePeriod));
  5412. }
  5413. }
  5414. }
  5415. }
  5416. else
  5417. {
  5418. int lastCompositePeriodIdx = compositePeriodIdx;
  5419. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  5420. {
  5421. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  5422. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  5423. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5424. {
  5425. if((maxProfile.chargingSchedule[idxSchedule].duration >= compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod))
  5426. {
  5427. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit > compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[lastCompositePeriodIdx-1].limit)
  5428. {
  5429. tmpPeriod.startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod;
  5430. tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  5431. tmpPeriod.limit = compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[lastCompositePeriodIdx-1].limit;
  5432. }
  5433. else
  5434. {
  5435. tmpPeriod.startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod;
  5436. tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  5437. tmpPeriod.limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit;
  5438. }
  5439. }
  5440. if(tmpPeriod.limit != -1)
  5441. {
  5442. if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)].limit)
  5443. {
  5444. if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)].startPeriod)
  5445. {
  5446. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5447. compositePeriodIdx++;
  5448. }
  5449. else
  5450. {
  5451. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5452. }
  5453. }
  5454. // Delete duplicate period
  5455. if(compositePeriodIdx > 1)
  5456. {
  5457. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  5458. {
  5459. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  5460. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  5461. compositePeriodIdx -= 1;
  5462. }
  5463. }
  5464. }
  5465. }
  5466. }
  5467. }
  5468. }
  5469. compositeProfile.chargingSchedule[idxSchedule].duration = durationReq;
  5470. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  5471. DEBUG_INFO("Schedule start: %s\n", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
  5472. DEBUG_INFO("Schedule duration: %d\n", compositeProfile.chargingSchedule[idxSchedule].duration);
  5473. DEBUG_INFO("Rate unit: %s\n", compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit);
  5474. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  5475. {
  5476. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  5477. {
  5478. compositeProfile.id = 1;
  5479. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  5480. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
  5481. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
  5482. }
  5483. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit == -1)
  5484. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit =0;
  5485. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  5486. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  5487. }
  5488. memcpy(targetCompositeProfile, &compositeProfile, sizeof(struct StructChargingProfile));
  5489. if(line)
  5490. free(line);
  5491. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  5492. }
  5493. //==========================================
  5494. // Init all share memory
  5495. //==========================================
  5496. int InitShareMemory()
  5497. {
  5498. int result = PASS;
  5499. int MeterSMId;
  5500. //creat ShmSysConfigAndInfo
  5501. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  5502. {
  5503. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  5504. result = FAIL;
  5505. }
  5506. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5507. {
  5508. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  5509. result = FAIL;
  5510. }
  5511. else
  5512. {}
  5513. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  5514. {
  5515. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  5516. result = FAIL;
  5517. }
  5518. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5519. {
  5520. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  5521. result = FAIL;
  5522. }
  5523. else
  5524. {}
  5525. //creat ShmPsuData
  5526. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  5527. {
  5528. DEBUG_ERROR("shmget ShmPsuData NG\n");
  5529. result = FAIL;
  5530. }
  5531. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5532. {
  5533. DEBUG_ERROR("shmat ShmPsuData NG\n");
  5534. result = FAIL;
  5535. }
  5536. else
  5537. {}
  5538. //creat ShmOCPP20Data
  5539. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  5540. {
  5541. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  5542. result = FAIL;
  5543. }
  5544. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5545. {
  5546. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  5547. result = FAIL;
  5548. }
  5549. else
  5550. {}
  5551. /****************************** For Initial Settings************************************************/
  5552. /*
  5553. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  5554. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  5555. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  5556. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  5557. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  5558. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  5559. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  5560. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  5561. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  5562. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  5563. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  5564. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  5565. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  5566. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  5567. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  5568. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  5569. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  5570. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  5571. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  5572. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  5573. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  5574. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  5575. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  5576. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  5577. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  5578. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  5579. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  5580. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  5581. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  5582. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  5583. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  5584. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  5585. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  5586. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  5587. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  5588. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  5589. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  5590. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  5591. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  5592. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  5593. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  5594. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  5595. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  5596. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  5597. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  5598. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  5599. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  5600. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  5601. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  5602. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  5603. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  5604. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  5605. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  5606. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  5607. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  5608. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  5609. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  5610. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  5611. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  5612. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  5613. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  5614. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  5615. */
  5616. return result;
  5617. }
  5618. int ProcessShareMemory()
  5619. {
  5620. int result = PASS;
  5621. if(InitShareMemory() == FAIL)
  5622. {
  5623. DEBUG_ERROR("InitShareMemory NG\n");
  5624. if(ShmStatusCodeData!=NULL)
  5625. {
  5626. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  5627. }
  5628. result = FAIL;
  5629. }
  5630. if(RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo) != -1)
  5631. {
  5632. DEBUG_INFO("Model name rated power: %d\n", modelnameInfo.ratedPower);
  5633. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
  5634. ((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
  5635. (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
  5636. (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
  5637. ) // 'D' means DC
  5638. {
  5639. // DO series
  5640. for(int gun_index=0; gun_index<GENERAL_GUN_QUANTITY ; gun_index++)
  5641. {
  5642. gunTotalNumber += 1;
  5643. gunType[gun_index] = GUN_TYPE_DO;
  5644. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  5645. {
  5646. case Gun_Type_Chademo:
  5647. DEBUG_INFO("Gun-%02d type: Cabinet CHAdeMO\n", gun_index);
  5648. break;
  5649. case Gun_Type_CCS_2:
  5650. DEBUG_INFO("Gun-%02d type: Cabinet CCS\n", gun_index);
  5651. break;
  5652. case Gun_Type_GB:
  5653. DEBUG_INFO("Gun-%02d type: Cabinet GBT\n", gun_index);
  5654. break;
  5655. case Gun_Type_AC:
  5656. DEBUG_INFO("Gun-%02d type: Cabinet AC\n", gun_index);
  5657. break;
  5658. default:
  5659. DEBUG_WARN("Gun-%02d type: Cabinet unknown\n", gun_index);
  5660. break;
  5661. }
  5662. }
  5663. }
  5664. else
  5665. {
  5666. for(int gun_index=0;gun_index<modelnameInfo.GetGunCount;gun_index++)
  5667. {
  5668. gunTotalNumber += 1;
  5669. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  5670. {
  5671. case Gun_Type_Chademo:
  5672. gunType[gun_index] = GUN_TYPE_CHAdeMO;
  5673. DEBUG_INFO("Gun-%02d type: CHAdeMO\n", gun_index);
  5674. break;
  5675. case Gun_Type_CCS_2:
  5676. gunType[gun_index] = GUN_TYPE_CCS;
  5677. DEBUG_INFO("Gun-%02d type: CCS\n", gun_index);
  5678. break;
  5679. case Gun_Type_GB:
  5680. gunType[gun_index] = GUN_TYPE_GBT;
  5681. DEBUG_INFO("Gun-%02d type: GBT\n", gun_index);
  5682. break;
  5683. case Gun_Type_AC:
  5684. gunType[gun_index] = GUN_TYPE_AC;
  5685. DEBUG_INFO("Gun-%02d type: AC\n", gun_index);
  5686. break;
  5687. default:
  5688. DEBUG_WARN("Gun-%02d type: Unknown\n", gun_index);
  5689. break;
  5690. }
  5691. }
  5692. }
  5693. }
  5694. else
  5695. {
  5696. DEBUG_ERROR("Model name parsing fail.\n");
  5697. result = FAIL;
  5698. }
  5699. if(result != PASS)sleep(5);
  5700. return result;
  5701. }
  5702. //---------------------common routine---------------------------//
  5703. void checkNetworkProfile(void)
  5704. {
  5705. memcpy(ShmOCPP20Data->OcppServerURL, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  5706. json_object *priority;
  5707. priority = json_tokener_parse((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value);
  5708. if(!is_error(priority))
  5709. {
  5710. for(uint8_t idxPriority=0;idxPriority<json_object_array_length(priority);idxPriority++)
  5711. {
  5712. for(uint8_t idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile);idx++)
  5713. {
  5714. if((ShmOCPP20Data->NetworkConnectionProfile[idx].slot == json_object_get_int(json_object_array_get_idx(priority, idxPriority))) &&
  5715. (strlen((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl) > 0) &&
  5716. (ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount < 3))
  5717. {
  5718. memcpy(ShmOCPP20Data->OcppServerURL, ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl));
  5719. ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount++;
  5720. break;
  5721. }
  5722. }
  5723. }
  5724. }
  5725. json_object_put(priority);
  5726. DEBUG_INFO("Get network profile URL: %s\n", ShmOCPP20Data->OcppServerURL);
  5727. }
  5728. void checkRemoteStart(uint8_t connectorIdx)
  5729. {
  5730. uint8_t tempIndex;
  5731. int isAllowStart = TRUE;
  5732. char cmdBuf[512];
  5733. //check Transaction active
  5734. if(gunType[connectorIdx-1] == GUN_TYPE_CHAdeMO)
  5735. {
  5736. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5737. {
  5738. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  5739. }
  5740. else
  5741. {
  5742. tempIndex = (connectorIdx-1);
  5743. }
  5744. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5745. {
  5746. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex )
  5747. {
  5748. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  5749. {
  5750. //Reserved
  5751. DEBUG_INFO("CHAdeMO connector already reserved and idTag match.\n");
  5752. }
  5753. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) != 0))
  5754. {
  5755. //Reserved
  5756. DEBUG_INFO("CHAdeMO connector already reserved and idTag does not match.\n");
  5757. isAllowStart = FALSE;
  5758. }
  5759. else
  5760. {
  5761. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5762. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) //S_PRECHARGE
  5763. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) //S_PREPARING_FOR_EV
  5764. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE )) // S_PREPARING_FOR_EVSE
  5765. {
  5766. DEBUG_WARN("CHAdeMO connector not allow start cause busy.\n.");
  5767. isAllowStart = FALSE;
  5768. }
  5769. }//END FOR ELSE
  5770. }
  5771. }// END FOR CHAdeMO_QUANTITY
  5772. }
  5773. else if(gunType[connectorIdx-1] == GUN_TYPE_CCS)
  5774. {
  5775. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5776. {
  5777. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  5778. }
  5779. else
  5780. {
  5781. tempIndex = (connectorIdx-1);
  5782. }
  5783. for (int index = 0; index < CCS_QUANTITY; index++)
  5784. {
  5785. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5786. {
  5787. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  5788. {
  5789. //Reserved
  5790. DEBUG_INFO("CCS connector already reserved and idTag match.\n");
  5791. }
  5792. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) != 0))
  5793. {
  5794. //Reserved
  5795. DEBUG_INFO("CCS connector already reserved and idTag does not match.\n");
  5796. isAllowStart = FALSE;
  5797. }
  5798. else
  5799. {
  5800. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5801. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  5802. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  5803. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  5804. {
  5805. DEBUG_WARN("CCS connector not allow start cause busy.\n.");
  5806. isAllowStart = FALSE;
  5807. }
  5808. }// END FOR ELSE
  5809. }
  5810. }// END FOR CCS_QUANTITY
  5811. }
  5812. else if(gunType[connectorIdx-1] == GUN_TYPE_GBT)
  5813. {
  5814. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5815. {
  5816. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  5817. }
  5818. else
  5819. {
  5820. tempIndex = (connectorIdx-1);
  5821. }
  5822. for (int index = 0; index < GB_QUANTITY; index++)
  5823. {
  5824. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex )
  5825. {
  5826. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  5827. {
  5828. //Reserved
  5829. DEBUG_INFO("GBT connector already reserved and idTag match.\n");
  5830. }
  5831. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) != 0))
  5832. {
  5833. //Reserved
  5834. DEBUG_INFO("GBT connector already reserved and idTag does not match.\n");
  5835. isAllowStart = FALSE;
  5836. }
  5837. else
  5838. {
  5839. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5840. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  5841. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  5842. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  5843. {
  5844. DEBUG_WARN("GBT connector not allow start cause busy.\n");
  5845. isAllowStart = FALSE;
  5846. }
  5847. }// END FOR ELSE
  5848. }
  5849. } // END FOR GB_QUANTITY
  5850. }
  5851. else if(gunType[connectorIdx-1] == GUN_TYPE_DO)
  5852. {
  5853. tempIndex = (connectorIdx-1);
  5854. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5855. {
  5856. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex )
  5857. {
  5858. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  5859. {
  5860. //Reserved
  5861. DEBUG_INFO("Dispenser connector already reserved and idTag match.\n");
  5862. }
  5863. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) != 0))
  5864. {
  5865. //Reserved
  5866. DEBUG_INFO("Dispenser connector already reserved and idTag does not match.\n");
  5867. isAllowStart = FALSE;
  5868. }
  5869. else
  5870. {
  5871. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5872. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  5873. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  5874. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  5875. {
  5876. DEBUG_WARN("Dispenser connector not allow start cause busy.\n");
  5877. isAllowStart = FALSE;
  5878. }
  5879. }// END FOR ELSE
  5880. }
  5881. } // END FOR GB_QUANTITY
  5882. }
  5883. else
  5884. {
  5885. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  5886. {
  5887. tempIndex = 2;
  5888. }
  5889. else
  5890. {
  5891. tempIndex = (connectorIdx-1);
  5892. }
  5893. for (int index = 0; index < AC_QUANTITY; index++)
  5894. {
  5895. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex )
  5896. {
  5897. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  5898. {
  5899. //Reserved
  5900. DEBUG_INFO("AC connector already reserved and idTag match.\n");
  5901. }
  5902. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) != 0))
  5903. {
  5904. //Reserved
  5905. DEBUG_INFO("AC connector already reserved and idTag does not match.\n");
  5906. isAllowStart = FALSE;
  5907. }
  5908. else
  5909. {
  5910. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5911. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  5912. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  5913. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  5914. {
  5915. DEBUG_WARN("AC connector not allow start cause busy.\n");
  5916. isAllowStart = FALSE;
  5917. }
  5918. }//END FOR ELSE
  5919. }
  5920. }// END FOR AC_QUANTITY
  5921. }
  5922. if(isAllowStart == TRUE)
  5923. {
  5924. if(ShmOCPP20Data->RequestStartTransaction[connectorIdx -1].chargingProfile.id > 0)
  5925. {
  5926. if((access("/Storage/OCPP/TxProfile_Tmp_OCPP20.json", F_OK))!=-1)
  5927. {
  5928. sprintf(cmdBuf, "mv /Storage/OCPP/TxProfile_Tmp_OCPP20.json /Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdx);
  5929. system(cmdBuf);
  5930. }
  5931. }
  5932. ShmOCPP20Data->CsMsg.bits[connectorIdx-1].RequestStartTransactionReq = ON;
  5933. }
  5934. }
  5935. void CheckSystemValue(void)
  5936. {
  5937. char filenmae[100]={0};
  5938. char str[100]={0};
  5939. int tempIndex = 0;
  5940. //===============================
  5941. // EVSE operation check
  5942. //===============================
  5943. //===============================
  5944. // Heartbeat check
  5945. //===============================
  5946. if((server_sign == TRUE) && (getDiffSecNow(clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  5947. {
  5948. //parameter for test
  5949. sendHeartbeatRequest(0);
  5950. //==============================================
  5951. // Reset Waiting Time
  5952. //==============================================
  5953. HeartBeatWithNOResponse += 1;
  5954. }
  5955. //===============================
  5956. // CSU Trigger Authorize Request
  5957. //===============================
  5958. if(isWebsocketSendable &&
  5959. (server_sign == TRUE) &&
  5960. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  5961. (authorizeRetryTimes < 3))
  5962. {
  5963. sendAuthorizeRequest(0);
  5964. authorizeRetryTimes = authorizeRetryTimes + 1;
  5965. if(authorizeRetryTimes < 3)
  5966. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5967. }
  5968. else if((server_sign == TRUE) &&
  5969. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  5970. (authorizeRetryTimes >= 3))
  5971. {
  5972. authorizeRetryTimes = 0;
  5973. SetOcppConnStatus(FALSE);
  5974. server_sign = FALSE;
  5975. }
  5976. else if((server_sign == FALSE) &&
  5977. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  5978. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  5979. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  5980. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  5981. {
  5982. sendAuthorizeRequest(0);
  5983. }
  5984. if(isWebsocketSendable &&
  5985. (server_sign == TRUE) &&
  5986. (ShmOCPP20Data->GetMonitoringReport.requestId > 0))
  5987. {
  5988. for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.monitoringCriteria);idxCriterion++)
  5989. {
  5990. if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_ThresholdMonitoring]) == 0)
  5991. {
  5992. /*
  5993. * TODO:
  5994. * 1. Report component that are ThresholdMonitoring
  5995. */
  5996. }
  5997. else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_DeltaMonitoring]) == 0)
  5998. {
  5999. /*
  6000. * TODO:
  6001. * 1. Report component that are DeltaMonitoring
  6002. */
  6003. }
  6004. else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_PeriodicMonitoring]) == 0)
  6005. {
  6006. /*
  6007. * TODO:
  6008. * 1. Report component that are PeriodicMonitoring
  6009. */
  6010. }
  6011. else
  6012. {
  6013. /*
  6014. * TODO:
  6015. * 1. Process unknown criteria condition
  6016. */
  6017. }
  6018. }
  6019. ShmOCPP20Data->GetMonitoringReport.requestId = 0;
  6020. }
  6021. if(isWebsocketSendable &&
  6022. (server_sign == TRUE) &&
  6023. (ShmOCPP20Data->GetReport.requestId > 0))
  6024. {
  6025. for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetReport.componentCriteria);idxCriterion++)
  6026. {
  6027. if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Active]) == 0)
  6028. {
  6029. /*
  6030. * TODO:
  6031. * 1. Report component that are active
  6032. */
  6033. }
  6034. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Available]) == 0)
  6035. {
  6036. /*
  6037. * TODO:
  6038. * 1. Report component that are available
  6039. */
  6040. }
  6041. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Enabled]) == 0)
  6042. {
  6043. /*
  6044. * TODO:
  6045. * 1. Report component that are enable
  6046. */
  6047. }
  6048. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Problem]) == 0)
  6049. {
  6050. /*
  6051. * TODO:
  6052. * 1. Report component that are problem
  6053. */
  6054. }
  6055. else
  6056. {
  6057. /*
  6058. * TODO:
  6059. * 1. Process unknown criteria condition
  6060. */
  6061. }
  6062. }
  6063. ShmOCPP20Data->GetReport.requestId = 0;
  6064. }
  6065. if(isWebsocketSendable &&
  6066. (server_sign == TRUE) &&
  6067. (ShmOCPP20Data->GetBaseReport.requestId > 0))
  6068. {
  6069. uint8_t reportIdx = 0;
  6070. ShmOCPP20Data->NotifyReport.requestId = ShmOCPP20Data->GetBaseReport.requestId;
  6071. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_ConfigurationInventory]) == 0)
  6072. {
  6073. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  6074. {
  6075. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  6076. {
  6077. if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].mutability, MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]) == 0) || (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].mutability, MutabilityEnumTypeStr[MutabilityEnumType_WriteOnly]) == 0))
  6078. {
  6079. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  6080. reportIdx++;
  6081. }
  6082. }
  6083. else
  6084. {
  6085. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  6086. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  6087. ShmOCPP20Data->NotifyReport.seqNo += 1;
  6088. else
  6089. ShmOCPP20Data->NotifyReport.seqNo = 0;
  6090. sendNotifyReportRequest();
  6091. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  6092. reportIdx = 0;
  6093. }
  6094. }
  6095. }
  6096. else if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_FullInventory]) == 0)
  6097. {
  6098. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  6099. {
  6100. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  6101. {
  6102. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  6103. reportIdx++;
  6104. }
  6105. else
  6106. {
  6107. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  6108. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  6109. ShmOCPP20Data->NotifyReport.seqNo += 1;
  6110. else
  6111. ShmOCPP20Data->NotifyReport.seqNo = 0;
  6112. sendNotifyReportRequest();
  6113. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  6114. reportIdx = 0;
  6115. }
  6116. }
  6117. }
  6118. else
  6119. {
  6120. /*
  6121. * TODO:
  6122. * 1. Fill out summary inventory to response message, currently not support
  6123. */
  6124. }
  6125. if(reportIdx > 0)
  6126. {
  6127. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  6128. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  6129. ShmOCPP20Data->NotifyReport.seqNo += 1;
  6130. else
  6131. ShmOCPP20Data->NotifyReport.seqNo = 0;
  6132. sendNotifyReportRequest();
  6133. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  6134. reportIdx = 0;
  6135. }
  6136. ShmOCPP20Data->GetBaseReport.requestId = 0;
  6137. }
  6138. if(isWebsocketSendable &&
  6139. (server_sign == TRUE) &&
  6140. ShmOCPP20Data->SpMsg.bits.NotifyEventReq)
  6141. {
  6142. getNowDatetime(ShmOCPP20Data->NotifyEvent.generatedAt);
  6143. ShmOCPP20Data->NotifyEvent.tbc = FALSE;
  6144. if(ShmOCPP20Data->NotifyEvent.seqNo < INT_MAX)
  6145. ShmOCPP20Data->NotifyEvent.seqNo += 1;
  6146. else
  6147. ShmOCPP20Data->NotifyEvent.seqNo = 0;
  6148. sendNotifyEventRequest();
  6149. memset(&ShmOCPP20Data->NotifyEvent.eventData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)* sizeof(struct EventDataType ));
  6150. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  6151. }
  6152. if(isWebsocketSendable &&
  6153. (server_sign == TRUE) &&
  6154. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq)
  6155. {
  6156. if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Install]) == 0)
  6157. {
  6158. /*
  6159. * TODO:
  6160. * 1.
  6161. */
  6162. }
  6163. else if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Update]) == 0)
  6164. {
  6165. /*
  6166. * TODO:
  6167. * 1.
  6168. */
  6169. }
  6170. else
  6171. {
  6172. /*
  6173. * TODO:
  6174. * 1.
  6175. */
  6176. }
  6177. sendGet15118EVCertificateRequest();
  6178. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  6179. }
  6180. if(isWebsocketSendable &&
  6181. (server_sign == TRUE) &&
  6182. (ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq == ON))
  6183. {
  6184. sendSecurityEventNotificationRequest();
  6185. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  6186. }
  6187. if(isWebsocketSendable &&
  6188. (server_sign == TRUE) &&
  6189. (ShmOCPP20Data->SpMsg.bits.NotifyCustomerInformationReq == ON))
  6190. {
  6191. sendNotifyCustomerInformationRequest();
  6192. ShmOCPP20Data->SpMsg.bits.NotifyCustomerInformationReq = OFF;
  6193. }
  6194. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  6195. {
  6196. // ClockAlign MeterValue
  6197. if(isWebsocketSendable && (server_sign == TRUE) && ((atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value) > 0)?((getTimePassSinceToday(gun_index)%(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value)))==0):FALSE))
  6198. {
  6199. //check Transaction active
  6200. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6201. {
  6202. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6203. {
  6204. tempIndex = ((gun_index==2) ? 1: 0);
  6205. }
  6206. else
  6207. {
  6208. tempIndex = gun_index;
  6209. }
  6210. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6211. {
  6212. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6213. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6214. {
  6215. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  6216. }
  6217. }// End for CHAdeMO
  6218. }
  6219. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6220. {
  6221. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6222. {
  6223. tempIndex = ((gun_index==2) ? 1: 0);
  6224. }
  6225. else
  6226. {
  6227. tempIndex = gun_index;
  6228. }
  6229. for (int index = 0; index < CCS_QUANTITY; index++)
  6230. {
  6231. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6232. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6233. {
  6234. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  6235. }
  6236. } // End for CCS
  6237. }
  6238. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6239. {
  6240. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6241. {
  6242. tempIndex = ((gun_index==2) ? 1: 0);
  6243. }
  6244. else
  6245. {
  6246. tempIndex = gun_index;
  6247. }
  6248. for (int index = 0; index < GB_QUANTITY; index++)
  6249. {
  6250. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6251. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6252. {
  6253. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6254. }
  6255. }// End for GB
  6256. }
  6257. else if(gunType[gun_index] == GUN_TYPE_DO)
  6258. {
  6259. tempIndex = gun_index;
  6260. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6261. {
  6262. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6263. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6264. {
  6265. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  6266. }
  6267. }
  6268. }
  6269. else
  6270. {
  6271. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6272. {
  6273. tempIndex = 2;
  6274. }
  6275. else
  6276. {
  6277. tempIndex = gun_index;
  6278. }
  6279. for (int index = 0; index < AC_QUANTITY; index++)
  6280. {
  6281. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6282. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6283. {
  6284. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  6285. }
  6286. }//End for AC
  6287. }
  6288. }
  6289. }
  6290. //===============================
  6291. // Each connector operation check
  6292. //===============================
  6293. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  6294. {
  6295. //==========================================
  6296. // Check remote start without connector id
  6297. //==========================================
  6298. if(ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
  6299. {
  6300. int connectorIdInt = -1;
  6301. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  6302. {
  6303. if(!cpinitateMsg.bits[gun_index].isOnCharging && (strstr((char*)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[ConnectorStatusEnumType_Occupied]) != NULL))
  6304. {
  6305. connectorIdInt = (gun_index+1);
  6306. DEBUG_INFO("Detect connector-%02d connected ready to start.\n", connectorIdInt);
  6307. checkRemoteStart(connectorIdInt);
  6308. ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq = OFF;
  6309. break;
  6310. }
  6311. }
  6312. if(getDiffSecNow(clientTime.RemoteStartWait) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value))
  6313. {
  6314. DEBUG_WARN("Remote start request without connector id wait link over %s seconds.\n", (char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value);
  6315. ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq = OFF;
  6316. }
  6317. }
  6318. //==========================================
  6319. // csu trigger DataTransferReq
  6320. //==========================================
  6321. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  6322. {
  6323. sendDataTransferRequest(gun_index);
  6324. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  6325. }
  6326. //==============================================
  6327. // Charger status notification & Transaction event report
  6328. //==============================================
  6329. //--- Check Mode Change ---//
  6330. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  6331. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6332. {
  6333. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6334. {
  6335. tempIndex = ((gun_index==2) ? 1: 0);
  6336. }
  6337. else
  6338. {
  6339. tempIndex = gun_index;
  6340. }
  6341. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6342. {
  6343. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6344. {
  6345. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  6346. {
  6347. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  6348. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  6349. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6350. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
  6351. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  6352. {
  6353. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6354. }
  6355. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  6356. {
  6357. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6358. if((access(filenmae,F_OK))!=-1)
  6359. {
  6360. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6361. sprintf(str,"rm -f %s",filenmae);
  6362. system(str);
  6363. }
  6364. }
  6365. }
  6366. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  6367. #if 1 // for TempStopTransaction
  6368. if(((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  6369. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6370. {
  6371. checkTempStopTransaction(gun_index);
  6372. }
  6373. #endif
  6374. }
  6375. }
  6376. }
  6377. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6378. {
  6379. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6380. {
  6381. tempIndex = ((gun_index==2) ? 1: 0);
  6382. }
  6383. else
  6384. {
  6385. tempIndex = gun_index;
  6386. }
  6387. for (int index = 0; index < CCS_QUANTITY; index++)
  6388. {
  6389. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6390. {
  6391. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != CcsPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn != CcsPreviousConnectorPlugIn[index]) )//if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != CcsPreviousSystemStatus[index]/*PRE_SYS_MODE[gun_index]*/ )
  6392. {
  6393. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  6394. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  6395. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6396. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
  6397. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  6398. {
  6399. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6400. }
  6401. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  6402. {
  6403. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6404. if((access(filenmae,F_OK))!=-1)
  6405. {
  6406. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6407. sprintf(str,"rm -f %s",filenmae);
  6408. system(str);
  6409. }
  6410. }
  6411. }
  6412. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  6413. #if 1 // for TempStopTransaction
  6414. if(((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  6415. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6416. {
  6417. checkTempStopTransaction(gun_index);
  6418. }
  6419. #endif
  6420. }
  6421. }
  6422. }
  6423. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6424. {
  6425. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6426. {
  6427. tempIndex = ((gun_index==2) ? 1: 0);
  6428. }
  6429. else
  6430. {
  6431. tempIndex = gun_index;
  6432. }
  6433. for (int index = 0; index < GB_QUANTITY; index++)
  6434. {
  6435. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6436. {
  6437. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  6438. {
  6439. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  6440. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  6441. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6442. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
  6443. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  6444. {
  6445. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6446. }
  6447. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  6448. {
  6449. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6450. if((access(filenmae,F_OK))!=-1)
  6451. {
  6452. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6453. sprintf(str,"rm -f %s",filenmae);
  6454. system(str);
  6455. }
  6456. }
  6457. }
  6458. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  6459. #if 1 // for TempStopTransaction
  6460. if(((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  6461. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6462. {
  6463. checkTempStopTransaction(gun_index);
  6464. }
  6465. #endif
  6466. }
  6467. }
  6468. }
  6469. else if(gunType[gun_index] == GUN_TYPE_DO)
  6470. {
  6471. tempIndex = gun_index;
  6472. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6473. {
  6474. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6475. {
  6476. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  6477. {
  6478. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  6479. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  6480. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6481. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CHARGING) &&
  6482. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_COMPLETE))
  6483. {
  6484. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6485. }
  6486. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_IDLE))) // complete
  6487. {
  6488. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6489. if((access(filenmae,F_OK))!=-1)
  6490. {
  6491. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6492. sprintf(str,"rm -f %s",filenmae);
  6493. system(str);
  6494. }
  6495. }
  6496. }
  6497. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING)?1:0);
  6498. #if 1 // for TempStopTransaction
  6499. if(((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE)) &&
  6500. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6501. {
  6502. checkTempStopTransaction(gun_index);
  6503. }
  6504. #endif
  6505. }
  6506. }
  6507. }
  6508. else
  6509. {
  6510. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6511. {
  6512. tempIndex = 2;
  6513. }
  6514. else
  6515. {
  6516. tempIndex = gun_index;
  6517. }
  6518. for (int index = 0; index < AC_QUANTITY; index++)
  6519. {
  6520. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6521. {
  6522. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  6523. {
  6524. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  6525. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  6526. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_AUTHORIZING)
  6527. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6528. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  6529. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  6530. {
  6531. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6532. }
  6533. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  6534. {
  6535. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6536. if((access(filenmae,F_OK))!=-1)
  6537. {
  6538. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6539. sprintf(str,"rm -f %s",filenmae);
  6540. system(str);
  6541. }
  6542. }
  6543. }
  6544. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  6545. #if 1 // for TempStopTransaction
  6546. if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  6547. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6548. {
  6549. checkTempStopTransaction(gun_index);
  6550. }
  6551. #endif
  6552. }
  6553. }// END
  6554. }
  6555. if(isWebsocketSendable && (server_sign == TRUE) && (getDiffSecNow(clientTime.StatusNotification[gun_index]) >= 5) && (ShmOCPP20Data->MsMsg.bits.ResetConf != ON) &&
  6556. ((cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) || (cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq == ON) ||
  6557. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].value, "TRUE") == 0) &&
  6558. (getDiffSecNow(clientTime.StatusNotification[gun_index]) >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].value)))))
  6559. {
  6560. sendStatusNotificationRequest(gun_index);
  6561. refreshStartTimer(&clientTime.StatusNotification[gun_index]);
  6562. }
  6563. //==============================================
  6564. // CSU Trigger Smart Charging Profile
  6565. //==============================================
  6566. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  6567. {
  6568. checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
  6569. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index], 0, TRUE);
  6570. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  6571. }
  6572. //==============================================
  6573. // CSU transaction event
  6574. //==============================================
  6575. if(ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == ON)
  6576. {
  6577. sendTransactionEventRequest(gun_index);
  6578. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  6579. //storeTempStopTransaction(gun_index);
  6580. //memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], 0x00, sizeof(struct MeterValueType));
  6581. }
  6582. //==============================================
  6583. // Meter report
  6584. //==============================================
  6585. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  6586. {
  6587. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  6588. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  6589. }
  6590. if(isWebsocketSendable && (cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON))
  6591. {
  6592. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  6593. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  6594. }
  6595. // Sample period MeterValue
  6596. if(getDiffSecNow(clientTime.MeterValues[gun_index]) >= ((atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)>3)?(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1):3))
  6597. {
  6598. //check Transaction active
  6599. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6600. {
  6601. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6602. {
  6603. tempIndex = ((gun_index==2) ? 1: 0);
  6604. }
  6605. else
  6606. {
  6607. tempIndex = gun_index;
  6608. }
  6609. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6610. {
  6611. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6612. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6613. {
  6614. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  6615. {
  6616. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6617. }
  6618. }
  6619. }// End for CHAdeMO
  6620. }
  6621. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6622. {
  6623. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6624. {
  6625. tempIndex = ((gun_index==2) ? 1: 0);
  6626. }
  6627. else
  6628. {
  6629. tempIndex = gun_index;
  6630. }
  6631. for (int index = 0; index < CCS_QUANTITY; index++)
  6632. {
  6633. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6634. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6635. {
  6636. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  6637. {
  6638. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6639. }
  6640. }
  6641. } // End for CCS
  6642. }
  6643. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6644. {
  6645. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6646. {
  6647. tempIndex = ((gun_index==2) ? 1: 0);
  6648. }
  6649. else
  6650. {
  6651. tempIndex = gun_index;
  6652. }
  6653. for (int index = 0; index < GB_QUANTITY; index++)
  6654. {
  6655. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6656. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6657. {
  6658. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  6659. {
  6660. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6661. }
  6662. }
  6663. }// End for GB
  6664. }
  6665. else if(gunType[gun_index] == GUN_TYPE_DO)
  6666. {
  6667. tempIndex = gun_index;
  6668. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6669. {
  6670. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6671. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6672. {
  6673. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  6674. {
  6675. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6676. }
  6677. }
  6678. }
  6679. }
  6680. else
  6681. {
  6682. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6683. {
  6684. tempIndex = 2;
  6685. }
  6686. else
  6687. {
  6688. tempIndex = gun_index;
  6689. }
  6690. for (int index = 0; index < AC_QUANTITY; index++)
  6691. {
  6692. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6693. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6694. {
  6695. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  6696. {
  6697. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6698. }
  6699. }
  6700. }//End for AC
  6701. }
  6702. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  6703. {
  6704. if(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value) > 0)
  6705. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  6706. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  6707. }
  6708. refreshStartTimer(&clientTime.MeterValues[gun_index]);
  6709. }
  6710. //==============================================
  6711. // Check Connector reserved
  6712. //==============================================
  6713. //===============================
  6714. // Check if Reserve is expired
  6715. //===============================
  6716. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0))
  6717. {
  6718. if(isOvertNow(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime))
  6719. {
  6720. DEBUG_INFO("reserve expired.\n");
  6721. ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId = ShmOCPP20Data->ReserveNow[gun_index].id;
  6722. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Expired]);
  6723. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = ON;
  6724. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  6725. }
  6726. }//END OF Check if Reserve is expired
  6727. //==========================================
  6728. // csu trigger FirmwareStatusNotificationReq
  6729. //==========================================
  6730. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  6731. {
  6732. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  6733. }
  6734. //==========================================
  6735. // csu cleared charging limit request
  6736. //==========================================
  6737. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq == ON))
  6738. {
  6739. sendClearedChargingLimitRequest(gun_index);
  6740. }
  6741. //==========================================
  6742. // csu trigger CancelReservationConf
  6743. //==========================================
  6744. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  6745. {
  6746. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  6747. }
  6748. //==========================================
  6749. // csu notify EV charging need request
  6750. //==========================================
  6751. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq == ON))
  6752. {
  6753. sendNotifyEVChargingNeedsRequest(gun_index);
  6754. }
  6755. //==========================================
  6756. // csu trigger ChangeAvailabilityConf
  6757. //==========================================
  6758. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  6759. {
  6760. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  6761. }
  6762. //==========================================
  6763. // csu trigger UnlockConnectorConf
  6764. //==========================================
  6765. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  6766. {
  6767. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  6768. }
  6769. //==========================================
  6770. // csu trigger ReserveNowConf
  6771. //==========================================
  6772. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  6773. {
  6774. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  6775. }
  6776. //==========================================
  6777. // csu trigger ReserveNowConf
  6778. //==========================================
  6779. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq == ON))
  6780. {
  6781. sendReservationStatusUpdateRequest(gun_index);
  6782. }
  6783. //==========================================
  6784. // csu trigger LogStatusNotificationReq
  6785. //==========================================
  6786. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq == ON))
  6787. {
  6788. sendLogStatusNotificationRequest((char *)ShmOCPP20Data->LogStatusNotification.status);
  6789. }
  6790. //==========================================
  6791. // csu trigger SignCertificateReq
  6792. //==========================================
  6793. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.SignCertificateReq == ON))
  6794. {
  6795. if((access("/Storage/OCPP/certCP.csr",F_OK) != -1) &&
  6796. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) == 0) )
  6797. {
  6798. sendSignCertificateRequest(CertificateSignedStatusEnumType_ChargingStationCertificate);
  6799. }
  6800. else if((access("/Storage/OCPP/certV2G.csr",F_OK) != -1) &&
  6801. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0))
  6802. {
  6803. sendSignCertificateRequest(CertificateSignedStatusEnumType_V2GCertificate);
  6804. }
  6805. }
  6806. }
  6807. }
  6808. //==========================================
  6809. // send request routine
  6810. //==========================================
  6811. int sendAuthorizeRequest(int gun_index)
  6812. {
  6813. mtrace();
  6814. int result = FAIL;
  6815. char message[4096]={0};
  6816. char guid[37];
  6817. char tempdata[128]={0};
  6818. json_object *Authorize = json_object_new_object();
  6819. json_object *idToken = json_object_new_object();
  6820. DEBUG_INFO("sendAuthorizeRequest...\n");
  6821. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  6822. //Local Authorize
  6823. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) && (ShmOCPP20Data->OcppConnStatus == 0))
  6824. {
  6825. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  6826. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  6827. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  6828. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  6829. result = PASS;
  6830. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6831. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6832. authorizeRetryTimes = 0;
  6833. return result;
  6834. }
  6835. else if(((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) && (ShmOCPP20Data->OcppConnStatus == 0)) ||
  6836. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  6837. {
  6838. // Query idtag from cache
  6839. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  6840. // Query idtag from list
  6841. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  6842. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  6843. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  6844. {
  6845. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  6846. {
  6847. DEBUG_INFO("Card %s does not find in list or cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  6848. }
  6849. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  6850. {
  6851. DEBUG_INFO("Card %s does not accepted in list and cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  6852. }
  6853. // Return authorize result if does not connect to server
  6854. if(!ShmOCPP20Data->OcppConnStatus)
  6855. {
  6856. DEBUG_INFO("Local Authorization Fail.\n");
  6857. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  6858. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6859. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  6860. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  6861. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6862. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6863. authorizeRetryTimes = 0;
  6864. return result;
  6865. }
  6866. }
  6867. else
  6868. {
  6869. DEBUG_INFO("Local Authorization get result.\n");
  6870. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  6871. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6872. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  6873. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  6874. else
  6875. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  6876. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  6877. result = PASS;
  6878. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6879. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6880. authorizeRetryTimes = 0;
  6881. return result;
  6882. }
  6883. }
  6884. //get data from shared memory
  6885. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6886. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  6887. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  6888. json_object_object_add(Authorize, "idToken", idToken);
  6889. random_uuid(guid);
  6890. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  6891. json_object_put(Authorize);
  6892. LWS_Send(message);
  6893. sprintf(tempdata, "Authorize,%d", gun_index);
  6894. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6895. {
  6896. result = PASS;
  6897. }
  6898. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6899. return result;
  6900. }
  6901. int sendBootNotificationRequest()
  6902. {
  6903. mtrace();
  6904. int result = FAIL;
  6905. char message[4096]={0};
  6906. char guid[37]={0};
  6907. char tempdata[128]={0};
  6908. json_object *BootNotification = json_object_new_object();
  6909. json_object *chargingStation = json_object_new_object();
  6910. json_object *modem = json_object_new_object();
  6911. DEBUG_INFO("sendBootNotificationRequest...\n");
  6912. // Fill BootNotification fields
  6913. DB_getBooType();
  6914. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  6915. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  6916. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  6917. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  6918. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  6919. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  6920. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  6921. {
  6922. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  6923. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  6924. json_object_object_add(chargingStation, "modem", modem);
  6925. }
  6926. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  6927. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  6928. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  6929. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  6930. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  6931. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  6932. random_uuid(guid);
  6933. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  6934. json_object_put(BootNotification);
  6935. LWS_Send(message);
  6936. sprintf(tempdata, "BootNotification,0");
  6937. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6938. {
  6939. result = PASS;
  6940. }
  6941. return result;
  6942. }
  6943. int sendClearedChargingLimitRequest(int gun_index)
  6944. {
  6945. mtrace();
  6946. int result = FAIL;
  6947. char message[4096]={0};
  6948. char guid[37]={0};
  6949. char tempdata[128]={0};
  6950. json_object *ClearedChargingLimit = json_object_new_object();
  6951. DEBUG_INFO("sendClearedChargingLimitRequest...\n");
  6952. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  6953. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  6954. random_uuid(guid);
  6955. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  6956. json_object_put(ClearedChargingLimit);
  6957. LWS_Send(message);
  6958. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  6959. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6960. {
  6961. result = PASS;
  6962. }
  6963. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  6964. return result;
  6965. }
  6966. int sendDataTransferRequest(int gun_index)
  6967. {
  6968. mtrace();
  6969. char message[1000]={0};
  6970. char guid[37]={0};
  6971. char tempdata[65]={0};
  6972. int result = FAIL;
  6973. DEBUG_INFO("sendDataTransferRequest...\n");
  6974. random_uuid(guid);
  6975. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  6976. MESSAGE_TYPE_CALL,
  6977. guid,
  6978. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  6979. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  6980. ShmOCPP20Data->DataTransfer[gun_index].data);
  6981. LWS_Send(message);
  6982. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  6983. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6984. {
  6985. result = PASS;
  6986. }
  6987. return result;
  6988. }
  6989. int sendFirmwareStatusNotificationRequest(char *status)
  6990. {
  6991. mtrace();
  6992. int result = FAIL;
  6993. char message[110]={0};
  6994. char guid[37]={0};
  6995. char tempdata[65]={0};
  6996. json_object *FirmwareStatusNotification = json_object_new_object();
  6997. DEBUG_INFO("sendFirmwareStatusNotificationRequest...\n");
  6998. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  6999. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  7000. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  7001. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  7002. random_uuid(guid);
  7003. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  7004. json_object_put(FirmwareStatusNotification);
  7005. LWS_SendNow(message);
  7006. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  7007. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7008. {
  7009. result = PASS;
  7010. }
  7011. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  7012. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  7013. //record status
  7014. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  7015. {
  7016. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  7017. }
  7018. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  7019. {
  7020. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  7021. }
  7022. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  7023. {
  7024. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  7025. }
  7026. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  7027. {
  7028. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  7029. }
  7030. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  7031. {
  7032. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  7033. }
  7034. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  7035. {
  7036. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  7037. }
  7038. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  7039. {
  7040. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  7041. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  7042. }
  7043. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  7044. {
  7045. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  7046. }
  7047. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  7048. {
  7049. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  7050. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  7051. DB_updateSecurityEventType(SecurityEventEnumType_FirmwareUpdated);
  7052. }
  7053. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  7054. {
  7055. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  7056. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  7057. DB_updateSecurityEventType(SecurityEventEnumType_FirmwareUpdated);
  7058. }
  7059. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  7060. {
  7061. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  7062. }
  7063. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  7064. {
  7065. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  7066. }
  7067. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  7068. {
  7069. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  7070. }
  7071. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  7072. {
  7073. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  7074. }
  7075. return result;
  7076. }
  7077. int sendGet15118EVCertificateRequest()
  7078. {
  7079. mtrace();
  7080. int result = FAIL;
  7081. char message[4096]={0};
  7082. char guid[37]={0};
  7083. char tempdata[128]={0};
  7084. json_object *Get15118EVCertificate = json_object_new_object();
  7085. DEBUG_INFO("sendGet15118EVCertificateRequest...\n");
  7086. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  7087. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  7088. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  7089. random_uuid(guid);
  7090. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  7091. json_object_put(Get15118EVCertificate);
  7092. LWS_Send(message);
  7093. sprintf(tempdata, "Get15118EVCertificate,0");
  7094. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7095. {
  7096. result = PASS;
  7097. }
  7098. return result;
  7099. }
  7100. int sendGetCertificateStatusRequest()
  7101. {
  7102. mtrace();
  7103. int result = FAIL;
  7104. char message[4096]={0};
  7105. char guid[37]={0};
  7106. char tempdata[128]={0};
  7107. json_object *GetCertificateStatus = json_object_new_object();
  7108. json_object *ocspRequestData = json_object_new_object();
  7109. DEBUG_INFO("sendGetCertificateStatusRequest...\n");
  7110. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  7111. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  7112. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  7113. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  7114. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  7115. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  7116. random_uuid(guid);
  7117. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  7118. json_object_put(GetCertificateStatus);
  7119. LWS_Send(message);
  7120. sprintf(tempdata, "GetCertificateStatus,0");
  7121. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7122. {
  7123. result = PASS;
  7124. }
  7125. return result;
  7126. }
  7127. int sendHeartbeatRequest()
  7128. {
  7129. mtrace();
  7130. int result = FAIL;
  7131. char message[40096]={0};
  7132. char guid[37]={0};
  7133. char tempdata[128]={0};
  7134. DEBUG_INFO("sendHeartbeatRequest...\n");
  7135. random_uuid(guid);
  7136. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  7137. , MESSAGE_TYPE_CALL
  7138. , guid );
  7139. LWS_Send(message);
  7140. sprintf(tempdata, "Heartbeat,%d", 0);
  7141. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7142. {
  7143. result = PASS;
  7144. }
  7145. return result;
  7146. }
  7147. int sendLogStatusNotificationRequest(char *status)
  7148. {
  7149. mtrace();
  7150. int result = FAIL;
  7151. char message[4096]={0};
  7152. char guid[37]={0};
  7153. char tempdata[128]={0};
  7154. json_object *LogStatusNotification = json_object_new_object();
  7155. DEBUG_INFO("sendLogStatusNotificationRequest...\n");
  7156. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  7157. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  7158. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  7159. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  7160. random_uuid(guid);
  7161. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  7162. json_object_put(LogStatusNotification);
  7163. LWS_SendNow(message);
  7164. sprintf(tempdata, "LogStatusNotification,%d", 0);
  7165. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7166. {
  7167. result = PASS;
  7168. }
  7169. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  7170. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  7171. //record status
  7172. if(strcmp(status,"BadMessage")==0)
  7173. {
  7174. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  7175. }
  7176. else if(strcmp(status,"Idle")==0)
  7177. {
  7178. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  7179. }
  7180. else if(strcmp(status,"NotSupportedOperation")==0)
  7181. {
  7182. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  7183. }
  7184. else if(strcmp(status,"PermissionDenied")==0)
  7185. {
  7186. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  7187. }
  7188. else if(strcmp(status,"Uploaded")==0)
  7189. {
  7190. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  7191. }
  7192. else if(strcmp(status,"UploadFailure")==0)
  7193. {
  7194. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  7195. }
  7196. else if(strcmp(status,"Uploading")==0)
  7197. {
  7198. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  7199. }
  7200. return result;
  7201. }
  7202. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  7203. {
  7204. mtrace();
  7205. int result = FAIL;
  7206. char guid[37]={0};
  7207. char tempdata[65]={0};
  7208. int tempIndex = 0;
  7209. json_object *MeterValueReq = json_object_new_object();
  7210. json_object *meterValues = json_object_new_array();
  7211. json_object *sampledValues = json_object_new_array();
  7212. DEBUG_INFO("sendMeterValuesRequest...\n");
  7213. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  7214. memset(&ShmOCPP20Data->MeterValues[gun_index], 0, sizeof(struct MeterValues_20));
  7215. //set value
  7216. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  7217. //UTC Date time
  7218. struct timeval tmnow;
  7219. struct tm *tm;
  7220. char buf[28];//, usec_buf[6];
  7221. gettimeofday(&tmnow, NULL);
  7222. time_t t;
  7223. t = time(NULL);
  7224. /*UTC time and date*/
  7225. tm = gmtime(&t);
  7226. if(dataType == ReadingContextEnumType_Sample_Clock)
  7227. {
  7228. struct tm *tmTarget;
  7229. struct timeb tbTarget;
  7230. tbTarget.time = mktime(tm);
  7231. tbTarget.time -= (atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value));
  7232. tmTarget = gmtime(&tbTarget.time);
  7233. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tmTarget);
  7234. }
  7235. else
  7236. {
  7237. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  7238. }
  7239. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  7240. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  7241. //idx_sample=0;
  7242. //********************************(1)Current.Import L1************************************************/
  7243. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7244. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7245. (dataType == ReadingContextEnumType_Trigger))
  7246. {
  7247. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7248. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7249. {
  7250. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7251. {
  7252. tempIndex = ((gun_index==2) ? 1: 0);
  7253. }
  7254. else
  7255. {
  7256. tempIndex = gun_index;
  7257. }
  7258. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7259. {
  7260. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7261. {
  7262. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent*100))/100.0;
  7263. }
  7264. }
  7265. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7266. }
  7267. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7268. {
  7269. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7270. {
  7271. tempIndex = ((gun_index==2) ? 1: 0);
  7272. }
  7273. else
  7274. {
  7275. tempIndex = gun_index;
  7276. }
  7277. for (int index = 0; index < CCS_QUANTITY; index++)
  7278. {
  7279. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7280. {
  7281. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent*100))/100.0;
  7282. }
  7283. }
  7284. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7285. }
  7286. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7287. {
  7288. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7289. {
  7290. tempIndex = ((gun_index==2) ? 1: 0);
  7291. }
  7292. else
  7293. {
  7294. tempIndex = gun_index;
  7295. }
  7296. for (int index = 0; index < GB_QUANTITY; index++)
  7297. {
  7298. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7299. {
  7300. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent*100))/100.0;
  7301. }
  7302. }
  7303. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7304. }
  7305. else if(gunType[gun_index] == GUN_TYPE_DO)
  7306. {
  7307. tempIndex = gun_index;
  7308. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7309. {
  7310. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7311. {
  7312. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*100))/100.0;
  7313. }
  7314. }
  7315. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7316. }
  7317. else
  7318. {
  7319. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7320. {
  7321. tempIndex = 2;
  7322. }
  7323. else
  7324. {
  7325. tempIndex = gun_index;
  7326. }
  7327. for (int index = 0; index < AC_QUANTITY; index++)
  7328. {
  7329. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7330. {
  7331. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent*100))/100.0;
  7332. }
  7333. }
  7334. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7335. }
  7336. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  7337. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  7338. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7339. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  7340. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  7341. }
  7342. //idx_sample=1;
  7343. //********************************(2)Energy.Active.Import.Register ************************************************/
  7344. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]) != NULL)) ||
  7345. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]) != NULL)) ||
  7346. (dataType == ReadingContextEnumType_Trigger))
  7347. {
  7348. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7349. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7350. {
  7351. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7352. {
  7353. tempIndex = ((gun_index==2) ? 1: 0);
  7354. }
  7355. else
  7356. {
  7357. tempIndex = gun_index;
  7358. }
  7359. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7360. {
  7361. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7362. {
  7363. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption*100))/100.0;
  7364. }
  7365. }
  7366. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7367. }
  7368. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7369. {
  7370. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7371. {
  7372. tempIndex = ((gun_index==2) ? 1: 0);
  7373. }
  7374. else
  7375. {
  7376. tempIndex = gun_index;
  7377. }
  7378. for (int index = 0; index < CCS_QUANTITY; index++)
  7379. {
  7380. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7381. {
  7382. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption*100))/100.0;
  7383. }
  7384. }
  7385. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7386. }
  7387. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7388. {
  7389. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7390. {
  7391. tempIndex = ((gun_index==2) ? 1: 0);
  7392. }
  7393. else
  7394. {
  7395. tempIndex = gun_index;
  7396. }
  7397. for (int index = 0; index < GB_QUANTITY; index++)
  7398. {
  7399. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7400. {
  7401. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption*100))/100.0;
  7402. }
  7403. }
  7404. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7405. }
  7406. else if(gunType[gun_index] == GUN_TYPE_DO)
  7407. {
  7408. tempIndex = gun_index;
  7409. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7410. {
  7411. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7412. {
  7413. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100))/100.0;
  7414. }
  7415. }
  7416. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7417. }
  7418. else
  7419. {
  7420. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7421. {
  7422. tempIndex = 2;
  7423. }
  7424. else
  7425. {
  7426. tempIndex = gun_index;
  7427. }
  7428. for (int index = 0; index < AC_QUANTITY; index++)
  7429. {
  7430. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7431. {
  7432. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption*100))/100.0;
  7433. }
  7434. }
  7435. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7436. }
  7437. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  7438. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  7439. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7440. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  7441. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  7442. }
  7443. //idx_sample=2;
  7444. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  7445. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]) != NULL)) ||
  7446. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]) != NULL)) ||
  7447. (dataType == ReadingContextEnumType_Trigger))
  7448. {
  7449. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7450. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7451. {
  7452. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7453. {
  7454. tempIndex = ((gun_index==2) ? 1: 0);
  7455. }
  7456. else
  7457. {
  7458. tempIndex = gun_index;
  7459. }
  7460. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7461. {
  7462. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7463. {
  7464. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy*100))/100.0;
  7465. }
  7466. } // END OF FOR CHAdeMO_QUANTITY
  7467. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7468. }
  7469. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7470. {
  7471. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7472. {
  7473. tempIndex = ((gun_index==2) ? 1: 0);
  7474. }
  7475. else
  7476. {
  7477. tempIndex = gun_index;
  7478. }
  7479. for (int index = 0; index < CCS_QUANTITY; index++)
  7480. {
  7481. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7482. {
  7483. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy*100))/100.0;
  7484. }
  7485. } // END OF CCS_QUANTITY
  7486. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7487. }
  7488. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7489. {
  7490. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7491. {
  7492. tempIndex = ((gun_index==2) ? 1: 0);
  7493. }
  7494. else
  7495. {
  7496. tempIndex = gun_index;
  7497. }
  7498. for (int index = 0; index < GB_QUANTITY; index++)
  7499. {
  7500. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7501. {
  7502. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy*100))/100.0;
  7503. }
  7504. } // END OF GB_QUANTITY
  7505. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7506. }
  7507. else if(gunType[gun_index] == GUN_TYPE_DO)
  7508. {
  7509. tempIndex = gun_index;
  7510. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7511. {
  7512. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7513. {
  7514. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100))/100.0;
  7515. }
  7516. }
  7517. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7518. }
  7519. else
  7520. {
  7521. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7522. {
  7523. tempIndex = 2;
  7524. }
  7525. else
  7526. {
  7527. tempIndex = gun_index;
  7528. }
  7529. for (int index = 0; index < AC_QUANTITY; index++)
  7530. {
  7531. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7532. {
  7533. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy*100))/100.0;
  7534. }
  7535. }
  7536. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7537. }
  7538. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  7539. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  7540. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7541. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  7542. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  7543. }
  7544. //idx_sample=3;
  7545. //********************************(4)Power.Active.Import************************************************/
  7546. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]) != NULL)) ||
  7547. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]) != NULL)) ||
  7548. (dataType == ReadingContextEnumType_Trigger))
  7549. {
  7550. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7551. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7552. {
  7553. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7554. {
  7555. tempIndex = ((gun_index==2) ? 1: 0);
  7556. }
  7557. else
  7558. {
  7559. tempIndex = gun_index;
  7560. }
  7561. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7562. {
  7563. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7564. {
  7565. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower*100))/100.0;
  7566. }
  7567. } // END OF FOR
  7568. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7569. }
  7570. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7571. {
  7572. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7573. {
  7574. tempIndex = ((gun_index==2) ? 1: 0);
  7575. }
  7576. else
  7577. {
  7578. tempIndex = gun_index;
  7579. }
  7580. for (int index = 0; index < CCS_QUANTITY; index++)
  7581. {
  7582. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7583. {
  7584. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower*100))/100.0;
  7585. }
  7586. }
  7587. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7588. }
  7589. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7590. {
  7591. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7592. {
  7593. tempIndex = ((gun_index==2) ? 1: 0);
  7594. }
  7595. else
  7596. {
  7597. tempIndex = gun_index;
  7598. }
  7599. for (int index = 0; index < GB_QUANTITY; index++)
  7600. {
  7601. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7602. {
  7603. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7604. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower*100))/100.0;
  7605. }
  7606. }
  7607. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7608. }
  7609. else if(gunType[gun_index] == GUN_TYPE_DO)
  7610. {
  7611. tempIndex = gun_index;
  7612. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7613. {
  7614. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7615. {
  7616. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7617. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower*100))/100.0;
  7618. }
  7619. }
  7620. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7621. }
  7622. else
  7623. {
  7624. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7625. {
  7626. tempIndex = 2;
  7627. }
  7628. else
  7629. {
  7630. tempIndex = gun_index;
  7631. }
  7632. for (int index = 0; index < AC_QUANTITY; index++)
  7633. {
  7634. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7635. {
  7636. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower*100))/100.0;
  7637. }
  7638. }
  7639. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7640. }
  7641. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  7642. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  7643. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7644. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  7645. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  7646. }
  7647. //idx_sample=4;
  7648. //***********************************************(5)VOLTAGE L1******************************************************/
  7649. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7650. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7651. (dataType == ReadingContextEnumType_Trigger))
  7652. {
  7653. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7654. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7655. {
  7656. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7657. {
  7658. tempIndex = ((gun_index==2) ? 1: 0);
  7659. }
  7660. else
  7661. {
  7662. tempIndex = gun_index;
  7663. }
  7664. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7665. {
  7666. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7667. {
  7668. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage*100))/100.0;
  7669. }
  7670. }
  7671. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7672. }
  7673. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7674. {
  7675. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7676. {
  7677. tempIndex = ((gun_index==2) ? 1: 0);
  7678. }
  7679. else
  7680. {
  7681. tempIndex = gun_index;
  7682. }
  7683. for (int index = 0; index < CCS_QUANTITY; index++)
  7684. {
  7685. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7686. {
  7687. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage*100))/100.0;
  7688. }
  7689. }
  7690. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7691. }
  7692. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7693. {
  7694. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7695. {
  7696. tempIndex = ((gun_index==2) ? 1: 0);
  7697. }
  7698. else
  7699. {
  7700. tempIndex = gun_index;
  7701. }
  7702. for (int index = 0; index < GB_QUANTITY; index++)
  7703. {
  7704. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7705. {
  7706. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage*100))/100.0;
  7707. }
  7708. }
  7709. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7710. }
  7711. else if(gunType[gun_index] == GUN_TYPE_DO)
  7712. {
  7713. tempIndex = gun_index;
  7714. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7715. {
  7716. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7717. {
  7718. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage*100))/100.0;
  7719. }
  7720. }
  7721. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7722. }
  7723. else
  7724. {
  7725. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7726. {
  7727. tempIndex = 2;
  7728. }
  7729. else
  7730. {
  7731. tempIndex = gun_index;
  7732. }
  7733. for (int index = 0; index < AC_QUANTITY; index++)
  7734. {
  7735. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7736. {
  7737. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage*100))/100.0;
  7738. }
  7739. }
  7740. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7741. }
  7742. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  7743. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  7744. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7745. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  7746. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  7747. }
  7748. //***********************************************(6)SOC******************************************************/
  7749. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) != NULL)) ||
  7750. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) != NULL)) ||
  7751. (dataType == ReadingContextEnumType_Trigger))
  7752. {
  7753. if((gunType[gun_index] == GUN_TYPE_CHAdeMO)||(gunType[gun_index] == GUN_TYPE_CCS)||(gunType[gun_index] == GUN_TYPE_GBT)||(gunType[gun_index] == GUN_TYPE_DO))
  7754. {
  7755. if((ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0') && (gunType[gun_index] != GUN_TYPE_DO))
  7756. {
  7757. tempIndex = ((gun_index==2) ? 1: 0);
  7758. }
  7759. else
  7760. {
  7761. tempIndex = gun_index;
  7762. }
  7763. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7764. {
  7765. //tempIndex = ((gun_index==2) ? 1: 0);
  7766. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7767. {
  7768. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7769. {
  7770. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  7771. }
  7772. }
  7773. }
  7774. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7775. {
  7776. //tempIndex = ((gun_index==2) ? 1: 0);
  7777. for (int index = 0; index < CCS_QUANTITY; index++)
  7778. {
  7779. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7780. {
  7781. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  7782. }
  7783. }
  7784. }
  7785. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7786. {
  7787. //tempIndex = ((gun_index==2) ? 1: 0);
  7788. for (int index = 0; index < GB_QUANTITY; index++)
  7789. {
  7790. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7791. {
  7792. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  7793. }
  7794. }
  7795. }
  7796. else if(gunType[gun_index] == GUN_TYPE_DO)
  7797. {
  7798. //tempIndex = ((gun_index==2) ? 1: 0);
  7799. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7800. {
  7801. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7802. {
  7803. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  7804. }
  7805. }
  7806. }
  7807. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  7808. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  7809. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7810. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  7811. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  7812. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  7813. }
  7814. }
  7815. //********************************(7)Current.Import L2************************************************/
  7816. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7817. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7818. (dataType == ReadingContextEnumType_Trigger))
  7819. {
  7820. // Only for AC 3 phase
  7821. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7822. {
  7823. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7824. {
  7825. tempIndex = 2;
  7826. }
  7827. else
  7828. {
  7829. tempIndex = gun_index;
  7830. }
  7831. for (int index = 0; index < AC_QUANTITY; index++)
  7832. {
  7833. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7834. {
  7835. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2*100))/100.0;
  7836. }
  7837. }
  7838. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  7839. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  7840. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  7841. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7842. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  7843. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  7844. }
  7845. }
  7846. //********************************(8)Current.Import L3************************************************/
  7847. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7848. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7849. (dataType == ReadingContextEnumType_Trigger))
  7850. {
  7851. // Only for AC 3 phase
  7852. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7853. {
  7854. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7855. {
  7856. tempIndex = 2;
  7857. }
  7858. else
  7859. {
  7860. tempIndex = gun_index;
  7861. }
  7862. for (int index = 0; index < AC_QUANTITY; index++)
  7863. {
  7864. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7865. {
  7866. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3*100))/100.0;
  7867. }
  7868. }
  7869. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7870. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  7871. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  7872. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7873. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  7874. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  7875. }
  7876. }
  7877. //***********************************************(9)VOLTAGE L2******************************************************/
  7878. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7879. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7880. (dataType == ReadingContextEnumType_Trigger))
  7881. {
  7882. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7883. {
  7884. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7885. {
  7886. tempIndex = 2;
  7887. }
  7888. else
  7889. {
  7890. tempIndex = gun_index;
  7891. }
  7892. for (int index = 0; index < AC_QUANTITY; index++)
  7893. {
  7894. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7895. {
  7896. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2*100))/100.0;
  7897. }
  7898. }
  7899. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  7900. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  7901. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  7902. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7903. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  7904. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  7905. }
  7906. }
  7907. //***********************************************(10)VOLTAGE L3******************************************************/
  7908. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7909. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7910. (dataType == ReadingContextEnumType_Trigger))
  7911. {
  7912. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7913. {
  7914. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7915. {
  7916. tempIndex = 2;
  7917. }
  7918. else
  7919. {
  7920. tempIndex = gun_index;
  7921. }
  7922. for (int index = 0; index < AC_QUANTITY; index++)
  7923. {
  7924. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7925. {
  7926. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3*100))/100.0;
  7927. }
  7928. }
  7929. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7930. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  7931. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  7932. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7933. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  7934. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  7935. }
  7936. }
  7937. //***********************************************(11)Current.Offered******************************************************/
  7938. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) != NULL)) ||
  7939. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) != NULL)) ||
  7940. (dataType == ReadingContextEnumType_Trigger))
  7941. {
  7942. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7943. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7944. {
  7945. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7946. {
  7947. tempIndex = ((gun_index==2) ? 1: 0);
  7948. }
  7949. else
  7950. {
  7951. tempIndex = gun_index;
  7952. }
  7953. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7954. {
  7955. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7956. {
  7957. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].AvailableChargingCurrent/10);
  7958. }
  7959. } // END OF FOR
  7960. }
  7961. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7962. {
  7963. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7964. {
  7965. tempIndex = ((gun_index==2) ? 1: 0);
  7966. }
  7967. else
  7968. {
  7969. tempIndex = gun_index;
  7970. }
  7971. for (int index = 0; index < CCS_QUANTITY; index++)
  7972. {
  7973. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7974. {
  7975. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].AvailableChargingCurrent/10);
  7976. }
  7977. }
  7978. }
  7979. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7980. {
  7981. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7982. {
  7983. tempIndex = ((gun_index==2) ? 1: 0);
  7984. }
  7985. else
  7986. {
  7987. tempIndex = gun_index;
  7988. }
  7989. for (int index = 0; index < GB_QUANTITY; index++)
  7990. {
  7991. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7992. {
  7993. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7994. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].AvailableChargingCurrent/10);;
  7995. }
  7996. }
  7997. }
  7998. else if(gunType[gun_index] == GUN_TYPE_DO)
  7999. {
  8000. tempIndex = gun_index;
  8001. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8002. {
  8003. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  8004. {
  8005. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  8006. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.AvailableChargingCurrent/10);;
  8007. }
  8008. }
  8009. }
  8010. else
  8011. {
  8012. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8013. {
  8014. tempIndex = 2;
  8015. }
  8016. else
  8017. {
  8018. tempIndex = gun_index;
  8019. }
  8020. for (int index = 0; index < AC_QUANTITY; index++)
  8021. {
  8022. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  8023. {
  8024. uint16_t currentOffer;
  8025. if(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent == 0)
  8026. {
  8027. currentOffer = ShmSysConfigAndInfo->SysConfig.RatingCurrent;
  8028. }
  8029. else
  8030. {
  8031. currentOffer = ((ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent>ShmSysConfigAndInfo->SysConfig.RatingCurrent)?ShmSysConfigAndInfo->SysConfig.RatingCurrent:ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
  8032. }
  8033. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = currentOffer;
  8034. }
  8035. }
  8036. }
  8037. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].context, ReadingContextEnumTypeStr[dataType]);
  8038. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]);
  8039. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  8040. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].unitOfMeasure.uint , "A");
  8041. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].unitOfMeasure.multiplier = 0;
  8042. }
  8043. //***********************************************(12)Power.Offered******************************************************/
  8044. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) != NULL)) ||
  8045. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) != NULL)) ||
  8046. (dataType == ReadingContextEnumType_Trigger))
  8047. {
  8048. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  8049. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  8050. {
  8051. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8052. {
  8053. tempIndex = ((gun_index==2) ? 1: 0);
  8054. }
  8055. else
  8056. {
  8057. tempIndex = gun_index;
  8058. }
  8059. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8060. {
  8061. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  8062. {
  8063. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].AvailableChargingPower*100);
  8064. }
  8065. } // END OF FOR
  8066. }
  8067. else if(gunType[gun_index] == GUN_TYPE_CCS)
  8068. {
  8069. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8070. {
  8071. tempIndex = ((gun_index==2) ? 1: 0);
  8072. }
  8073. else
  8074. {
  8075. tempIndex = gun_index;
  8076. }
  8077. for (int index = 0; index < CCS_QUANTITY; index++)
  8078. {
  8079. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  8080. {
  8081. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].AvailableChargingPower*100);
  8082. }
  8083. }
  8084. }
  8085. else if(gunType[gun_index] == GUN_TYPE_GBT)
  8086. {
  8087. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8088. {
  8089. tempIndex = ((gun_index==2) ? 1: 0);
  8090. }
  8091. else
  8092. {
  8093. tempIndex = gun_index;
  8094. }
  8095. for (int index = 0; index < GB_QUANTITY; index++)
  8096. {
  8097. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  8098. {
  8099. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  8100. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].AvailableChargingPower*100);
  8101. }
  8102. }
  8103. }
  8104. else if(gunType[gun_index] == GUN_TYPE_DO)
  8105. {
  8106. tempIndex = gun_index;
  8107. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8108. {
  8109. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  8110. {
  8111. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  8112. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.AvailableChargingPower*100);
  8113. }
  8114. }
  8115. }
  8116. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].context, ReadingContextEnumTypeStr[dataType]);
  8117. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]);
  8118. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  8119. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].unitOfMeasure.uint , "W");
  8120. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].unitOfMeasure.multiplier = 0;
  8121. }
  8122. // Message create ====================================================================================================
  8123. random_uuid(guid);
  8124. for(uint8_t idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue);idxMeter++)
  8125. {
  8126. json_object *meterValue = json_object_new_object();
  8127. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  8128. {
  8129. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  8130. {
  8131. json_object *sampledValue = json_object_new_object();
  8132. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  8133. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  8134. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  8135. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  8136. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  8137. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  8138. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  8139. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  8140. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  8141. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  8142. {
  8143. json_object *unitOfMeasure = json_object_new_object();
  8144. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  8145. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  8146. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  8147. }
  8148. json_object_array_add(sampledValues, sampledValue);
  8149. }
  8150. }
  8151. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  8152. json_object_object_add(meterValue, "sampledValue", sampledValues);
  8153. json_object_array_add(meterValues, meterValue);
  8154. idxMeter++;
  8155. }
  8156. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  8157. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  8158. sprintf(queuedata,"[%d,\"%s\",\"MeterValues\",%s]"
  8159. ,MESSAGE_TYPE_CALL
  8160. ,guid
  8161. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  8162. json_object_put(MeterValueReq);
  8163. if((dataType != ReadingContextEnumType_Trigger) &&
  8164. (dataType != ReadingContextEnumType_Sample_Clock))
  8165. {
  8166. // Transaction meter value send by TransactionEvent message
  8167. memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
  8168. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  8169. result = PASS;
  8170. }
  8171. else
  8172. {
  8173. // Put request guid to hash map
  8174. sprintf(tempdata, "MeterValues,%d", (gun_index));
  8175. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8176. {
  8177. result = PASS;
  8178. }
  8179. if((dataType != ReadingContextEnumType_Trigger) &&
  8180. (dataType != ReadingContextEnumType_Sample_Clock))
  8181. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  8182. else
  8183. {
  8184. if(FirstHeartBeat)
  8185. LWS_Send(queuedata +2);
  8186. }
  8187. }
  8188. return result;
  8189. }
  8190. int sendNotifyChargingLimitRequest(int gun_index)
  8191. {
  8192. mtrace();
  8193. int result = FAIL;
  8194. char message[4096]={0};
  8195. char guid[37]={0};
  8196. char tempdata[128]={0};
  8197. json_object *NotifyChargingLimit = json_object_new_object();
  8198. json_object *chargingLimit = json_object_new_object();
  8199. DEBUG_INFO("sendNotifyChargingLimitRequest...\n");
  8200. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  8201. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  8202. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  8203. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  8204. random_uuid(guid);
  8205. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  8206. json_object_put(NotifyChargingLimit);
  8207. LWS_Send(message);
  8208. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  8209. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8210. {
  8211. result = PASS;
  8212. }
  8213. return result;
  8214. }
  8215. int sendNotifyCustomerInformationRequest()
  8216. {
  8217. mtrace();
  8218. int result = FAIL;
  8219. char message[4096]={0};
  8220. char guid[37]={0};
  8221. char tempdata[128]={0};
  8222. json_object *NotifyCustomerInformation = json_object_new_object();
  8223. DEBUG_INFO("sendNotifyCustomerInformationRequest...\n");
  8224. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  8225. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  8226. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  8227. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  8228. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  8229. random_uuid(guid);
  8230. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  8231. json_object_put(NotifyCustomerInformation);
  8232. LWS_Send(message);
  8233. sprintf(tempdata, "NotifyCustomerInformation,0");
  8234. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8235. {
  8236. result = PASS;
  8237. }
  8238. return result;
  8239. }
  8240. int sendNotifyDisplayMessagesRequest()
  8241. {
  8242. mtrace();
  8243. int result = FAIL;
  8244. char message[4096]={0};
  8245. char guid[37]={0};
  8246. char tempdata[128]={0};
  8247. json_object *NotifyDisplayMessages = json_object_new_object();
  8248. json_object *messageInfos = json_object_new_array();
  8249. DEBUG_INFO("sendNotifyDisplayMessagesRequest...\n");
  8250. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  8251. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  8252. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  8253. {
  8254. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  8255. {
  8256. json_object *messageInfo = json_object_new_object();
  8257. json_object *message = json_object_new_object();
  8258. json_object *display = json_object_new_object();
  8259. json_object *evse = json_object_new_object();
  8260. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  8261. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  8262. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  8263. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  8264. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  8265. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  8266. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  8267. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  8268. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  8269. json_object_object_add(messageInfo, "message", message);
  8270. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  8271. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  8272. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  8273. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  8274. json_object_object_add(display, "evse",evse);
  8275. json_object_object_add(messageInfo, "evse", display);
  8276. json_object_array_add(messageInfos, messageInfo);
  8277. }
  8278. }
  8279. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  8280. random_uuid(guid);
  8281. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  8282. json_object_put(NotifyDisplayMessages);
  8283. LWS_Send(message);
  8284. sprintf(tempdata, "NotifyDisplayMessages,0");
  8285. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8286. {
  8287. result = PASS;
  8288. }
  8289. return result;
  8290. }
  8291. int sendNotifyEVChargingNeedsRequest(int gun_index)
  8292. {
  8293. mtrace();
  8294. int result = FAIL;
  8295. char message[4096]={0};
  8296. char guid[37]={0};
  8297. char tempdata[128]={0};
  8298. json_object *NotifyEVChargingNeeds = json_object_new_object();
  8299. json_object *chargingNeeds = json_object_new_object();
  8300. json_object *acChargingParameters = json_object_new_object();
  8301. json_object *dcChargingParameters = json_object_new_object();
  8302. DEBUG_INFO("sendNotifyEVChargingNeedsRequest...\n");
  8303. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  8304. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  8305. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  8306. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  8307. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  8308. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  8309. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  8310. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  8311. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  8312. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  8313. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  8314. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  8315. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  8316. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  8317. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  8318. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  8319. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  8320. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  8321. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  8322. random_uuid(guid);
  8323. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  8324. json_object_put(NotifyEVChargingNeeds);
  8325. LWS_Send(message);
  8326. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  8327. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8328. {
  8329. result = PASS;
  8330. }
  8331. return result;
  8332. }
  8333. int sendNotifyEVChargingScheduleRequest(int gun_index)
  8334. {
  8335. mtrace();
  8336. int result = FAIL;
  8337. char message[4096]={0};
  8338. char guid[37]={0};
  8339. char tempdata[128]={0};
  8340. json_object *NotifyEVChargingSchedule = json_object_new_object();
  8341. json_object *chargingSchedule = json_object_new_object();
  8342. json_object *periods = json_object_new_array();
  8343. DEBUG_INFO("sendNotifyEVChargingScheduleRequest...\n");
  8344. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  8345. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  8346. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  8347. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  8348. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  8349. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  8350. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  8351. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  8352. {
  8353. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  8354. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  8355. {
  8356. json_object *Period = json_object_new_object();
  8357. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  8358. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  8359. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  8360. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  8361. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  8362. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  8363. json_object_array_add(periods, Period);
  8364. }
  8365. }
  8366. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  8367. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  8368. random_uuid(guid);
  8369. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  8370. json_object_put(NotifyEVChargingSchedule);
  8371. LWS_Send(message);
  8372. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  8373. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8374. {
  8375. result = PASS;
  8376. }
  8377. return result;
  8378. }
  8379. int sendNotifyEventRequest()
  8380. {
  8381. mtrace();
  8382. int result = FAIL;
  8383. char message[4096]={0};
  8384. char guid[37]={0};
  8385. char tempdata[128]={0};
  8386. json_object *NotifyEvent = json_object_new_object();
  8387. json_object *eventDatas = json_object_new_array();
  8388. DEBUG_INFO("sendNotifyEventRequest...\n");
  8389. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  8390. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  8391. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  8392. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  8393. {
  8394. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  8395. {
  8396. json_object *eventData = json_object_new_object();
  8397. json_object *component = json_object_new_object();
  8398. json_object *evse = json_object_new_object();
  8399. json_object *variable = json_object_new_object();
  8400. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  8401. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  8402. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  8403. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  8404. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  8405. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  8406. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  8407. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  8408. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  8409. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  8410. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  8411. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  8412. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  8413. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  8414. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  8415. json_object_object_add(component, "evse",evse);
  8416. json_object_object_add(eventData, "component", component);
  8417. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  8418. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  8419. json_object_object_add(eventData, "variable", variable);
  8420. json_object_array_add(eventDatas, eventData);
  8421. }
  8422. }
  8423. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  8424. random_uuid(guid);
  8425. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  8426. json_object_put(NotifyEvent);
  8427. LWS_Send(message);
  8428. sprintf(tempdata, "NotifyEvent,0");
  8429. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8430. {
  8431. result = PASS;
  8432. }
  8433. return result;
  8434. }
  8435. int sendNotifyMonitoringReportRequest()
  8436. {
  8437. mtrace();
  8438. int result = FAIL;
  8439. char message[4096]={0};
  8440. char guid[37]={0};
  8441. char tempdata[128]={0};
  8442. json_object *NotifyMonitoringReport = json_object_new_object();
  8443. json_object *monitors = json_object_new_array();
  8444. DEBUG_INFO("sendNotifyMonitoringReportRequest...\n");
  8445. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  8446. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  8447. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  8448. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  8449. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  8450. {
  8451. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  8452. {
  8453. json_object *monitor = json_object_new_object();
  8454. json_object *component = json_object_new_object();
  8455. json_object *evse = json_object_new_object();
  8456. json_object *variable = json_object_new_object();
  8457. json_object *variableMonitorings = json_object_new_array();
  8458. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  8459. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  8460. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  8461. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  8462. json_object_object_add(component, "evse",evse);
  8463. json_object_object_add(monitor, "component", component);
  8464. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  8465. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  8466. json_object_object_add(monitor, "variable", variable);
  8467. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  8468. {
  8469. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  8470. {
  8471. json_object *variableMonitoring = json_object_new_object();
  8472. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  8473. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  8474. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  8475. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  8476. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  8477. json_object_array_add(variableMonitorings, variableMonitoring);
  8478. }
  8479. }
  8480. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  8481. json_object_array_add(monitors, monitor);
  8482. }
  8483. }
  8484. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  8485. random_uuid(guid);
  8486. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  8487. json_object_put(NotifyMonitoringReport);
  8488. LWS_Send(message);
  8489. sprintf(tempdata, "NotifyMonitoringReport,0");
  8490. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8491. {
  8492. result = PASS;
  8493. }
  8494. return result;
  8495. }
  8496. int sendNotifyReportRequest()
  8497. {
  8498. mtrace();
  8499. int result = FAIL;
  8500. char message[4096]={0};
  8501. char guid[37]={0};
  8502. char tempdata[128]={0};
  8503. json_object *NotifyReport = json_object_new_object();
  8504. json_object *reportDatas = json_object_new_array();
  8505. DEBUG_INFO("sendNotifyReportRequest...\n");
  8506. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  8507. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  8508. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  8509. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  8510. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  8511. {
  8512. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  8513. {
  8514. json_object *reportData = json_object_new_object();
  8515. json_object *component = json_object_new_object();
  8516. json_object *evse = json_object_new_object();
  8517. json_object *variable = json_object_new_object();
  8518. json_object *variableAttributes = json_object_new_array();
  8519. json_object *variableCharacteristics = json_object_new_object();
  8520. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  8521. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  8522. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  8523. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  8524. json_object_object_add(component, "evse",evse);
  8525. json_object_object_add(reportData, "component", component);
  8526. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  8527. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  8528. json_object_object_add(reportData, "variable",variable);
  8529. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  8530. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  8531. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  8532. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  8533. json_object_object_add(variableCharacteristics, "supportsMonitoring", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.supportsMonitoring));
  8534. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  8535. DEBUG_INFO("+++++++++++++++++++-->VariableName: %s\n", ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name);
  8536. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  8537. {
  8538. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  8539. {
  8540. json_object *variableAttribute = json_object_new_object();
  8541. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  8542. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  8543. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  8544. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  8545. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  8546. json_object_array_add(variableAttributes, variableAttribute);
  8547. }
  8548. /*else
  8549. {
  8550. sprintf((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  8551. sprintf((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_WriteOnly]);
  8552. sprintf((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value, "%s", "0");
  8553. json_object *variableAttribute = json_object_new_object();q1314qgrh
  8554. //if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type)==0)
  8555. DEBUG_INFO("AAAAAAAAAAAAAAAAA\n");
  8556. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  8557. DEBUG_INFO("BBBBBBBBBBBBBBBBBBB\n");
  8558. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  8559. DEBUG_INFO("CCCCCCCCCCCCCCCCCCCCC\n");
  8560. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  8561. DEBUG_INFO("DDDDDDDDDDDDDDDDDDDDDD\n");
  8562. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  8563. DEBUG_INFO("EEEEEEEEEEEEEEEEEEE\n");
  8564. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  8565. DEBUG_INFO("FFFFFFFFFFFFFFFFFFF\n");
  8566. json_object_array_add(variableAttributes, variableAttribute);
  8567. DEBUG_INFO("GGGGGGGGGGGGGGGGGGGGG\n");
  8568. }*/
  8569. }
  8570. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  8571. json_object_array_add(reportDatas, reportData);
  8572. }
  8573. }
  8574. json_object_object_add(NotifyReport, "reportData", reportDatas);
  8575. random_uuid(guid);
  8576. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  8577. json_object_put(NotifyReport);
  8578. LWS_SendNow(message);
  8579. sprintf(tempdata, "NotifyReport,0");
  8580. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8581. {
  8582. result = PASS;
  8583. }
  8584. return result;
  8585. }
  8586. int sendPublishFirmwareStatusNotificationRequest()
  8587. {
  8588. mtrace();
  8589. int result = FAIL;
  8590. char message[4096]={0};
  8591. char guid[37]={0};
  8592. char tempdata[128]={0};
  8593. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  8594. json_object *locations = json_object_new_array();
  8595. DEBUG_INFO("sendPublishFirmwareStatusNotificationRequest...\n");
  8596. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  8597. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  8598. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  8599. {
  8600. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  8601. }
  8602. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  8603. random_uuid(guid);
  8604. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  8605. json_object_put(PublishFirmwareStatusNotification);
  8606. LWS_Send(message);
  8607. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  8608. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8609. {
  8610. result = PASS;
  8611. }
  8612. return result;
  8613. }
  8614. int sendReportChargingProfilesRequest(int gun_index)
  8615. {
  8616. mtrace();
  8617. int result = FAIL;
  8618. char message[4096]={0};
  8619. char guid[37]={0};
  8620. char tempdata[128]={0};
  8621. json_object *ReportChargingProfiles = json_object_new_object();
  8622. json_object *chargingProfiles = json_object_new_array();
  8623. DEBUG_INFO("sendReportChargingProfilesRequest...\n");
  8624. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  8625. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  8626. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  8627. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  8628. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  8629. {
  8630. json_object *chargingProfile = json_object_new_object();
  8631. json_object *chargingSchedules = json_object_new_array();
  8632. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  8633. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  8634. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  8635. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  8636. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  8637. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  8638. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  8639. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  8640. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  8641. {
  8642. json_object *chargingSchedule = json_object_new_object();
  8643. json_object *chargingSchedulePeriods = json_object_new_array();
  8644. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  8645. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  8646. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  8647. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  8648. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  8649. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  8650. {
  8651. json_object *chargingSchedulePeriod = json_object_new_object();
  8652. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  8653. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  8654. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  8655. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  8656. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  8657. }
  8658. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  8659. json_object_array_add(chargingSchedules, chargingSchedule);
  8660. }
  8661. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  8662. json_object_array_add(chargingProfiles, chargingProfile);
  8663. }
  8664. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  8665. random_uuid(guid);
  8666. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  8667. json_object_put(ReportChargingProfiles);
  8668. LWS_Send(message);
  8669. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  8670. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8671. {
  8672. result = PASS;
  8673. }
  8674. return result;
  8675. }
  8676. int sendReservationStatusUpdateRequest(int gun_index)
  8677. {
  8678. mtrace();
  8679. int result = FAIL;
  8680. char message[4096]={0};
  8681. char guid[37]={0};
  8682. char tempdata[128]={0};
  8683. json_object *ReservationStatusUpdate = json_object_new_object();
  8684. DEBUG_INFO("sendReservationStatusUpdateRequest...\n");
  8685. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  8686. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  8687. random_uuid(guid);
  8688. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  8689. json_object_put(ReservationStatusUpdate);
  8690. LWS_Send(message);
  8691. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  8692. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8693. {
  8694. result = PASS;
  8695. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  8696. }
  8697. return result;
  8698. }
  8699. int sendSecurityEventNotificationRequest()
  8700. {
  8701. mtrace();
  8702. int result = FAIL;
  8703. char message[4096]={0};
  8704. char guid[37]={0};
  8705. char tempdata[128]={0};
  8706. struct timeval tmnow;
  8707. struct tm *tm;
  8708. char buf[28];//, usec_buf[6];
  8709. json_object *SecurityEventNotification = json_object_new_object();
  8710. DEBUG_INFO("sendSecurityEventNotificationRequest...\n");
  8711. DB_getSecurityEventType();
  8712. gettimeofday(&tmnow, NULL);
  8713. time_t t;
  8714. t = time(NULL);
  8715. /*UTC time and date*/
  8716. tm = gmtime(&t);
  8717. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  8718. #if 0 // remove temporally
  8719. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  8720. strcat(buf,".");
  8721. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  8722. strcat(buf,usec_buf);
  8723. #endif
  8724. printf("%s",buf);
  8725. strcpy((char *)ShmOCPP20Data->SecurityEventNotification.timestamp, buf);
  8726. if(strlen((char *)ShmOCPP20Data->SecurityEventNotification.techInfo)==0)
  8727. sprintf((char*)ShmOCPP20Data->SecurityEventNotification.type,"%s", SecurityEventEnumTypeStr[SecurityEventEnumType_ResetOrReboot]);
  8728. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  8729. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  8730. if(strlen((char *)ShmOCPP20Data->SecurityEventNotification.techInfo)>0)
  8731. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techInfo));
  8732. random_uuid(guid);
  8733. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  8734. json_object_put(SecurityEventNotification);
  8735. LWS_Send(message);
  8736. sprintf(tempdata, "SecurityEventNotification,0");
  8737. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8738. {
  8739. result = PASS;
  8740. }
  8741. return result;
  8742. }
  8743. int sendSignCertificateRequest(CertificateSigningUseEnumType certType)
  8744. {
  8745. mtrace();
  8746. int result = FAIL;
  8747. char message[4096]={0};
  8748. char guid[37]={0};
  8749. char tempdata[128]={0};
  8750. json_object *SignCertificate = json_object_new_object();
  8751. DEBUG_INFO("sendSignCertificateRequest...\n");
  8752. // Read csr file content
  8753. memset(ShmOCPP20Data->SignCertificate.csr, 0x00, ARRAY_SIZE(ShmOCPP20Data->SignCertificate.csr));
  8754. FILE *fp=fopen(((certType == CertificateSignedStatusEnumType_V2GCertificate)?"/Storage/OCPP/certV2G.csr":"/Storage/OCPP/certCP.csr"),"r");
  8755. char *line = NULL;
  8756. size_t len = 0;
  8757. while(getline(&line, &len, fp) != -1)
  8758. {
  8759. if((strstr(line, "BEGIN CERTIFICATE REQUEST") == NULL) && (strstr(line, "END CERTIFICATE REQUEST") == NULL))
  8760. {
  8761. memcpy(&ShmOCPP20Data->SignCertificate.csr[strlen((char*)ShmOCPP20Data->SignCertificate.csr)], line, (strlen(line)-1));
  8762. }
  8763. }
  8764. fclose(fp);
  8765. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  8766. sprintf((char*)ShmOCPP20Data->SignCertificate.certificateType, CertificateSigningUseEnumTypeStr[certType]);
  8767. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  8768. random_uuid(guid);
  8769. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  8770. json_object_put(SignCertificate);
  8771. LWS_Send(message);
  8772. sprintf(tempdata, "SignCertificate,0");
  8773. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8774. {
  8775. result = PASS;
  8776. }
  8777. return result;
  8778. }
  8779. int sendStatusNotificationRequest(int gun_index)
  8780. {
  8781. mtrace();
  8782. int result = FAIL;
  8783. char message[600]={0};
  8784. char guid[37];
  8785. int currentStatus = 0;
  8786. struct timeval tmnow;
  8787. struct tm *tm;
  8788. char buf[28];//, usec_buf[6];
  8789. char tempdata[65]={0};
  8790. int tempIndex = 0;
  8791. uint8_t isStateChanged = TRUE;
  8792. DEBUG_INFO("sendStatusNotificationRequest...\n");
  8793. gettimeofday(&tmnow, NULL);
  8794. time_t t;
  8795. t = time(NULL);
  8796. /*UTC time and date*/
  8797. tm = gmtime(&t);
  8798. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  8799. #if 0 // remove temporally
  8800. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  8801. strcat(buf,".");
  8802. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  8803. strcat(buf,usec_buf);
  8804. #endif
  8805. printf("%s",buf);
  8806. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  8807. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  8808. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  8809. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  8810. /*
  8811. enum _SYSTEM_STATUS
  8812. {
  8813. S_BOOTING = 0,
  8814. S_IDLE, = 1
  8815. S_AUTHORIZING, =2
  8816. S_REASSIGN_CHECK, =3
  8817. S_REASSIGN, =4
  8818. S_PRECHARGE, =5
  8819. S_PREPARING_FOR_EV, =6
  8820. S_PREPARING_FOR_EVSE, =7
  8821. S_CHARGING, =8
  8822. S_TERMINATING, =9
  8823. S_COMPLETE, =10
  8824. S_ALARM, =11
  8825. S_FAULT =12
  8826. }
  8827. */
  8828. //check Transaction active
  8829. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  8830. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  8831. {
  8832. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8833. {
  8834. tempIndex = ((gun_index==2) ? 1: 0);
  8835. }
  8836. else
  8837. {
  8838. tempIndex = gun_index;
  8839. }
  8840. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8841. {
  8842. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  8843. {
  8844. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  8845. {
  8846. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8847. {
  8848. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8849. }
  8850. else
  8851. {
  8852. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8853. }
  8854. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8855. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8856. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8857. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8858. }
  8859. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8860. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8861. ) //S_PRECHARGE
  8862. {
  8863. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8864. }
  8865. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8866. {
  8867. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8868. }
  8869. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8870. {
  8871. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8872. }
  8873. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8874. {
  8875. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8876. }
  8877. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_UPDATE)) // ---> Unavailable
  8878. {
  8879. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  8880. }
  8881. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  8882. {
  8883. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8884. }
  8885. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8886. {
  8887. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8888. }
  8889. } //end of the same index
  8890. }//end of for CHAdeMO_QUANTITY
  8891. }
  8892. else if(gunType[gun_index] == GUN_TYPE_CCS)
  8893. {
  8894. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8895. {
  8896. tempIndex = ((gun_index==2) ? 1: 0);
  8897. }
  8898. else
  8899. {
  8900. tempIndex = gun_index;
  8901. }
  8902. for (int index = 0; index < CCS_QUANTITY; index++)
  8903. {
  8904. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  8905. {
  8906. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8907. {
  8908. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  8909. {
  8910. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8911. }
  8912. else
  8913. {
  8914. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8915. }
  8916. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8917. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8918. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8919. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8920. }
  8921. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8922. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8923. ) //S_PRECHARGE
  8924. {
  8925. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8926. }
  8927. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8928. {
  8929. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8930. }
  8931. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8932. {
  8933. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8934. }
  8935. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  8936. {
  8937. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8938. }
  8939. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_UPDATE)) // ---> Unavailable
  8940. {
  8941. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  8942. }
  8943. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  8944. {
  8945. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  8946. }
  8947. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  8948. {
  8949. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  8950. }
  8951. } //end of the same index
  8952. } // end of for CCS_QUANTITY
  8953. }
  8954. else if(gunType[gun_index] == GUN_TYPE_GBT)
  8955. {
  8956. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8957. {
  8958. tempIndex = ((gun_index==2) ? 1: 0);
  8959. }
  8960. else
  8961. {
  8962. tempIndex = gun_index;
  8963. }
  8964. for (int index = 0; index < GB_QUANTITY; index++)
  8965. {
  8966. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  8967. {
  8968. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  8969. {
  8970. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8971. {
  8972. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8973. }
  8974. else
  8975. {
  8976. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8977. }
  8978. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8979. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8980. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8981. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8982. }
  8983. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8984. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8985. ) //S_PRECHARGE
  8986. {
  8987. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8988. }
  8989. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8990. {
  8991. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8992. }
  8993. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8994. {
  8995. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8996. }
  8997. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8998. {
  8999. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  9000. }
  9001. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_UPDATE)) // ---> Unavailable
  9002. {
  9003. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  9004. }
  9005. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  9006. {
  9007. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  9008. }
  9009. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9010. {
  9011. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  9012. }
  9013. } //end of the same index
  9014. } // end of for GB_QUANTITY
  9015. }
  9016. else if(gunType[gun_index] == GUN_TYPE_DO)
  9017. {
  9018. tempIndex = gun_index;
  9019. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  9020. {
  9021. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  9022. {
  9023. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  9024. {
  9025. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  9026. {
  9027. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  9028. }
  9029. else
  9030. {
  9031. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  9032. }
  9033. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  9034. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  9035. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  9036. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  9037. }
  9038. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9039. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9040. ) //S_PRECHARGE
  9041. {
  9042. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  9043. }
  9044. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9045. {
  9046. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  9047. }
  9048. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9049. {
  9050. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  9051. }
  9052. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9053. {
  9054. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  9055. }
  9056. else if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_UPDATE)) // ---> Unavailable
  9057. {
  9058. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  9059. }
  9060. else if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  9061. {
  9062. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  9063. }
  9064. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9065. {
  9066. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  9067. }
  9068. } //end of the same index
  9069. }
  9070. }
  9071. else
  9072. {
  9073. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  9074. {
  9075. tempIndex = 2;
  9076. }
  9077. else
  9078. {
  9079. tempIndex = gun_index;
  9080. }
  9081. for (int index = 0; index < AC_QUANTITY; index++)
  9082. {
  9083. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  9084. {
  9085. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  9086. {
  9087. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_B) ||(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_C) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_D))
  9088. {
  9089. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  9090. }
  9091. else
  9092. {
  9093. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  9094. }
  9095. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  9096. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  9097. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  9098. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  9099. }
  9100. else if (/*(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || */(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  9101. {
  9102. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  9103. }
  9104. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  9105. {
  9106. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  9107. }
  9108. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  9109. {
  9110. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  9111. }
  9112. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9113. {
  9114. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  9115. }
  9116. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_UPDATE)) // ---> Unavailable
  9117. {
  9118. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  9119. }
  9120. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9121. {
  9122. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  9123. }
  9124. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9125. {
  9126. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  9127. }
  9128. }//end of the same index
  9129. }//end of for AC_QUANTITY
  9130. }
  9131. //it's option
  9132. if((strstr((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]) != NULL) &&
  9133. !cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq &&
  9134. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].value, "TRUE") != 0))
  9135. {
  9136. isStateChanged = FALSE;
  9137. }
  9138. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  9139. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  9140. random_uuid(guid);
  9141. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  9142. , MESSAGE_TYPE_CALL
  9143. , guid
  9144. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  9145. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  9146. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  9147. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  9148. if((server_sign == TRUE) && isStateChanged)
  9149. {
  9150. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  9151. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  9152. LWS_Send(message);
  9153. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  9154. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  9155. {
  9156. result = PASS;
  9157. }
  9158. }
  9159. else
  9160. {
  9161. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  9162. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  9163. result = PASS;
  9164. }
  9165. return result;
  9166. }
  9167. int sendTransactionEventRequest(int gun_index)
  9168. {
  9169. mtrace();
  9170. int result = FAIL;
  9171. char message[1024*20]={0};
  9172. char guid[37]={0};
  9173. char tempdata[128]={0};
  9174. uint8_t tempIndex;
  9175. json_object *TransactionEvent = json_object_new_object();
  9176. json_object *transactionInfo = json_object_new_object();
  9177. json_object *idToken = json_object_new_object();
  9178. json_object *evse = json_object_new_object();
  9179. json_object *meterValues = json_object_new_array();
  9180. char TempStopTransaction[256];
  9181. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
  9182. DEBUG_INFO("sendTransactionEventRequest...\n");
  9183. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  9184. {
  9185. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  9186. {
  9187. tempIndex = ((gun_index==2) ? 1: 0);
  9188. }
  9189. else
  9190. {
  9191. tempIndex = gun_index;
  9192. }
  9193. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  9194. {
  9195. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  9196. {
  9197. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  9198. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  9199. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  9200. else
  9201. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  9202. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  9203. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  9204. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  9205. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  9206. {
  9207. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9208. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9209. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  9210. {
  9211. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  9212. }
  9213. else
  9214. {
  9215. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  9216. }
  9217. }
  9218. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  9219. {
  9220. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9221. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9222. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  9223. }
  9224. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9225. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9226. ) //S_PRECHARGE
  9227. {
  9228. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9229. {
  9230. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9231. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  9232. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartIdType]);
  9233. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9234. }
  9235. else
  9236. {
  9237. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9238. }
  9239. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  9240. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9241. }
  9242. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9243. {
  9244. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9245. {
  9246. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartMethod == 2)
  9247. {
  9248. ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
  9249. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
  9250. }
  9251. else
  9252. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9253. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9254. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  9255. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartIdType]);
  9256. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9257. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9258. }
  9259. else
  9260. {
  9261. storeTempStopTransaction(gun_index);
  9262. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9263. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9264. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  9265. }
  9266. }
  9267. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9268. {
  9269. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  9270. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9271. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9272. if((access(TempStopTransaction,F_OK))!=-1)
  9273. {
  9274. remove(TempStopTransaction); // remove file "TempStopTransaction"
  9275. }
  9276. }
  9277. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9278. {
  9279. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9280. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  9281. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9282. }
  9283. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_UPDATE)) // ---> Unavailable
  9284. {
  9285. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9286. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9287. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9288. }
  9289. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9290. {
  9291. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9292. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9293. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9294. }
  9295. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9296. {
  9297. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9298. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9299. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9300. }
  9301. } //end of the same index
  9302. }//end of for CHAdeMO_QUANTITY
  9303. }
  9304. else if(gunType[gun_index] == GUN_TYPE_CCS)
  9305. {
  9306. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  9307. {
  9308. tempIndex = ((gun_index==2) ? 1: 0);
  9309. }
  9310. else
  9311. {
  9312. tempIndex = gun_index;
  9313. }
  9314. for (int index = 0; index < CCS_QUANTITY; index++)
  9315. {
  9316. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  9317. {
  9318. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  9319. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  9320. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  9321. else
  9322. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  9323. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  9324. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  9325. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  9326. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  9327. {
  9328. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9329. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9330. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  9331. {
  9332. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  9333. }
  9334. else
  9335. {
  9336. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  9337. }
  9338. }
  9339. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  9340. {
  9341. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9342. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9343. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  9344. }
  9345. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9346. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9347. ) //S_PRECHARGE
  9348. {
  9349. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9350. {
  9351. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9352. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  9353. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartIdType]);
  9354. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9355. }
  9356. else
  9357. {
  9358. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9359. }
  9360. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  9361. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9362. }
  9363. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9364. {
  9365. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9366. {
  9367. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartMethod == 2)
  9368. {
  9369. ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
  9370. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
  9371. }
  9372. else
  9373. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9374. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9375. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  9376. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartIdType]);
  9377. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9378. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9379. }
  9380. else
  9381. {
  9382. storeTempStopTransaction(gun_index);
  9383. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9384. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9385. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  9386. }
  9387. }
  9388. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9389. {
  9390. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  9391. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9392. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9393. if((access(TempStopTransaction,F_OK))!=-1)
  9394. {
  9395. remove(TempStopTransaction); // remove file "TempStopTransaction"
  9396. }
  9397. }
  9398. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9399. {
  9400. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9401. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  9402. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9403. }
  9404. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_UPDATE)) // ---> Unavailable
  9405. {
  9406. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9407. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9408. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9409. }
  9410. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9411. {
  9412. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9413. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9414. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9415. }
  9416. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9417. {
  9418. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9419. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9420. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9421. }
  9422. } //end of the same index
  9423. } // end of for CCS_QUANTITY
  9424. }
  9425. else if(gunType[gun_index] == GUN_TYPE_GBT)
  9426. {
  9427. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  9428. {
  9429. tempIndex = ((gun_index==2) ? 1: 0);
  9430. }
  9431. else
  9432. {
  9433. tempIndex = gun_index;
  9434. }
  9435. for (int index = 0; index < GB_QUANTITY; index++)
  9436. {
  9437. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  9438. {
  9439. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  9440. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  9441. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  9442. else
  9443. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  9444. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  9445. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  9446. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  9447. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  9448. {
  9449. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9450. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9451. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  9452. {
  9453. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  9454. }
  9455. else
  9456. {
  9457. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  9458. }
  9459. }
  9460. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  9461. {
  9462. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9463. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9464. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  9465. }
  9466. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9467. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9468. ) //S_PRECHARGE
  9469. {
  9470. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9471. {
  9472. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9473. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  9474. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartIdType]);
  9475. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9476. }
  9477. else
  9478. {
  9479. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9480. }
  9481. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  9482. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9483. }
  9484. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9485. {
  9486. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9487. {
  9488. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartMethod == 2)
  9489. {
  9490. ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
  9491. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
  9492. }
  9493. else
  9494. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9495. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9496. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  9497. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartIdType]);
  9498. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9499. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9500. }
  9501. else
  9502. {
  9503. storeTempStopTransaction(gun_index);
  9504. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9505. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9506. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  9507. }
  9508. }
  9509. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9510. {
  9511. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  9512. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9513. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9514. if((access(TempStopTransaction,F_OK))!=-1)
  9515. {
  9516. remove(TempStopTransaction); // remove file "TempStopTransaction"
  9517. }
  9518. }
  9519. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9520. {
  9521. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9522. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  9523. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9524. }
  9525. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_UPDATE)) // ---> Unavailable
  9526. {
  9527. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9528. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9529. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9530. }
  9531. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9532. {
  9533. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9534. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9535. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9536. }
  9537. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9538. {
  9539. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9540. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9541. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9542. }
  9543. } //end of the same index
  9544. } // end of for GB_QUANTITY
  9545. }
  9546. else if(gunType[gun_index] == GUN_TYPE_DO)
  9547. {
  9548. tempIndex = gun_index;
  9549. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  9550. {
  9551. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  9552. {
  9553. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  9554. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  9555. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  9556. else
  9557. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  9558. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  9559. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  9560. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  9561. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  9562. {
  9563. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9564. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9565. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  9566. {
  9567. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  9568. }
  9569. else
  9570. {
  9571. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  9572. }
  9573. }
  9574. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  9575. {
  9576. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9577. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9578. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  9579. }
  9580. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9581. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9582. ) //S_PRECHARGE
  9583. {
  9584. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9585. {
  9586. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9587. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  9588. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartIdType]);
  9589. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9590. }
  9591. else
  9592. {
  9593. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9594. }
  9595. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  9596. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9597. }
  9598. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9599. {
  9600. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9601. {
  9602. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartMethod == 2)
  9603. {
  9604. ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
  9605. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
  9606. }
  9607. else
  9608. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9609. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9610. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  9611. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartIdType]);
  9612. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9613. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9614. }
  9615. else
  9616. {
  9617. storeTempStopTransaction(gun_index);
  9618. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9619. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9620. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  9621. }
  9622. }
  9623. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9624. {
  9625. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  9626. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9627. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9628. if((access(TempStopTransaction,F_OK))!=-1)
  9629. {
  9630. remove(TempStopTransaction); // remove file "TempStopTransaction"
  9631. }
  9632. }
  9633. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9634. {
  9635. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9636. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  9637. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9638. }
  9639. else if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_MAINTAIN)|| (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_UPDATE)) // ---> Unavailable
  9640. {
  9641. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9642. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9643. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9644. }
  9645. else if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9646. {
  9647. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9648. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9649. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9650. }
  9651. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9652. {
  9653. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9654. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9655. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9656. }
  9657. } //end of the same index
  9658. }
  9659. }
  9660. else
  9661. {
  9662. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  9663. {
  9664. tempIndex = 2;
  9665. }
  9666. else
  9667. {
  9668. tempIndex = gun_index;
  9669. }
  9670. for (int index = 0; index < AC_QUANTITY; index++)
  9671. {
  9672. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  9673. {
  9674. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  9675. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  9676. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  9677. else
  9678. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  9679. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  9680. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  9681. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  9682. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  9683. {
  9684. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9685. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9686. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_B) ||(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_C) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_D))
  9687. {
  9688. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  9689. }
  9690. else
  9691. {
  9692. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  9693. }
  9694. }
  9695. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  9696. {
  9697. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9698. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9699. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  9700. }
  9701. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9702. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9703. ) //S_PRECHARGE
  9704. {
  9705. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9706. {
  9707. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9708. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  9709. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartIdType]);
  9710. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9711. }
  9712. else
  9713. {
  9714. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9715. }
  9716. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  9717. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9718. }
  9719. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9720. {
  9721. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9722. {
  9723. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == 2)
  9724. {
  9725. ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
  9726. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
  9727. }
  9728. else
  9729. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9730. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9731. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  9732. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartIdType]);
  9733. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9734. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9735. }
  9736. else
  9737. {
  9738. storeTempStopTransaction(gun_index);
  9739. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9740. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9741. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  9742. }
  9743. }
  9744. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9745. {
  9746. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  9747. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9748. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9749. if((access(TempStopTransaction,F_OK))!=-1)
  9750. {
  9751. remove(TempStopTransaction); // remove file "TempStopTransaction"
  9752. }
  9753. }
  9754. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9755. {
  9756. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9757. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  9758. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9759. }
  9760. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_UPDATE)) // ---> Unavailable
  9761. {
  9762. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9763. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9764. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9765. }
  9766. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9767. {
  9768. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9769. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9770. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9771. }
  9772. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9773. {
  9774. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9775. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9776. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9777. }
  9778. }//end of the same index
  9779. }//end of for AC_QUANTITY
  9780. }
  9781. // Message
  9782. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  9783. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  9784. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  9785. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  9786. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  9787. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  9788. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  9789. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  9790. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  9791. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  9792. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  9793. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  9794. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  9795. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  9796. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  9797. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0) && (strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL))
  9798. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  9799. //if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  9800. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == 2)
  9801. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  9802. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  9803. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  9804. {
  9805. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  9806. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  9807. json_object_object_add(TransactionEvent, "idToken", idToken);
  9808. }
  9809. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  9810. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  9811. json_object_object_add(TransactionEvent, "evse", evse);
  9812. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  9813. {
  9814. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  9815. {
  9816. json_object *meterValue = json_object_new_object();
  9817. json_object *sampledValues = json_object_new_array();
  9818. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  9819. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  9820. {
  9821. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  9822. ((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) == 0) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) == 0) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) == 0)))
  9823. {
  9824. if(((strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, (char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) != NULL)) ||
  9825. (strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) == NULL))
  9826. {
  9827. json_object *sampledValue = json_object_new_object();
  9828. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  9829. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  9830. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  9831. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  9832. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  9833. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  9834. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  9835. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  9836. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  9837. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  9838. {
  9839. json_object *unitOfMeasure = json_object_new_object();
  9840. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  9841. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  9842. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  9843. }
  9844. json_object_array_add(sampledValues, sampledValue);
  9845. }
  9846. }
  9847. }
  9848. json_object_object_add(meterValue, "sampledValue", sampledValues);
  9849. json_object_array_add(meterValues, meterValue);
  9850. }
  9851. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  9852. }
  9853. random_uuid(guid);
  9854. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  9855. json_object_put(TransactionEvent);
  9856. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  9857. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  9858. {
  9859. result = PASS;
  9860. }
  9861. queue_operation(QUEUE_OPERATION_ADD, guid, message);
  9862. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Started]) != NULL)
  9863. OCPP_insert_transaction_msg(YES, message);
  9864. else if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL)
  9865. {
  9866. OCPP_insert_transaction_msg(NO, message);
  9867. memset(&ShmOCPP20Data->SessionTarget[gun_index], 0x00, sizeof(struct StructSessionTarget));
  9868. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  9869. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  9870. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  9871. }
  9872. return result;
  9873. }
  9874. //==========================================
  9875. // send confirm routine
  9876. //==========================================
  9877. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  9878. {
  9879. mtrace();
  9880. int result = FAIL;
  9881. char message[4096]={0};
  9882. json_object *CancelReservation = json_object_new_object();
  9883. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  9884. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  9885. sprintf(message,"[%d,\"%s\",%s]"
  9886. ,MESSAGE_TYPE_CALLRESULT
  9887. ,uuid
  9888. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  9889. json_object_put(CancelReservation);
  9890. ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf = OFF;
  9891. LWS_Send(message);
  9892. result = TRUE;
  9893. return result;
  9894. }
  9895. int sendCertificateSignedConfirmation(char *uuid)
  9896. {
  9897. mtrace();
  9898. int result = FAIL;
  9899. char message[4096]={0};
  9900. json_object *CertificateSigned = json_object_new_object();
  9901. json_object *statusInfo = json_object_new_object();
  9902. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  9903. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  9904. if(strlen((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.reasonCode) > 0)
  9905. {
  9906. json_object_object_add(statusInfo, "reasonCode", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.reasonCode));
  9907. if(strlen((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.additionalInfo) > 0)
  9908. json_object_object_add(statusInfo, "statadditionalInfous", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.additionalInfo));
  9909. }
  9910. json_object_object_add(CertificateSigned, "statusInfo", statusInfo);
  9911. sprintf(message,"[%d,\"%s\",%s]"
  9912. ,MESSAGE_TYPE_CALLRESULT
  9913. ,uuid
  9914. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  9915. json_object_put(CertificateSigned);
  9916. LWS_Send(message);
  9917. result = TRUE;
  9918. return result;
  9919. }
  9920. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  9921. {
  9922. mtrace();
  9923. int result = FAIL;
  9924. char message[4096]={0};
  9925. json_object *ChangeAvailability = json_object_new_object();
  9926. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  9927. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  9928. sprintf(message,"[%d,\"%s\",%s]"
  9929. ,MESSAGE_TYPE_CALLRESULT
  9930. ,uuid
  9931. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  9932. json_object_put(ChangeAvailability);
  9933. LWS_Send(message);
  9934. result = TRUE;
  9935. return result;
  9936. }
  9937. int sendClearCacheConfirmation(char *uuid)
  9938. {
  9939. mtrace();
  9940. int result = FAIL;
  9941. char message[4096]={0};
  9942. json_object *ClearCache = json_object_new_object();
  9943. DEBUG_INFO("sendClearCacheConfirmation...\n");
  9944. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  9945. sprintf(message,"[%d,\"%s\",%s]"
  9946. ,MESSAGE_TYPE_CALLRESULT
  9947. ,uuid
  9948. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  9949. json_object_put(ClearCache);
  9950. LWS_Send(message);
  9951. result = TRUE;
  9952. return result;
  9953. }
  9954. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  9955. {
  9956. mtrace();
  9957. int result = FAIL;
  9958. char message[500]={0};
  9959. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  9960. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  9961. LWS_Send(message);
  9962. return result;
  9963. }
  9964. int sendClearDisplayMessageConfirmation(char *uuid)
  9965. {
  9966. mtrace();
  9967. int result = FAIL;
  9968. char message[4096]={0};
  9969. json_object *ClearDisplayMessage = json_object_new_object();
  9970. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  9971. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  9972. sprintf(message,"[%d,\"%s\",%s]"
  9973. ,MESSAGE_TYPE_CALLRESULT
  9974. ,uuid
  9975. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  9976. json_object_put(ClearDisplayMessage);
  9977. LWS_Send(message);
  9978. result = TRUE;
  9979. return result;
  9980. }
  9981. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  9982. {
  9983. mtrace();
  9984. int result = FAIL;
  9985. char message[4096]={0};
  9986. json_object *ClearVariableMonitoring = json_object_new_object();
  9987. json_object *clearMonitoringResults = json_object_new_array();
  9988. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  9989. for(int idx=0;idx<variableQuantity;idx++)
  9990. {
  9991. json_object *clearMonitoringResult = json_object_new_object();
  9992. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  9993. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  9994. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  9995. }
  9996. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  9997. sprintf(message,"[%d,\"%s\",%s]"
  9998. ,MESSAGE_TYPE_CALLRESULT
  9999. ,uuid
  10000. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  10001. json_object_put(ClearVariableMonitoring);
  10002. LWS_Send(message);
  10003. result = TRUE;
  10004. return result;
  10005. }
  10006. int sendCostUpdatedConfirmation(char *uuid)
  10007. {
  10008. mtrace();
  10009. int result = FAIL;
  10010. char message[4096]={0};
  10011. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  10012. sprintf(message,"[%d,\"%s\",{}]"
  10013. ,MESSAGE_TYPE_CALLRESULT
  10014. ,uuid);
  10015. LWS_Send(message);
  10016. result = TRUE;
  10017. return result;
  10018. }
  10019. int sendCustomerInformationConfirmation(char *uuid)
  10020. {
  10021. mtrace();
  10022. int result = FAIL;
  10023. char message[4096]={0};
  10024. json_object *CustomerInformation = json_object_new_object();
  10025. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  10026. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  10027. sprintf(message,"[%d,\"%s\",%s]"
  10028. ,MESSAGE_TYPE_CALLRESULT
  10029. ,uuid
  10030. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  10031. json_object_put(CustomerInformation);
  10032. LWS_Send(message);
  10033. result = TRUE;
  10034. return result;
  10035. }
  10036. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  10037. {
  10038. mtrace();
  10039. int result = FAIL;
  10040. char message[4096]={0};
  10041. json_object *DataTransfer = json_object_new_object();
  10042. DEBUG_INFO("sendDataTransferConfirmation...\n");
  10043. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  10044. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  10045. sprintf(message,"[%d,\"%s\",%s]"
  10046. ,MESSAGE_TYPE_CALLRESULT
  10047. ,uuid
  10048. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  10049. json_object_put(DataTransfer);
  10050. LWS_Send(message);
  10051. result = TRUE;
  10052. return result;
  10053. }
  10054. int sendDeleteCertificateConfirmation(char *uuid)
  10055. {
  10056. mtrace();
  10057. int result = FAIL;
  10058. char message[4096]={0};
  10059. json_object *DeleteCertificate = json_object_new_object();
  10060. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  10061. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  10062. sprintf(message,"[%d,\"%s\",%s]"
  10063. ,MESSAGE_TYPE_CALLRESULT
  10064. ,uuid
  10065. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  10066. json_object_put(DeleteCertificate);
  10067. LWS_Send(message);
  10068. result = TRUE;
  10069. return result;
  10070. }
  10071. int sendGetBaseReportConfirmation(char *uuid)
  10072. {
  10073. mtrace();
  10074. int result = FAIL;
  10075. char message[4096]={0};
  10076. json_object *GetBaseReport = json_object_new_object();
  10077. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  10078. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  10079. sprintf(message,"[%d,\"%s\",%s]"
  10080. ,MESSAGE_TYPE_CALLRESULT
  10081. ,uuid
  10082. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  10083. json_object_put(GetBaseReport);
  10084. LWS_Send(message);
  10085. result = TRUE;
  10086. return result;
  10087. }
  10088. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  10089. {
  10090. mtrace();
  10091. int result = FAIL;
  10092. char message[4096]={0};
  10093. json_object *GetChargingProfiles = json_object_new_object();
  10094. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  10095. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  10096. sprintf(message,"[%d,\"%s\",%s]"
  10097. ,MESSAGE_TYPE_CALLRESULT
  10098. ,uuid
  10099. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  10100. json_object_put(GetChargingProfiles);
  10101. LWS_Send(message);
  10102. result = TRUE;
  10103. return result;
  10104. }
  10105. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  10106. {
  10107. mtrace();
  10108. int result = FAIL;
  10109. char message[4096]={0};
  10110. int CompositeScheduleIndex = 0;
  10111. json_object *GetCompositeSchedule = json_object_new_object();
  10112. json_object *schedule = json_object_new_object();
  10113. json_object *chargingSchedule = json_object_new_object();
  10114. json_object *chargingSchedulePeriod = json_object_new_array();
  10115. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  10116. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  10117. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  10118. json_object_object_add(chargingSchedule, "evseId", json_object_new_int(CompositeScheduleIndex));
  10119. if(nPeriod == 0)
  10120. {
  10121. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  10122. {
  10123. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  10124. json_object_object_add(schedule, "scheduleStart", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  10125. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  10126. json_object_object_add(schedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  10127. json_object_object_add(schedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  10128. //if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  10129. //json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  10130. //json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  10131. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  10132. {
  10133. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  10134. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  10135. {
  10136. json_object *Period = json_object_new_object();
  10137. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  10138. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  10139. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  10140. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  10141. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  10142. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  10143. json_object_array_add(chargingSchedulePeriod, Period);
  10144. }
  10145. }
  10146. json_object_object_add(schedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  10147. //json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  10148. //json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  10149. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  10150. }
  10151. }
  10152. else
  10153. {
  10154. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  10155. json_object_object_add(chargingSchedule, "scheduleStart", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  10156. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  10157. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  10158. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  10159. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  10160. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  10161. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  10162. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  10163. {
  10164. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  10165. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  10166. {
  10167. json_object *Period = json_object_new_object();
  10168. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  10169. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  10170. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  10171. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  10172. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  10173. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  10174. json_object_array_add(chargingSchedulePeriod, Period);
  10175. }
  10176. }
  10177. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  10178. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  10179. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  10180. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  10181. }
  10182. sprintf(message,"[%d,\"%s\",%s]"
  10183. ,MESSAGE_TYPE_CALLRESULT
  10184. ,uuid
  10185. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  10186. json_object_put(GetCompositeSchedule);
  10187. LWS_Send(message);
  10188. result = TRUE;
  10189. return result;
  10190. }
  10191. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  10192. {
  10193. mtrace();
  10194. int result = FAIL;
  10195. char message[4096]={0};
  10196. json_object *GetGetDisplayMessages = json_object_new_object();
  10197. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  10198. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  10199. sprintf(message,"[%d,\"%s\",%s]"
  10200. ,MESSAGE_TYPE_CALLRESULT
  10201. ,uuid
  10202. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  10203. json_object_put(GetGetDisplayMessages);
  10204. LWS_Send(message);
  10205. result = TRUE;
  10206. return result;
  10207. }
  10208. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  10209. {
  10210. mtrace();
  10211. int result = FAIL;
  10212. char message[4096]={0};
  10213. json_object *GetInstalledCertificateIds = json_object_new_object();
  10214. json_object *certificateHashDataChains = json_object_new_array();
  10215. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  10216. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  10217. for(int idx=0;idx<certQuantity;idx++)
  10218. {
  10219. json_object *cert = json_object_new_object();
  10220. json_object *certificateHashData = json_object_new_object();
  10221. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  10222. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  10223. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  10224. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  10225. json_object_object_add(cert, "certificateHashData", certificateHashData);
  10226. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  10227. json_object_array_add(certificateHashDataChains, cert);
  10228. }
  10229. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  10230. sprintf(message,"[%d,\"%s\",%s]"
  10231. ,MESSAGE_TYPE_CALLRESULT
  10232. ,uuid
  10233. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  10234. json_object_put(GetInstalledCertificateIds);
  10235. LWS_Send(message);
  10236. result = TRUE;
  10237. return result;
  10238. }
  10239. int sendGetLocalListVersionConfirmation(char *uuid)
  10240. {
  10241. mtrace();
  10242. int result = FAIL;
  10243. char message[4096]={0};
  10244. json_object *GetLocalListVersion = json_object_new_object();
  10245. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  10246. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  10247. sprintf(message,"[%d,\"%s\",%s]"
  10248. ,MESSAGE_TYPE_CALLRESULT
  10249. ,uuid
  10250. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  10251. json_object_put(GetLocalListVersion);
  10252. LWS_Send(message);
  10253. result = TRUE;
  10254. return result;
  10255. }
  10256. int sendGetLogConfirmation(char *uuid)
  10257. {
  10258. mtrace();
  10259. int result = FAIL;
  10260. char message[4096]={0};
  10261. json_object *GetLog = json_object_new_object();
  10262. DEBUG_INFO("sendGetLogConfirmation...\n");
  10263. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  10264. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  10265. sprintf(message,"[%d,\"%s\",%s]"
  10266. ,MESSAGE_TYPE_CALLRESULT
  10267. ,uuid
  10268. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  10269. json_object_put(GetLog);
  10270. LWS_Send(message);
  10271. result = TRUE;
  10272. return result;
  10273. }
  10274. int sendGetMonitoringReportConfirmation(char *uuid)
  10275. {
  10276. mtrace();
  10277. int result = FAIL;
  10278. char message[4096]={0};
  10279. json_object *GetMonitoringReport = json_object_new_object();
  10280. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  10281. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  10282. sprintf(message,"[%d,\"%s\",%s]"
  10283. ,MESSAGE_TYPE_CALLRESULT
  10284. ,uuid
  10285. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  10286. json_object_put(GetMonitoringReport);
  10287. LWS_Send(message);
  10288. result = TRUE;
  10289. return result;
  10290. }
  10291. int sendGetReportConfirmation(char *uuid)
  10292. {
  10293. mtrace();
  10294. int result = FAIL;
  10295. char message[4096]={0};
  10296. json_object *GetReport = json_object_new_object();
  10297. DEBUG_INFO("sendGetReportConfirmation...\n");
  10298. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  10299. sprintf(message,"[%d,\"%s\",%s]"
  10300. ,MESSAGE_TYPE_CALLRESULT
  10301. ,uuid
  10302. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  10303. json_object_put(GetReport);
  10304. LWS_Send(message);
  10305. result = TRUE;
  10306. return result;
  10307. }
  10308. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  10309. {
  10310. mtrace();
  10311. int result = FAIL;
  10312. char message[4096]={0};
  10313. json_object *GetTransactionStatus = json_object_new_object();
  10314. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  10315. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  10316. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  10317. sprintf(message,"[%d,\"%s\",%s]"
  10318. ,MESSAGE_TYPE_CALLRESULT
  10319. ,uuid
  10320. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  10321. json_object_put(GetTransactionStatus);
  10322. LWS_Send(message);
  10323. result = TRUE;
  10324. return result;
  10325. }
  10326. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  10327. {
  10328. mtrace();
  10329. int result = FAIL;
  10330. char message[4096]={0};
  10331. json_object *GetVariables = json_object_new_object();
  10332. json_object *getVariableResults = json_object_new_array();
  10333. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  10334. for(int idx=0;idx<variableQuantity;idx++)
  10335. {
  10336. json_object *variableResult = json_object_new_object();
  10337. json_object *component = json_object_new_object();
  10338. json_object *variable = json_object_new_object();
  10339. json_object *evse = json_object_new_object();
  10340. if(strlen((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType) > 0)
  10341. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  10342. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  10343. if(strlen((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue) > 0)
  10344. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  10345. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  10346. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  10347. json_object_object_add(component, "evse", evse);
  10348. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  10349. if(strlen((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance) > 0)
  10350. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  10351. json_object_object_add(variableResult, "component", component);
  10352. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  10353. if(strlen((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance) > 0)
  10354. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  10355. json_object_object_add(variableResult, "variable", variable);
  10356. json_object_array_add(getVariableResults, variableResult);
  10357. }
  10358. json_object_object_add(GetVariables , "getVariableResult", getVariableResults);
  10359. sprintf(message,"[%d,\"%s\",%s]"
  10360. ,MESSAGE_TYPE_CALLRESULT
  10361. ,uuid
  10362. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  10363. json_object_put(GetVariables);
  10364. LWS_Send(message);
  10365. result = TRUE;
  10366. return result;
  10367. }
  10368. int sendInstallCertificateConfirmation(char *uuid)
  10369. {
  10370. mtrace();
  10371. int result = FAIL;
  10372. char message[4096]={0};
  10373. json_object *InstallCertificate = json_object_new_object();
  10374. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  10375. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  10376. sprintf(message,"[%d,\"%s\",%s]"
  10377. ,MESSAGE_TYPE_CALLRESULT
  10378. ,uuid
  10379. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  10380. json_object_put(InstallCertificate);
  10381. LWS_Send(message);
  10382. result = TRUE;
  10383. return result;
  10384. }
  10385. int sendPublishFirmwareConfirmation(char *uuid)
  10386. {
  10387. mtrace();
  10388. int result = FAIL;
  10389. char message[4096]={0};
  10390. json_object *PublishFirmware = json_object_new_object();
  10391. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  10392. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  10393. sprintf(message,"[%d,\"%s\",%s]"
  10394. ,MESSAGE_TYPE_CALLRESULT
  10395. ,uuid
  10396. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  10397. json_object_put(PublishFirmware);
  10398. LWS_Send(message);
  10399. result = TRUE;
  10400. return result;
  10401. }
  10402. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  10403. {
  10404. mtrace();
  10405. int result = FAIL;
  10406. char message[4096]={0};
  10407. json_object *RemoteStartTransaction = json_object_new_object();
  10408. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  10409. if((strstr((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]) != NULL) &&
  10410. (strlen((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId) > 0))
  10411. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  10412. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  10413. sprintf(message,"[%d,\"%s\",%s]"
  10414. ,MESSAGE_TYPE_CALLRESULT
  10415. ,uuid
  10416. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  10417. json_object_put(RemoteStartTransaction);
  10418. LWS_Send(message);
  10419. result = TRUE;
  10420. return result;
  10421. }
  10422. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  10423. {
  10424. mtrace();
  10425. int result = FAIL;
  10426. char message[4096]={0};
  10427. json_object *RemoteStopTransaction = json_object_new_object();
  10428. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  10429. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  10430. sprintf(message,"[%d,\"%s\",%s]"
  10431. ,MESSAGE_TYPE_CALLRESULT
  10432. ,uuid
  10433. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  10434. json_object_put(RemoteStopTransaction);
  10435. LWS_Send(message);
  10436. result = TRUE;
  10437. return result;
  10438. }
  10439. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  10440. {
  10441. mtrace();
  10442. int result = FAIL;
  10443. char message[4096]={0};
  10444. json_object *ReserveNow = json_object_new_object();
  10445. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  10446. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  10447. sprintf(message,"[%d,\"%s\",%s]"
  10448. ,MESSAGE_TYPE_CALLRESULT
  10449. ,uuid
  10450. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  10451. json_object_put(ReserveNow);
  10452. LWS_Send(message);
  10453. result = TRUE;
  10454. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  10455. return result;
  10456. }
  10457. int sendResetConfirmation(char *uuid)
  10458. {
  10459. mtrace();
  10460. int result = FAIL;
  10461. char message[4096]={0};
  10462. json_object *Reset = json_object_new_object();
  10463. DEBUG_INFO("sendResetConfirmation...\n");
  10464. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  10465. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  10466. sprintf(message,"[%d,\"%s\",%s]"
  10467. ,MESSAGE_TYPE_CALLRESULT
  10468. ,uuid
  10469. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  10470. json_object_put(Reset);
  10471. LWS_Send(message);
  10472. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  10473. {
  10474. DB_updateBootType(BootReasonEnumType_RemoteReset);
  10475. DB_updateSecurityEventType(SecurityEventEnumType_ResetOrReboot);
  10476. }
  10477. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  10478. {
  10479. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  10480. DB_updateSecurityEventType(SecurityEventEnumType_ResetOrReboot);
  10481. }
  10482. result = TRUE;
  10483. return result;
  10484. }
  10485. int sendSendLocalListConfirmation(char *uuid)
  10486. {
  10487. mtrace();
  10488. int result = FAIL;
  10489. char message[4096]={0};
  10490. json_object *SendLocalList = json_object_new_object();
  10491. DEBUG_INFO("sendSendLocalListConfirmation...\n");
  10492. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  10493. sprintf(message,"[%d,\"%s\",%s]"
  10494. ,MESSAGE_TYPE_CALLRESULT
  10495. ,uuid
  10496. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  10497. json_object_put(SendLocalList);
  10498. LWS_Send(message);
  10499. result = TRUE;
  10500. return result;
  10501. }
  10502. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  10503. {
  10504. mtrace();
  10505. int result = FAIL;
  10506. char message[4096]={0};
  10507. json_object *SetChargingProfile = json_object_new_object();
  10508. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  10509. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  10510. sprintf(message,"[%d,\"%s\",%s]"
  10511. ,MESSAGE_TYPE_CALLRESULT
  10512. ,uuid
  10513. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  10514. json_object_put(SetChargingProfile);
  10515. LWS_Send(message);
  10516. result = TRUE;
  10517. return result;
  10518. }
  10519. int sendSetDisplayMessagesConfirmation(char *uuid)
  10520. {
  10521. mtrace();
  10522. int result = FAIL;
  10523. char message[4096]={0};
  10524. json_object *SetDisplayMessage = json_object_new_object();
  10525. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  10526. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  10527. sprintf(message,"[%d,\"%s\",%s]"
  10528. ,MESSAGE_TYPE_CALLRESULT
  10529. ,uuid
  10530. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  10531. json_object_put(SetDisplayMessage);
  10532. LWS_Send(message);
  10533. result = TRUE;
  10534. return result;
  10535. }
  10536. int sendSetMonitoringBaseConfirmation(char *uuid)
  10537. {
  10538. mtrace();
  10539. int result = FAIL;
  10540. char message[4096]={0};
  10541. json_object *SetMonitoringBase = json_object_new_object();
  10542. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  10543. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  10544. sprintf(message,"[%d,\"%s\",%s]"
  10545. ,MESSAGE_TYPE_CALLRESULT
  10546. ,uuid
  10547. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  10548. json_object_put(SetMonitoringBase);
  10549. LWS_Send(message);
  10550. result = TRUE;
  10551. return result;
  10552. }
  10553. int sendSetMonitoringLevelConfirmation(char *uuid)
  10554. {
  10555. mtrace();
  10556. int result = FAIL;
  10557. char message[4096]={0};
  10558. json_object *SetMonitoringLevel = json_object_new_object();
  10559. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  10560. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  10561. sprintf(message,"[%d,\"%s\",%s]"
  10562. ,MESSAGE_TYPE_CALLRESULT
  10563. ,uuid
  10564. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  10565. json_object_put(SetMonitoringLevel);
  10566. LWS_Send(message);
  10567. result = TRUE;
  10568. return result;
  10569. }
  10570. int sendSetNetworkProfileConfirmation(char *uuid)
  10571. {
  10572. mtrace();
  10573. int result = FAIL;
  10574. char message[4096]={0};
  10575. json_object *SetNetworkProfile = json_object_new_object();
  10576. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  10577. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  10578. sprintf(message,"[%d,\"%s\",%s]"
  10579. ,MESSAGE_TYPE_CALLRESULT
  10580. ,uuid
  10581. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  10582. json_object_put(SetNetworkProfile);
  10583. LWS_Send(message);
  10584. result = TRUE;
  10585. return result;
  10586. }
  10587. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  10588. {
  10589. mtrace();
  10590. int result = FAIL;
  10591. char message[4096]={0};
  10592. json_object *SetVariableMonitoring = json_object_new_object();
  10593. json_object *setMonitoringResults = json_object_new_array();
  10594. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  10595. for(int idx=0;idx<variableQuantity;idx++)
  10596. {
  10597. json_object *variableMonitorResult = json_object_new_object();
  10598. json_object *component = json_object_new_object();
  10599. json_object *variable = json_object_new_object();
  10600. json_object *evse = json_object_new_object();
  10601. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  10602. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  10603. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  10604. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  10605. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  10606. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  10607. json_object_object_add(component, "evse", evse);
  10608. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  10609. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  10610. json_object_object_add(variableMonitorResult, "component", component);
  10611. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  10612. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  10613. json_object_object_add(variableMonitorResult, "variable", variable);
  10614. json_object_array_add(setMonitoringResults, variableMonitorResult);
  10615. }
  10616. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  10617. sprintf(message,"[%d,\"%s\",%s]"
  10618. ,MESSAGE_TYPE_CALLRESULT
  10619. ,uuid
  10620. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  10621. json_object_put(SetVariableMonitoring);
  10622. LWS_Send(message);
  10623. result = TRUE;
  10624. return result;
  10625. }
  10626. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  10627. {
  10628. mtrace();
  10629. int result = FAIL;
  10630. char message[4096]={0};
  10631. json_object *SetVariable = json_object_new_object();
  10632. json_object *setVariableResults = json_object_new_array();
  10633. DEBUG_INFO("sendSetVariableConfirmation...\n");
  10634. for(int idx=0;idx<variableQuantity;idx++)
  10635. {
  10636. json_object *variableResult = json_object_new_object();
  10637. json_object *component = json_object_new_object();
  10638. json_object *variable = json_object_new_object();
  10639. json_object *evse = json_object_new_object();
  10640. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  10641. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  10642. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  10643. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  10644. json_object_object_add(component, "evse", evse);
  10645. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  10646. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  10647. json_object_object_add(variableResult, "component", component);
  10648. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  10649. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  10650. json_object_object_add(variableResult, "variable", variable);
  10651. json_object_array_add(setVariableResults, variableResult);
  10652. }
  10653. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  10654. sprintf(message,"[%d,\"%s\",%s]"
  10655. ,MESSAGE_TYPE_CALLRESULT
  10656. ,uuid
  10657. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  10658. json_object_put(SetVariable);
  10659. LWS_Send(message);
  10660. result = TRUE;
  10661. return result;
  10662. }
  10663. int sendTriggerMessageConfirmation(char *uuid)
  10664. {
  10665. mtrace();
  10666. int result = FAIL;
  10667. char message[4096]={0};
  10668. json_object *TriggerMessage = json_object_new_object();
  10669. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  10670. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  10671. sprintf(message,"[%d,\"%s\",%s]",
  10672. MESSAGE_TYPE_CALLRESULT,
  10673. uuid,
  10674. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  10675. json_object_put(TriggerMessage);
  10676. LWS_Send(message);
  10677. result = TRUE;
  10678. return result;
  10679. }
  10680. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  10681. {
  10682. mtrace();
  10683. int result = FAIL;
  10684. char message[4096]={0};
  10685. json_object *UnlockConnector = json_object_new_object();
  10686. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  10687. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  10688. sprintf(message,"[%d,\"%s\",%s]",
  10689. MESSAGE_TYPE_CALLRESULT,
  10690. uuid,
  10691. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  10692. json_object_put(UnlockConnector);
  10693. LWS_Send(message);
  10694. result = TRUE;
  10695. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  10696. return result;
  10697. }
  10698. int sendUnpublishFirmwareConfirmation(char *uuid)
  10699. {
  10700. mtrace();
  10701. int result = FAIL;
  10702. char message[4096]={0};
  10703. json_object *UnpublishFirmware = json_object_new_object();
  10704. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  10705. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  10706. sprintf(message,"[%d,\"%s\",%s]"
  10707. ,MESSAGE_TYPE_CALLRESULT
  10708. ,uuid
  10709. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  10710. json_object_put(UnpublishFirmware);
  10711. LWS_Send(message);
  10712. result = TRUE;
  10713. return result;
  10714. }
  10715. int sendUpdateFirmwareConfirmation(char *uuid)
  10716. {
  10717. mtrace();
  10718. int result = FAIL;
  10719. char message[4096]={0};
  10720. json_object *UpdateFirmware = json_object_new_object();
  10721. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  10722. sprintf((char*)ShmOCPP20Data->UpdateFirmware.Response_status, "%s", UpdateFirmwareStatusEnumTypeStr[UpdateFirmwareStatusEnumType_Accepted]);
  10723. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  10724. sprintf(message,"[%d,\"%s\",%s]"
  10725. ,MESSAGE_TYPE_CALLRESULT
  10726. ,uuid
  10727. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  10728. json_object_put(UpdateFirmware);
  10729. LWS_Send(message);
  10730. result = TRUE;
  10731. return result;
  10732. }
  10733. int sendUnknownConfirmation(char *uuid)
  10734. {
  10735. mtrace();
  10736. int result = FAIL;
  10737. char message[256]={0};
  10738. //[ 3, "ba1cbd49-2a76-493a-8f76-fa23e7606532", { "status": "Unlocked" } ]
  10739. DEBUG_INFO("sendUnknownConfirmation...\n");
  10740. sprintf(message,"[%d,\"%s\",\"NotImplemented\",\"Requested Action is not known by receiver\",{}]", MESSAGE_TYPE_CALLERROR, uuid);
  10741. LWS_Send(message);
  10742. result = TRUE;
  10743. return result;
  10744. }
  10745. //==========================================
  10746. // send CallError routine
  10747. //==========================================
  10748. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  10749. {
  10750. mtrace();
  10751. char message[220]={0};
  10752. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  10753. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  10754. LWS_Send(message);
  10755. }
  10756. //==========================================
  10757. // Handle server request routine Start
  10758. //==========================================
  10759. int handleCancelReservationRequest(char *uuid, char *payload)
  10760. {
  10761. mtrace();
  10762. int result = FAIL;
  10763. int gunNO = 0;
  10764. int reservationIdInt = -1;
  10765. DEBUG_INFO("handleCancelReservationRequest...\n");
  10766. json_object *CancelReservation;
  10767. CancelReservation = json_tokener_parse(payload);
  10768. if(!is_error(CancelReservation))
  10769. {
  10770. // Required data
  10771. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  10772. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  10773. }
  10774. json_object_put(CancelReservation);
  10775. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  10776. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  10777. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  10778. if(reservationIdInt != -1)
  10779. {
  10780. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  10781. //check Transaction active
  10782. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  10783. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10784. {
  10785. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  10786. {
  10787. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10788. if(gunType[2] == GUN_TYPE_CHAdeMO)
  10789. {
  10790. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  10791. }
  10792. else
  10793. {
  10794. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  10795. }
  10796. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10797. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10798. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10799. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10800. goto end;
  10801. }
  10802. }
  10803. for (int index = 0; index < CCS_QUANTITY; index++)
  10804. {
  10805. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  10806. {
  10807. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10808. if(gunType[2] == GUN_TYPE_CCS)
  10809. {
  10810. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  10811. }
  10812. else
  10813. {
  10814. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  10815. }
  10816. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10817. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10818. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10819. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10820. goto end;
  10821. }
  10822. }
  10823. for (int index = 0; index < GB_QUANTITY; index++)
  10824. {
  10825. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  10826. {
  10827. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10828. if(gunType[2] == GUN_TYPE_GBT)
  10829. {
  10830. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  10831. }
  10832. else
  10833. {
  10834. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  10835. }
  10836. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10837. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10838. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10839. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10840. goto end;
  10841. }
  10842. }
  10843. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10844. {
  10845. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId == reservationIdInt)
  10846. {
  10847. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10848. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  10849. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10850. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10851. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10852. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10853. goto end;
  10854. }
  10855. }
  10856. for (int index = 0; index < AC_QUANTITY; index++)
  10857. {
  10858. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  10859. {
  10860. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10861. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  10862. {
  10863. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  10864. }
  10865. else
  10866. {
  10867. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  10868. }
  10869. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10870. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10871. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10872. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10873. goto end;
  10874. }
  10875. }
  10876. }
  10877. //The reservationId does NOT match the reservationId
  10878. sendCancelReservationConfirmation(uuid, gunNO);
  10879. end:
  10880. // Fill in ocpp packet uuid
  10881. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  10882. return result;
  10883. }
  10884. int handleCertificateSignedRequest(char *uuid, char *payload)
  10885. {
  10886. mtrace();
  10887. int result = FAIL;
  10888. json_object *CertificateSigned;
  10889. DEBUG_INFO("handleCertificateSignedRequest...\n");
  10890. CertificateSigned = json_tokener_parse(payload);
  10891. if(!is_error(CertificateSigned))
  10892. {
  10893. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  10894. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  10895. // Required data
  10896. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateChain, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateChain")));
  10897. // Optional data
  10898. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  10899. {
  10900. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  10901. if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_ChargingStationCertificate]) == 0)
  10902. {
  10903. FILE *fp = fopen("/Storage/OCPP/certCP.crt", "w");
  10904. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  10905. fclose(fp);
  10906. }
  10907. else if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0)
  10908. {
  10909. FILE *fp = fopen("/Storage/OCPP/certV2G.crt", "w");
  10910. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  10911. fclose(fp);
  10912. }
  10913. }
  10914. else
  10915. {
  10916. FILE *fp = fopen("/Storage/OCPP/certCP.crt", "w");
  10917. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  10918. fclose(fp);
  10919. fp = fopen("/Storage/OCPP/certV2G.crt", "w");
  10920. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  10921. fclose(fp);
  10922. }
  10923. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  10924. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  10925. }
  10926. else
  10927. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  10928. json_object_put(CertificateSigned);
  10929. sendCertificateSignedConfirmation(uuid);
  10930. return result;
  10931. }
  10932. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  10933. {
  10934. mtrace();
  10935. int result = FAIL;
  10936. int evseId = 0, gunIndex = 0;
  10937. char operationalStatus[16]={0};
  10938. char comfirmstr[20];
  10939. int specificId = FALSE;
  10940. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  10941. json_object *ChangeAvailability;
  10942. ChangeAvailability = json_tokener_parse(payload);
  10943. if(!is_error(ChangeAvailability))
  10944. {
  10945. // Required data
  10946. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  10947. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  10948. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  10949. {
  10950. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  10951. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  10952. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  10953. }
  10954. }
  10955. json_object_put(ChangeAvailability);
  10956. if((evseId != 0) && (evseId <= gunTotalNumber))
  10957. {
  10958. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  10959. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  10960. }
  10961. else if(evseId == 0)
  10962. {
  10963. for(int i=0; i < gunTotalNumber; i++)
  10964. {
  10965. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  10966. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  10967. }
  10968. }
  10969. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  10970. {
  10971. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  10972. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  10973. }
  10974. else if(gunIndex == 0)
  10975. {
  10976. for(int i=0; i < gunTotalNumber; i++)
  10977. {
  10978. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  10979. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  10980. }
  10981. }
  10982. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  10983. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  10984. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  10985. {
  10986. specificId = TRUE;
  10987. }
  10988. if(specificId == FALSE)
  10989. goto end;
  10990. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  10991. {
  10992. //----------------------gunIndex is 0 ------------------------------------------------//
  10993. if(gunIndex == 0)
  10994. {
  10995. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10996. {
  10997. for(int i=0; i < gunTotalNumber; i++)
  10998. {
  10999. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11000. {
  11001. if ((gunType[i] == GUN_TYPE_CHAdeMO)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  11002. {
  11003. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  11004. {
  11005. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11006. goto end;
  11007. }
  11008. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11009. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11010. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11011. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11012. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11013. {
  11014. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11015. goto end;
  11016. }
  11017. }
  11018. }//END FOR CHAdeMO_QUANTITY
  11019. for (int index = 0; index < CCS_QUANTITY; index++)
  11020. {
  11021. if ((gunType[i] == GUN_TYPE_CCS)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  11022. {
  11023. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  11024. {
  11025. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11026. goto end;
  11027. }
  11028. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11029. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11030. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11031. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11032. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11033. {
  11034. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11035. goto end;
  11036. }
  11037. }
  11038. }//END FOR CCS_QUANTITY
  11039. for (int index = 0; index < GB_QUANTITY; index++)
  11040. {
  11041. if ((gunType[i] == GUN_TYPE_GBT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  11042. {
  11043. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  11044. {
  11045. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11046. goto end;
  11047. }
  11048. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11049. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11050. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11051. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11052. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11053. {
  11054. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11055. goto end;
  11056. }
  11057. }
  11058. }// END FOR GB_QUANTITY
  11059. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11060. {
  11061. if ((gunType[i] == GUN_TYPE_DO)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == i))
  11062. {
  11063. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  11064. {
  11065. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11066. goto end;
  11067. }
  11068. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  11069. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  11070. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  11071. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  11072. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11073. {
  11074. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11075. goto end;
  11076. }
  11077. }
  11078. }// END FOR DO_QUANTITY
  11079. for (int index = 0; index < AC_QUANTITY; index++)
  11080. {
  11081. if ((gunType[i] == GUN_TYPE_AC)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  11082. {
  11083. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  11084. {
  11085. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11086. goto end;
  11087. }
  11088. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11089. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11090. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11091. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11092. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11093. {
  11094. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11095. goto end;
  11096. }
  11097. }
  11098. }//END FOR AC_QUANTITY
  11099. }// END FOR gunTotalNumber
  11100. }
  11101. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  11102. {
  11103. for(int i=0; i < gunTotalNumber; i++)
  11104. {
  11105. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  11106. {
  11107. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11108. goto end;
  11109. }
  11110. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11111. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  11112. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  11113. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  11114. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11115. {
  11116. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11117. goto end;
  11118. }
  11119. }
  11120. }
  11121. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11122. goto end;
  11123. }
  11124. //----------------------gunIndex is not 0 ------------------------------------------------//
  11125. //check Transaction active
  11126. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11127. {
  11128. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO))
  11129. {
  11130. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  11131. {
  11132. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11133. goto end;
  11134. }
  11135. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11136. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11137. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11138. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11139. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11140. {
  11141. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11142. goto end;
  11143. }
  11144. else
  11145. {
  11146. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  11147. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11148. goto end;
  11149. }
  11150. }
  11151. }//END FOR CHAdeMO_QUANTITY
  11152. for (int index = 0; index < CCS_QUANTITY; index++)
  11153. {
  11154. if ((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS))
  11155. {
  11156. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  11157. {
  11158. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11159. goto end;
  11160. }
  11161. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11162. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11163. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11164. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11165. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11166. {
  11167. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11168. goto end;
  11169. }
  11170. else
  11171. {
  11172. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  11173. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11174. goto end;
  11175. }
  11176. }
  11177. }//END FOR CCS_QUANTITY
  11178. for (int index = 0; index < GB_QUANTITY; index++)
  11179. {
  11180. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))
  11181. {
  11182. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  11183. {
  11184. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11185. goto end;
  11186. }
  11187. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11188. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11189. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11190. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11191. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11192. {
  11193. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11194. goto end;
  11195. }
  11196. else
  11197. {
  11198. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  11199. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11200. goto end;
  11201. }
  11202. }
  11203. }// END FOR GB_QUANTITY
  11204. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11205. {
  11206. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))
  11207. {
  11208. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  11209. {
  11210. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11211. goto end;
  11212. }
  11213. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  11214. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  11215. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  11216. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  11217. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11218. {
  11219. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11220. goto end;
  11221. }
  11222. else
  11223. {
  11224. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  11225. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11226. goto end;
  11227. }
  11228. }
  11229. }// END FOR DO_QUANTITY
  11230. for (int index = 0; index < AC_QUANTITY; index++)
  11231. {
  11232. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC))
  11233. {
  11234. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  11235. {
  11236. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11237. goto end;
  11238. }
  11239. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11240. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11241. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11242. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11243. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11244. {
  11245. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11246. goto end;
  11247. }
  11248. else
  11249. {
  11250. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  11251. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11252. goto end;
  11253. }
  11254. }
  11255. }//END FOR AC_QUANTITY
  11256. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  11257. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  11258. {
  11259. //----------------------gunIndex is 0 ------------------------------------------------//
  11260. if(gunIndex == 0)
  11261. {
  11262. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11263. {
  11264. for(int i=0; i < gunTotalNumber; i++)
  11265. {
  11266. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11267. {
  11268. if ((gunType[i] == GUN_TYPE_CHAdeMO )&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT //(((gunIndex == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO)) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11269. {
  11270. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11271. goto end;
  11272. }
  11273. }//END FOR CHAdeMO_QUANTITY
  11274. for (int index = 0; index < CCS_QUANTITY; index++)
  11275. {
  11276. if ((gunType[i] == GUN_TYPE_CCS)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT//(((gunIndex == 0)|| ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11277. {
  11278. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11279. goto end;
  11280. }
  11281. }//END FOR CCS_QUANTITY
  11282. for (int index = 0; index < GB_QUANTITY; index++)
  11283. {
  11284. if ((gunType[i] == GUN_TYPE_GBT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT //(((gunIndex == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT)))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11285. {
  11286. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  11287. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11288. goto end;
  11289. }
  11290. }// END FOR GB_QUANTITY
  11291. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11292. {
  11293. if ((gunType[i] == GUN_TYPE_DO)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == i)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_FAULT)) //S_FAULT //(((gunIndex == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT)))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11294. {
  11295. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  11296. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11297. goto end;
  11298. }
  11299. }// END FOR DO_QUANTITY
  11300. for (int index = 0; index < AC_QUANTITY; index++)
  11301. {
  11302. if ((gunType[i] == GUN_TYPE_AC) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT // (((gunIndex == 0)|| ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11303. {
  11304. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11305. goto end;
  11306. }
  11307. }//END FOR CHAdeMO_QUANTITY
  11308. }// END FOR gunTotalNumber
  11309. }
  11310. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  11311. {
  11312. for(int i=0; i < gunTotalNumber; i++)
  11313. {
  11314. for (int index = 0; index < AC_QUANTITY; index++)
  11315. {
  11316. if ((gunType[i] == GUN_TYPE_AC) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT // (((gunIndex == 0)|| ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11317. {
  11318. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11319. goto end;
  11320. }
  11321. }//END FOR CHAdeMO_QUANTITY
  11322. } // END FOR gunTotalNumber
  11323. }
  11324. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11325. goto end;
  11326. }
  11327. //----------------------gunIndex is not 0 ------------------------------------------------//
  11328. //check Transaction active
  11329. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11330. {
  11331. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11332. {
  11333. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11334. goto end;
  11335. }
  11336. }//END FOR CHAdeMO_QUANTITY
  11337. for (int index = 0; index < CCS_QUANTITY; index++)
  11338. {
  11339. if ((((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS)) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11340. {
  11341. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11342. goto end;
  11343. }
  11344. }//END FOR CCS_QUANTITY
  11345. for (int index = 0; index < GB_QUANTITY; index++)
  11346. {
  11347. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11348. {
  11349. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11350. goto end;
  11351. }
  11352. }// END FOR GB_QUANTITY
  11353. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11354. {
  11355. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11356. {
  11357. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11358. goto end;
  11359. }
  11360. }// END FOR DO_QUANTITY
  11361. for (int index = 0; index < AC_QUANTITY; index++)
  11362. {
  11363. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC)) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11364. {
  11365. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11366. goto end;
  11367. }
  11368. }//END FOR AC_QUANTITY
  11369. }//END FOR AvailabilityEnumTypeStr[Operative]
  11370. end:
  11371. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  11372. {
  11373. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  11374. }
  11375. else
  11376. {
  11377. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  11378. }
  11379. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  11380. {
  11381. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  11382. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  11383. }
  11384. else if(gunIndex == 0)
  11385. {
  11386. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  11387. {
  11388. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  11389. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  11390. }
  11391. }
  11392. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  11393. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  11394. return result;
  11395. }
  11396. int handleClearCacheRequest(char *uuid, char *payload)
  11397. {
  11398. mtrace();
  11399. int result = FAIL;
  11400. char rmFileCmd[100]={0};
  11401. struct stat stats;
  11402. DEBUG_INFO("handleClearCacheRequest...\n");
  11403. stat("/Storage/OCPP", &stats);
  11404. // Check for directory existence
  11405. if (S_ISDIR(stats.st_mode) == 1)
  11406. {}
  11407. else
  11408. {
  11409. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  11410. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  11411. system(rmFileCmd);
  11412. }
  11413. if(DB_cleanLocalCache() != PASS)
  11414. {
  11415. DEBUG_INFO("open AuthorizationCache file failed\n");
  11416. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  11417. }
  11418. else
  11419. {
  11420. DEBUG_INFO("open AuthorizationCache file successful\n");
  11421. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  11422. }
  11423. sendClearCacheConfirmation(uuid);
  11424. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  11425. return result;
  11426. }
  11427. int handleClearChargingProfileRequest(char *uuid, char *payload)
  11428. {
  11429. mtrace();
  11430. int result = FAIL;
  11431. int resultRename;
  11432. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  11433. char chargingProfilePurposeStr[26]={0};
  11434. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  11435. char tempchargingProfilePurposeStr[26]={0};
  11436. char sstr[160]={0};
  11437. char str[100]={0};
  11438. int c = 0;
  11439. char *loc;
  11440. char fname[200]={0};
  11441. char comfirmstr[20]={0};
  11442. char word[1600]={0};
  11443. int clearflag = FALSE;
  11444. int chargingProfileIdIsNULL = FALSE;
  11445. int connectorIsNULL = FALSE;
  11446. int chargingProfilePurposeIsNULL = FALSE;
  11447. int stackLevelIsNULL = FALSE;
  11448. //int GotoEnd = FALSE;
  11449. FILE *fptr1, *fptr2;
  11450. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  11451. int n_chargingProfile=0;
  11452. int isEmptyFile = FALSE;
  11453. char sLineWord[1600]={0};
  11454. char chargingProfiles[10][100]={0};
  11455. int ChargeProfileCount = 0;
  11456. int ch;
  11457. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  11458. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  11459. json_object *ClearChargingProfile;
  11460. ClearChargingProfile = json_tokener_parse(payload);
  11461. if(!is_error(ClearChargingProfile))
  11462. {
  11463. // Optional data
  11464. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  11465. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  11466. else
  11467. chargingProfileIdIsNULL = TRUE;
  11468. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  11469. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  11470. else
  11471. connectorIsNULL = TRUE;
  11472. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  11473. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  11474. else
  11475. chargingProfilePurposeIsNULL = TRUE;
  11476. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  11477. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  11478. else
  11479. stackLevelIsNULL = TRUE;
  11480. }
  11481. json_object_put(ClearChargingProfile);
  11482. if(connectorIsNULL == FALSE)
  11483. {
  11484. switch(connectorIdInt)
  11485. {
  11486. case 0:
  11487. if(chargingProfilePurposeIsNULL == TRUE)
  11488. {
  11489. int l = 0;
  11490. strcpy(fname, ChargingStationMaxProfile_JSON);
  11491. if((access(fname,F_OK))!=-1)
  11492. {
  11493. strcpy(chargingProfiles[l], fname);
  11494. l = l + 1;
  11495. }
  11496. strcpy(fname, TxDefaultProfile_0_JSON);
  11497. if((access(fname,F_OK))!=-1)
  11498. {
  11499. strcpy(chargingProfiles[l], fname);
  11500. l = l + 1;
  11501. }
  11502. ChargeProfileCount = l;
  11503. }
  11504. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  11505. {
  11506. strcpy(fname, ChargingStationMaxProfile_JSON);
  11507. if((access(fname,F_OK))!=-1)
  11508. {
  11509. strcpy(chargingProfiles[0], fname);
  11510. ChargeProfileCount = 1;
  11511. }
  11512. }
  11513. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  11514. {
  11515. strcpy(fname, TxDefaultProfile_0_JSON);
  11516. if((access(fname,F_OK))!=-1)
  11517. {
  11518. strcpy(chargingProfiles[0], fname);
  11519. ChargeProfileCount = 1;
  11520. }
  11521. }
  11522. break;
  11523. default:
  11524. if(chargingProfilePurposeIsNULL == TRUE)
  11525. {
  11526. int m = 0;
  11527. memset(fname, 0, ARRAY_SIZE(fname));
  11528. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", connectorIdInt);
  11529. if((access(fname,F_OK))!=-1)
  11530. {
  11531. strcpy(chargingProfiles[m], fname);
  11532. m = m + 1;
  11533. }
  11534. memset(fname, 0, ARRAY_SIZE(fname));
  11535. sprintf(fname, "/Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdInt);
  11536. if((access(fname,F_OK))!=-1)
  11537. {
  11538. strcpy(chargingProfiles[m], fname);
  11539. m = m + 1;
  11540. }
  11541. ChargeProfileCount = m;
  11542. }
  11543. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  11544. {
  11545. //strcpy(fname, TxDefaultProfile_1_JSON);
  11546. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", connectorIdInt);
  11547. if((access(fname,F_OK))!=-1)
  11548. {
  11549. strcpy(chargingProfiles[0], fname);
  11550. ChargeProfileCount = 1;
  11551. }
  11552. }
  11553. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  11554. {
  11555. sprintf(fname, "/Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdInt);
  11556. if((access(fname,F_OK))!=-1)
  11557. {
  11558. strcpy(chargingProfiles[0], fname);
  11559. ChargeProfileCount = 1;
  11560. }
  11561. }
  11562. //strcpy(fname, ChargePointMaxProfile_JSON );
  11563. break;
  11564. }
  11565. }
  11566. else // Check all Charging Profiles
  11567. {
  11568. int i = 0;
  11569. char fnametemp[200]={0};
  11570. ChargeProfileCount = 0;
  11571. //Check ChargePointMaxProfile.json exit
  11572. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  11573. {
  11574. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  11575. i = i + 1;
  11576. }
  11577. //Check TxDefaultProfile_%d.json
  11578. for(int j=1; j <= gunTotalNumber; j++)
  11579. {
  11580. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  11581. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", j);
  11582. if((access(fnametemp,F_OK))!=-1)
  11583. {
  11584. strcpy(chargingProfiles[i], fnametemp);
  11585. i = i + 1;
  11586. }
  11587. }
  11588. //Check TxProfile_%d.json
  11589. for(int j=1; j <= gunTotalNumber; j++)
  11590. {
  11591. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  11592. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d_OCPP20.json", j);
  11593. if((access(fnametemp,F_OK))!=-1)
  11594. {
  11595. strcpy(chargingProfiles[i], fnametemp);
  11596. i = i + 1;
  11597. }
  11598. }
  11599. ChargeProfileCount = i;
  11600. }// End connectorIsNULL is TRUE
  11601. if(ChargeProfileCount == 0)
  11602. {
  11603. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  11604. goto end;
  11605. }
  11606. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  11607. {
  11608. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  11609. goto end;
  11610. }
  11611. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  11612. {
  11613. memset(str, 0, ARRAY_SIZE(str));
  11614. // clear temp file
  11615. sprintf(str,"rm -f %s",temp);
  11616. system(str);
  11617. for(int k=0; k < ChargeProfileCount; k++)
  11618. {
  11619. memset(str, 0, ARRAY_SIZE(str));
  11620. //clear file in C
  11621. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11622. system(str);
  11623. }
  11624. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11625. goto end;
  11626. }
  11627. else if(connectorIsNULL == TRUE)
  11628. {
  11629. for(int k=0; k < ChargeProfileCount; k++)
  11630. {
  11631. fptr1 = fopen(chargingProfiles[k], "r");
  11632. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  11633. //Check Charging Profile Count
  11634. while(fscanf(fptr1, "%s", word) != EOF)
  11635. {
  11636. //DEBUG_INFO("word=%s\n",word);
  11637. if(strstr(word, "id")!= NULL)
  11638. {
  11639. //DEBUG_INFO("test id \n");
  11640. n_chargingProfile = n_chargingProfile + 1;
  11641. //DEBUG_INFO("id Found\n");
  11642. }
  11643. }
  11644. rewind(fptr1);
  11645. //search Charging Profile Element
  11646. //int i= 0;
  11647. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  11648. {
  11649. //------------------------tempconnectorIdInt------------------------//
  11650. loc = strstr(sLineWord, "connectorId");
  11651. c = 0;
  11652. memset(sstr ,0, sizeof(sstr) );
  11653. while (loc[strlen("connectorId")+2+c] != ',')
  11654. {
  11655. sstr[c] = loc[strlen("connectorId")+2+c];
  11656. c++;
  11657. }
  11658. sstr[c] = '\0';
  11659. tempconnectorIdInt = atoi(sstr);
  11660. printf("file's gun number is %d\n", tempconnectorIdInt);
  11661. //--------------------------id--------------------//
  11662. c = 0;
  11663. loc = strstr(sLineWord, "id");
  11664. memset(sstr ,0, ARRAY_SIZE(sstr));
  11665. while (loc[strlen("id")+2+c] != ',')
  11666. {
  11667. sstr[c] = loc[strlen("id")+2+c];
  11668. //printf("i=%d sstr=%c\n",c, sstr[c]);
  11669. c++;
  11670. }
  11671. sstr[c] = '\0';
  11672. tempchargingProfileIdInt = atoi(sstr);
  11673. //stackLevel
  11674. c = 0;
  11675. loc = strstr(sLineWord, "stackLevel");
  11676. memset(sstr ,0, ARRAY_SIZE(sstr));
  11677. while (loc[strlen("stackLevel")+2+c] != ',')
  11678. {
  11679. sstr[c] = loc[strlen("stackLevel")+2+c];
  11680. //printf("i=%d sstr=%c\n",c, sstr[c]);
  11681. c++;
  11682. }
  11683. sstr[c] = '\0';
  11684. tempstackLevelInt = atoi(sstr);
  11685. c = 0;
  11686. loc = strstr(sLineWord, "chargingProfilePurpose");
  11687. memset(sstr ,0, ARRAY_SIZE(sstr));
  11688. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  11689. {
  11690. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  11691. c++;
  11692. }
  11693. sstr[c] = '\0';
  11694. strcpy(tempchargingProfilePurposeStr, sstr);
  11695. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  11696. {
  11697. //------- not write to fptr2-------//
  11698. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11699. //clearflag = TRUE;
  11700. }
  11701. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  11702. {
  11703. //------- not write to fptr2-------//
  11704. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11705. }
  11706. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  11707. {
  11708. //------- not write to fptr2-------//
  11709. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11710. }
  11711. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  11712. {
  11713. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11714. }
  11715. else
  11716. {
  11717. fprintf(fptr2, sLineWord);//writing data into file
  11718. }
  11719. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  11720. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  11721. if(clearflag == TRUE)
  11722. {
  11723. fclose(fptr1);
  11724. fclose(fptr2);
  11725. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11726. system(str);
  11727. // clear temp file
  11728. sprintf(str,"rm -f %s",temp);
  11729. system(str);
  11730. }
  11731. else
  11732. {
  11733. fclose(fptr1);
  11734. fclose(fptr2);
  11735. memset(str, 0, ARRAY_SIZE(str));
  11736. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11737. system(str);
  11738. resultRename = rename(temp, chargingProfiles[k]);
  11739. if(resultRename == 0)
  11740. {
  11741. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  11742. }
  11743. else
  11744. {
  11745. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  11746. }
  11747. if(comfirmstr[0]== 0)
  11748. {
  11749. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  11750. }
  11751. //Check chargingProfile is empty file
  11752. /*------ Read the file ----------------*/
  11753. fptr1=fopen(chargingProfiles[k],"r");
  11754. ch=fgetc(fptr1);
  11755. rewind(fptr1);
  11756. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  11757. if(ch!=EOF)
  11758. {
  11759. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  11760. {
  11761. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  11762. if(sLineWord[0]=='\0')
  11763. {
  11764. isEmptyFile = TRUE;
  11765. break;
  11766. }
  11767. else
  11768. {
  11769. isEmptyFile = FALSE;
  11770. break;
  11771. }
  11772. }
  11773. }
  11774. else
  11775. isEmptyFile = TRUE;
  11776. fclose(fptr1);
  11777. if(isEmptyFile == TRUE)
  11778. {
  11779. memset(str, 0, ARRAY_SIZE(str));
  11780. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11781. system(str);
  11782. }
  11783. }
  11784. }// End of while(int k=0; k < ChargePointCount; k++)
  11785. }
  11786. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  11787. {
  11788. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  11789. for(int k=0; k < ChargeProfileCount; k++)
  11790. {
  11791. fptr1 = fopen(chargingProfiles[k], "r");
  11792. fptr2 = fopen(temp, "w+");
  11793. //Check Charging Profile Count
  11794. while(fscanf(fptr1, "%s", word) != EOF)
  11795. {
  11796. //DEBUG_INFO("word=%s\n",word);
  11797. if(strstr(word, "id")!= NULL)
  11798. {
  11799. n_chargingProfile = n_chargingProfile + 1;
  11800. }
  11801. }
  11802. rewind(fptr1);
  11803. //search Charging Profile Element
  11804. //int i= 0;
  11805. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  11806. {
  11807. //*************************tempconnectorIdInt*********************************/
  11808. loc = strstr(sLineWord, "connectorId");
  11809. c = 0;
  11810. memset(sstr ,0, ARRAY_SIZE(sstr));
  11811. while (loc[strlen("connectorId")+2+c] != ',')
  11812. {
  11813. sstr[c] = loc[strlen("connectorId")+2+c];
  11814. c++;
  11815. }
  11816. sstr[c] = '\0';
  11817. tempconnectorIdInt = atoi(sstr);
  11818. //id
  11819. c = 0;
  11820. loc = strstr(sLineWord, "id");
  11821. memset(sstr ,0, ARRAY_SIZE(sstr));
  11822. while (loc[strlen("id")+2+c] != ',')
  11823. {
  11824. sstr[c] = loc[strlen("id")+2+c];
  11825. //printf("i=%d sstr=%c\n",c, sstr[c]);
  11826. c++;
  11827. }
  11828. sstr[c] = '\0';
  11829. tempchargingProfileIdInt = atoi(sstr);
  11830. //stackLevel
  11831. c = 0;
  11832. loc = strstr(sLineWord, "stackLevel");
  11833. memset(sstr ,0, ARRAY_SIZE(sstr));
  11834. while (loc[strlen("stackLevel")+2+c] != ',')
  11835. {
  11836. sstr[c] = loc[strlen("stackLevel")+2+c];
  11837. //printf("i=%d sstr=%c\n",c, sstr[c]);
  11838. c++;
  11839. }
  11840. sstr[c] = '\0';
  11841. tempstackLevelInt = atoi(sstr);
  11842. c = 0;
  11843. loc = strstr(sLineWord, "chargingProfilePurpose");
  11844. memset(sstr ,0, ARRAY_SIZE(sstr));
  11845. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  11846. {
  11847. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  11848. c++;
  11849. }
  11850. sstr[c] = '\0';
  11851. strcpy(tempchargingProfilePurposeStr, sstr);
  11852. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  11853. {
  11854. //------- not write to fptr2-------//
  11855. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11856. //clearflag = TRUE;
  11857. }
  11858. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  11859. {
  11860. //------- not write to fptr2-------//
  11861. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11862. }
  11863. else if(stackLevelIsNULL == TRUE)
  11864. {
  11865. //Clear Whole File
  11866. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11867. clearflag = TRUE;
  11868. break;
  11869. }
  11870. else
  11871. {
  11872. fprintf(fptr2, sLineWord);//writing data into file
  11873. }
  11874. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  11875. }
  11876. if(clearflag == TRUE)
  11877. {
  11878. fclose(fptr1);
  11879. fclose(fptr2);
  11880. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11881. system(str);
  11882. // clear temp file
  11883. sprintf(str,"rm -f %s",temp);
  11884. system(str);
  11885. }
  11886. else
  11887. {
  11888. fclose(fptr1);
  11889. fclose(fptr2);
  11890. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11891. system(str);
  11892. resultRename = rename(temp, chargingProfiles[k]);
  11893. if(resultRename == 0)
  11894. {
  11895. DEBUG_INFO("File ChargingProfile renamed successfully");
  11896. }
  11897. else
  11898. {
  11899. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  11900. }
  11901. if(comfirmstr[0]== 0)
  11902. {
  11903. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  11904. }
  11905. //Check chargingProfile is empty file
  11906. /*------ Read the file ----------------*/
  11907. fptr1=fopen(chargingProfiles[k],"r");
  11908. ch=fgetc(fptr1);
  11909. rewind(fptr1);
  11910. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  11911. if(ch!=EOF)
  11912. {
  11913. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  11914. {
  11915. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  11916. if(sLineWord[0]=='\0')
  11917. {
  11918. isEmptyFile = TRUE;
  11919. break;
  11920. }
  11921. else
  11922. {
  11923. isEmptyFile = FALSE;
  11924. break;
  11925. }
  11926. }
  11927. }
  11928. else
  11929. isEmptyFile = TRUE;
  11930. fclose(fptr1);
  11931. if(isEmptyFile == TRUE)
  11932. {
  11933. memset(str, 0, ARRAY_SIZE(str));
  11934. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11935. system(str);
  11936. }
  11937. /*------- End of reading ---------------*/
  11938. }
  11939. } // while(int k=0; k < ChargeProfileCount; k++)
  11940. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  11941. end:
  11942. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  11943. {
  11944. if(connectorIdInt == 0)
  11945. {
  11946. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  11947. {
  11948. checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
  11949. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
  11950. }
  11951. }
  11952. else
  11953. {
  11954. checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
  11955. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1], 0, TRUE);
  11956. }
  11957. }
  11958. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  11959. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  11960. return result;
  11961. }
  11962. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  11963. {
  11964. mtrace();
  11965. int result = FAIL;
  11966. json_object *ClearDisplayMessage;
  11967. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  11968. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  11969. ClearDisplayMessage = json_tokener_parse(payload);
  11970. if(!is_error(ClearDisplayMessage))
  11971. {
  11972. // Required data
  11973. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  11974. {
  11975. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  11976. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  11977. }
  11978. }
  11979. json_object_put(ClearDisplayMessage);
  11980. sendCostUpdatedConfirmation(uuid);
  11981. return result;
  11982. }
  11983. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  11984. {
  11985. mtrace();
  11986. int result = FAIL;
  11987. json_object *ClearVariableMonitorin;
  11988. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  11989. ClearVariableMonitorin = json_tokener_parse(payload);
  11990. if(!is_error(ClearVariableMonitorin))
  11991. {
  11992. // Required data
  11993. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  11994. {
  11995. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  11996. {
  11997. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  11998. /*
  11999. * TODO:
  12000. * 1. Check response
  12001. */
  12002. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  12003. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  12004. }
  12005. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  12006. }
  12007. }
  12008. json_object_put(ClearVariableMonitorin);
  12009. return result;
  12010. }
  12011. int handleCostUpdatedRequest(char *uuid, char *payload)
  12012. {
  12013. mtrace();
  12014. int result = FAIL;
  12015. json_object *CostUpdate;
  12016. DEBUG_INFO("handleCostUpdatedRequest...\n");
  12017. CostUpdate = json_tokener_parse(payload);
  12018. if(!is_error(CostUpdate))
  12019. {
  12020. // Required data
  12021. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  12022. {
  12023. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  12024. }
  12025. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  12026. {
  12027. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  12028. }
  12029. }
  12030. json_object_put(CostUpdate);
  12031. sendCostUpdatedConfirmation(uuid);
  12032. return result;
  12033. }
  12034. int handleCustomerInformationRequest(char *uuid, char *payload)
  12035. {
  12036. mtrace();
  12037. int result = FAIL;
  12038. json_object *CustomerInformation;
  12039. DEBUG_INFO("handleCustomerInformationRequest...\n");
  12040. CustomerInformation = json_tokener_parse(payload);
  12041. if(!is_error(CustomerInformation))
  12042. {
  12043. // Required data
  12044. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  12045. {
  12046. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  12047. }
  12048. if(json_object_object_get(CustomerInformation, "report") != NULL)
  12049. {
  12050. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  12051. }
  12052. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  12053. {
  12054. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  12055. }
  12056. // Optional data
  12057. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  12058. {
  12059. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  12060. {
  12061. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  12062. }
  12063. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  12064. {
  12065. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  12066. }
  12067. }
  12068. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  12069. {
  12070. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  12071. {
  12072. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  12073. }
  12074. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  12075. {
  12076. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  12077. }
  12078. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  12079. {
  12080. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  12081. }
  12082. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  12083. {
  12084. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  12085. }
  12086. }
  12087. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  12088. ShmOCPP20Data->SpMsg.bits.NotifyCustomerInformationReq = ON;
  12089. }
  12090. else
  12091. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  12092. json_object_put(CustomerInformation);
  12093. sendCustomerInformationConfirmation(uuid);
  12094. return result;
  12095. }
  12096. void createFirmwareVersionByDataTransfer(void)
  12097. {
  12098. json_object *FirmwareDataTransfer = json_object_new_object();
  12099. // AC & DC model
  12100. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  12101. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  12102. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  12103. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  12104. // DC model
  12105. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  12106. {
  12107. if((gunType[1] != GUN_TYPE_UNKNOWN) ||
  12108. (gunType[2] != GUN_TYPE_UNKNOWN) ||
  12109. (gunType[3] != GUN_TYPE_UNKNOWN))
  12110. {
  12111. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  12112. }
  12113. if((ShmSysConfigAndInfo->SysConfig.ModelName[1]!='B') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='K') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='O'))
  12114. {
  12115. // DS DM DW
  12116. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  12117. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  12118. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  12119. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  12120. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  12121. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  12122. }
  12123. else
  12124. {
  12125. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  12126. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  12127. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  12128. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  12129. json_object_object_add(FirmwareDataTransfer, "DD0_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuBootLoadFwRev));
  12130. json_object_object_add(FirmwareDataTransfer, "DD0_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuKernelFwRev));
  12131. json_object_object_add(FirmwareDataTransfer, "DD0_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuRootFsFwRev));
  12132. json_object_object_add(FirmwareDataTransfer, "DD0_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuPrimFwRev));
  12133. json_object_object_add(FirmwareDataTransfer, "DD0_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].FanModuleFwRev));
  12134. json_object_object_add(FirmwareDataTransfer, "DD0_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].RelayModuleFwRev));
  12135. json_object_object_add(FirmwareDataTransfer, "DD0_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].LedModuleFwRev));
  12136. json_object_object_add(FirmwareDataTransfer, "DD0_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector1FwRev));
  12137. json_object_object_add(FirmwareDataTransfer, "DD0_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector2FwRev));
  12138. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev) > 0)
  12139. json_object_object_add(FirmwareDataTransfer, "DD1_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev));
  12140. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev) > 0)
  12141. json_object_object_add(FirmwareDataTransfer, "DD1_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev));
  12142. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev) > 0)
  12143. json_object_object_add(FirmwareDataTransfer, "DD1_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev));
  12144. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev) > 0)
  12145. json_object_object_add(FirmwareDataTransfer, "DD1_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev));
  12146. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev) > 0)
  12147. json_object_object_add(FirmwareDataTransfer, "DD1_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev));
  12148. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev) > 0)
  12149. json_object_object_add(FirmwareDataTransfer, "DD1_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev));
  12150. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev) > 0)
  12151. json_object_object_add(FirmwareDataTransfer, "DD1_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev));
  12152. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev) > 0)
  12153. json_object_object_add(FirmwareDataTransfer, "DD1_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev));
  12154. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev) > 0)
  12155. json_object_object_add(FirmwareDataTransfer, "D11_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev));
  12156. }
  12157. }
  12158. // 4G model
  12159. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  12160. {
  12161. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  12162. }
  12163. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, json_object_to_json_string_ext(FirmwareDataTransfer, JSON_C_TO_STRING_PLAIN));
  12164. json_object_put(FirmwareDataTransfer);
  12165. }
  12166. int handleDataTransferRequest(char *uuid, char *payload)
  12167. {
  12168. mtrace();
  12169. int result = PASS;
  12170. DEBUG_INFO("handleDataTransferRequest...\n");
  12171. if((uuid != NULL) && (payload != NULL))
  12172. {
  12173. json_object *DataTransfer;
  12174. DataTransfer = json_tokener_parse(payload);
  12175. if(!is_error(DataTransfer))
  12176. {
  12177. // Required data
  12178. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  12179. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  12180. // Optional data
  12181. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  12182. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  12183. if(json_object_object_get(DataTransfer, "data") != NULL)
  12184. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  12185. result = PASS;
  12186. }
  12187. json_object_put(DataTransfer);
  12188. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  12189. {
  12190. // Send all moudle firmware version on EVSE
  12191. createFirmwareVersionByDataTransfer();
  12192. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12193. }
  12194. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_Tmate") != NULL)
  12195. {
  12196. system("/usr/bin/run_tmate_restart.sh &");
  12197. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12198. }
  12199. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_ChargingPreference") != NULL)
  12200. {
  12201. json_object *data;
  12202. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  12203. if(!is_error(data))
  12204. {
  12205. if((json_object_object_get(data, "ConnectorId") != NULL) && (json_object_get_int(json_object_object_get(data, "ConnectorId")) > 0) && (json_object_get_int(json_object_object_get(data, "ConnectorId")) <= gunTotalNumber))
  12206. {
  12207. DEBUG_INFO("ChargeingPreference connector id: %d\n", json_object_get_int(json_object_object_get(data, "ConnectorId")));
  12208. memset(&ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))], 0x00, sizeof(struct StructSessionTarget));
  12209. if(json_object_object_get(data, "SOC") != NULL)
  12210. {
  12211. ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))].targetSoc = json_object_get_int(json_object_object_get(data, "SOC"));
  12212. DEBUG_INFO("ChargeingPreference target soc: %d\n", json_object_get_int(json_object_object_get(data, "SOC")));
  12213. }
  12214. if(json_object_object_get(data, "Energy") != NULL)
  12215. {
  12216. ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))].targetEnergy = json_object_get_int(json_object_object_get(data, "Energy"));
  12217. DEBUG_INFO("ChargeingPreference target energy: %d KWH\n", json_object_get_int(json_object_object_get(data, "Energy")));
  12218. }
  12219. if(json_object_object_get(data, "Duration") != NULL)
  12220. {
  12221. ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))].targetDuration = json_object_get_int(json_object_object_get(data, "Duration"));
  12222. DEBUG_INFO("ChargeingPreference target duration: %d minutes\n", json_object_get_int(json_object_object_get(data, "Duration")));
  12223. }
  12224. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12225. }
  12226. else
  12227. {
  12228. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12229. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Connector id must > 0.");
  12230. }
  12231. }
  12232. else
  12233. {
  12234. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12235. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12236. }
  12237. json_object_put(data);
  12238. }
  12239. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  12240. {
  12241. json_object *data;
  12242. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  12243. if(!is_error(data))
  12244. {
  12245. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  12246. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  12247. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  12248. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  12249. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  12250. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  12251. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  12252. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  12253. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  12254. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  12255. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12256. }
  12257. else
  12258. {
  12259. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12260. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12261. }
  12262. json_object_put(data);
  12263. }
  12264. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_ConfigQR") != NULL)
  12265. {
  12266. json_object *data;
  12267. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  12268. if(!is_error(data))
  12269. {
  12270. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12271. if(json_object_object_get(data, "Content_Type") != NULL)
  12272. {
  12273. if((0 <= json_object_get_int(json_object_object_get(data, "Content_Type"))) && (json_object_get_int(json_object_object_get(data, "Content_Type")) <= 1))
  12274. {
  12275. ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode = json_object_get_int(json_object_object_get(data, "Content_Type"));
  12276. if(json_object_object_get(data, "Customization_Conent") != NULL)
  12277. {
  12278. sprintf((char*)ShmSysConfigAndInfo->SysConfig.QRCodeContent, "%s", json_object_get_string(json_object_object_get(data, "Customization_Conent")));
  12279. }
  12280. }
  12281. else
  12282. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12283. }
  12284. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  12285. }
  12286. else
  12287. {
  12288. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12289. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12290. }
  12291. json_object_put(data);
  12292. }
  12293. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_DisplayLcdPage") != NULL)
  12294. {
  12295. json_object *data;
  12296. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  12297. if(!is_error(data))
  12298. {
  12299. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12300. if(json_object_object_get(data, "ConnectorId") != NULL)
  12301. {
  12302. ShmSysConfigAndInfo->SysInfo.LcdOveride.connectorId = json_object_get_int(json_object_object_get(data, "ConnectorId"));
  12303. }
  12304. if(json_object_object_get(data, "Page_Index") != NULL)
  12305. {
  12306. ShmSysConfigAndInfo->SysInfo.LcdOveride.page_index = json_object_get_int(json_object_object_get(data, "Page_Index"));
  12307. }
  12308. if(json_object_object_get(data, "Duration") != NULL)
  12309. {
  12310. ShmSysConfigAndInfo->SysInfo.LcdOveride.duration = json_object_get_int(json_object_object_get(data, "Duration"));
  12311. }
  12312. ShmSysConfigAndInfo->SysInfo.LcdOveride.isOverideReq = ON;
  12313. }
  12314. else
  12315. {
  12316. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12317. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12318. }
  12319. json_object_put(data);
  12320. }
  12321. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_CpConfiguration") != NULL)
  12322. {
  12323. json_object *data;
  12324. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  12325. if(!is_error(data))
  12326. {
  12327. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12328. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, " ");
  12329. if(json_object_object_get(data, "MaxChargingCurrent") != NULL)
  12330. {
  12331. if(json_object_get_int(json_object_object_get(data, "MaxChargingCurrent")) >= 0)
  12332. ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent = json_object_get_int(json_object_object_get(data, "MaxChargingCurrent"));
  12333. else
  12334. {
  12335. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12336. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12337. }
  12338. }
  12339. if(json_object_object_get(data, "MaxChargingDuration") != NULL)
  12340. {
  12341. if(json_object_get_int(json_object_object_get(data, "MaxChargingDuration")) >= 0)
  12342. ShmSysConfigAndInfo->SysConfig.MaxChargingDuration = json_object_get_int(json_object_object_get(data, "MaxChargingDuration"));
  12343. else
  12344. {
  12345. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12346. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12347. }
  12348. }
  12349. if(json_object_object_get(data, "MaxChargingEnergy") != NULL)
  12350. {
  12351. if(json_object_get_int(json_object_object_get(data, "MaxChargingEnergy")) >= 0)
  12352. ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy = json_object_get_int(json_object_object_get(data, "MaxChargingEnergy"));
  12353. else
  12354. {
  12355. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12356. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12357. }
  12358. }
  12359. if(json_object_object_get(data, "MaxChargingPower") != NULL)
  12360. {
  12361. if(json_object_get_int(json_object_object_get(data, "MaxChargingPower")) >= 0)
  12362. ShmSysConfigAndInfo->SysConfig.MaxChargingPower = json_object_get_int(json_object_object_get(data, "MaxChargingPower"));
  12363. else
  12364. {
  12365. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12366. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12367. }
  12368. }
  12369. if(json_object_object_get(data, "OfflineMaxChargeEnergy") != NULL)
  12370. {
  12371. if(json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy")) >= 0)
  12372. ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy = json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy"));
  12373. else
  12374. {
  12375. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12376. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12377. }
  12378. }
  12379. if(json_object_object_get(data, "OfflinePolicy") != NULL)
  12380. {
  12381. if((json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 0) ||
  12382. (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 2) ||
  12383. (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 3))
  12384. ShmSysConfigAndInfo->SysConfig.OfflinePolicy = json_object_get_int(json_object_object_get(data, "OfflinePolicy"));
  12385. else
  12386. {
  12387. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12388. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12389. }
  12390. }
  12391. if(json_object_object_get(data, "isAuthentication") != NULL)
  12392. {
  12393. switch(json_object_get_int(json_object_object_get(data, "isAuthentication")))
  12394. {
  12395. case 0:
  12396. case 1:
  12397. ShmSysConfigAndInfo->SysConfig.AuthorisationMode = json_object_get_int(json_object_object_get(data, "isAuthentication"))^1;
  12398. break;
  12399. default:
  12400. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12401. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12402. break;
  12403. }
  12404. }
  12405. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]) != NULL)
  12406. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  12407. }
  12408. else
  12409. {
  12410. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12411. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12412. }
  12413. json_object_put(data);
  12414. }
  12415. else
  12416. {
  12417. // Can not find valid message id
  12418. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  12419. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  12420. ,ShmOCPP20Data->DataTransfer[0].vendorId
  12421. ,ShmOCPP20Data->DataTransfer[0].messageId
  12422. ,ShmOCPP20Data->DataTransfer[0].data);
  12423. }
  12424. }
  12425. else
  12426. {
  12427. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  12428. result = FAIL;
  12429. }
  12430. sendDataTransferConfirmation(uuid, 0);
  12431. return result;
  12432. }
  12433. int handleDeleteCertificateRequest(char *uuid, char *payload)
  12434. {
  12435. mtrace();
  12436. int result = FAIL;
  12437. json_object *DeleteCertificate;
  12438. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  12439. DeleteCertificate = json_tokener_parse(payload);
  12440. if(!is_error(DeleteCertificate))
  12441. {
  12442. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  12443. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  12444. // Required data
  12445. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  12446. {
  12447. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  12448. {
  12449. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  12450. }
  12451. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  12452. {
  12453. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  12454. }
  12455. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  12456. {
  12457. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  12458. }
  12459. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  12460. {
  12461. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  12462. }
  12463. /*
  12464. * TODO:
  12465. * 1. Delete certification and response
  12466. */
  12467. if(strstr((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, HashAlgorithmEnumTypeStr[HashAlgorithmEnumType_SHA256]) != NULL)
  12468. {
  12469. }
  12470. else if(strstr((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, HashAlgorithmEnumTypeStr[HashAlgorithmEnumType_SHA384]) != NULL)
  12471. {
  12472. }
  12473. else
  12474. {
  12475. }
  12476. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  12477. }
  12478. }
  12479. else
  12480. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  12481. json_object_put(DeleteCertificate);
  12482. sendDeleteCertificateConfirmation(uuid);
  12483. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  12484. return result;
  12485. }
  12486. int handleGetBaseReportRequest(char *uuid, char *payload)
  12487. {
  12488. mtrace();
  12489. int result = FAIL;
  12490. json_object *GetBaseRepor;
  12491. DEBUG_INFO("handleGetBaseReportRequest...\n");
  12492. GetBaseRepor = json_tokener_parse(payload);
  12493. if(!is_error(GetBaseRepor))
  12494. {
  12495. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  12496. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  12497. // Required data
  12498. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  12499. {
  12500. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  12501. }
  12502. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  12503. {
  12504. sprintf((char*)ShmOCPP20Data->GetBaseReport.reportBase, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  12505. }
  12506. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_SummaryInventory]) == 0)
  12507. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  12508. else
  12509. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  12510. }
  12511. else
  12512. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  12513. json_object_put(GetBaseRepor);
  12514. sendGetBaseReportConfirmation(uuid);
  12515. return result;
  12516. }
  12517. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  12518. {
  12519. mtrace();
  12520. int result = FAIL;
  12521. int gun_index = -1;
  12522. json_object *GetChargingProfiles;
  12523. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  12524. GetChargingProfiles = json_tokener_parse(payload);
  12525. if(!is_error(GetChargingProfiles))
  12526. {
  12527. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  12528. {
  12529. gun_index = json_object_get_int(json_object_object_get(GetChargingProfiles, "evseId"))>0?json_object_get_int(json_object_object_get(GetChargingProfiles, "evseId"))-1:0;
  12530. }
  12531. if(gun_index >-1)
  12532. {
  12533. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  12534. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  12535. // Required data
  12536. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  12537. {
  12538. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  12539. }
  12540. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  12541. {
  12542. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  12543. {
  12544. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  12545. }
  12546. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  12547. {
  12548. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  12549. }
  12550. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  12551. {
  12552. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  12553. {
  12554. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingLimitSource[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"), idx)));
  12555. }
  12556. }
  12557. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  12558. {
  12559. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  12560. {
  12561. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfileId[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"), idx));
  12562. }
  12563. }
  12564. }
  12565. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  12566. }
  12567. else
  12568. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  12569. }
  12570. json_object_put(GetChargingProfiles);
  12571. sendGetChargingProfilesConfirmation(uuid, gun_index);
  12572. return result;
  12573. }
  12574. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  12575. {
  12576. mtrace();
  12577. int result = FAIL;
  12578. int connectorIdInt, durationInt;
  12579. char chargingRateUnitStr[4]={0};
  12580. char comfirmstr[20];
  12581. int confirmPeriods = 0;
  12582. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  12583. json_object *GetCompositeSchedule;
  12584. GetCompositeSchedule = json_tokener_parse(payload);
  12585. if(!is_error(GetCompositeSchedule))
  12586. {
  12587. // Required data
  12588. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  12589. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  12590. else
  12591. connectorIdInt = -1;
  12592. if(json_object_object_get(GetCompositeSchedule, "duration"))
  12593. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  12594. else
  12595. durationInt = 86400;
  12596. // Optional data
  12597. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  12598. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  12599. }
  12600. json_object_put(GetCompositeSchedule);
  12601. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  12602. if((connectorIdInt == 0) ||
  12603. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  12604. {
  12605. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  12606. struct ChargingProfileType tmpProfile[1];
  12607. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  12608. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  12609. if(strstr(chargingRateUnitStr, "W") != NULL || strlen(chargingRateUnitStr) == 0)
  12610. {
  12611. sprintf((char*)ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingRateUnit, "W");
  12612. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0], 0, FALSE);
  12613. }
  12614. else
  12615. {
  12616. sprintf((char*)ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingRateUnit, "A");
  12617. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0], 0, TRUE);
  12618. }
  12619. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  12620. {
  12621. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  12622. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  12623. }
  12624. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  12625. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  12626. {
  12627. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  12628. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  12629. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  12630. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0) &&
  12631. (idx<(ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod)-1)?(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx+1].startPeriod==0):TRUE))
  12632. {
  12633. confirmPeriods = idx;
  12634. break;
  12635. }
  12636. }
  12637. if((confirmPeriods == 0) && (tmpProfile[0].id > 0))
  12638. {
  12639. confirmPeriods += 1;
  12640. }
  12641. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  12642. }
  12643. else
  12644. {
  12645. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  12646. }
  12647. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  12648. return result;
  12649. }
  12650. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  12651. {
  12652. mtrace();
  12653. int result = FAIL;
  12654. json_object *GetDisplayMessages;
  12655. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  12656. GetDisplayMessages = json_tokener_parse(payload);
  12657. if(!is_error(GetDisplayMessages))
  12658. {
  12659. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  12660. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  12661. // Required data
  12662. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  12663. {
  12664. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  12665. }
  12666. // Optional data
  12667. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  12668. {
  12669. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  12670. }
  12671. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  12672. {
  12673. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  12674. }
  12675. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  12676. {
  12677. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  12678. {
  12679. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  12680. }
  12681. strcpy((char*)ShmOCPP20Data->GetDisplayMessages.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  12682. ShmOCPP20Data->MsMsg.bits.GetDisplayMessagesReq = ON;
  12683. }
  12684. else
  12685. strcpy((char*)ShmOCPP20Data->GetDisplayMessages.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  12686. }
  12687. json_object_put(GetDisplayMessages);
  12688. return result;
  12689. }
  12690. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  12691. {
  12692. mtrace();
  12693. int result = FAIL;
  12694. json_object *GetInstalledCertificateIds;
  12695. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  12696. GetInstalledCertificateIds = json_tokener_parse(payload);
  12697. if(!is_error(GetInstalledCertificateIds))
  12698. {
  12699. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  12700. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  12701. // Optional data
  12702. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  12703. {
  12704. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  12705. {
  12706. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  12707. /*
  12708. * TODO:
  12709. * 1. Get installed certificate info for response
  12710. */
  12711. if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_V2GRootCertificate]) != NULL)
  12712. {
  12713. }
  12714. else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_MORootCertificate]) != NULL)
  12715. {
  12716. }
  12717. else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_CSMSRootCertificate]) != NULL)
  12718. {
  12719. }
  12720. else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_V2GCertificateChain]) != NULL)
  12721. {
  12722. }
  12723. else
  12724. {
  12725. }
  12726. }
  12727. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  12728. }
  12729. else
  12730. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  12731. }
  12732. json_object_put(GetInstalledCertificateIds);
  12733. sendInstallCertificateConfirmation(uuid);
  12734. return result;
  12735. }
  12736. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  12737. {
  12738. mtrace();
  12739. int result = FAIL;
  12740. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  12741. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  12742. {
  12743. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  12744. localversion = 0;
  12745. }
  12746. else
  12747. {
  12748. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  12749. localversion = 0;
  12750. DB_getListVerion();
  12751. }
  12752. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  12753. sendGetLocalListVersionConfirmation(uuid);
  12754. return result;
  12755. }
  12756. static char fnamePlusPath[100]={0};
  12757. static char fnamePWithNoPath[60]={0};
  12758. void checkUploadLog(void)
  12759. {
  12760. FILE *fp;
  12761. /* Open the command for reading. */
  12762. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  12763. if (fp == NULL) {
  12764. printf("Failed to run command\n" );
  12765. exit(1);
  12766. }
  12767. int ftppathlen = 0;
  12768. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  12769. int i = 0;
  12770. /* Read the output a line at a time - output it. */
  12771. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  12772. if(i==0)
  12773. {
  12774. ftppathlen = strlen(fnamePlusPath);
  12775. printf("%s\n", fnamePlusPath);
  12776. fnamePlusPath[ftppathlen]='\0';
  12777. break;
  12778. }
  12779. i= i+1;
  12780. }
  12781. /* close */
  12782. pclose(fp);
  12783. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  12784. {
  12785. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  12786. {
  12787. fnamePlusPath[k]='\0';
  12788. }
  12789. }
  12790. i=1;
  12791. //char fname[60]={0};
  12792. while(i < ftppathlen)
  12793. {
  12794. int len=ftppathlen-i;
  12795. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  12796. {
  12797. printf("compare '/' all right\n");
  12798. break;
  12799. }
  12800. i=i+1;
  12801. }
  12802. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  12803. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  12804. fnamePWithNoPath[i+1] = '\0';
  12805. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  12806. {
  12807. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  12808. {
  12809. fnamePWithNoPath[j]='\0';
  12810. }
  12811. }
  12812. FILE* fp1 = fopen(fnamePlusPath, "r");
  12813. if (fp1)
  12814. {
  12815. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  12816. // file exists
  12817. fclose(fp1);
  12818. }
  12819. else
  12820. {
  12821. // file doesn't exist
  12822. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  12823. }
  12824. }
  12825. void* GetLogProcess(void* data)
  12826. {
  12827. pthread_detach(pthread_self());
  12828. mtrace();
  12829. int requestId, retriesInt=0, retryIntervalInt=0;
  12830. char logType[32], remoteLocation[1024]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  12831. char protocol[10]={0}, user[64]={0},password[64]={0},host[128]={0}, path[512]={0}, ftppath[512]={0},host1[128]={0},path1[512]={0};
  12832. int port=0;
  12833. int isSuccess = FALSE;
  12834. char ftpbuf[1024]={0};
  12835. char cmdBuf[2048];
  12836. struct tm *tmNow;
  12837. time_t CurrentTime;
  12838. struct tm tmStart;
  12839. struct tm tmStop;
  12840. CurrentTime = time(NULL);
  12841. tmNow=localtime(&CurrentTime);
  12842. uint16_t targetYear, targetMonth;
  12843. json_object *GetLog;
  12844. DEBUG_INFO("GetGetProcess...\n");
  12845. GetLog = json_tokener_parse(data);
  12846. if(!is_error(GetLog))
  12847. {
  12848. // Required data
  12849. if(json_object_object_get(GetLog, "requestId") != NULL)
  12850. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  12851. if(json_object_object_get(GetLog, "logType") != NULL)
  12852. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  12853. if(json_object_object_get(GetLog, "log") != NULL)
  12854. {
  12855. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  12856. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  12857. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  12858. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  12859. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  12860. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  12861. }
  12862. // Optional data
  12863. if(json_object_object_get(GetLog, "retries") != NULL)
  12864. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  12865. else
  12866. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  12867. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  12868. retryIntervalInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  12869. else
  12870. retryIntervalInt = 30;
  12871. }
  12872. json_object_put(GetLog);
  12873. ShmOCPP20Data->GetLog.requestId = requestId;
  12874. if(strstr(logType, LogEnumTypeStr[LogEnumType_SecurityLog]))
  12875. {
  12876. /*
  12877. * TODO:
  12878. * 1. Pack security log
  12879. */
  12880. }
  12881. else
  12882. {
  12883. // Pack log to compress file
  12884. if((sscanf((char*)oldestTimestamp, "%4d-%2d-%2dT%2d:%2d:%2d", &tmStart.tm_year, &tmStart.tm_mon, &tmStart.tm_mday, &tmStart.tm_hour, &tmStart.tm_min, &tmStart.tm_sec) == 6) &&
  12885. (sscanf((char*)latestTimestamp, "%4d-%2d-%2dT%2d:%2d:%2d", &tmStop.tm_year, &tmStop.tm_mon, &tmStop.tm_mday, &tmStop.tm_hour, &tmStop.tm_min, &tmStop.tm_sec) == 6))
  12886. {
  12887. // Pack system log
  12888. memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
  12889. sprintf(cmdBuf, "exec zip -9 --password %04d%02d%s /mnt/system.zip", tmNow->tm_year+1900, tmNow->tm_mon+1, ShmSysConfigAndInfo->SysConfig.SerialNumber);
  12890. targetYear = tmStart.tm_year;
  12891. targetMonth = tmStart.tm_mon;
  12892. do
  12893. {
  12894. sprintf(cmdBuf, "%s /Storage/SystemLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  12895. sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*SystemLog*", cmdBuf, targetYear, targetMonth);
  12896. if(targetMonth+1>=13)
  12897. {
  12898. targetYear += 1;
  12899. targetMonth = 1;
  12900. }
  12901. else
  12902. {
  12903. targetMonth += 1;
  12904. }
  12905. }while((targetYear < (tmNow->tm_year+1900)) ||
  12906. ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
  12907. sprintf(cmdBuf, "%s /Storage/CCS*.zip", cmdBuf);
  12908. system(cmdBuf);
  12909. // Pack charging & event log
  12910. memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
  12911. sprintf(cmdBuf, "exec zip -9 /mnt/charging_event.zip");
  12912. targetYear = tmStart.tm_year;
  12913. targetMonth = tmStart.tm_mon;
  12914. do
  12915. {
  12916. sprintf(cmdBuf, "%s /Storage/EventLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  12917. sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*OcppMessageLog*", cmdBuf, targetYear, targetMonth);
  12918. if(targetMonth+1>=13)
  12919. {
  12920. targetYear += 1;
  12921. targetMonth = 1;
  12922. }
  12923. else
  12924. {
  12925. targetMonth += 1;
  12926. }
  12927. }while((targetYear < (tmNow->tm_year+1900)) ||
  12928. ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
  12929. sprintf(cmdBuf, "%s /Storage/ChargeLog/*.db", cmdBuf);
  12930. sprintf(cmdBuf, "%s /Storage/EventLog/*.db", cmdBuf);
  12931. system(cmdBuf);
  12932. // Combine log file
  12933. system("exec zip -9 /mnt/log.zip /mnt/system.zip /mnt/charging_event.zip");
  12934. system("exec rm -f /mnt/system.zip /mnt/charging_event.zip");
  12935. }
  12936. else
  12937. {
  12938. system("exec /root/logPackTools 'log' 6");
  12939. }
  12940. }
  12941. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", ShmOCPP20Data->GetLog.Response_filename);
  12942. system(cmdBuf);
  12943. checkUploadLog();
  12944. //****************location*******************/
  12945. if(strcmp(remoteLocation,"")==0)
  12946. {
  12947. DEBUG_INFO("remoteLocation is <Empty>!\n");
  12948. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  12949. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12950. goto end;
  12951. }
  12952. memset(protocol, 0, ARRAY_SIZE(protocol));
  12953. memset(user, 0, ARRAY_SIZE(user) );
  12954. memset(password, 0, ARRAY_SIZE(password));
  12955. memset(host, 0, ARRAY_SIZE(host));
  12956. memset(path, 0, ARRAY_SIZE(path));
  12957. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  12958. memset(host1, 0, ARRAY_SIZE(host1));
  12959. memset(path1, 0, ARRAY_SIZE(path1));
  12960. /*location: ftp://user:password@host:port/path*/
  12961. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  12962. if((access(fnamePlusPath,F_OK))!=-1)
  12963. {
  12964. DEBUG_INFO("fnamePlusPath exist.\n");
  12965. }
  12966. else
  12967. {
  12968. DEBUG_INFO("fnamePlusPath not exist!\n");
  12969. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  12970. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12971. goto end;
  12972. }
  12973. if(strchr(remoteLocation,'@')==NULL)
  12974. {
  12975. sscanf(remoteLocation,
  12976. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  12977. protocol, host, &port, path);
  12978. strcpy(user,"anonymous");
  12979. strcpy(password,"");
  12980. }
  12981. else
  12982. {
  12983. //DEBUG_INFO("pch=%s\n", pch);
  12984. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  12985. protocol, user, password, host, &port, path);
  12986. }
  12987. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0)&&(strcmp(protocol,"https")!=0))
  12988. {
  12989. DEBUG_INFO("protocol is not ftp/http ! \n");
  12990. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  12991. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  12992. goto end;
  12993. }
  12994. if(strncmp(remoteLocation,"http", 4) == 0)
  12995. {
  12996. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  12997. sprintf(ftppath,"/%s", path);
  12998. do
  12999. {
  13000. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  13001. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13002. sleep(3);
  13003. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  13004. if(!isSuccess)
  13005. {
  13006. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  13007. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  13008. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13009. sleep(retryIntervalInt);
  13010. }
  13011. else
  13012. {
  13013. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  13014. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  13015. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13016. }
  13017. retriesInt--;
  13018. }while((isSuccess == 0)&&(retriesInt >= 0));
  13019. }
  13020. else
  13021. {
  13022. sscanf(host,"%[^/]%s",host1, path1);
  13023. if(strlen(path) > 0)
  13024. sprintf(ftppath,"/%s", path);
  13025. else
  13026. sprintf(ftppath,"/%s", path1);
  13027. int ftppathlen=strlen(ftppath);
  13028. int i=1;
  13029. char filenametemp[50];
  13030. while(i < ftppathlen)
  13031. {
  13032. int len=ftppathlen-i;
  13033. if(ftppath[len]== 47) // '/' ascll code: 47
  13034. {
  13035. DEBUG_INFO("find '/' all right\n");
  13036. break;
  13037. }
  13038. i=i+1;
  13039. }
  13040. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  13041. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  13042. filenametemp[i+1] = 0;
  13043. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13044. if(port == 0)
  13045. port = 21;
  13046. do
  13047. {
  13048. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  13049. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13050. sleep(3);
  13051. isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  13052. if(!isSuccess)
  13053. {
  13054. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  13055. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  13056. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13057. sleep(retryIntervalInt);
  13058. }
  13059. else
  13060. {
  13061. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  13062. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  13063. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13064. }
  13065. retriesInt--;
  13066. }while((!isSuccess)&&(retriesInt >= 0));
  13067. }
  13068. end:
  13069. system("rm -f /mnt/*");
  13070. sleep(5);
  13071. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  13072. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13073. interLock.isGetLogGoing = OFF;
  13074. pthread_exit(NULL);
  13075. }
  13076. int handleGetLogRequest(char *uuid, char *payload)
  13077. {
  13078. mtrace();
  13079. int result = FAIL;
  13080. char fName[258];
  13081. time_t CurrentTime;
  13082. struct tm *tm;
  13083. pthread_t th_Status;
  13084. CurrentTime = time(NULL);
  13085. tm = localtime(&CurrentTime);
  13086. sprintf(fName ,"%s-%s-%04d%02d%02d%02d%02d%02d.zip", ShmSysConfigAndInfo->SysConfig.ModelName, ShmSysConfigAndInfo->SysConfig.SerialNumber, (tm->tm_year+1900), (tm->tm_mon+1),tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec);
  13087. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  13088. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  13089. sendGetLogConfirmation(uuid);
  13090. if(!interLock.isGetLogGoing)
  13091. {
  13092. interLock.isGetLogGoing = ON;
  13093. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  13094. sleep(1);
  13095. }
  13096. else
  13097. DEBUG_WARN("Other GetDiagnostic request on going.\n");
  13098. return result;
  13099. }
  13100. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  13101. {
  13102. mtrace();
  13103. int result = FAIL;
  13104. json_object *GetMonitoringReport;
  13105. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  13106. GetMonitoringReport = json_tokener_parse(payload);
  13107. if(!is_error(GetMonitoringReport))
  13108. {
  13109. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  13110. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  13111. // Required data
  13112. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  13113. {
  13114. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  13115. }
  13116. // Optional data
  13117. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  13118. {
  13119. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  13120. }
  13121. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  13122. {
  13123. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  13124. {
  13125. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  13126. {
  13127. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  13128. {
  13129. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  13130. {
  13131. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.componentVariable[idx].component.name, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name")));
  13132. }
  13133. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  13134. {
  13135. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.componentVariable[idx].component.instance, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance")));
  13136. }
  13137. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  13138. {
  13139. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse"), "id") != NULL)
  13140. {
  13141. ShmOCPP20Data->GetMonitoringReport.componentVariable[idx].component.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance"), "id"));
  13142. }
  13143. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse"), "connectorId") != NULL)
  13144. {
  13145. ShmOCPP20Data->GetMonitoringReport.componentVariable[idx].component.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance"), "connectorId"));
  13146. }
  13147. }
  13148. }
  13149. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  13150. {
  13151. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  13152. {
  13153. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.componentVariable[idx].variable.name, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name")));
  13154. }
  13155. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  13156. {
  13157. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.componentVariable[idx].variable.instance, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance")));
  13158. }
  13159. }
  13160. }
  13161. }
  13162. }
  13163. }
  13164. json_object_put(GetMonitoringReport);
  13165. /*
  13166. * TODO:
  13167. * 1. Response result
  13168. */
  13169. strcpy((char*)ShmOCPP20Data->GetMonitoringReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  13170. sendGetMonitoringReportConfirmation(uuid);
  13171. return result;
  13172. }
  13173. int handleGetReportRequest(char *uuid, char *payload)
  13174. {
  13175. mtrace();
  13176. int result = FAIL;
  13177. json_object *GetReport;
  13178. DEBUG_INFO("handleGetReportRequest...\n");
  13179. GetReport = json_tokener_parse(payload);
  13180. if(!is_error(GetReport))
  13181. {
  13182. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  13183. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  13184. // Required data
  13185. if(json_object_object_get(GetReport, "requestId") != NULL)
  13186. {
  13187. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  13188. }
  13189. // Optional data
  13190. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  13191. {
  13192. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  13193. }
  13194. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  13195. {
  13196. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  13197. {
  13198. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  13199. {
  13200. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  13201. {
  13202. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  13203. {
  13204. sprintf((char*)ShmOCPP20Data->GetReport.componentVariable[idx].component.name, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name")));
  13205. }
  13206. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  13207. {
  13208. sprintf((char*)ShmOCPP20Data->GetReport.componentVariable[idx].component.instance, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance")));
  13209. }
  13210. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  13211. {
  13212. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse"), "id") != NULL)
  13213. {
  13214. ShmOCPP20Data->GetReport.componentVariable[idx].component.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse"), "id"));
  13215. }
  13216. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse"), "connectorId") != NULL)
  13217. {
  13218. ShmOCPP20Data->GetReport.componentVariable[idx].component.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse"), "connectorId"));
  13219. }
  13220. }
  13221. }
  13222. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  13223. {
  13224. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  13225. {
  13226. sprintf((char*)ShmOCPP20Data->GetReport.componentVariable[idx].variable.name, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name")));
  13227. }
  13228. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  13229. {
  13230. sprintf((char*)ShmOCPP20Data->GetReport.componentVariable[idx].variable.instance, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance")));
  13231. }
  13232. }
  13233. }
  13234. }
  13235. }
  13236. }
  13237. json_object_put(GetReport);
  13238. /*
  13239. * TODO:
  13240. * 1. Response result
  13241. */
  13242. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  13243. sendGetReportConfirmation(uuid);
  13244. return result;
  13245. }
  13246. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  13247. {
  13248. mtrace();
  13249. int result = FAIL;
  13250. int8_t gun_index = -1;
  13251. json_object *GetTransactionStatus;
  13252. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  13253. GetTransactionStatus = json_tokener_parse(payload);
  13254. if(!is_error(GetTransactionStatus))
  13255. {
  13256. /*
  13257. * TODO:
  13258. * 1. Check transaction locate which connector
  13259. */
  13260. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  13261. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  13262. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  13263. {
  13264. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  13265. }
  13266. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  13267. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  13268. }
  13269. json_object_put(GetTransactionStatus);
  13270. sendGetTransactionStatusConfirmation(uuid, gun_index);
  13271. return result;
  13272. }
  13273. int handleGetVariablesRequest(char *uuid, char *payload)
  13274. {
  13275. mtrace();
  13276. int result = FAIL;
  13277. int isUnknownComponent = TRUE;
  13278. json_object *GetVariables;
  13279. DEBUG_INFO("handleGetVariablesRequest...\n");
  13280. GetVariables = json_tokener_parse(payload);
  13281. if(!is_error(GetVariables))
  13282. {
  13283. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  13284. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  13285. // Required data
  13286. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  13287. {
  13288. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  13289. {
  13290. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  13291. {
  13292. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  13293. {
  13294. sprintf((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType")));
  13295. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  13296. }
  13297. /*if(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType != NULL)
  13298. {
  13299. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, "Actual");
  13300. }*/
  13301. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  13302. {
  13303. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  13304. {
  13305. sprintf((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name")));
  13306. }
  13307. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  13308. {
  13309. sprintf((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance")));
  13310. }
  13311. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  13312. {
  13313. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse"), "id") != NULL)
  13314. {
  13315. ShmOCPP20Data->GetVariables.getVariableData[idx].component.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance"), "id"));
  13316. }
  13317. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse"), "connectorId") != NULL)
  13318. {
  13319. ShmOCPP20Data->GetVariables.getVariableData[idx].component.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance"), "connectorId"));
  13320. }
  13321. }
  13322. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  13323. }
  13324. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  13325. {
  13326. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  13327. {
  13328. sprintf((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name")));
  13329. }
  13330. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  13331. {
  13332. sprintf((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance")));
  13333. }
  13334. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  13335. }
  13336. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  13337. {
  13338. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) == 0) &&
  13339. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance) == 0) &&
  13340. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) == 0) &&
  13341. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance) == 0))
  13342. {
  13343. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  13344. isUnknownComponent = FALSE;
  13345. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type) != 0) &&
  13346. (json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL))
  13347. {
  13348. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_NotSupportedAttributeType]);
  13349. break;
  13350. }
  13351. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, "ChargingStation") == 0) &&
  13352. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, "SystemUptimeSec") == 0))
  13353. {
  13354. struct sysinfo s_info;
  13355. int error = sysinfo(&s_info);
  13356. if(error != 0)
  13357. {
  13358. DEBUG_WARN("System uptime get error: %d\n", error);
  13359. }
  13360. else
  13361. {
  13362. sprintf((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, "%ld", s_info.uptime);
  13363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, "%ld", s_info.uptime);
  13364. }
  13365. }
  13366. else if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, "ChargingStation") == 0) &&
  13367. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, "FreeVend") == 0))
  13368. {
  13369. sprintf((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, "%s", (ShmSysConfigAndInfo->SysConfig.AuthorisationMode?"TRUE":"FALSE"));
  13370. }
  13371. else
  13372. {
  13373. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  13374. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type);
  13375. }
  13376. break;
  13377. }
  13378. else
  13379. {
  13380. if(strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) != 0)
  13381. {
  13382. isUnknownComponent = FALSE;
  13383. }
  13384. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownVariable]);
  13385. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  13386. }
  13387. }
  13388. if(isUnknownComponent == TRUE)
  13389. {
  13390. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  13391. }
  13392. }
  13393. }
  13394. }
  13395. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  13396. }
  13397. json_object_put(GetVariables);
  13398. return result;
  13399. }
  13400. int handleInstallCertificateRequest(char *uuid, char *payload)
  13401. {
  13402. mtrace();
  13403. int result = FAIL;
  13404. json_object *InstallCertificate;
  13405. DEBUG_INFO("handleInstallCertificateRequest...\n");
  13406. InstallCertificate = json_tokener_parse(payload);
  13407. if(!is_error(InstallCertificate))
  13408. {
  13409. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  13410. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  13411. // Required data
  13412. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  13413. {
  13414. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  13415. }
  13416. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  13417. {
  13418. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  13419. }
  13420. }
  13421. json_object_put(InstallCertificate);
  13422. /*
  13423. * TODO:
  13424. * 1. Install certification preocess and response
  13425. */
  13426. if(strstr((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_V2GRootCertificate]))
  13427. {
  13428. }
  13429. else if(strstr((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_MORootCertificate]))
  13430. {
  13431. }
  13432. else if(strstr((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_CSMSRootCertificate]))
  13433. {
  13434. }
  13435. else
  13436. {
  13437. }
  13438. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  13439. sendInstallCertificateConfirmation(uuid);
  13440. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  13441. return result;
  13442. }
  13443. int handlePublishFirmwareRequest(char *uuid, char *payload)
  13444. {
  13445. mtrace();
  13446. int result = FAIL;
  13447. json_object *PublishFirmware;
  13448. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  13449. PublishFirmware = json_tokener_parse(payload);
  13450. if(!is_error(PublishFirmware))
  13451. {
  13452. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  13453. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  13454. // Required data
  13455. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  13456. {
  13457. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  13458. }
  13459. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  13460. {
  13461. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  13462. }
  13463. // Optional data
  13464. if(json_object_object_get(PublishFirmware, "location") != NULL)
  13465. {
  13466. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  13467. }
  13468. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  13469. {
  13470. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  13471. }
  13472. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  13473. {
  13474. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  13475. }
  13476. }
  13477. json_object_put(PublishFirmware);
  13478. /*
  13479. * TODO:
  13480. * 1. Publish firmware preocess and response
  13481. */
  13482. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  13483. sendPublishFirmwareConfirmation(uuid);
  13484. return result;
  13485. }
  13486. int handleRequestStartTransactionRequest(char *uuid, char *payload)
  13487. {
  13488. mtrace();
  13489. int result = FAIL;
  13490. int8_t connectorIdx = -1;
  13491. uint8_t tempIndex;
  13492. uint8_t isOverConnectorMax = FALSE;
  13493. uint8_t isPeriodOverMax = FALSE;
  13494. uint8_t isTxProfile = TRUE;
  13495. uint8_t isAllowStart = TRUE;
  13496. uint8_t filename[128]={0};
  13497. char cmdBuf[128];
  13498. FILE *filePtr;
  13499. json_object *RemoteStartTransaction;
  13500. DEBUG_INFO("handleRequestStartTransactionRequest...\n");
  13501. RemoteStartTransaction = json_tokener_parse(payload);
  13502. if(!is_error(RemoteStartTransaction))
  13503. {
  13504. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  13505. {
  13506. if((0 < json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))) && (json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))<=gunTotalNumber))
  13507. {
  13508. connectorIdx = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
  13509. }
  13510. else
  13511. {
  13512. isOverConnectorMax = TRUE;
  13513. DEBUG_WARN("Connector id shall not equal 0 and less than max connector id.\n");
  13514. }
  13515. }
  13516. else
  13517. {
  13518. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  13519. {
  13520. if(!cpinitateMsg.bits[idx].isOnCharging && (strstr((char*)ShmOCPP20Data->StatusNotification[idx].connectorStatus, ConnectorStatusEnumTypeStr[ConnectorStatusEnumType_Occupied]) != NULL))
  13521. {
  13522. connectorIdx = (idx+1);
  13523. DEBUG_INFO("Remote start without connectorId but detect connector-%02d connected ready to start.\n", connectorIdx);
  13524. break;
  13525. }
  13526. }
  13527. }
  13528. if(isOverConnectorMax == FALSE)
  13529. {
  13530. if(connectorIdx > 0)
  13531. {
  13532. DEBUG_INFO("Connector id: %d\n", connectorIdx);
  13533. memset(&ShmOCPP20Data->RequestStartTransaction[connectorIdx-1], 0, sizeof(struct RequestStartTransaction_20));
  13534. memcpy(&ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].guid));
  13535. // Required data
  13536. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  13537. {
  13538. ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  13539. }
  13540. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  13541. {
  13542. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  13543. {
  13544. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  13545. }
  13546. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  13547. {
  13548. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  13549. }
  13550. }
  13551. // Optional data
  13552. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  13553. {
  13554. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  13555. {
  13556. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  13557. }
  13558. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  13559. {
  13560. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  13561. }
  13562. }
  13563. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  13564. {
  13565. // Check periods is over max configuration
  13566. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value))
  13567. {
  13568. isPeriodOverMax = TRUE;
  13569. }
  13570. // Check profile purpose is TxProfile
  13571. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  13572. {
  13573. ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].chargingProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "id"));
  13574. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdx);
  13575. }
  13576. else
  13577. {
  13578. isTxProfile = FALSE;
  13579. }
  13580. }
  13581. //check Transaction active
  13582. if(gunType[connectorIdx-1] == GUN_TYPE_CHAdeMO)
  13583. {
  13584. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13585. {
  13586. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  13587. }
  13588. else
  13589. {
  13590. tempIndex = (connectorIdx-1);
  13591. }
  13592. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13593. {
  13594. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex )
  13595. {
  13596. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  13597. {
  13598. //Reserved
  13599. DEBUG_INFO("CHAdeMO connector already reserved and idTag match.\n");
  13600. }
  13601. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) != 0))
  13602. {
  13603. //Reserved
  13604. DEBUG_INFO("CHAdeMO connector already reserved and idTag does not match.\n");
  13605. isAllowStart = FALSE;
  13606. }
  13607. else
  13608. {
  13609. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13610. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) //S_PRECHARGE
  13611. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) //S_PREPARING_FOR_EV
  13612. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE )) // S_PREPARING_FOR_EVSE
  13613. {
  13614. DEBUG_WARN("CHAdeMO connector not allow start cause busy.\n.");
  13615. isAllowStart = FALSE;
  13616. }
  13617. }//END FOR ELSE
  13618. }
  13619. }// END FOR CHAdeMO_QUANTITY
  13620. }
  13621. else if(gunType[connectorIdx-1] == GUN_TYPE_CCS)
  13622. {
  13623. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13624. {
  13625. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  13626. }
  13627. else
  13628. {
  13629. tempIndex = (connectorIdx-1);
  13630. }
  13631. for (int index = 0; index < CCS_QUANTITY; index++)
  13632. {
  13633. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  13634. {
  13635. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  13636. {
  13637. //Reserved
  13638. DEBUG_INFO("CCS connector already reserved and idTag match.\n");
  13639. }
  13640. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) != 0))
  13641. {
  13642. //Reserved
  13643. DEBUG_INFO("CCS connector already reserved and idTag does not match.\n");
  13644. isAllowStart = FALSE;
  13645. }
  13646. else
  13647. {
  13648. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13649. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  13650. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  13651. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  13652. {
  13653. DEBUG_WARN("CCS connector not allow start cause busy.\n.");
  13654. isAllowStart = FALSE;
  13655. }
  13656. }// END FOR ELSE
  13657. }
  13658. }// END FOR CCS_QUANTITY
  13659. }
  13660. else if(gunType[connectorIdx-1] == GUN_TYPE_GBT)
  13661. {
  13662. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13663. {
  13664. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  13665. }
  13666. else
  13667. {
  13668. tempIndex = (connectorIdx-1);
  13669. }
  13670. for (int index = 0; index < GB_QUANTITY; index++)
  13671. {
  13672. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex )
  13673. {
  13674. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  13675. {
  13676. //Reserved
  13677. DEBUG_INFO("GBT connector already reserved and idTag match.\n");
  13678. }
  13679. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) != 0))
  13680. {
  13681. //Reserved
  13682. DEBUG_INFO("GBT connector already reserved and idTag does not match.\n");
  13683. isAllowStart = FALSE;
  13684. }
  13685. else
  13686. {
  13687. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13688. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  13689. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  13690. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  13691. {
  13692. DEBUG_WARN("GBT connector not allow start cause busy.\n");
  13693. isAllowStart = FALSE;
  13694. }
  13695. }// END FOR ELSE
  13696. }
  13697. } // END FOR GB_QUANTITY
  13698. }
  13699. else if(gunType[connectorIdx-1] == GUN_TYPE_DO)
  13700. {
  13701. tempIndex = (connectorIdx-1);
  13702. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13703. {
  13704. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex )
  13705. {
  13706. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  13707. {
  13708. //Reserved
  13709. DEBUG_INFO("Dispenser connector already reserved and idTag match.\n");
  13710. }
  13711. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) != 0))
  13712. {
  13713. //Reserved
  13714. DEBUG_INFO("Dispenser connector already reserved and idTag does not match.\n");
  13715. isAllowStart = FALSE;
  13716. }
  13717. else
  13718. {
  13719. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13720. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  13721. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  13722. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  13723. {
  13724. DEBUG_WARN("Dispenser connector not allow start cause busy.\n");
  13725. isAllowStart = FALSE;
  13726. }
  13727. }// END FOR ELSE
  13728. }
  13729. } // END FOR GB_QUANTITY
  13730. }
  13731. else
  13732. {
  13733. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13734. {
  13735. tempIndex = 2;
  13736. }
  13737. else
  13738. {
  13739. tempIndex = (connectorIdx-1);
  13740. }
  13741. for (int index = 0; index < AC_QUANTITY; index++)
  13742. {
  13743. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex )
  13744. {
  13745. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) == 0))
  13746. {
  13747. //Reserved
  13748. DEBUG_INFO("AC connector already reserved and idTag match.\n");
  13749. }
  13750. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId != -1)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId >= 0)&&(strcmp((const char *)ShmOCPP20Data->ReserveNow[index].idToken.idToken, (char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken) != 0))
  13751. {
  13752. //Reserved
  13753. DEBUG_INFO("AC connector already reserved and idTag does not match.\n");
  13754. isAllowStart = FALSE;
  13755. }
  13756. else
  13757. {
  13758. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13759. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  13760. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  13761. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  13762. {
  13763. DEBUG_WARN("AC connector not allow start cause busy.\n");
  13764. isAllowStart = FALSE;
  13765. }
  13766. }//END FOR ELSE
  13767. }
  13768. }// END FOR AC_QUANTITY
  13769. }
  13770. }
  13771. else
  13772. {
  13773. DEBUG_INFO("Connector id does not specific.\n");
  13774. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  13775. {
  13776. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  13777. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  13778. // Required data
  13779. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  13780. {
  13781. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  13782. }
  13783. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  13784. {
  13785. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  13786. {
  13787. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  13788. }
  13789. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  13790. {
  13791. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  13792. }
  13793. }
  13794. // Optional data
  13795. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  13796. {
  13797. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  13798. {
  13799. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  13800. }
  13801. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  13802. {
  13803. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  13804. }
  13805. }
  13806. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  13807. {
  13808. // Check periods is over max configuration
  13809. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value))
  13810. {
  13811. isPeriodOverMax = TRUE;
  13812. }
  13813. // Check profile purpose is TxProfile
  13814. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  13815. {
  13816. ShmOCPP20Data->RequestStartTransaction[gun_index].chargingProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "id"));
  13817. sprintf((char*)filename, "/Storage/OCPP/TxProfile_Tmp_OCPP20.json");
  13818. }
  13819. else
  13820. {
  13821. isTxProfile = FALSE;
  13822. }
  13823. }
  13824. }
  13825. }
  13826. }
  13827. // Profile replace or add info
  13828. if((isOverConnectorMax == FALSE) && !isPeriodOverMax && isTxProfile && isAllowStart)
  13829. {
  13830. if(connectorIdx != -1)
  13831. {
  13832. if(strlen((char*)filename) > 0)
  13833. {
  13834. // Save profile to file
  13835. sprintf(cmdBuf, "rm -f /Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdx);
  13836. system(cmdBuf);
  13837. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json.json", connectorIdx);
  13838. filePtr = fopen((char*)filename, "w");
  13839. fprintf(filePtr, "{\"evseId\":%d,\"chargingProfile\":%s}\n", connectorIdx, json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
  13840. fclose(filePtr);
  13841. }
  13842. ShmOCPP20Data->CsMsg.bits[connectorIdx-1].RequestStartTransactionReq = ON;
  13843. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  13844. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].Response_transactionId);
  13845. result = PASS;
  13846. }
  13847. else
  13848. {
  13849. uint8_t isHasIdleConnector = FALSE;
  13850. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  13851. {
  13852. if(!cpinitateMsg.bits[gun_index].isOnCharging)
  13853. {
  13854. isHasIdleConnector = TRUE;
  13855. break;
  13856. }
  13857. }
  13858. if(isHasIdleConnector == TRUE)
  13859. {
  13860. DEBUG_INFO("Start wait connector link to EV in %s seconds.\n", ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value);
  13861. if(strlen((char*)filename) > 0)
  13862. {
  13863. // Save profile to file
  13864. sprintf(cmdBuf, "rm -f /Storage/OCPP/TxProfile_Tmp_OCPP20.json");
  13865. system(cmdBuf);
  13866. sprintf((char*)filename, "/Storage/OCPP/TxProfile_Tmp_OCPP20.json.json");
  13867. filePtr = fopen((char*)filename, "w");
  13868. fprintf(filePtr, "{\"evseId\":0,\"chargingProfile\":%s}\n", json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
  13869. fclose(filePtr);
  13870. }
  13871. refreshStartTimer(&clientTime.RemoteStartWait);
  13872. ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq = ON;
  13873. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  13874. {
  13875. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  13876. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId);
  13877. }
  13878. result = PASS;
  13879. }
  13880. else
  13881. {
  13882. DEBUG_INFO("There is not any connector is idle.\n");
  13883. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  13884. strcpy((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  13885. }
  13886. }
  13887. }
  13888. else
  13889. {
  13890. if(isOverConnectorMax != FALSE)
  13891. DEBUG_WARN("evseId id equal 0 or over maximun id.\n");
  13892. if(isPeriodOverMax)
  13893. DEBUG_WARN("Profile periods quantity is over spec.\n");
  13894. if(!isTxProfile)
  13895. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  13896. if(!isAllowStart)
  13897. DEBUG_WARN("Target connector does not allow start.\n");
  13898. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[((connectorIdx-1)<0?0:(connectorIdx-1))].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  13899. }
  13900. }
  13901. json_object_put(RemoteStartTransaction);
  13902. sendRemoteStartTransactionConfirmation(uuid, ((connectorIdx-1)<0?0:(connectorIdx-1)));
  13903. return result;
  13904. }
  13905. int handleRequestStopTransactionRequest(char *uuid, char *payload)
  13906. {
  13907. mtrace();
  13908. int result = FAIL;
  13909. int match = FALSE;
  13910. int GunNO = 0;
  13911. int tempIndex = 0;
  13912. char transactionIdStr[37];
  13913. int transactionIdIsNULL= TRUE;
  13914. json_object *RemoteStopTransaction;
  13915. DEBUG_INFO("handleRequestStopTransactionRequest...\n");
  13916. if(server_pending == TRUE)
  13917. {
  13918. return 0;
  13919. }
  13920. RemoteStopTransaction = json_tokener_parse(payload);
  13921. if(!is_error(RemoteStopTransaction))
  13922. {
  13923. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  13924. {
  13925. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  13926. transactionIdIsNULL = FALSE;
  13927. }
  13928. }
  13929. json_object_put(RemoteStopTransaction);
  13930. if(transactionIdIsNULL == FALSE)
  13931. {
  13932. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  13933. {
  13934. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  13935. {
  13936. //check Transaction active
  13937. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  13938. {
  13939. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13940. {
  13941. tempIndex = ((gun_index==2) ? 1: 0);
  13942. }
  13943. else
  13944. {
  13945. tempIndex = gun_index;
  13946. }
  13947. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13948. {
  13949. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  13950. {
  13951. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  13952. {
  13953. match = TRUE;
  13954. GunNO = gun_index;
  13955. }
  13956. }
  13957. }// END FOR CHAdeMO_QUANTITY
  13958. }
  13959. else if(gunType[gun_index] == GUN_TYPE_CCS)
  13960. {
  13961. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13962. {
  13963. tempIndex = ((gun_index==2) ? 1: 0);
  13964. }
  13965. else
  13966. {
  13967. tempIndex = gun_index;
  13968. }
  13969. for (int index = 0; index < CCS_QUANTITY; index++)
  13970. {
  13971. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  13972. {
  13973. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  13974. {
  13975. match = TRUE;
  13976. GunNO = gun_index;
  13977. }
  13978. }
  13979. }// END FOR CCS_QUANTITY
  13980. }
  13981. else if(gunType[gun_index] == GUN_TYPE_GBT)
  13982. {
  13983. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13984. {
  13985. tempIndex = ((gun_index==2) ? 1: 0);
  13986. }
  13987. else
  13988. {
  13989. tempIndex = gun_index;
  13990. }
  13991. for (int index = 0; index < GB_QUANTITY; index++)
  13992. {
  13993. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  13994. {
  13995. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  13996. {
  13997. match = TRUE;
  13998. GunNO = gun_index;
  13999. }
  14000. }
  14001. }// END FOR GB_QUANTITY
  14002. }
  14003. else if(gunType[gun_index] == GUN_TYPE_DO)
  14004. {
  14005. tempIndex = gun_index;
  14006. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  14007. {
  14008. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  14009. {
  14010. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  14011. {
  14012. match = TRUE;
  14013. GunNO = gun_index;
  14014. }
  14015. }
  14016. }// END FOR GB_QUANTITY
  14017. }
  14018. else
  14019. {
  14020. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  14021. {
  14022. tempIndex = 2;
  14023. }
  14024. else
  14025. {
  14026. tempIndex = gun_index;
  14027. }
  14028. for (int index = 0; index < AC_QUANTITY; index++)
  14029. {
  14030. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  14031. {
  14032. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  14033. {
  14034. match = TRUE;
  14035. GunNO = gun_index;
  14036. }
  14037. }
  14038. }// END FOR CHAdeMO_QUANTITY
  14039. } // END FOR AC ELSE
  14040. }// CHECK IF ResponseTransactionId == transactionIdInt
  14041. }//END FOR
  14042. if( match == TRUE)
  14043. {
  14044. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  14045. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  14046. }
  14047. else
  14048. {
  14049. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  14050. }
  14051. }
  14052. else
  14053. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  14054. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  14055. return result;
  14056. }
  14057. int handleReserveNowRequest(char *uuid, char *payload)
  14058. {
  14059. mtrace();
  14060. int result = FAIL;
  14061. int connectorIdInt=0, reservationIdInt=0;
  14062. int tempIndex = 0;
  14063. json_object *ReserveNow;
  14064. DEBUG_INFO("handleReserveNowRequest ...\n");
  14065. ReserveNow = json_tokener_parse(payload);
  14066. if(!is_error(ReserveNow))
  14067. {
  14068. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  14069. {
  14070. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  14071. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  14072. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  14073. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  14074. }
  14075. // Required data
  14076. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  14077. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  14078. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  14079. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  14080. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  14081. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  14082. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  14083. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  14084. // Optional data
  14085. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  14086. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  14087. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  14088. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  14089. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  14090. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  14091. result = PASS;
  14092. }
  14093. json_object_put(ReserveNow);
  14094. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14095. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  14096. {
  14097. //check Transaction active
  14098. if(gunType[connectorIdInt -1] == GUN_TYPE_CHAdeMO)
  14099. {
  14100. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14101. {
  14102. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  14103. }
  14104. else
  14105. {
  14106. tempIndex = connectorIdInt -1;
  14107. }
  14108. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  14109. {
  14110. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  14111. {
  14112. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  14113. {
  14114. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  14115. {
  14116. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  14117. {
  14118. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == 1) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].InProgress == 1))
  14119. {
  14120. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14121. }
  14122. else
  14123. {
  14124. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14125. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14126. }
  14127. }
  14128. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)||(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == 11) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == '9'))
  14129. {
  14130. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14131. }
  14132. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  14133. {
  14134. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14135. }
  14136. else
  14137. {
  14138. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14139. }
  14140. }
  14141. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_FAULT, SYS_MODE_ALARM, SYS_MODE_TERMINATING ---> SuspendedEV
  14142. {
  14143. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14144. }
  14145. }
  14146. else
  14147. {
  14148. //replace reservation
  14149. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14150. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14151. }
  14152. }
  14153. } // END FOR CHAdeMO_QUANTITY
  14154. }
  14155. else if(gunType[connectorIdInt -1] == GUN_TYPE_CCS)
  14156. {
  14157. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14158. {
  14159. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  14160. }
  14161. else
  14162. {
  14163. tempIndex = connectorIdInt -1;
  14164. }
  14165. for (int index = 0; index < CCS_QUANTITY; index++)
  14166. {
  14167. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  14168. {
  14169. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  14170. {
  14171. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  14172. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  14173. {
  14174. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  14175. {
  14176. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == 1) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].InProgress == 1))
  14177. {
  14178. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14179. }
  14180. else
  14181. {
  14182. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14183. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14184. }
  14185. }
  14186. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) ||(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == '9'))
  14187. {
  14188. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14189. }
  14190. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  14191. {
  14192. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14193. }
  14194. else
  14195. {
  14196. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14197. }
  14198. }
  14199. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus ==SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus ==SYS_MODE_ALARM) ||(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) //SYS_MODE_FAUL, SYS_MODE_TERMINATING ---> SuspendedEV
  14200. {
  14201. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14202. }
  14203. }
  14204. else
  14205. {
  14206. //replace reservation
  14207. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14208. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14209. }
  14210. }
  14211. } // END FOR CCS_QUANTITY
  14212. }
  14213. else if(gunType[connectorIdInt -1] == GUN_TYPE_GBT)
  14214. {
  14215. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14216. {
  14217. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  14218. }
  14219. else
  14220. {
  14221. tempIndex = connectorIdInt -1;
  14222. }
  14223. for (int index = 0; index < GB_QUANTITY; index++)
  14224. {
  14225. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  14226. {
  14227. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  14228. {
  14229. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  14230. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  14231. {
  14232. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  14233. {
  14234. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == 1) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].InProgress == 1))
  14235. {
  14236. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14237. }
  14238. else
  14239. {
  14240. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14241. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14242. }
  14243. }
  14244. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '9'))
  14245. {
  14246. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14247. }
  14248. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  14249. {
  14250. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14251. }
  14252. else
  14253. {
  14254. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14255. }
  14256. }
  14257. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus ==SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus ==SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus ==SYS_MODE_TERMINATING)) //SYS_MODE_FAULT, SYS_MODE_ALARM ,SYS_MODE_TERMINATING ---> SuspendedEV
  14258. {
  14259. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14260. }
  14261. }
  14262. else
  14263. {
  14264. //replace reservation
  14265. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14266. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14267. }
  14268. }
  14269. }// END FOR GB_QUANTITY
  14270. }
  14271. else if(gunType[connectorIdInt -1] == GUN_TYPE_DO)
  14272. {
  14273. tempIndex = connectorIdInt -1;
  14274. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  14275. {
  14276. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  14277. {
  14278. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId)
  14279. {
  14280. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  14281. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  14282. {
  14283. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  14284. {
  14285. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == 1) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.InProgress == 1))
  14286. {
  14287. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14288. }
  14289. else
  14290. {
  14291. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14292. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14293. }
  14294. }
  14295. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '9'))
  14296. {
  14297. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14298. }
  14299. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  14300. {
  14301. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14302. }
  14303. else
  14304. {
  14305. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14306. }
  14307. }
  14308. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus ==SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus ==SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus ==SYS_MODE_TERMINATING)) //SYS_MODE_FAULT, SYS_MODE_ALARM ,SYS_MODE_TERMINATING ---> SuspendedEV
  14309. {
  14310. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14311. }
  14312. }
  14313. else
  14314. {
  14315. //replace reservation
  14316. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14317. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14318. }
  14319. }
  14320. }// END FOR DO_QUANTITY
  14321. }
  14322. else
  14323. {
  14324. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  14325. {
  14326. tempIndex = 2;
  14327. }
  14328. else
  14329. {
  14330. tempIndex = (connectorIdInt -1);
  14331. }
  14332. for (int index = 0; index < AC_QUANTITY; index++)
  14333. {
  14334. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  14335. {
  14336. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  14337. {
  14338. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  14339. {
  14340. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  14341. {
  14342. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_B) ||(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_C) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_D))
  14343. {
  14344. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14345. }
  14346. else
  14347. {
  14348. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14349. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14350. }
  14351. }
  14352. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) ||(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == 11) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == '9'))
  14353. {
  14354. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14355. }
  14356. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  14357. {
  14358. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14359. }
  14360. else
  14361. {
  14362. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14363. }
  14364. }
  14365. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) ||(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) //SYS_MODE_FAULT, SYS_MODE_ALARM, SYS_MODE_TERMINATING ---> SuspendedEV
  14366. {
  14367. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14368. }
  14369. }
  14370. else
  14371. {
  14372. //replace reservation
  14373. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14374. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14375. }
  14376. }
  14377. } // END FOR AC_QUANTITY
  14378. }
  14379. }
  14380. else if(connectorIdInt == 0)
  14381. {
  14382. //check Transaction active
  14383. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  14384. {
  14385. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  14386. {
  14387. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == 11) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == '9'))
  14388. {
  14389. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14390. goto end;
  14391. }
  14392. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  14393. {
  14394. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14395. goto end;
  14396. }
  14397. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) //SYS_MODE_FAULT, SYS_MODE_TERMINATING ---> SuspendedEV
  14398. {
  14399. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14400. goto end;
  14401. }
  14402. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  14403. {
  14404. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14405. goto end;
  14406. }
  14407. }
  14408. }// END FOR CHAdeMO_QUANTITY
  14409. for (int index = 0; index < CCS_QUANTITY; index++)
  14410. {
  14411. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  14412. {
  14413. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)||(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == '9'))
  14414. {
  14415. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14416. goto end;
  14417. }
  14418. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  14419. {
  14420. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14421. goto end;
  14422. }
  14423. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus ==SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus ==SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus ==SYS_MODE_TERMINATING)) //SYS_MODE_FAULT, SYS_MODE_TERMINATING ---> SuspendedEV
  14424. {
  14425. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14426. goto end;
  14427. }
  14428. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  14429. {
  14430. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14431. goto end;
  14432. }
  14433. }
  14434. } // END FOR CCS_QUANTITY
  14435. for (int index = 0; index < GB_QUANTITY; index++)
  14436. {
  14437. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  14438. {
  14439. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '6') || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == '9'))
  14440. {
  14441. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14442. goto end;
  14443. }
  14444. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  14445. {
  14446. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14447. goto end;
  14448. }
  14449. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus ==SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus ==SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus ==SYS_MODE_TERMINATING) ) //SYS_MODE_FAULT, SYS_MODE_TERMINATING ---> SuspendedEV
  14450. {
  14451. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14452. goto end;
  14453. }
  14454. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  14455. {
  14456. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14457. goto end;
  14458. }
  14459. }
  14460. } // END FOR GB_QUANTITY
  14461. for (int index = 0; index < AC_QUANTITY; index++)
  14462. {
  14463. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  14464. {
  14465. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_UPDATE)) //S_TERMINATING //else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == 11) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == '9'))
  14466. {
  14467. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14468. goto end;
  14469. }
  14470. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  14471. {
  14472. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14473. goto end;
  14474. }
  14475. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) //SYS_MODE_FAULT, SYS_MODE_TERMINATING ---> SuspendedEV
  14476. {
  14477. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14478. goto end;
  14479. }
  14480. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  14481. {
  14482. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_B) ||(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_C) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_D))
  14483. {
  14484. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14485. goto end;
  14486. }
  14487. }
  14488. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  14489. {
  14490. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14491. goto end;
  14492. }
  14493. }
  14494. }// END FOR AC_QUANTITY
  14495. //The connectorId is 0
  14496. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  14497. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14498. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  14499. result = TRUE;
  14500. return result;
  14501. }
  14502. else
  14503. {
  14504. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14505. }
  14506. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  14507. {
  14508. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  14509. result = TRUE;
  14510. return result;
  14511. }
  14512. end:
  14513. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  14514. return result;
  14515. }
  14516. int handleResetRequest(char *uuid, char *payload)
  14517. {
  14518. mtrace();
  14519. int result = FAIL;
  14520. json_object *Reset = json_object_new_object();
  14521. DEBUG_INFO("handleResetRequest...\n");
  14522. Reset = json_tokener_parse(payload);
  14523. if(!is_error(Reset))
  14524. {
  14525. // Required data
  14526. if(json_object_object_get(Reset, "type") != NULL)
  14527. {
  14528. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  14529. }
  14530. if(json_object_object_get(Reset, "evseId") != NULL)
  14531. {
  14532. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  14533. }
  14534. }
  14535. json_object_put(Reset);
  14536. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  14537. {
  14538. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  14539. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]);
  14540. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  14541. result = PASS;
  14542. }
  14543. else
  14544. {
  14545. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  14546. }
  14547. if(strlen((char*)ShmOCPP20Data->Reset.Response_status) > 0)
  14548. sendResetConfirmation(uuid);
  14549. return result;
  14550. }
  14551. int handleSendLocalListRequest(char *uuid, char *payload)
  14552. {
  14553. mtrace();
  14554. int result = FAIL;
  14555. int checkState_Faulted = FALSE;
  14556. json_object *SendLocalList;
  14557. DEBUG_INFO("handleSendLocalListRequest...\n");
  14558. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  14559. {
  14560. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  14561. goto end;
  14562. }
  14563. SendLocalList = json_tokener_parse(payload);
  14564. if(!is_error(SendLocalList))
  14565. {
  14566. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  14567. // Required data
  14568. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  14569. {
  14570. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  14571. }
  14572. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  14573. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  14574. // Optional data
  14575. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  14576. {
  14577. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  14578. {
  14579. // Required data
  14580. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  14581. {
  14582. sprintf((char*)ShmOCPP20Data->SendLocalList.localAuthorizationList[idx].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken"), "idToken")));
  14583. sprintf((char*)ShmOCPP20Data->SendLocalList.localAuthorizationList[idx].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken"), "type")));
  14584. }
  14585. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  14586. {
  14587. sprintf((char*)ShmOCPP20Data->SendLocalList.localAuthorizationList[idx].idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "status")));
  14588. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  14589. sprintf((char*)ShmOCPP20Data->SendLocalList.localAuthorizationList[idx].idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime")));
  14590. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  14591. ShmOCPP20Data->SendLocalList.localAuthorizationList[idx].idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority"));
  14592. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  14593. {
  14594. sprintf((char*)ShmOCPP20Data->SendLocalList.localAuthorizationList[idx].idTokenInfo.groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken"), "idToken")));
  14595. sprintf((char*)ShmOCPP20Data->SendLocalList.localAuthorizationList[idx].idTokenInfo.groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken"), "type")));
  14596. }
  14597. }
  14598. }
  14599. }
  14600. }
  14601. json_object_put(SendLocalList);
  14602. //check Charge Point state
  14603. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  14604. {
  14605. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  14606. {
  14607. checkState_Faulted = TRUE; //OCPP Status: Faulted
  14608. }
  14609. }
  14610. for (int index = 0; index < CCS_QUANTITY; index++)
  14611. {
  14612. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  14613. {
  14614. checkState_Faulted = TRUE; //OCPP Status
  14615. }
  14616. }
  14617. for (int index = 0; index < GB_QUANTITY; index++)
  14618. {
  14619. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  14620. {
  14621. checkState_Faulted = TRUE; //OCPP Status: Faulted
  14622. }
  14623. }
  14624. for (int index = 0; index < AC_QUANTITY; index++)
  14625. {
  14626. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  14627. {
  14628. checkState_Faulted = TRUE; //OCPP Status: Faulted
  14629. }
  14630. }
  14631. if(checkState_Faulted == TRUE)
  14632. {
  14633. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  14634. goto end;
  14635. }
  14636. // Check update type
  14637. if(strcmp((char*)ShmOCPP20Data->SendLocalList.updateType, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  14638. {
  14639. //Local list full update
  14640. DEBUG_INFO("Local list full update.\n");
  14641. DB_getListVerion();
  14642. /*if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  14643. {
  14644. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  14645. goto end;
  14646. }*/
  14647. DB_cleanLocalList();
  14648. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  14649. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  14650. }
  14651. else if(strcmp((char*)ShmOCPP20Data->SendLocalList.updateType, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  14652. {
  14653. //Local list different update
  14654. DEBUG_INFO("Local list different update.\n");
  14655. DB_getListVerion();
  14656. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  14657. {
  14658. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  14659. goto end;
  14660. }
  14661. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  14662. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  14663. }
  14664. else
  14665. {
  14666. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  14667. goto end;
  14668. }
  14669. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  14670. end:
  14671. sendSendLocalListConfirmation(uuid);
  14672. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  14673. return result;
  14674. }
  14675. int handleSetChargingProfileRequest(char *uuid, char *payload)
  14676. {
  14677. mtrace();
  14678. int result = FAIL;
  14679. struct SetChargingProfile_20 SetProfileReq = {0};
  14680. uint8_t isLostConnectorId = FALSE;
  14681. uint8_t isPeriodOverMax = FALSE;
  14682. uint8_t isStackOverMax = FALSE;
  14683. uint8_t isProfileOverMax = FALSE;
  14684. uint8_t isConnectorMismatch = FALSE;
  14685. uint8_t isTransactiodIdMismatch = FALSE;
  14686. uint8_t isInvalidLimit = FALSE;
  14687. uint8_t isWrongFormat = FALSE;
  14688. uint8_t replaceableProfileCnt = 0;
  14689. uint8_t existProfileQuantity = 0;
  14690. uint8_t filename[128]={0};
  14691. uint8_t dataLine[4096]={0};
  14692. FILE *filePtr;
  14693. json_object *SetChargingProfile;
  14694. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  14695. SetChargingProfile = json_tokener_parse(payload);
  14696. if(!is_error(SetChargingProfile))
  14697. {
  14698. // Required data
  14699. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  14700. SetProfileReq.evseId = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  14701. else
  14702. isLostConnectorId = TRUE;
  14703. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "id") != NULL)
  14704. SetProfileReq.chargingProfile.id = json_object_get_int((json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "id")));
  14705. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  14706. {
  14707. sprintf((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")));
  14708. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "stackLevel") != NULL)
  14709. {
  14710. SetProfileReq.chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "stackLevel"));
  14711. }
  14712. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose") != NULL)
  14713. {
  14714. strcpy((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")));
  14715. }
  14716. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfileKind") != NULL)
  14717. {
  14718. strcpy((char*)SetProfileReq.chargingProfile.chargingProfileKind, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfileKind")));
  14719. }
  14720. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "transactionId") != NULL)
  14721. {
  14722. strcpy((char*)SetProfileReq.chargingProfile.transactionId, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "transactionId")));
  14723. }
  14724. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "recurrencyKind") != NULL)
  14725. {
  14726. strcpy((char*)SetProfileReq.chargingProfile.recurrencyKind, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "recurrencyKind")));
  14727. }
  14728. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "validFrom") != NULL)
  14729. {
  14730. strcpy((char*)SetProfileReq.chargingProfile.validFrom, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "validFrom")));
  14731. }
  14732. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "validTo") != NULL)
  14733. {
  14734. strcpy((char*)SetProfileReq.chargingProfile.validTo, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "validTo")));
  14735. }
  14736. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule") != NULL)
  14737. {
  14738. int chargingScheduleCount = 0;
  14739. int chargingSchedulePeriodCount = 0;
  14740. if(json_object_is_type(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), 5))
  14741. {
  14742. chargingScheduleCount = json_object_array_length(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"));
  14743. for(int idxSchedule=0;idxSchedule<chargingScheduleCount;idxSchedule++)
  14744. {
  14745. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingRateUnit") != NULL)
  14746. {
  14747. strcpy((char*)SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit, json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingRateUnit")));
  14748. }
  14749. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "duration") != NULL)
  14750. {
  14751. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].duration = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "duration"));
  14752. }
  14753. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "minChargingRate") != NULL)
  14754. {
  14755. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].minChargingRate = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "minChargingRate"));
  14756. }
  14757. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "startSchedule") != NULL)
  14758. {
  14759. strcpy((char*)SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].startSchedule, json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "startSchedule")));
  14760. }
  14761. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod") != NULL)
  14762. {
  14763. chargingSchedulePeriodCount = json_object_array_length(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"));
  14764. if(chargingSchedulePeriodCount <= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value))
  14765. {
  14766. for(int idxPeriod=0;idxPeriod<chargingSchedulePeriodCount;idxPeriod++)
  14767. {
  14768. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "startPeriod") != NULL)
  14769. {
  14770. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  14771. }
  14772. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "limit") != NULL)
  14773. {
  14774. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "limit"));
  14775. }
  14776. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "numberPhases") != NULL)
  14777. {
  14778. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "numberPhases"));
  14779. }
  14780. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "phaseToUse") != NULL)
  14781. {
  14782. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod"), idxPeriod), "phaseToUse"));
  14783. }
  14784. // Check invalid limit
  14785. if((strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) == NULL) ||
  14786. ((strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL) && (ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing != 1)))
  14787. {
  14788. if(ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'A')
  14789. {
  14790. if(((0 < SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit) && (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit < (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit[0]=='A'?6:6*220*(SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases==0?3:SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases)))) ||
  14791. (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit > (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit[0]=='W'?modelnameInfo.ratedPower:ShmSysConfigAndInfo->SysConfig.RatingCurrent)))
  14792. {
  14793. DEBUG_WARN("Profile chargingSchedule-%d period-%02d is invalid limit: %.2f %s with phase %d.\n", idxSchedule, idxPeriod,
  14794. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit,
  14795. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit,
  14796. (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases==0?3:SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  14797. DEBUG_WARN("Rated Power: %d, Rating Current: %d\n", modelnameInfo.ratedPower, ShmSysConfigAndInfo->SysConfig.RatingCurrent);
  14798. isInvalidLimit = TRUE;
  14799. }
  14800. }
  14801. else
  14802. {
  14803. if((SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit*(SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit[0]=='W'?1:220*(SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases==0?3:SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases)) > modelnameInfo.ratedPower) ||
  14804. (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit*(SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit[0]=='W'?1:220*(SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases==0?3:SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases)) < (modelnameInfo.ratedPower*0.01)))
  14805. {
  14806. DEBUG_WARN("Profile period-%02d is invalid limit: %.2f %s with phase %d.\n", idxPeriod,
  14807. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit,
  14808. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit,
  14809. (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases==0?3:SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  14810. DEBUG_WARN("Rated Power: %d \n", modelnameInfo.ratedPower);
  14811. isInvalidLimit = TRUE;
  14812. }
  14813. }
  14814. }
  14815. }
  14816. }
  14817. else
  14818. {
  14819. isPeriodOverMax = TRUE;
  14820. }
  14821. }
  14822. }
  14823. }
  14824. else
  14825. {
  14826. isWrongFormat = TRUE;
  14827. }
  14828. }
  14829. // Check periods is over max configuration
  14830. if(strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  14831. {
  14832. if(SetProfileReq.evseId == 0)
  14833. {
  14834. sprintf((char*)filename, ChargingStationMaxProfile_JSON);
  14835. filePtr = fopen((char*)filename, "r");
  14836. if (!filePtr)
  14837. {
  14838. DEBUG_INFO("%s not exist, create it.\n", ChargingStationMaxProfile_JSON);
  14839. filePtr = fopen((char*)filename, "w+");
  14840. }
  14841. else
  14842. {
  14843. //Check Charging Profile Count
  14844. //while(fscanf(filePtr, "%s", dataLine) != EOF)
  14845. char *line = NULL;
  14846. size_t len = 0;
  14847. while(getline(&line, &len, filePtr) != -1)
  14848. {
  14849. json_object *obj = NULL;
  14850. obj = json_tokener_parse(line);
  14851. if(is_error(obj))
  14852. {
  14853. DEBUG_ERROR("Parse ChargingStationMaxProfile from file error.\n");
  14854. }
  14855. else
  14856. {
  14857. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != SetProfileReq.chargingProfile.id) &&
  14858. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) != SetProfileReq.chargingProfile.stackLevel))
  14859. {
  14860. existProfileQuantity += 1;
  14861. }
  14862. else
  14863. replaceableProfileCnt += 1;
  14864. }
  14865. //DEBUG_INFO("word=%s\n",word);
  14866. /*if(strstr((char*)dataLine, "id")!= NULL)
  14867. {
  14868. existProfileQuantity += 1;
  14869. }*/
  14870. }
  14871. DEBUG_INFO("existProfileQuantity: %d, Max stack limit: %d\n", existProfileQuantity, atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value));
  14872. if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value))
  14873. {
  14874. isStackOverMax = TRUE;
  14875. }
  14876. }
  14877. fclose(filePtr);
  14878. }
  14879. else
  14880. isConnectorMismatch = TRUE;
  14881. }
  14882. else if(strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  14883. {
  14884. if((0 < SetProfileReq.evseId) && (SetProfileReq.evseId > gunTotalNumber))
  14885. isConnectorMismatch = TRUE;
  14886. if(!isConnectorMismatch)
  14887. {
  14888. if(SetProfileReq.evseId == 0)
  14889. {
  14890. int tmpExistProfileQuantity;
  14891. for(int idxCon=1;idxCon<=gunTotalNumber;idxCon++)
  14892. {
  14893. tmpExistProfileQuantity = 0;
  14894. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
  14895. filePtr = fopen((char*)filename, "r");
  14896. if (!filePtr)
  14897. {
  14898. DEBUG_INFO("%s not exist, create it.\n", filename);
  14899. filePtr = fopen((char*)filename, "w+");
  14900. }
  14901. else
  14902. {
  14903. //Check Charging Profile Count
  14904. //while(fscanf(filePtr, "%s", dataLine) != EOF)
  14905. char *line = NULL;
  14906. size_t len = 0;
  14907. while(getline(&line, &len, filePtr) != -1)
  14908. {
  14909. json_object *obj = NULL;
  14910. obj = json_tokener_parse(line);
  14911. if(is_error(obj))
  14912. {
  14913. DEBUG_ERROR("Parse ChargingStationMaxProfile from file error.\n");
  14914. }
  14915. else
  14916. {
  14917. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != SetProfileReq.chargingProfile.id) &&
  14918. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) != SetProfileReq.chargingProfile.stackLevel))
  14919. {
  14920. tmpExistProfileQuantity += 1;
  14921. }
  14922. else
  14923. replaceableProfileCnt += 1;
  14924. }
  14925. //DEBUG_INFO("word=%s\n",word);
  14926. /*if(strstr((char*)dataLine, "id")!= NULL)
  14927. {
  14928. tmpExistProfileQuantity += 1;
  14929. }*/
  14930. }
  14931. }
  14932. fclose(filePtr);
  14933. DEBUG_INFO("existProfileQuantity: %d, Max stack limit: %d\n", tmpExistProfileQuantity, atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value));
  14934. if(tmpExistProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value))
  14935. {
  14936. isStackOverMax = TRUE;
  14937. }
  14938. //existProfileQuantity = (existProfileQuantity < tmpExistProfileQuantity) ? tmpExistProfileQuantity : existProfileQuantity;
  14939. }
  14940. }
  14941. else
  14942. {
  14943. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", SetProfileReq.evseId);
  14944. filePtr = fopen((char*)filename, "r");
  14945. if (!filePtr)
  14946. {
  14947. DEBUG_INFO("%s not exist, create it.\n", filename);
  14948. filePtr = fopen((char*)filename, "w+");
  14949. }
  14950. else
  14951. {
  14952. //Check Charging Profile Count
  14953. //while(fscanf(filePtr, "%s", dataLine) != EOF)
  14954. char *line = NULL;
  14955. size_t len = 0;
  14956. while(getline(&line, &len, filePtr) != -1)
  14957. {
  14958. json_object *obj = NULL;
  14959. obj = json_tokener_parse(line);
  14960. if(is_error(obj))
  14961. {
  14962. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  14963. }
  14964. else
  14965. {
  14966. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != SetProfileReq.chargingProfile.id) &&
  14967. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) != SetProfileReq.chargingProfile.stackLevel))
  14968. {
  14969. existProfileQuantity += 1;
  14970. }
  14971. else
  14972. replaceableProfileCnt += 1;
  14973. }
  14974. //DEBUG_INFO("word=%s\n",word);
  14975. /*if(strstr((char*)dataLine, "id")!= NULL)
  14976. {
  14977. existProfileQuantity += 1;
  14978. }*/
  14979. }
  14980. DEBUG_INFO("existProfileQuantity: %d, Max stack limit: %d\n", existProfileQuantity, atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value));
  14981. if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value))
  14982. {
  14983. isStackOverMax = TRUE;
  14984. }
  14985. }
  14986. fclose(filePtr);
  14987. }
  14988. }
  14989. }
  14990. else if(strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  14991. {
  14992. if((SetProfileReq.evseId > 0) && (SetProfileReq.evseId <= gunTotalNumber))
  14993. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", SetProfileReq.evseId);
  14994. else
  14995. isConnectorMismatch = TRUE;
  14996. if(!isConnectorMismatch)
  14997. {
  14998. filePtr = fopen((char*)filename, "r");
  14999. if (!filePtr)
  15000. {
  15001. DEBUG_INFO("%s not exist, create it.\n", filename);
  15002. filePtr = fopen((char*)filename, "w+");
  15003. }
  15004. else
  15005. {
  15006. //Check Charging Profile Count
  15007. //while(fscanf(filePtr, "%s", dataLine) != EOF)
  15008. char *line = NULL;
  15009. size_t len = 0;
  15010. while(getline(&line, &len, filePtr) != -1)
  15011. {
  15012. json_object *obj = NULL;
  15013. obj = json_tokener_parse(line);
  15014. if(is_error(obj))
  15015. {
  15016. DEBUG_ERROR("Parse TxProfile from file error.\n");
  15017. }
  15018. else
  15019. {
  15020. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != SetProfileReq.chargingProfile.id) &&
  15021. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) != SetProfileReq.chargingProfile.stackLevel))
  15022. {
  15023. existProfileQuantity += 1;
  15024. }
  15025. else
  15026. replaceableProfileCnt += 1;
  15027. }
  15028. //DEBUG_INFO("word=%s\n",word);
  15029. /*if(strstr((char*)dataLine, "id")!= NULL)
  15030. {
  15031. existProfileQuantity += 1;
  15032. }*/
  15033. }
  15034. DEBUG_INFO("existProfileQuantity: %d, Max stack limit: %d\n", existProfileQuantity, atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value));
  15035. if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value))
  15036. {
  15037. isStackOverMax = TRUE;
  15038. }
  15039. }
  15040. fclose(filePtr);
  15041. if(SetProfileReq.chargingProfile.transactionId != ShmOCPP20Data->TransactionEvent[SetProfileReq.evseId-1].transactionInfo.transactionId)
  15042. isTransactiodIdMismatch = TRUE;
  15043. }
  15044. }
  15045. else if(strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  15046. {
  15047. /*
  15048. * TODO:
  15049. *
  15050. */
  15051. }
  15052. else
  15053. {}
  15054. //------------------------------Start: Check ChargingProfileEntries Logic---------------------------------------//
  15055. {
  15056. FILE *fp;
  15057. char dataLine[4096]={0};
  15058. char fnametemp[128]={0};
  15059. int tmpProfileQuantity;
  15060. //Check ChargePointMaxProfile.json exit
  15061. existProfileQuantity = 0;
  15062. if((access(ChargingStationMaxProfile_JSON,F_OK))!=-1)
  15063. {
  15064. fp = fopen(ChargingStationMaxProfile_JSON, "r");
  15065. //Check Charging Profile Count
  15066. tmpProfileQuantity = 0;
  15067. while(fscanf(fp, "%s", dataLine) != EOF)
  15068. {
  15069. if(strstr(dataLine, "id")!= NULL)
  15070. {
  15071. existProfileQuantity += 1;
  15072. tmpProfileQuantity += 1;
  15073. }
  15074. memset(dataLine, 0, ARRAY_SIZE(dataLine));
  15075. }
  15076. fclose(fp);
  15077. DEBUG_INFO("ChargePointMaxProfile_OCPP20.json has %d charging Profile\n", tmpProfileQuantity);
  15078. }
  15079. //Check TxDefaultProfile_%d.json
  15080. for(int idxCon=1; idxCon <= gunTotalNumber; idxCon++)
  15081. {
  15082. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  15083. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
  15084. if((access(fnametemp,F_OK))!=-1)
  15085. {
  15086. fp = fopen(fnametemp, "r");
  15087. //Check Charging Profile Count
  15088. tmpProfileQuantity = 0;
  15089. while(fscanf(fp, "%s", dataLine) != EOF)
  15090. {
  15091. //DEBUG_INFO("word=%s\n",word);
  15092. if(strstr(dataLine, "id")!= NULL)
  15093. {
  15094. existProfileQuantity += 1;
  15095. tmpProfileQuantity += 1;
  15096. }
  15097. memset(dataLine, 0, ARRAY_SIZE(dataLine));
  15098. }
  15099. fclose(fp);
  15100. DEBUG_INFO("%s has %d charging Profile\n",fnametemp, tmpProfileQuantity);
  15101. }
  15102. }
  15103. //Check TxProfile_%d.json
  15104. for(int idxCon=1; idxCon <= gunTotalNumber; idxCon++)
  15105. {
  15106. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  15107. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d_OCPP20.json", idxCon);
  15108. if((access(fnametemp,F_OK))!=-1)
  15109. {
  15110. fp = fopen(fnametemp, "r");
  15111. //Check Charging Profile Count
  15112. tmpProfileQuantity = 0;
  15113. while(fscanf(fp, "%s", dataLine) != EOF)
  15114. {
  15115. if(strstr(dataLine, "id")!= NULL)
  15116. {
  15117. existProfileQuantity += 1;
  15118. tmpProfileQuantity += 1;
  15119. }
  15120. memset(dataLine, 0, ARRAY_SIZE(dataLine));
  15121. }
  15122. fclose(fp);
  15123. DEBUG_INFO("%s has %d charging Profile\n",fnametemp, tmpProfileQuantity);
  15124. }
  15125. }
  15126. DEBUG_INFO("All purpose profile quantity: %d\n", existProfileQuantity);
  15127. DEBUG_INFO("Replaceable profile quantity: %d\n", replaceableProfileCnt);
  15128. // To check total Profile quantity
  15129. if((SetProfileReq.evseId > 0) || (strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL))
  15130. {
  15131. if((existProfileQuantity-replaceableProfileCnt) >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value))
  15132. isProfileOverMax = TRUE;
  15133. }
  15134. else
  15135. {
  15136. if((existProfileQuantity+gunTotalNumber-replaceableProfileCnt) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value))
  15137. isProfileOverMax = TRUE;
  15138. }
  15139. }
  15140. //------------------------------End: Check ChargingProfileEntries Logic---------------------------------------//
  15141. }
  15142. // Profile replace or add info
  15143. if(!isLostConnectorId && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTransactiodIdMismatch && !isInvalidLimit && !isWrongFormat && !isStackOverMax)
  15144. {
  15145. FILE *infile;
  15146. FILE *outfile;
  15147. char tmpProfileName[] = "/Storage/OCPP/SetChargingProfiletemp_OCPP20.json";
  15148. char rmFileCmd[128];
  15149. int tempchargingProfileIdInt;
  15150. int tempchargingProfileStackLevelInt;
  15151. int chkChar;
  15152. for(int idxCon=1; idxCon <= (SetProfileReq.evseId==0?gunTotalNumber:1); idxCon++)
  15153. {
  15154. if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) == 0)
  15155. {
  15156. sprintf((char*)filename, "%s", ChargingStationMaxProfile_JSON);
  15157. }
  15158. else if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0)
  15159. {
  15160. if(SetProfileReq.evseId==0)
  15161. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
  15162. else
  15163. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", SetProfileReq.evseId);
  15164. }
  15165. else if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) == 0)
  15166. {
  15167. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", SetProfileReq.evseId);
  15168. }
  15169. else
  15170. {
  15171. /*
  15172. * TODO:
  15173. *
  15174. */
  15175. }
  15176. infile = fopen ((char*)filename, "r");
  15177. outfile = fopen ((char*)tmpProfileName, "w");
  15178. chkChar = fgetc(infile);
  15179. rewind(infile);
  15180. if(chkChar == EOF)
  15181. {
  15182. // Profile is empty
  15183. if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
  15184. json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
  15185. fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  15186. fclose(infile);
  15187. fclose(outfile);
  15188. sprintf(rmFileCmd,"rm -f %s",filename);
  15189. system(rmFileCmd);
  15190. rename((char*)tmpProfileName, (char*)filename);
  15191. }
  15192. else
  15193. {
  15194. // Profile is not empty
  15195. int ChargingProfileAdded = FALSE;
  15196. while (fgets((char*)dataLine, ARRAY_SIZE(dataLine), infile) != NULL)
  15197. {
  15198. dataLine[strlen((char*)dataLine) - 1] = '\0'; // eat the newline fgets() stores
  15199. json_object *tmpChargingProfile;
  15200. tmpChargingProfile = json_tokener_parse((char*)dataLine);
  15201. if(!is_error(tmpChargingProfile))
  15202. {
  15203. if(json_object_object_get(tmpChargingProfile, "chargingProfile") != NULL)
  15204. {
  15205. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "id") != NULL)
  15206. {
  15207. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "id"));
  15208. DEBUG_INFO("tempchargingProfileIdInt: %d\n", tempchargingProfileIdInt);
  15209. DEBUG_INFO("SetProfileReq.chargingProfile.id: %d\n", SetProfileReq.chargingProfile.id);
  15210. }
  15211. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "stackLevel") != NULL)
  15212. {
  15213. tempchargingProfileStackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "stackLevel"));
  15214. DEBUG_INFO("tempchargingProfileStackLevelInt: %d\n", tempchargingProfileStackLevelInt);
  15215. DEBUG_INFO("SetProfileReq.chargingProfile.stackLevel: %d\n", SetProfileReq.chargingProfile.stackLevel);
  15216. }
  15217. }
  15218. }
  15219. json_object_put(tmpChargingProfile);
  15220. if((tempchargingProfileIdInt == SetProfileReq.chargingProfile.id) || (tempchargingProfileStackLevelInt == SetProfileReq.chargingProfile.stackLevel))
  15221. {
  15222. if(ChargingProfileAdded == FALSE)
  15223. {
  15224. if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
  15225. json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
  15226. fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  15227. ChargingProfileAdded = TRUE;
  15228. }
  15229. }
  15230. else
  15231. {
  15232. fprintf(outfile,"%s\n",dataLine);
  15233. if(ChargingProfileAdded == FALSE)
  15234. {
  15235. if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
  15236. json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
  15237. fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  15238. ChargingProfileAdded = TRUE;
  15239. }
  15240. }
  15241. } // end of while loop
  15242. fclose(infile);
  15243. fclose(outfile);
  15244. sprintf(rmFileCmd,"rm -f %s",filename);
  15245. system(rmFileCmd);
  15246. rename((char*)tmpProfileName, (char*)filename);
  15247. }
  15248. }
  15249. sleep(1);
  15250. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  15251. result = PASS;
  15252. }
  15253. else
  15254. {
  15255. if(isLostConnectorId)
  15256. DEBUG_WARN("Connector id is wrong.\n");
  15257. if(isConnectorMismatch)
  15258. DEBUG_WARN("Connector id is mismatch.\n");
  15259. if(isPeriodOverMax)
  15260. DEBUG_WARN("Profile periods quantity is over spec.\n");
  15261. if(isProfileOverMax)
  15262. DEBUG_WARN("Profile quantity is over spec.\n");
  15263. if(isTransactiodIdMismatch)
  15264. DEBUG_WARN("Transaction id is mismatch.\n");
  15265. if(isInvalidLimit)
  15266. DEBUG_WARN("Limit value is invalid.\n");
  15267. if(isStackOverMax)
  15268. DEBUG_WARN("Profile stack is over spec.\n");
  15269. if(isWrongFormat)
  15270. DEBUG_WARN("Profile format is wrong.\n");
  15271. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  15272. }
  15273. }
  15274. json_object_put(SetChargingProfile);
  15275. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  15276. {
  15277. if(SetProfileReq.evseId == 0)
  15278. {
  15279. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  15280. {
  15281. //ShmOCPP20Data->CSUMsg.bits[idx].ChargingProfileReq = ON;
  15282. checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
  15283. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
  15284. }
  15285. }
  15286. else
  15287. {
  15288. //ShmOCPP20Data->CSUMsg.bits[SetProfileReq.evseId-1].ChargingProfileReq = ON;
  15289. checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
  15290. checkCompositeSchedule(SetProfileReq.evseId, 86400, &ShmOCPP20Data->SmartChargingProfile[SetProfileReq.evseId-1], 0, TRUE);
  15291. }
  15292. }
  15293. sendSetChargingProfileConfirmation(uuid, (SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1));
  15294. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  15295. return result;
  15296. }
  15297. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  15298. {
  15299. mtrace();
  15300. int result = FAIL;
  15301. json_object *SetDisplayMessage;
  15302. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  15303. SetDisplayMessage = json_tokener_parse(payload);
  15304. if(!is_error(SetDisplayMessage))
  15305. {
  15306. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  15307. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  15308. // Required data
  15309. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  15310. {
  15311. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  15312. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  15313. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  15314. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  15315. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  15316. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  15317. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  15318. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  15319. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  15320. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  15321. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  15322. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  15323. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  15324. {
  15325. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  15326. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.format, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format")));
  15327. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  15328. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.language, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language")));
  15329. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  15330. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.message.content, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content")));
  15331. }
  15332. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  15333. {
  15334. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  15335. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.display.name, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name")));
  15336. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  15337. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.display.instance, "%s",json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance")));
  15338. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  15339. {
  15340. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  15341. ShmOCPP20Data->SetDisplayMessage.message.display.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id"));
  15342. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  15343. ShmOCPP20Data->SetDisplayMessage.message.display.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId"));
  15344. }
  15345. }
  15346. }
  15347. }
  15348. json_object_put(SetDisplayMessage);
  15349. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  15350. sendSetDisplayMessagesConfirmation(uuid);
  15351. // Announce CSU there is display request come from server
  15352. ShmOCPP20Data->MsMsg.bits.SetDisplayMessageReq = ON;
  15353. return result;
  15354. }
  15355. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  15356. {
  15357. mtrace();
  15358. int result = FAIL;
  15359. json_object *SetMonitoringBase;
  15360. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  15361. SetMonitoringBase = json_tokener_parse(payload);
  15362. if(!is_error(SetMonitoringBase))
  15363. {
  15364. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  15365. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  15366. // Required data
  15367. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  15368. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  15369. }
  15370. json_object_put(SetMonitoringBase);
  15371. /*
  15372. * TODO:
  15373. * 1. Configure monitor base and response
  15374. */
  15375. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  15376. sendSetMonitoringBaseConfirmation(uuid);
  15377. return result;
  15378. }
  15379. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  15380. {
  15381. mtrace();
  15382. int result = FAIL;
  15383. json_object *SetMonitoringLevel;
  15384. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  15385. SetMonitoringLevel = json_tokener_parse(payload);
  15386. if(!is_error(SetMonitoringLevel))
  15387. {
  15388. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  15389. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  15390. // Required data
  15391. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  15392. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  15393. }
  15394. json_object_put(SetMonitoringLevel);
  15395. /*
  15396. * TODO:
  15397. * Configure monitor status and response
  15398. */
  15399. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  15400. sendSetMonitoringLevelConfirmation(uuid);
  15401. return result;
  15402. }
  15403. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  15404. {
  15405. mtrace();
  15406. int result = FAIL;
  15407. json_object *SetNetworkProfile;
  15408. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  15409. SetNetworkProfile = json_tokener_parse(payload);
  15410. if(!is_error(SetNetworkProfile))
  15411. {
  15412. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  15413. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  15414. // Required data
  15415. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  15416. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  15417. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  15418. {
  15419. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  15420. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  15421. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  15422. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  15423. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  15424. {
  15425. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  15426. memcpy((char*)ShmOCPP20Data->OcppServerURL, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl));
  15427. }
  15428. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  15429. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  15430. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  15431. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  15432. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  15433. {
  15434. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  15435. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server")));
  15436. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  15437. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user")));
  15438. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  15439. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group")));
  15440. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  15441. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password")));
  15442. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  15443. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key")));
  15444. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  15445. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type")));
  15446. }
  15447. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  15448. {
  15449. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  15450. {
  15451. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  15452. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn")));
  15453. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  15454. }
  15455. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  15456. {
  15457. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  15458. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName")));
  15459. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  15460. }
  15461. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  15462. {
  15463. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  15464. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword")));
  15465. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  15466. }
  15467. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  15468. ShmOCPP20Data->SetNetworkProfile.connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin"));
  15469. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  15470. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork")));
  15471. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  15472. ShmOCPP20Data->SetNetworkProfile.connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork"));
  15473. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  15474. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication")));
  15475. }
  15476. DB_addNetworkProfile(ShmOCPP20Data->SetNetworkProfile.configurationSlot, (char*)json_object_get_string(json_object_object_get(SetNetworkProfile, "connectionData")));
  15477. }
  15478. }
  15479. json_object_put(SetNetworkProfile);
  15480. /*
  15481. * TODO:
  15482. * 1. Process network configuration and response
  15483. */
  15484. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  15485. {
  15486. }
  15487. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  15488. {
  15489. }
  15490. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  15491. {
  15492. }
  15493. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  15494. {
  15495. }
  15496. else
  15497. {
  15498. }
  15499. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  15500. {
  15501. }
  15502. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  15503. {
  15504. }
  15505. else
  15506. {
  15507. }
  15508. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  15509. {
  15510. }
  15511. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  15512. {
  15513. }
  15514. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  15515. {
  15516. }
  15517. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  15518. {
  15519. }
  15520. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  15521. {
  15522. }
  15523. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  15524. {
  15525. }
  15526. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  15527. {
  15528. }
  15529. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  15530. {
  15531. }
  15532. else
  15533. {
  15534. }
  15535. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  15536. {
  15537. }
  15538. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  15539. {
  15540. }
  15541. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  15542. {
  15543. }
  15544. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  15545. {
  15546. }
  15547. else
  15548. {
  15549. }
  15550. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  15551. {
  15552. }
  15553. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  15554. {
  15555. }
  15556. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  15557. {
  15558. }
  15559. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  15560. {
  15561. }
  15562. else
  15563. {
  15564. }
  15565. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  15566. sendSetNetworkProfileConfirmation(uuid);
  15567. return result;
  15568. }
  15569. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  15570. {
  15571. mtrace();
  15572. int result = FAIL;
  15573. json_object *SetVariableMonitoring;
  15574. uint8_t variableQuantity = 0;
  15575. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  15576. SetVariableMonitoring = json_tokener_parse(payload);
  15577. if(!is_error(SetVariableMonitoring))
  15578. {
  15579. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  15580. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  15581. // Required data
  15582. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  15583. {
  15584. variableQuantity++;
  15585. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  15586. {
  15587. ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id"));
  15588. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  15589. }
  15590. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  15591. {
  15592. ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].value = json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value"));
  15593. }
  15594. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  15595. {
  15596. sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type")));
  15597. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  15598. }
  15599. else
  15600. {
  15601. sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type, "Actual");
  15602. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  15603. }
  15604. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  15605. {
  15606. ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity"));
  15607. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  15608. }
  15609. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  15610. {
  15611. ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].transaction = json_object_get_boolean(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction"));
  15612. }
  15613. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component") != NULL)
  15614. {
  15615. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "name") != NULL)
  15616. {
  15617. sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component.name, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "name")));
  15618. }
  15619. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "instance") != NULL)
  15620. {
  15621. sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component.instance, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "instance")));
  15622. }
  15623. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "evse") != NULL)
  15624. {
  15625. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "evse"), "id") != NULL)
  15626. {
  15627. ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "instance"), "id"));
  15628. }
  15629. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "evse"), "connectorId") != NULL)
  15630. {
  15631. ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "instance"), "connectorId"));
  15632. }
  15633. }
  15634. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  15635. }
  15636. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "variable") != NULL)
  15637. {
  15638. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "variable"), "name") != NULL)
  15639. {
  15640. sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable.name, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "variable"), "name")));
  15641. }
  15642. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "variable"), "instance") != NULL)
  15643. {
  15644. sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable.instance, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "variable"), "instance")));
  15645. }
  15646. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  15647. }
  15648. /*
  15649. * TODO
  15650. * Set Variables and save to DB
  15651. */
  15652. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, SetMonitoringStatusEnumTypeStr[SetMonitoringStatusEnumType_Accepted]);
  15653. }
  15654. }
  15655. json_object_put(SetVariableMonitoring);
  15656. sendSetVariableMonitoringConfirmation(uuid, variableQuantity);
  15657. return result;
  15658. }
  15659. int handleSetVariablesRequest(char *uuid, char *payload)
  15660. {
  15661. mtrace();
  15662. int result = FAIL;
  15663. int isUnknownComponent = TRUE;
  15664. json_object *SetVariables;
  15665. DEBUG_INFO("handleSetVariablesRequest...\n");
  15666. SetVariables = json_tokener_parse(payload);
  15667. if(!is_error(SetVariables))
  15668. {
  15669. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  15670. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  15671. // Required data
  15672. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  15673. {
  15674. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  15675. {
  15676. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  15677. {
  15678. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  15679. {
  15680. sprintf((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name")));
  15681. }
  15682. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  15683. {
  15684. sprintf((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.instance, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance")));
  15685. }
  15686. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  15687. {
  15688. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse"), "id") != NULL)
  15689. {
  15690. ShmOCPP20Data->SetVariables.setVariableData[idx].component.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse"), "id"));
  15691. }
  15692. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse"), "connectorId") != NULL)
  15693. {
  15694. ShmOCPP20Data->SetVariables.setVariableData[idx].component.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse"), "connectorId"));
  15695. }
  15696. }
  15697. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  15698. }
  15699. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  15700. {
  15701. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  15702. {
  15703. sprintf((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name")));
  15704. }
  15705. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  15706. {
  15707. sprintf((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.instance, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance")));
  15708. }
  15709. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  15710. }
  15711. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  15712. {
  15713. sprintf((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType")));
  15714. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  15715. }
  15716. if(strlen((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType) == 0)
  15717. {
  15718. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, "Actual");
  15719. }
  15720. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  15721. {
  15722. sprintf((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue, "%s", json_object_get_string(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue")));
  15723. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  15724. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  15725. {
  15726. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL) &&
  15727. (strlen((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.instance)>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.instance) != NULL):TRUE) &&
  15728. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name) != NULL) &&
  15729. (strlen((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.instance)>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.instance) != NULL):TRUE))
  15730. {
  15731. isUnknownComponent = FALSE;
  15732. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType) == NULL) &&
  15733. (json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL))
  15734. {
  15735. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_NotSupportedAttributeType]);
  15736. break;
  15737. }
  15738. if(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].mutability, MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]) != NULL)
  15739. {
  15740. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
  15741. break;
  15742. }
  15743. if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "NetworkConfigurationPriority") != NULL))
  15744. {
  15745. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]);
  15746. }
  15747. else
  15748. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  15749. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "WebSocketPingInterval") != NULL))
  15750. {
  15751. if((0 < atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)) && (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < 10) )
  15752. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  15753. else
  15754. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  15755. }
  15756. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "HeartbeatInterval") != NULL))
  15757. {
  15758. if((atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
  15759. {
  15760. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  15761. }
  15762. else
  15763. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  15764. }
  15765. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "StatusNotificationPeriodically") != NULL))
  15766. {
  15767. char tmp[ARRAY_SIZE(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)];
  15768. for(int tmpidx=0;tmpidx<ARRAY_SIZE(tmp);tmpidx++)
  15769. tmp[idx] = tolower(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue[tmpidx]);
  15770. if((strstr((char*)tmp, "true") != NULL) || (strstr((char*)tmp, "false") != NULL))
  15771. {
  15772. strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,(strstr((char*)tmp, "true") != NULL)? "TRUE" : "FALSE");
  15773. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  15774. }
  15775. }
  15776. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "StatusNotificationInterval") != NULL))
  15777. {
  15778. if((atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
  15779. {
  15780. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  15781. }
  15782. else
  15783. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  15784. }
  15785. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "SecurityCtrlr") != NULL) &&
  15786. ((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "SecurityProfile") != NULL) || (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "BasicAuthPassword") != NULL)))
  15787. {
  15788. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  15789. SetOcppConnStatus(FALSE);
  15790. }
  15791. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "AlignedDataCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "Interval") != NULL))
  15792. {
  15793. if((0 < atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)) && (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
  15794. {
  15795. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  15796. }
  15797. else
  15798. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  15799. }
  15800. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "SampledDataCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "TxUpdatedInterval") != NULL))
  15801. {
  15802. if((0 < atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)) && (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
  15803. {
  15804. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  15805. }
  15806. else
  15807. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  15808. }
  15809. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "ChargingStation") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "FreeVend") != NULL))
  15810. {
  15811. char tmp[ARRAY_SIZE(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)];
  15812. for(int tmpidx=0;tmpidx<ARRAY_SIZE(tmp);tmpidx++)
  15813. tmp[idx] = tolower(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue[tmpidx]);
  15814. if((strstr((char*)tmp, "true") != NULL) || (strstr((char*)tmp, "false") != NULL))
  15815. {
  15816. strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,(strstr((char*)tmp, "true") != NULL)? "TRUE" : "FALSE");
  15817. ShmSysConfigAndInfo->SysConfig.AuthorisationMode =((strstr((char*)tmp, "true") != NULL)? 1 : 0);
  15818. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  15819. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  15820. }
  15821. }
  15822. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "ChargingStation") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "FreeVendIdtag") != NULL))
  15823. {
  15824. if(strlen((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) > 20)
  15825. {
  15826. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  15827. }
  15828. else
  15829. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  15830. }
  15831. if((strstr((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]) != NULL) ||
  15832. (strstr((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]) != NULL))
  15833. {
  15834. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  15835. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  15836. }
  15837. break;
  15838. }
  15839. else
  15840. {
  15841. if(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL)
  15842. {
  15843. isUnknownComponent = FALSE;
  15844. }
  15845. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownVariable]);
  15846. }
  15847. }
  15848. if(isUnknownComponent == TRUE)
  15849. {
  15850. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  15851. }
  15852. }
  15853. }
  15854. }
  15855. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  15856. }
  15857. json_object_put(SetVariables);
  15858. return result;
  15859. }
  15860. int handleTriggerMessageRequest(char *uuid, char *payload)
  15861. {
  15862. mtrace();
  15863. int result = FAIL;
  15864. int connectorIdIsNULL = FALSE;
  15865. int connectorIdInt =0;
  15866. json_object *TriggerMessage;
  15867. DEBUG_INFO("handleTriggerMessageRequest\n");
  15868. TriggerMessage = json_tokener_parse(payload);
  15869. if(!is_error(TriggerMessage))
  15870. {
  15871. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  15872. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  15873. // Required data
  15874. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  15875. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  15876. // Optional data
  15877. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  15878. {
  15879. // Required data
  15880. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  15881. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  15882. // Optional data
  15883. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  15884. {
  15885. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  15886. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  15887. }
  15888. else
  15889. connectorIdIsNULL = TRUE;
  15890. }
  15891. else
  15892. connectorIdIsNULL = TRUE;
  15893. }
  15894. json_object_put(TriggerMessage);
  15895. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  15896. {
  15897. if((strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  15898. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  15899. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  15900. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  15901. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  15902. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  15903. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  15904. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  15905. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  15906. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  15907. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  15908. {
  15909. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  15910. sendTriggerMessageConfirmation(uuid);
  15911. return TRUE;
  15912. }
  15913. else
  15914. {
  15915. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  15916. sendTriggerMessageConfirmation(uuid);
  15917. }
  15918. }
  15919. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  15920. {
  15921. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  15922. sendTriggerMessageConfirmation(uuid);
  15923. return TRUE;
  15924. }
  15925. //==========================
  15926. // Trigger message
  15927. //==========================
  15928. if( strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  15929. {
  15930. if((strlen((char*)ShmOCPP20Data->FirmwareStatusNotification.status) == 0) ||
  15931. ((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing)))
  15932. {
  15933. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  15934. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  15935. }
  15936. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  15937. }
  15938. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  15939. {
  15940. if(strlen((char*)ShmOCPP20Data->LogStatusNotification.status) == 0)
  15941. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Idle]);
  15942. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  15943. }
  15944. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  15945. {
  15946. if(DB_updateBootType(BootReasonEnumType_Triggered))
  15947. server_sign = FALSE;
  15948. }
  15949. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  15950. {
  15951. refreshStartTimer(&clientTime.Heartbeat);
  15952. clientTime.Heartbeat.tv_sec -= ShmOCPP20Data->BootNotification.Response_interval;
  15953. }
  15954. else if (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  15955. {
  15956. if(connectorIdIsNULL == FALSE)
  15957. {
  15958. if((connectorIdInt > 0) && ((connectorIdInt-1) < gunTotalNumber))
  15959. {
  15960. cpinitateMsg.bits[connectorIdInt-1].TriggerMeterValueReq = ON;
  15961. }
  15962. }
  15963. else
  15964. {
  15965. for(int idx=0;idx< gunTotalNumber;idx++)
  15966. {
  15967. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  15968. }
  15969. }
  15970. }
  15971. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  15972. {
  15973. if(connectorIdIsNULL == FALSE)
  15974. {
  15975. if((connectorIdInt > 0) && ((connectorIdInt-1) < gunTotalNumber))
  15976. {
  15977. cpinitateMsg.bits[connectorIdInt-1].TriggerStatusNotificationReq = ON;
  15978. //clientTime.StatusNotification[connectorIdInt-1] = time((time_t*)NULL);
  15979. }
  15980. }
  15981. else
  15982. {
  15983. for(int idx=0;idx< gunTotalNumber;idx++)
  15984. {
  15985. cpinitateMsg.bits[idx].TriggerStatusNotificationReq = ON;
  15986. //clientTime.StatusNotification[idx] = time((time_t*)NULL);
  15987. }
  15988. }
  15989. }
  15990. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) == 0 )
  15991. {
  15992. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  15993. if(access("/Storage/OCPP/certCP.csr",F_OK) == -1)
  15994. {
  15995. system("openssl req -newkey rsa:2048 -out /Storage/OCPP/certCP.csr -nodes -keyout /Storage/OCPP/certCP.key -subj \"/C=TW/ST=Taiwan/L=Taoyuan/O=Phihong Technology/OU=IT/CN=phihong.com\" &");
  15996. }
  15997. }
  15998. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) == 0 )
  15999. {
  16000. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  16001. if(access("/Storage/OCPP/certV2G.csr",F_OK) == -1)
  16002. {
  16003. system("openssl req -newkey rsa:2048 -out /Storage/OCPP/certV2G.csr -nodes -keyout /Storage/OCPP/certV2G.key -subj \"/C=TW/ST=Taiwan/L=Taoyuan/O=Phihong Technology/OU=IT/CN=phihong.com\" &");
  16004. }
  16005. }
  16006. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) == 0 )
  16007. {
  16008. if(connectorIdIsNULL == FALSE)
  16009. {
  16010. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  16011. {
  16012. ShmOCPP20Data->CpMsg.bits[connectorIdInt -1].TransactionEventReq = ON;
  16013. }
  16014. }
  16015. else
  16016. {
  16017. for(int idx=0;idx< gunTotalNumber;idx++)
  16018. ShmOCPP20Data->CpMsg.bits[idx].TransactionEventReq = ON;
  16019. }
  16020. }
  16021. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) == 0 )
  16022. {
  16023. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  16024. if(access("/Storage/OCPP/certCP.csr",F_OK) == -1)
  16025. {
  16026. system("openssl req -newkey rsa:2048 -out /Storage/OCPP/certCP.csr -nodes -keyout /Storage/OCPP/certCP.key -subj \"/C=TW/ST=Taiwan/L=Taoyuan/O=Phihong Technology/OU=IT/CN=phihong.com\" &");
  16027. }
  16028. if(access("/Storage/OCPP/certV2G.csr",F_OK) == -1)
  16029. {
  16030. system("openssl req -newkey rsa:2048 -out /Storage/OCPP/certV2G.csr -nodes -keyout /Storage/OCPP/certV2G.key -subj \"/C=TW/ST=Taiwan/L=Taoyuan/O=Phihong Technology/OU=IT/CN=phihong.com\" &");
  16031. }
  16032. }
  16033. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) == 0 )
  16034. {
  16035. ShmOCPP20Data->MsMsg.bits.PublishFirmwareReq = ON;
  16036. }
  16037. return result;
  16038. }
  16039. int handleUnlockConnectorRequest(char *uuid, char *payload)
  16040. {
  16041. mtrace();
  16042. int result = FAIL;
  16043. int connectorIdInt =0;
  16044. int tempIndex = 0;
  16045. json_object *UnlockConnector;
  16046. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  16047. UnlockConnector = json_tokener_parse(payload);
  16048. if(!is_error(UnlockConnector))
  16049. {
  16050. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  16051. {
  16052. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  16053. }
  16054. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  16055. {
  16056. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  16057. }
  16058. }
  16059. json_object_put(UnlockConnector);
  16060. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  16061. if(gunTotalNumber == 0)
  16062. {
  16063. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  16064. goto end;
  16065. }
  16066. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  16067. {
  16068. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  16069. goto end;
  16070. }
  16071. else
  16072. {
  16073. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  16074. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  16075. //check Transaction active
  16076. if(gunType[connectorIdInt-1] == GUN_TYPE_CHAdeMO)
  16077. {
  16078. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  16079. {
  16080. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  16081. }
  16082. else
  16083. {
  16084. tempIndex = connectorIdInt -1;
  16085. }
  16086. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  16087. {
  16088. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ))
  16089. {
  16090. //stop Transaction
  16091. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  16092. }
  16093. }
  16094. }
  16095. else if(gunType[connectorIdInt-1] == GUN_TYPE_CCS)
  16096. {
  16097. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  16098. {
  16099. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  16100. }
  16101. else
  16102. {
  16103. tempIndex = connectorIdInt -1;
  16104. }
  16105. for (int index = 0; index < CCS_QUANTITY; index++)
  16106. {
  16107. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ))
  16108. {
  16109. //stop Transaction
  16110. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  16111. }
  16112. }
  16113. }
  16114. else if(gunType[connectorIdInt-1] == GUN_TYPE_GBT)
  16115. {
  16116. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  16117. {
  16118. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  16119. }
  16120. else
  16121. {
  16122. tempIndex = connectorIdInt -1;
  16123. }
  16124. for (int index = 0; index < GB_QUANTITY; index++)
  16125. {
  16126. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ))
  16127. {
  16128. //stop Transaction
  16129. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  16130. }
  16131. }
  16132. }
  16133. else if(gunType[connectorIdInt-1] == GUN_TYPE_DO)
  16134. {
  16135. tempIndex = connectorIdInt -1;
  16136. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  16137. {
  16138. if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex ))
  16139. {
  16140. //stop Transaction
  16141. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  16142. }
  16143. }
  16144. }
  16145. else
  16146. {
  16147. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  16148. {
  16149. tempIndex = 2;
  16150. }
  16151. else
  16152. {
  16153. tempIndex = connectorIdInt-1;
  16154. }
  16155. for (int index = 0; index < AC_QUANTITY; index++)
  16156. {
  16157. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ))
  16158. {
  16159. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  16160. }
  16161. }
  16162. }
  16163. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  16164. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  16165. result = TRUE;
  16166. return result;
  16167. }
  16168. end:
  16169. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorConf = ON;
  16170. return result;
  16171. }
  16172. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  16173. {
  16174. mtrace();
  16175. int result = FAIL;
  16176. json_object *UnpublishFirmware;
  16177. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  16178. UnpublishFirmware = json_tokener_parse(payload);
  16179. if(!is_error(UnpublishFirmware))
  16180. {
  16181. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  16182. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  16183. // Required data
  16184. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  16185. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  16186. }
  16187. json_object_put(UnpublishFirmware);
  16188. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  16189. /*
  16190. * TODO:
  16191. * 1. Check unpublished status
  16192. */
  16193. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  16194. sendUnpublishFirmwareConfirmation(uuid);
  16195. return result;
  16196. }
  16197. static char UpdateFirmwarepayloadData[512]={0};
  16198. void *UpdateFirmwareProcess(void *data)
  16199. {
  16200. pthread_detach(pthread_self());
  16201. mtrace();
  16202. char protocol[10], user[64],password[64],host[128], path[512], ftppath[512],host1[128],path1[512];
  16203. int port=0;
  16204. int isSuccess = 0;
  16205. char ftpbuf[1024];
  16206. char temp[1024];
  16207. char * pch;
  16208. DEBUG_INFO("handleUpdateFirmwareRequest...\n");
  16209. json_object *UpdateFirmware;
  16210. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  16211. if(!is_error(UpdateFirmware))
  16212. {
  16213. // Required data
  16214. if(json_object_object_get(UpdateFirmware, "requestId"))
  16215. {
  16216. ShmOCPP20Data->UpdateFirmware.requestId = json_object_get_int(json_object_object_get(UpdateFirmware, "requestId"));
  16217. }
  16218. if(json_object_object_get(UpdateFirmware, "firmware"))
  16219. {
  16220. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "location") != NULL)
  16221. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "location")));
  16222. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "retrieveDate") != NULL)
  16223. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "retrieveDate")));
  16224. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "installDateTime") != NULL)
  16225. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "installDateTime")));
  16226. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signingCertificate") != NULL)
  16227. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signingCertificate")));
  16228. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signature") != NULL)
  16229. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signature")));
  16230. }
  16231. // Optional data
  16232. if(json_object_object_get(UpdateFirmware, "retries"))
  16233. {
  16234. ShmOCPP20Data->UpdateFirmware.retries = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  16235. }
  16236. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  16237. {
  16238. ShmOCPP20Data->UpdateFirmware.retryInterval = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  16239. }
  16240. }
  16241. json_object_put(UpdateFirmware);
  16242. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  16243. memset(path, 0, ARRAY_SIZE(path));
  16244. // Wait retrieveData
  16245. if(strlen((char*)ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime) > 10)
  16246. {
  16247. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16248. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled]);
  16249. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16250. do
  16251. {
  16252. sleep(1);
  16253. }while(!isOvertNow(ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime));
  16254. }
  16255. system("rm -f /mnt/*");
  16256. if(strncmp((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"http", 4) == 0)
  16257. {
  16258. sscanf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  16259. sprintf(ftppath,"/%s", path);
  16260. DEBUG_INFO("locationstr: %s\n", ShmOCPP20Data->UpdateFirmware.firmware.location);
  16261. DEBUG_INFO("protocol: %s\n",protocol);
  16262. DEBUG_INFO("host: %s\n",host);
  16263. DEBUG_INFO("path: %s\n",path);
  16264. DEBUG_INFO("ftppath: %s\n",ftppath);
  16265. int ftppathlen=strlen(ftppath);
  16266. int i=1;
  16267. char filenametemp[50];
  16268. while(i < ftppathlen)
  16269. {
  16270. int len=ftppathlen-i;
  16271. if(ftppath[len]== 47) // '/' ascll code: 47
  16272. {
  16273. DEBUG_INFO("compare '/' all right\n");
  16274. break;
  16275. }
  16276. i=i+1;
  16277. }
  16278. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  16279. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  16280. filenametemp[i+1] = 0;
  16281. do
  16282. {
  16283. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16284. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  16285. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16286. sleep(3);
  16287. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
  16288. if(!isSuccess)
  16289. {
  16290. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16291. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  16292. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16293. if(ShmOCPP20Data->UpdateFirmware.retries>0)sleep(ShmOCPP20Data->UpdateFirmware.retryInterval);else sleep(1);
  16294. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16295. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  16296. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16297. }
  16298. else
  16299. {
  16300. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16301. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  16302. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16303. }
  16304. ShmOCPP20Data->UpdateFirmware.retries--;
  16305. }while((isSuccess == 0)&&(ShmOCPP20Data->UpdateFirmware.retries >= 0));
  16306. }
  16307. else if(strncmp((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"ftp", 3) == 0)
  16308. {
  16309. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  16310. memset(temp, 0, ARRAY_SIZE(temp));
  16311. strcpy(ftpbuf, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
  16312. int ftppathlen=strlen(ftpbuf);
  16313. int i=1;
  16314. char filenametemp[50];
  16315. while(i < ftppathlen)
  16316. {
  16317. int len=ftppathlen-i;
  16318. if(ftpbuf[len]== 47) // '/' ascll code: 47
  16319. {
  16320. DEBUG_INFO(" compare '/' all right\n");
  16321. break;
  16322. }
  16323. i=i+1;
  16324. }
  16325. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  16326. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  16327. filenametemp[i+1] = 0;
  16328. strncpy(temp, ftpbuf, ftppathlen-i+1);
  16329. pch=strchr(temp,'@');
  16330. if(pch==NULL)
  16331. {
  16332. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  16333. protocol, host, &port, path);
  16334. strcpy(user,"anonymous");
  16335. strcpy(password,"");
  16336. }
  16337. else
  16338. {
  16339. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  16340. protocol, user, password, host, &port, path);
  16341. }
  16342. sscanf(host,"%[^/]%s",host1, path1);
  16343. sprintf(ftppath,"%s", path1);
  16344. if(port == 0)
  16345. {
  16346. port = 21;
  16347. }
  16348. do
  16349. {
  16350. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16351. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  16352. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16353. sleep(3);
  16354. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
  16355. if(!isSuccess)
  16356. {
  16357. //BulldogUtil.sleepMs(interval*1000);
  16358. DEBUG_INFO("Update firmware request and download file fail.\n");
  16359. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16360. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  16361. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16362. if(ShmOCPP20Data->UpdateFirmware.retries>0)sleep(ShmOCPP20Data->UpdateFirmware.retryInterval);else sleep(1);
  16363. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16364. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  16365. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16366. }
  16367. else
  16368. {
  16369. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16370. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  16371. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16372. }
  16373. ShmOCPP20Data->UpdateFirmware.retries--;
  16374. }while((!isSuccess)&&(ShmOCPP20Data->UpdateFirmware.retries >= 0));
  16375. }
  16376. else
  16377. {
  16378. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16379. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  16380. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16381. sleep(1);
  16382. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16383. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  16384. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16385. }
  16386. if(strstr((char*)ShmOCPP20Data->FirmwareStatusNotification.status, FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]) != NULL)ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  16387. interLock.isUpdateFirmwareGoing = OFF;
  16388. pthread_exit(NULL);
  16389. }
  16390. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  16391. {
  16392. mtrace();
  16393. int result = FAIL;
  16394. pthread_t t;
  16395. sendUpdateFirmwareConfirmation(uuid);
  16396. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  16397. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  16398. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  16399. if(!interLock.isUpdateFirmwareGoing)
  16400. {
  16401. interLock.isUpdateFirmwareGoing = ON;
  16402. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  16403. sleep(1);
  16404. }
  16405. else
  16406. DEBUG_WARN("Other UpdateFirmware request on going.\n");
  16407. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  16408. return result;
  16409. }
  16410. int handleUnknownRequest(char *uuid, char *payload)
  16411. {
  16412. mtrace();
  16413. int result = FAIL;
  16414. DEBUG_INFO("handleUnknownRequest...\n");
  16415. sendUnknownConfirmation(uuid);
  16416. result = PASS;
  16417. return result;
  16418. }
  16419. //==========================================
  16420. // Handle server response routine
  16421. //==========================================
  16422. void handleAuthorizeResponse(char *payload, int gun_index)
  16423. {
  16424. mtrace();
  16425. DEBUG_INFO("handleAuthorizeResponse...\n");
  16426. json_object *Authorize;
  16427. Authorize = json_tokener_parse(payload);
  16428. if(!is_error(Authorize))
  16429. {
  16430. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  16431. {
  16432. // Required data
  16433. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  16434. // Optional data
  16435. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  16436. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  16437. else
  16438. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  16439. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  16440. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  16441. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  16442. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  16443. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  16444. {
  16445. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  16446. {
  16447. ShmOCPP20Data->Authorize.Response_idTokenInfo.evseId[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "evseId"), idx));
  16448. }
  16449. }
  16450. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  16451. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  16452. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  16453. {
  16454. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  16455. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken")));
  16456. else
  16457. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  16458. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  16459. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type")));
  16460. }
  16461. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  16462. {
  16463. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  16464. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.personalMessage.format, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format")));
  16465. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  16466. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.personalMessage.language, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language")));
  16467. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  16468. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.personalMessage.content, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content")));
  16469. }
  16470. }
  16471. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  16472. {
  16473. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  16474. }
  16475. }
  16476. json_object_put(Authorize);
  16477. //Update idTag information to authorization cache if supported
  16478. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  16479. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  16480. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  16481. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  16482. {
  16483. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  16484. }
  16485. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  16486. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  16487. authorizeRetryTimes = 0;
  16488. }
  16489. void handleBootNotificationResponse(char *payload, int gun_index)
  16490. {
  16491. mtrace();
  16492. char statusStr[12]={0};
  16493. char currentTimeStr[30]={0};
  16494. int intervalInt = 0;
  16495. DEBUG_INFO("handleBootNotificationResponse...\n");
  16496. json_object *BootNotification;
  16497. BootNotification = json_tokener_parse(payload);
  16498. if(!is_error(BootNotification))
  16499. {
  16500. // Required data
  16501. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  16502. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  16503. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  16504. }
  16505. json_object_put(BootNotification);
  16506. DEBUG_INFO("statusStr: %s\n", statusStr);
  16507. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  16508. BootNotificationInterval = intervalInt;
  16509. //write back to ShmOCPP20Data->BootNotification
  16510. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  16511. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  16512. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  16513. {
  16514. if(intervalInt < (int)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.minLimit)
  16515. {
  16516. //Do nothing because the value is out of range.
  16517. }
  16518. else
  16519. {
  16520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value,"%d", HeartBeatWaitTime);
  16521. HeartBeatWaitTime = intervalInt;
  16522. DEBUG_INFO("BootNotificationResponse setting interval to %d...\n",intervalInt);
  16523. }
  16524. server_sign = TRUE;
  16525. server_pending =FALSE;
  16526. DB_updateBootType(BootReasonEnumType_PowerUp);
  16527. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = ON;
  16528. }
  16529. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  16530. {
  16531. server_pending = TRUE;
  16532. }
  16533. syncDateTimeRTC(ShmOCPP20Data->BootNotification.Response_currentTime);
  16534. srand(time(NULL));
  16535. refreshStartTimer(&clientTime.Heartbeat);
  16536. clientTime.Heartbeat.tv_sec -= (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  16537. SetOcppConnStatus(TRUE);
  16538. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  16539. }
  16540. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  16541. {
  16542. mtrace();
  16543. json_object *ClearedChargingLimit;
  16544. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  16545. ClearedChargingLimit = json_tokener_parse(payload);
  16546. if(!is_error(ClearedChargingLimit))
  16547. {
  16548. // Required data
  16549. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  16550. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  16551. }
  16552. json_object_put(ClearedChargingLimit);
  16553. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  16554. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitConf = ON;
  16555. }
  16556. void handleDataTransferResponse(char *payload, int gun_index)
  16557. {
  16558. mtrace();
  16559. json_object *DataTrans;
  16560. DEBUG_INFO("handleDataTransferResponse...\n");
  16561. DataTrans = json_tokener_parse(payload);
  16562. if(!is_error(DataTrans))
  16563. {
  16564. // Required data
  16565. if(json_object_object_get(DataTrans,"status") != NULL)
  16566. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  16567. // Optional data
  16568. if(json_object_object_get(DataTrans,"data") != NULL)
  16569. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  16570. }
  16571. json_object_put(DataTrans);
  16572. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  16573. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  16574. }
  16575. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  16576. {
  16577. mtrace();
  16578. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  16579. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  16580. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  16581. }
  16582. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  16583. {
  16584. mtrace();
  16585. json_object *Get15118EVCertificate;
  16586. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  16587. Get15118EVCertificate = json_tokener_parse(payload);
  16588. if(!is_error(Get15118EVCertificate))
  16589. {
  16590. // Required data
  16591. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  16592. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  16593. // Optional data
  16594. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  16595. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  16596. }
  16597. json_object_put(Get15118EVCertificate);
  16598. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  16599. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  16600. }
  16601. void handleGetCertificateStatusResponse(char *payload, int gun_index)
  16602. {
  16603. mtrace();
  16604. json_object *GetCertificateStatus;
  16605. DEBUG_INFO("handleGetCertificateStatusResponse...\n");
  16606. GetCertificateStatus = json_tokener_parse(payload);
  16607. if(!is_error(GetCertificateStatus))
  16608. {
  16609. // Required data
  16610. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  16611. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  16612. // Optional data
  16613. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  16614. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  16615. if(json_object_object_get(GetCertificateStatus,"statusInfo") != NULL)
  16616. {
  16617. if(json_object_object_get(json_object_object_get(GetCertificateStatus,"statusInfo"), "reasonCode") != NULL)
  16618. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_statusInfo.reasonCode, json_object_get_string(json_object_object_get(json_object_object_get(GetCertificateStatus,"ocspResult"), "reasonCode")));
  16619. if(json_object_object_get(json_object_object_get(GetCertificateStatus,"statusInfo"), "additionalInfo") != NULL)
  16620. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_statusInfo.additionalInfo, json_object_get_string(json_object_object_get(json_object_object_get(GetCertificateStatus,"ocspResult"), "additionalInfo")));
  16621. }
  16622. }
  16623. json_object_put(GetCertificateStatus);
  16624. if(strstr((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, GetCertificateStatusEnumTypeStr[GetCertificateStatusEnumType_Accepted]) != NULL)
  16625. {
  16626. /*
  16627. * TODO:
  16628. * 1. If get certificate response accepted process something here
  16629. */
  16630. }
  16631. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  16632. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  16633. }
  16634. void handleHeartbeatResponse(char *payload, int gun_index)
  16635. {
  16636. mtrace();
  16637. DEBUG_INFO("handleHeartbeatResponse...\n");
  16638. json_object *Heartbeat;
  16639. Heartbeat = json_tokener_parse(payload);
  16640. if(!is_error(Heartbeat))
  16641. {
  16642. // Required data
  16643. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  16644. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  16645. }
  16646. json_object_put(Heartbeat);
  16647. if(FirstHeartBeat == OFF)
  16648. {
  16649. FirstHeartBeat = ON;
  16650. DEBUG_INFO("FirstHeartBeat \n");
  16651. }
  16652. HeartBeatWithNOResponse = 0;
  16653. refreshStartTimer(&clientTime.Heartbeat);
  16654. syncDateTimeRTC(ShmOCPP20Data->Heartbeat.Response_currentTime);
  16655. }
  16656. void handleLogStatusNotificationResponse(char *payload, int gun_index)
  16657. {
  16658. mtrace();
  16659. DEBUG_INFO("handleLogStatusNotificationResponse...\n");
  16660. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  16661. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  16662. }
  16663. void handleMeterValuesResponse(char *payload, int gun_index)
  16664. {
  16665. mtrace();
  16666. DEBUG_INFO("handleMeterValuesResponse...\n");
  16667. isQueueSendable = ON;
  16668. }
  16669. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  16670. {
  16671. mtrace();
  16672. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  16673. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  16674. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  16675. }
  16676. void handleNotifyCustomerInformationResponse(char *payload, int gun_index)
  16677. {
  16678. mtrace();
  16679. DEBUG_INFO("handleNotifyCustomerInformationResponse...\n");
  16680. }
  16681. void handleNotifyDisplayMessagesResponse(char *payload, int gun_index)
  16682. {
  16683. mtrace();
  16684. DEBUG_INFO("handleNotifyDisplayMessagesResponse...\n");
  16685. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  16686. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  16687. }
  16688. void handleNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  16689. {
  16690. mtrace();
  16691. json_object *NotifyEVChargingNeeds;
  16692. DEBUG_INFO("handleNotifyEVChargingNeedsResponse...\n");
  16693. NotifyEVChargingNeeds = json_tokener_parse(payload);
  16694. if(!is_error(NotifyEVChargingNeeds))
  16695. {
  16696. // Required data
  16697. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  16698. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  16699. }
  16700. json_object_put(NotifyEVChargingNeeds);
  16701. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  16702. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  16703. }
  16704. void handleNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  16705. {
  16706. mtrace();
  16707. json_object *NotifyEVChargingSchedule;
  16708. DEBUG_INFO("handleNotifyEVChargingScheduleResponse...\n");
  16709. NotifyEVChargingSchedule = json_tokener_parse(payload);
  16710. if(!is_error(NotifyEVChargingSchedule))
  16711. {
  16712. // Required data
  16713. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  16714. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  16715. }
  16716. json_object_put(NotifyEVChargingSchedule);
  16717. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  16718. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  16719. }
  16720. void handleNotifyEventResponse(char *payload, int gun_index)
  16721. {
  16722. mtrace();
  16723. DEBUG_INFO("handleNotifyEventResponse...\n");
  16724. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  16725. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  16726. }
  16727. void handleNotifyMonitoringReportResponse(char *payload, int gun_index)
  16728. {
  16729. mtrace();
  16730. DEBUG_INFO("handleNotifyMonitoringReportResponse...\n");
  16731. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  16732. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  16733. }
  16734. void handleNotifyReportResponse(char *payload, int gun_index)
  16735. {
  16736. mtrace();
  16737. DEBUG_INFO("handleNotifyReportResponse...\n");
  16738. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  16739. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  16740. }
  16741. void handlePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  16742. {
  16743. mtrace();
  16744. DEBUG_INFO("handlePublishFirmwareStatusNotificationResponse...\n");
  16745. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  16746. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  16747. }
  16748. void handleReportChargingProfilesResponse(char *payload, int gun_index)
  16749. {
  16750. mtrace();
  16751. DEBUG_INFO("handleReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  16752. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  16753. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  16754. }
  16755. void handleReservationStatusUpdateResponse(char *payload, int gun_index)
  16756. {
  16757. mtrace();
  16758. DEBUG_INFO("handleReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  16759. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  16760. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  16761. }
  16762. void handleSecurityEventNotificationResponse(char *payload, int gun_index)
  16763. {
  16764. mtrace();
  16765. DEBUG_INFO("handleSecurityEventNotificationResponse...\n");
  16766. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  16767. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  16768. DB_updateSecurityEventType(SecurityEventEnumType_ResetOrReboot);
  16769. }
  16770. void handleSignCertificateResponse(char *payload, int gun_index)
  16771. {
  16772. mtrace();
  16773. json_object *SignCertificate;
  16774. DEBUG_INFO("handleSignCertificateResponse...\n");
  16775. SignCertificate = json_tokener_parse(payload);
  16776. if(!is_error(SignCertificate))
  16777. {
  16778. // Required data
  16779. if(json_object_object_get(SignCertificate,"status") != NULL)
  16780. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  16781. // Optional data
  16782. if(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "reasonCode") != NULL)
  16783. {
  16784. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_statusInfo.reasonCode, json_object_get_string(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "reasonCode")));
  16785. if(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "additionalInfo") != NULL)
  16786. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_statusInfo.additionalInfo, json_object_get_string(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "additionalInfo")));
  16787. }
  16788. }
  16789. json_object_put(SignCertificate);
  16790. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  16791. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  16792. }
  16793. void handleStatusNotificationResponse(char *payload, int gun_index)
  16794. {
  16795. mtrace();
  16796. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  16797. //cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  16798. //cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  16799. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  16800. }
  16801. void handleTransactionEventResponse(char *payload, int gun_index)
  16802. {
  16803. mtrace();
  16804. json_object *TransactionEven;
  16805. DEBUG_INFO("handleTransactionEventResponse...\n");
  16806. TransactionEven = json_tokener_parse(payload);
  16807. if(!is_error(TransactionEven))
  16808. {
  16809. // Required data
  16810. // Optional data
  16811. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  16812. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  16813. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  16814. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  16815. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  16816. {
  16817. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  16818. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  16819. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  16820. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  16821. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  16822. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  16823. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  16824. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  16825. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  16826. {
  16827. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  16828. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.groupIdToken.idToken, json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken")));
  16829. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  16830. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.groupIdToken.type, json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type")));
  16831. }
  16832. }
  16833. if(json_object_object_get(TransactionEven,"updatedPersonalMessage") != NULL)
  16834. {
  16835. if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "format") != NULL)
  16836. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.format, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "format")));
  16837. if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "language") != NULL)
  16838. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.language, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "language")));
  16839. if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "content") != NULL)
  16840. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.content, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "content")));
  16841. }
  16842. }
  16843. json_object_put(TransactionEven);
  16844. isQueueSendable = ON;
  16845. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  16846. }
  16847. //==========================================
  16848. // Handle Error routine
  16849. //==========================================
  16850. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  16851. {
  16852. mtrace();
  16853. #ifdef SystemLogMessage
  16854. DEBUG_INFO("errorCode: %s\n", errorCode);
  16855. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  16856. DEBUG_INFO("errorDetails: %s\n", payload);
  16857. #endif
  16858. }
  16859. //===============================================
  16860. // Common routine
  16861. //===============================================
  16862. int initialConfigurationTable(void)
  16863. {
  16864. DEBUG_INFO("initialConfigurationTable...\n");
  16865. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  16866. DB_variableIsCreate();
  16867. DB_variableLoadFromDb();
  16868. if(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].value) != variableVersion)
  16869. {
  16870. DEBUG_WARN("EVSE variable version in local db older than firmware.\n");
  16871. DB_variableClear();
  16872. DB_variableIsCreate();
  16873. DB_variableLoadFromDb();
  16874. }
  16875. DB_getNetworkProfileFromDb();
  16876. return 0;
  16877. }
  16878. int TransactionMessageAttemptsGet(void)
  16879. {
  16880. return TransactionMessageAttemptsValue;
  16881. }
  16882. int FirstHeartBeatResponse(void)
  16883. {
  16884. return FirstHeartBeat;
  16885. }
  16886. int TransactionMessageRetryIntervalGet(void)
  16887. {
  16888. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  16889. }
  16890. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  16891. {
  16892. int result = TRUE;
  16893. char rmFileCmd[100]={0};
  16894. char FilePath[100]={0};
  16895. char ftpbuf[200];
  16896. int systemresult;
  16897. sprintf(FilePath,"/mnt/%s",filename);
  16898. system("ping 8.8.8.8 &");
  16899. if((access(FilePath,F_OK))!=-1)
  16900. {
  16901. DEBUG_INFO("filename=%s exist.\n",FilePath);
  16902. sprintf(rmFileCmd,"rm -f %s",FilePath);
  16903. system(rmFileCmd);
  16904. }
  16905. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  16906. sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
  16907. DEBUG_INFO("Download command: %s\n",ftpbuf);
  16908. systemresult = system(ftpbuf);
  16909. if(systemresult != 0)
  16910. {
  16911. DEBUG_INFO("HTTP/HTTPS download fail!\n");
  16912. result = FALSE;
  16913. }
  16914. system("pkill ping");
  16915. return result;
  16916. }
  16917. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  16918. {
  16919. int result = TRUE;
  16920. char rmFileCmd[100]={0};
  16921. char FilePath[100]={0};
  16922. char ftpbuf[200];
  16923. int systemresult;
  16924. sprintf(FilePath,"/mnt/%s",filename);
  16925. system("ping 8.8.8.8 &");
  16926. if((access(FilePath,F_OK))!=-1)
  16927. {
  16928. DEBUG_INFO("filename=%s exist.\n",FilePath);
  16929. sprintf(rmFileCmd,"rm -f %s",FilePath);
  16930. system(rmFileCmd);
  16931. }
  16932. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  16933. sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120",filename, url);
  16934. DEBUG_INFO("Download command: %s\n",ftpbuf);
  16935. systemresult = system(ftpbuf);
  16936. if(systemresult != 0)
  16937. {
  16938. sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-passive-ftp",filename, url);
  16939. DEBUG_INFO("Download command: %s\n",ftpbuf);
  16940. systemresult = system(ftpbuf);
  16941. if(systemresult != 0)
  16942. {
  16943. DEBUG_WARN("FTP download fail!\n");
  16944. result = FALSE;
  16945. }
  16946. }
  16947. system("pkill ping");
  16948. return result;
  16949. }
  16950. int httpUploadFile(char *location, char *path, char *filename,char *url)
  16951. {
  16952. char rmFileCmd[100]={0};
  16953. char FilePath[100]={0};
  16954. char buf[512];
  16955. int systemresult = 0;
  16956. //DEBUG_INFO("filename=%s\n",filename);
  16957. //DEBUG_INFO("url=%s\n",url);
  16958. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  16959. if((access(FilePath,F_OK))!=-1)
  16960. {
  16961. DEBUG_INFO("filename=%s exist.\n",FilePath);
  16962. sprintf(rmFileCmd,"rm -f %s",FilePath);
  16963. system(rmFileCmd);
  16964. }
  16965. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  16966. if(fp == NULL)
  16967. {
  16968. DEBUG_INFO("log is NULL\n");
  16969. return FALSE;
  16970. }
  16971. else
  16972. {
  16973. fprintf(fp, "%s\n", url);
  16974. fprintf(fp, "%s\n", filename);
  16975. fclose(fp);
  16976. }
  16977. FILE *phpFP = popen("/bin/php-cgi /var/www/ocpp_upload.php", "r");
  16978. if(phpFP == NULL)
  16979. {
  16980. DEBUG_INFO("PHP upload fail.\n");
  16981. return FALSE;
  16982. }
  16983. else
  16984. {
  16985. while(fgets(buf, sizeof(buf), phpFP) != NULL)
  16986. {
  16987. if(strstr(buf, "result") != NULL)
  16988. {
  16989. sscanf(buf, "result: %d", &systemresult);
  16990. DEBUG_INFO("PHP HTTP upload result: %d\n", systemresult);
  16991. }
  16992. }
  16993. pclose(phpFP);
  16994. }
  16995. if(systemresult != 1)
  16996. {
  16997. DEBUG_WARN("HTTP POST upload error, change to PUT method\n");
  16998. FILE *phpFP = popen("/bin/php-cgi /var/www/ocpp_upload_put.php", "r");
  16999. if(phpFP == NULL)
  17000. {
  17001. DEBUG_WARN("PHP PUT upload fail.\n");
  17002. return FALSE;
  17003. }
  17004. else
  17005. {
  17006. while(fgets(buf, sizeof(buf), phpFP) != NULL)
  17007. {
  17008. if(strstr(buf, "result") != NULL)
  17009. {
  17010. sscanf(buf, "result: %d", &systemresult);
  17011. DEBUG_INFO("PHP HTTP PUT upload result: %d\n", systemresult);
  17012. }
  17013. }
  17014. pclose(phpFP);
  17015. }
  17016. }
  17017. if(systemresult != 1)
  17018. {
  17019. DEBUG_WARN("PHP PUT upload fail.\n");
  17020. return FALSE;
  17021. }
  17022. return TRUE;
  17023. }
  17024. int ftpUploadFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  17025. {
  17026. int result = FALSE;
  17027. char ftpbuf[200];
  17028. int systemresult;
  17029. /*
  17030. // Domaind name transfer to IP address
  17031. struct hostent* server;
  17032. char *IPbuffer;
  17033. server = gethostbyname(location);
  17034. IPbuffer = inet_ntoa(*((struct in_addr*)server->h_addr_list[0]));*/
  17035. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  17036. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s", user, password, location, port/*21*/, path, filename, fnamePlusPath);
  17037. DEBUG_INFO("ftp command: %s\n",ftpbuf);
  17038. systemresult = system(ftpbuf);
  17039. if(systemresult != 0)
  17040. {
  17041. DEBUG_INFO("ftpput error!\n");
  17042. }
  17043. else
  17044. {
  17045. result = TRUE;
  17046. DEBUG_INFO("ftpput OK!\n");
  17047. }
  17048. return result;
  17049. }
  17050. //=========================================
  17051. // Routine
  17052. //=========================================
  17053. int GetOcppServerURL()
  17054. {
  17055. int result = FALSE;
  17056. struct yuarel url;
  17057. char urlStr[512];
  17058. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  17059. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  17060. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  17061. if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  17062. {
  17063. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  17064. if(yuarel_parse(&url, urlStr) != -1)
  17065. {
  17066. sprintf(OcppProtocol, "%s", url.scheme);
  17067. sprintf(OcppHost, "%s", url.host);
  17068. if(url.path == NULL)
  17069. OcppTempPath[0] = '\0';
  17070. else
  17071. sprintf(OcppTempPath, "%s", url.path);
  17072. if(url.port == 0)
  17073. {
  17074. if(strcmp(OcppProtocol, "wss") == 0)
  17075. OcppPort = 443;
  17076. else
  17077. OcppPort = 80;
  17078. }
  17079. else
  17080. OcppPort = url.port;
  17081. result = TRUE;
  17082. }
  17083. }
  17084. else
  17085. {
  17086. strcpy(OcppHost,"");
  17087. }
  17088. return result;
  17089. }
  17090. int GetOcppPath()
  17091. {
  17092. int result = FALSE;
  17093. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  17094. {
  17095. if(OcppTempPath == NULL)
  17096. {
  17097. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  17098. }
  17099. else
  17100. {
  17101. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  17102. }
  17103. result = TRUE;
  17104. }
  17105. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  17106. {
  17107. if(OcppTempPath == NULL)
  17108. {
  17109. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  17110. }
  17111. else
  17112. {
  17113. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  17114. }
  17115. result = TRUE;
  17116. }
  17117. else
  17118. {
  17119. strcpy(OcppPath,"");
  17120. }
  17121. return result;
  17122. }
  17123. int GetOcppPort()
  17124. {
  17125. return OcppPort;
  17126. }
  17127. int GetOcppConnStatus(void)
  17128. {
  17129. return ShmOCPP20Data->OcppConnStatus;
  17130. }
  17131. void SetOcppConnStatus(uint8_t status)
  17132. {
  17133. ShmOCPP20Data->OcppConnStatus = status;
  17134. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  17135. }
  17136. int GetHeartBeatWithNOResponse(void)
  17137. {
  17138. return HeartBeatWithNOResponse;
  17139. }
  17140. void SetHeartBeatWithNOResponse(void)
  17141. {
  17142. HeartBeatWithNOResponse = 0;
  17143. }
  17144. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  17145. void storeTempStopTransaction(int gun_index)
  17146. {
  17147. char TempStopTransaction[256];
  17148. char message[1024*20]={0};
  17149. char guid[37]={0};
  17150. json_object *TransactionEvent = json_object_new_object();
  17151. json_object *transactionInfo = json_object_new_object();
  17152. json_object *idToken = json_object_new_object();
  17153. json_object *evse = json_object_new_object();
  17154. json_object *meterValues = json_object_new_array();
  17155. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
  17156. DEBUG_INFO("storeTempStopTransaction...\n");
  17157. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  17158. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  17159. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  17160. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  17161. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  17162. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  17163. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  17164. // Message
  17165. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  17166. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  17167. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  17168. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo+1));
  17169. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  17170. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  17171. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  17172. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  17173. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  17174. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  17175. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  17176. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  17177. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  17178. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  17179. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  17180. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  17181. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  17182. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  17183. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  17184. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  17185. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  17186. {
  17187. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  17188. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  17189. json_object_object_add(TransactionEvent, "idToken", idToken);
  17190. }
  17191. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  17192. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  17193. json_object_object_add(TransactionEvent, "evse", evse);
  17194. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  17195. {
  17196. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  17197. {
  17198. json_object *meterValue = json_object_new_object();
  17199. json_object *sampledValues = json_object_new_array();
  17200. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  17201. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  17202. {
  17203. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  17204. ((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) == 0) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) == 0) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) == 0)))
  17205. {
  17206. if(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, (char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) != NULL)
  17207. {
  17208. json_object *sampledValue = json_object_new_object();
  17209. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  17210. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  17211. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  17212. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  17213. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  17214. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  17215. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  17216. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  17217. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  17218. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  17219. {
  17220. json_object *unitOfMeasure = json_object_new_object();
  17221. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  17222. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  17223. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  17224. }
  17225. json_object_array_add(sampledValues, sampledValue);
  17226. }
  17227. }
  17228. }
  17229. json_object_object_add(meterValue, "sampledValue", sampledValues);
  17230. json_object_array_add(meterValues, meterValue);
  17231. }
  17232. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  17233. }
  17234. random_uuid(guid);
  17235. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL
  17236. , guid
  17237. , "TransactionEvent"
  17238. , json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  17239. json_object_put(TransactionEvent);
  17240. // open file for writing
  17241. FILE *outfile;
  17242. outfile = fopen (TempStopTransaction, "w+");
  17243. //DEBUG_INFO("data = %s\n", queuedata);
  17244. fputs(message, outfile);
  17245. fputs("\n", outfile);
  17246. fclose (outfile);
  17247. }
  17248. void checkTempStopTransaction(int gun_index)
  17249. {
  17250. FILE *fptr1;
  17251. char ch;
  17252. char str[QUEUE_MESSAGE_LENGTH]={0};
  17253. char guid[37]={0};
  17254. char tempdata[65]={0};
  17255. char TempStopTransaction[256];
  17256. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
  17257. fptr1 = fopen(TempStopTransaction, "r");
  17258. if (!fptr1)
  17259. {
  17260. //DEBUG_INFO("TempStopTransaction20_%d not found or unable to open the input file!\n", (gun_index+1));
  17261. return ;
  17262. }
  17263. ch=fgetc(fptr1);
  17264. rewind(fptr1);
  17265. if(ch!=EOF)
  17266. {
  17267. // copy all contents to the temporary file except the specific line
  17268. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  17269. {
  17270. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  17271. if(str[0]=='\0')
  17272. {
  17273. break;
  17274. }
  17275. strncpy(guid, str+4, 36); //copy guid
  17276. sprintf(tempdata, "TransactionEvent,%d", (gun_index));
  17277. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  17278. {
  17279. //DEBUG_INFO("StopTransaction mapitem pass\n");
  17280. }
  17281. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  17282. memset(str,0,ARRAY_SIZE(str));
  17283. }
  17284. }
  17285. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  17286. fclose(fptr1);
  17287. remove(TempStopTransaction); // remove the original file
  17288. }
  17289. int GetWebSocketPingInterval(void)
  17290. {
  17291. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  17292. }
  17293. int GetServerSign(void)
  17294. {
  17295. return server_sign;
  17296. }
  17297. uint8_t GetOcppSecurityProfile()
  17298. {
  17299. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  17300. }
  17301. void GetOcppChargerBoxId(uint8_t *data)
  17302. {
  17303. sprintf((char*)data, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  17304. }
  17305. void GetOcppSecurityPassword(uint8_t *data)
  17306. {
  17307. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  17308. }
  17309. void SetServerSign(int value)
  17310. {
  17311. server_sign = value;
  17312. }
  17313. int GetBootNotificationInterval(void)
  17314. {
  17315. return BootNotificationInterval;
  17316. }
  17317. int GetInternetConn(void)
  17318. {
  17319. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  17320. }
  17321. int GetBackendConnectionTimeout(void)
  17322. {
  17323. return ShmSysConfigAndInfo->SysConfig.BackendConnTimeout>=0?ShmSysConfigAndInfo->SysConfig.BackendConnTimeout:300;
  17324. }
  17325. int isConnectorInitMode(int gun_index)
  17326. {
  17327. int tempIndex = 0;
  17328. int result = TRUE;
  17329. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  17330. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  17331. {
  17332. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  17333. {
  17334. tempIndex = ((gun_index==2) ? 1: 0);
  17335. }
  17336. else
  17337. {
  17338. tempIndex = gun_index;
  17339. }
  17340. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  17341. {
  17342. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  17343. {
  17344. result = (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  17345. } //end of the same index
  17346. }//end of for CHAdeMO_QUANTITY
  17347. }
  17348. else if(gunType[gun_index] == GUN_TYPE_CCS)
  17349. {
  17350. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  17351. {
  17352. tempIndex = ((gun_index==2) ? 1: 0);
  17353. }
  17354. else
  17355. {
  17356. tempIndex = gun_index;
  17357. }
  17358. for (int index = 0; index < CCS_QUANTITY; index++)
  17359. {
  17360. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  17361. {
  17362. result = (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  17363. } //end of the same index
  17364. } // end of for CCS_QUANTITY
  17365. }
  17366. else if(gunType[gun_index] == GUN_TYPE_GBT)
  17367. {
  17368. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  17369. {
  17370. tempIndex = ((gun_index==2) ? 1: 0);
  17371. }
  17372. else
  17373. {
  17374. tempIndex = gun_index;
  17375. }
  17376. for (int index = 0; index < GB_QUANTITY; index++)
  17377. {
  17378. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  17379. {
  17380. result = (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  17381. } //end of the same index
  17382. } // end of for GB_QUANTITY
  17383. }
  17384. else if(gunType[gun_index] == GUN_TYPE_DO)
  17385. {
  17386. tempIndex = gun_index;
  17387. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  17388. {
  17389. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  17390. {
  17391. result = (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  17392. } //end of the same index
  17393. }
  17394. }
  17395. else
  17396. {
  17397. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  17398. {
  17399. tempIndex = 2;
  17400. }
  17401. else
  17402. {
  17403. tempIndex = gun_index;
  17404. }
  17405. for (int index = 0; index < AC_QUANTITY; index++)
  17406. {
  17407. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  17408. {
  17409. result = (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  17410. }//end of the same index
  17411. }//end of for AC_QUANTITY
  17412. }
  17413. return result;
  17414. }
  17415. void refreshProcDogTimer()
  17416. {
  17417. ShmOCPP20Data->procDogTime = time((time_t*)NULL);
  17418. }
  17419. void InitialSystemValue(void)
  17420. {
  17421. localversion=0;
  17422. BootNotificationInterval = 10;
  17423. authorizeRetryTimes = 0;
  17424. GunStatusInterval = 10;
  17425. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  17426. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  17427. //Hear Beat
  17428. HeartBeatWithNOResponse = 0;
  17429. HeartBeatCountPerHour = 0;
  17430. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  17431. FirstHeartBeat = 0;
  17432. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  17433. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  17434. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  17435. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  17436. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  17437. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  17438. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  17439. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  17440. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  17441. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  17442. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  17443. //Status && ConnectorPlugIn Setting
  17444. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  17445. {
  17446. ChademoPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  17447. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  17448. }
  17449. for (int index = 0; index < CCS_QUANTITY; index++)
  17450. {
  17451. CcsPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  17452. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  17453. }
  17454. for (int index = 0; index < GB_QUANTITY; index++)
  17455. {
  17456. GbPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  17457. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  17458. }
  17459. for (int index = 0; index < AC_QUANTITY; index++)
  17460. {
  17461. AcPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  17462. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  17463. }
  17464. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  17465. {
  17466. DoPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  17467. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  17468. }
  17469. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  17470. {
  17471. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  17472. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  17473. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  17474. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  17475. refreshStartTimer(&clientTime.StatusNotification[gun_index]);
  17476. //memset(&ShmOCPP20Data->StatusNotification[gun_index], 0x00, sizeof(struct StatusNotification_20));
  17477. memset(&ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, 0x00, sizeof(ShmOCPP20Data->StatusNotification[gun_index].connectorStatus));
  17478. }
  17479. refreshStartTimer(&clientTime.Heartbeat);
  17480. sleep(1);
  17481. }
  17482. void LWS_Send(char *str)
  17483. {
  17484. //=====================================================
  17485. // Check InternetConn 0: disconnected, 1: connected
  17486. //====================================================
  17487. if(GetOcppConnStatus() == 0)
  17488. {
  17489. DEBUG_INFO("offline now !!!\n");
  17490. return;
  17491. }
  17492. // Only disable isWebsocketSendable operation initiated by charger
  17493. if((strstr((char*)str, "\"Authorize\"") != NULL)
  17494. || (strstr((char*)str, "\"BootNotification\"") != NULL)
  17495. || (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
  17496. || (strstr((char*)str, "\"DataTransfer\"") != NULL)
  17497. || (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
  17498. || (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
  17499. || (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
  17500. || (strstr((char*)str, "\"Heartbeat\"") != NULL)
  17501. || (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
  17502. || (strstr((char*)str, "\"MeterValues\"") != NULL)
  17503. || (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
  17504. || (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
  17505. || (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
  17506. || (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
  17507. || (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
  17508. || (strstr((char*)str, "\"NotifyEvent\"") != NULL)
  17509. || (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
  17510. || (strstr((char*)str, "\"NotifyReport\"") != NULL)
  17511. || (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
  17512. || (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
  17513. || (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
  17514. || (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
  17515. || (strstr((char*)str, "\"SignCertificate\"") != NULL)
  17516. || (strstr((char*)str, "\"StatusNotification\"") != NULL)
  17517. || (strstr((char*)str, "\"TransactionEvent\"") != NULL))
  17518. {
  17519. isWebsocketSendable = OFF;
  17520. }
  17521. pthread_mutex_lock(&lock_send);
  17522. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  17523. sprintf((char *)SendBuffer, "%s", str);
  17524. SendBufLen = strlen(str);
  17525. pthread_mutex_unlock(&lock_send);
  17526. lws_callback_on_writable(wsi_client);
  17527. //lws_service(context, 0);
  17528. //sleep(1);
  17529. }
  17530. void LWS_SendNow(char *str)
  17531. {
  17532. //=====================================================
  17533. // Check InternetConn 0: disconnected, 1: connected
  17534. //====================================================
  17535. if(GetOcppConnStatus() == 0)
  17536. {
  17537. DEBUG_INFO("offline now !!!\n");
  17538. return;
  17539. }
  17540. // Only disable isWebsocketSendable operation initiated by charger
  17541. if((strstr((char*)str, "\"Authorize\"") != NULL)
  17542. || (strstr((char*)str, "\"BootNotification\"") != NULL)
  17543. || (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
  17544. || (strstr((char*)str, "\"DataTransfer\"") != NULL)
  17545. || (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
  17546. || (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
  17547. || (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
  17548. || (strstr((char*)str, "\"Heartbeat\"") != NULL)
  17549. || (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
  17550. || (strstr((char*)str, "\"MeterValues\"") != NULL)
  17551. || (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
  17552. || (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
  17553. || (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
  17554. || (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
  17555. || (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
  17556. || (strstr((char*)str, "\"NotifyEvent\"") != NULL)
  17557. || (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
  17558. || (strstr((char*)str, "\"NotifyReport\"") != NULL)
  17559. || (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
  17560. || (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
  17561. || (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
  17562. || (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
  17563. || (strstr((char*)str, "\"SignCertificate\"") != NULL)
  17564. || (strstr((char*)str, "\"StatusNotification\"") != NULL)
  17565. || (strstr((char*)str, "\"TransactionEvent\"") != NULL))
  17566. {
  17567. isWebsocketSendable = OFF;
  17568. }
  17569. pthread_mutex_lock(&lock_send);
  17570. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  17571. sprintf((char *)SendBuffer, "%s", str);
  17572. SendBufLen = strlen(str);
  17573. pthread_mutex_unlock(&lock_send);
  17574. lws_callback_on_writable(wsi_client);
  17575. lws_service(context, 0);
  17576. //sleep(1);
  17577. }