MessageHandler.c 1.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436
  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. MACROSTR(AcceptedCanceled)
  636. };
  637. static char *VPNEnumTypeStr[] = {
  638. MACROSTR(IKEv2),
  639. MACROSTR(IPSec),
  640. MACROSTR(L2TP),
  641. MACROSTR(PPTP)
  642. };
  643. #if 0
  644. static char *ChargePointErrorCodeEnumTypeStr[] = {
  645. MACROSTR(ConnectorLockFailure),
  646. MACROSTR(EVCommunicationError),
  647. MACROSTR(GroundFailure),
  648. MACROSTR(HighTemperature),
  649. MACROSTR(InternalError),
  650. MACROSTR(LocalListConflict),
  651. MACROSTR(NoError),
  652. MACROSTR(OtherError),
  653. MACROSTR(OverCurrentFailure),
  654. MACROSTR(OverVoltage),
  655. MACROSTR(PowerMeterFailure),
  656. MACROSTR(PowerSwitchFailure),
  657. MACROSTR(ReaderFailure),
  658. MACROSTR(ResetFailure),
  659. MACROSTR(UnderVoltage),
  660. MACROSTR(WeakSignal)
  661. };
  662. #endif
  663. static char *GetCompositeScheduleStatusEnumTypeStr[] = {
  664. MACROSTR(Accepted),
  665. MACROSTR(Rejected)
  666. };
  667. static char *RemoteStartStopStatusEnumTypeStr[] = {
  668. MACROSTR(Accepted),
  669. MACROSTR(Rejected)
  670. };
  671. #if 0
  672. static char * StopTransactionReasonEnumTypeStr[] = {
  673. MACROSTR(EmergencyStop),
  674. MACROSTR(EVDisconnected),
  675. MACROSTR(HardReset),
  676. MACROSTR(Local),
  677. MACROSTR(Other),
  678. MACROSTR(PowerLoss),
  679. MACROSTR(Reboot),
  680. MACROSTR(Remote),
  681. MACROSTR(SoftReset),
  682. MACROSTR(UnlockCommand),
  683. MACROSTR(DeAuthorized)
  684. };
  685. #endif
  686. //ChargePointMaxProfile
  687. #define ChargingStationMaxProfile_JSON "/Storage/OCPP/ChargingStationMaxProfile_OCPP20.json"
  688. //TxDefaultProfile
  689. #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0_OCPP20.json"
  690. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  691. struct StatusCodeData *ShmStatusCodeData;
  692. struct PsuData *ShmPsuData ;
  693. struct OCPP20Data *ShmOCPP20Data;
  694. pthread_mutex_t lock_send = PTHREAD_MUTEX_INITIALIZER;
  695. char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
  696. //===============================
  697. // Gun Total Numbers
  698. //===============================
  699. static ParsingRatedCur modelnameInfo = {0};
  700. static int gunTotalNumber = 0;
  701. static uint8_t gunType[4] = {0};
  702. //===============================
  703. // Local List Version
  704. //===============================
  705. static int localversion=0;
  706. //===============================
  707. // Variable Version
  708. //===============================
  709. static int variableVersion=7;
  710. //===============================
  711. // OCPP sign variable
  712. //===============================
  713. static int server_sign = FALSE;
  714. int server_pending = FALSE;
  715. static int BootNotificationInterval = 10;
  716. //===============================
  717. // OCPP auth variable
  718. //===============================
  719. static int authorizeRetryTimes = 0; //number of Retry times
  720. //===============================
  721. // OCPP other variables
  722. //===============================
  723. static int HeartBeatWaitTime = 10;
  724. static int FirstHeartBeat = 0;
  725. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  726. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  727. static char CurrentChargingProfileScheduleStr[30] = {0};
  728. static int isCancelUploadLog = FALSE;
  729. pthread_t th_GetLog;
  730. //========================================
  731. // OCPP status/previous related variables
  732. //========================================
  733. static int GunStatusInterval = 10;
  734. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  735. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  736. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  737. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  738. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  739. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  740. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  741. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  742. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  743. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  744. static int TransactionMessageAttemptsValue = 0;
  745. static int TransactionMessageRetryIntervalValue = 0;
  746. static struct AuthorizationData idTagQuery;
  747. static float periousPeriodicPowerConsumption[CONNECTOR_QUANTITY] = {0};
  748. static float periousClockPowerConsumption[CONNECTOR_QUANTITY] = {0};
  749. //=============================================
  750. // OCPP HeartBeat Response Not Receive Counts
  751. //============================================
  752. static int HeartBeatWithNOResponse = 0;
  753. static int HeartBeatCountPerHour = 0;
  754. sqlite3 *db;
  755. int TransactionMessageAttemptsGet(void);
  756. int TransactionMessageRetryIntervalGet(void);
  757. int GetOcppConnStatus(void);
  758. void SetOcppConnStatus(uint8_t status);
  759. int setKeyValue(char *key, char *value);
  760. void OCPP_get_TableAuthlocalAllData(void);
  761. void processUnkownKey(void);
  762. struct InterLock
  763. {
  764. unsigned char isGetLogGoing:1;
  765. unsigned char isUpdateFirmwareGoing:1;
  766. }interLock;
  767. struct ClientTime
  768. {
  769. struct timespec Heartbeat;
  770. struct timespec StatusNotification[CONNECTOR_QUANTITY];
  771. struct timespec StartTransaction;
  772. struct timespec StopTransaction;
  773. struct timespec MeterValues[CONNECTOR_QUANTITY];
  774. struct timespec RemoteStartWait;
  775. }clientTime;
  776. typedef union
  777. {
  778. //Operations Initiated by Central System
  779. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  780. struct
  781. {
  782. //CsMsgValue[0]
  783. unsigned char StatusNotificationReq:1; //bit 0,
  784. unsigned char StatusNotificationConf:1; //bit 1,
  785. unsigned char TriggerMeterValueReq:1; //bit 2,
  786. unsigned char SampleMeterReq:1; //bit 3,
  787. unsigned char ClockAlignMeterReq:1; //bit 4,
  788. unsigned char TriggerStatusNotificationReq:1; //bit 5,
  789. unsigned char isOnCharging:1; //bit 6,
  790. unsigned char TriggerTransactionEventReq:1; //bit 7
  791. }bits[CONNECTOR_QUANTITY];
  792. }CpinitiateMsg;
  793. CpinitiateMsg cpinitateMsg;
  794. //=========================================
  795. // Save configuration
  796. //=========================================
  797. int runShellCmd(const char*cmd)
  798. {
  799. int result = FAIL;
  800. char buf[256];
  801. FILE *fp;
  802. fp = popen(cmd, "r");
  803. if(fp != NULL)
  804. {
  805. while(fgets(buf, sizeof(buf), fp) != NULL)
  806. {
  807. DEBUG_INFO("%s\n", buf);
  808. }
  809. result = PASS;
  810. }
  811. pclose(fp);
  812. return result;
  813. }
  814. int StoreUsrConfigData(struct SysConfigData *UsrData)
  815. {
  816. int result = PASS;
  817. int fd,wrd;
  818. unsigned int i,Chk;
  819. unsigned char *ptr, *BufTmp;
  820. int MtdBlockSize = 0x300000;
  821. Chk=0;
  822. ptr=(unsigned char *)UsrData;
  823. if((BufTmp=malloc(MtdBlockSize))!=NULL)
  824. {
  825. memset(BufTmp,0,MtdBlockSize);
  826. memcpy(BufTmp,ptr,sizeof(struct SysConfigData));
  827. for(i=ARRAY_SIZE(UsrData->CsuBootLoadFwRev);i<MtdBlockSize-4;i++)
  828. Chk+=*(BufTmp+i);
  829. memcpy(BufTmp+MtdBlockSize-4, &Chk, 4);
  830. // Output configuration to file.
  831. fd = open("/mnt/EvseConfig.bin", O_RDWR|O_CREAT);
  832. if (fd < 0)
  833. {
  834. DEBUG_ERROR("open /mnt/EvseConfig.bin NG\n");
  835. free(BufTmp);
  836. return 0;
  837. }
  838. wrd=write(fd, BufTmp, MtdBlockSize);
  839. close(fd);
  840. if(wrd<MtdBlockSize)
  841. {
  842. DEBUG_ERROR("write /mnt/EvseConfig.bin NG\n");
  843. free(BufTmp);
  844. return 0;
  845. }
  846. DEBUG_INFO("EvseConfig write to file in /mnt OK.\n");
  847. DEBUG_INFO("Erase /dev/mtd10.\n");
  848. runShellCmd("flash_erase /dev/mtd10 0 0");
  849. DEBUG_INFO("Write /dev/mtd10.\n");
  850. runShellCmd("nandwrite -p /dev/mtd10 /mnt/EvseConfig.bin");
  851. DEBUG_INFO("Erase /dev/mtd11.\n");
  852. runShellCmd("flash_erase /dev/mtd11 0 0");
  853. DEBUG_INFO("Write /dev/mtd11.\n");
  854. runShellCmd("nandwrite -p /dev/mtd11 /mnt/EvseConfig.bin");
  855. system("rm -f /mnt/EvseConfig.bin");
  856. DEBUG_INFO("EvseConfig write to flash OK\n");
  857. }
  858. else
  859. {
  860. DEBUG_ERROR("alloc BlockSize NG\r\n");
  861. result = FAIL;
  862. }
  863. if(BufTmp!=NULL)
  864. free(BufTmp);
  865. return result;
  866. }
  867. //=========================================
  868. // Date time related function
  869. //=========================================
  870. void getNowDatetime(uint8_t *data)
  871. {
  872. time_t t = time(NULL);
  873. struct tm tm = *localtime(&t);
  874. 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);
  875. }
  876. //=========================================
  877. // Sqlite3 related function
  878. //=========================================
  879. int DB_Initial()
  880. {
  881. int result = PASS;
  882. char* errMsg = NULL;
  883. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  884. "idToken text UNIQUE,"
  885. "type text,"
  886. "status text,"
  887. "cacheExpiryDateTime text,"
  888. "chargingPriority integer,"
  889. "language1 text,"
  890. "evseId text,"
  891. "language2 text,"
  892. "groupIdToken_idToken text,"
  893. "groupIdToken_type text,"
  894. "personalMessage text);";
  895. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  896. "idToken text UNIQUE,"
  897. "type text,"
  898. "status text,"
  899. "cacheExpiryDateTime text,"
  900. "chargingPriority integer,"
  901. "language1 text,"
  902. "evseId text,"
  903. "language2 text,"
  904. "groupIdToken_idToken text,"
  905. "groupIdToken_type text,"
  906. "personalMessage text,"
  907. "version text);";
  908. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  909. "componentName text NOT NULL ,"
  910. "componentInstance text, "
  911. "variableName text NOT NULL, "
  912. "variableInstance text, "
  913. "variableCharacteristicsDataType integer, "
  914. "variableCharacteristicsUnit text, "
  915. "variableCharacteristicsMaxLimit real,"
  916. "variableAttributesType text, "
  917. "variableAttributesTypeMutability text, "
  918. "variableAttributesTypeValue text, "
  919. "variableCharacteristicsMinLimit real,"
  920. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  921. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  922. "type text);";
  923. char *sqlSecurityEventType = "create table if not exists ocpp20_securityevent_type (idx integer primary key,"
  924. "type text);";
  925. char *sqlNetworkProfile = "create table if not exists ocpp20_networkprofile (idx integer primary key,"
  926. "slot integer UNIQUE, connectionData text);";
  927. char *sqlTransaction = "create table if not exists ocpp20_transaction_record (idx integer primary key,"
  928. "occurDatetime text,"
  929. "message_type text,"
  930. "message_content text)";
  931. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  932. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  933. {
  934. result = FAIL;
  935. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  936. sqlite3_close(db);
  937. }
  938. else
  939. {
  940. DEBUG_INFO( "OCPP local database open successfully.\n");
  941. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  942. {
  943. result = FAIL;
  944. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  945. }
  946. else
  947. {
  948. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  949. }
  950. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  951. {
  952. result = FAIL;
  953. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  954. }
  955. else
  956. {
  957. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  958. }
  959. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  960. {
  961. result = FAIL;
  962. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  963. }
  964. else
  965. {
  966. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  967. }
  968. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  969. {
  970. result = FAIL;
  971. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  972. }
  973. else
  974. {
  975. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  976. }
  977. if (sqlite3_exec(db, sqlSecurityEventType, 0, 0, &errMsg) != SQLITE_OK)
  978. {
  979. result = FAIL;
  980. DEBUG_ERROR( "Create OCPP 2.0 securityevent_type table error message: %s\n", errMsg);
  981. }
  982. else
  983. {
  984. DEBUG_INFO( "Create OCPP 2.0 securityevent_type table successfully\n");
  985. }
  986. if (sqlite3_exec(db, sqlNetworkProfile, 0, 0, &errMsg) != SQLITE_OK)
  987. {
  988. result = FAIL;
  989. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_networkprofile table error message: %s\n", errMsg);
  990. }
  991. else
  992. {
  993. DEBUG_INFO( "Create OCPP 2.0 ocpp20_networkprofile table successfully\n");
  994. }
  995. if (sqlite3_exec(db, sqlTransaction, 0, 0, &errMsg) != SQLITE_OK)
  996. {
  997. result = FAIL;
  998. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_transaction_record table error message: %s\n", errMsg);
  999. }
  1000. else
  1001. {
  1002. DEBUG_INFO( "Create OCPP 2.0 ocpp20_transaction_record table successfully\n");
  1003. }
  1004. //sqlite3_close(db);
  1005. }
  1006. return result;
  1007. }
  1008. int DB_cbGetVersion(void *para, int columnCount, char **columnValue, char **columnName)
  1009. {
  1010. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  1011. return 0;
  1012. }
  1013. void DB_getListVerion()
  1014. {
  1015. char sql[256];
  1016. char* errMsg = NULL;
  1017. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  1018. /* Execute SQL statement */
  1019. if( sqlite3_exec(db, sql, DB_cbGetVersion, 0, &errMsg) != SQLITE_OK )
  1020. {
  1021. DEBUG_INFO("SQL error: %s", errMsg);
  1022. }
  1023. }
  1024. int DB_cbGetIdTag(void *para, int columnCount, char **columnValue, char **columnName)
  1025. {
  1026. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  1027. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  1028. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  1029. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  1030. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  1031. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  1032. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  1033. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  1034. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  1035. return 0;
  1036. }
  1037. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  1038. {
  1039. char sql[256];
  1040. char* errMsg = NULL;
  1041. memset(&idTagQuery, 0, sizeof(idTagQuery));
  1042. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  1043. if(isQueryFromCache)
  1044. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  1045. else
  1046. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  1047. /* Execute SQL statement */
  1048. if(sqlite3_exec(db, sql, DB_cbGetIdTag, 0, &errMsg) != SQLITE_OK )
  1049. {
  1050. DEBUG_INFO("SQL error: %s", errMsg);
  1051. }
  1052. }
  1053. int DB_cbTableAuthlocalAllData(void *para, int columnCount, char **columnValue, char **columnName)
  1054. {
  1055. for (int i = 0; i < columnCount; i++)
  1056. {
  1057. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  1058. }
  1059. return 0;
  1060. }
  1061. void DB_get_TableAuthlocalAllData(void)
  1062. {
  1063. char sql[256];
  1064. char* errMsg = NULL;
  1065. sprintf(sql,"select * from ocpp20_auth_local;");
  1066. /* Execute SQL statement */
  1067. if(sqlite3_exec(db, sql, DB_cbTableAuthlocalAllData, 0,&errMsg) != SQLITE_OK)
  1068. {
  1069. DEBUG_INFO("SQL error: %s", errMsg);
  1070. }
  1071. }
  1072. int DB_cbAddLocalListCache(void *para, int columnCount, char **columnValue, char **columnName)
  1073. {
  1074. for(int i = 0; i<columnCount; i++)
  1075. {
  1076. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1077. }
  1078. return 0;
  1079. }
  1080. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  1081. {
  1082. int result = PASS;
  1083. char sql[512];
  1084. char* errMsg = NULL;
  1085. 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;",
  1086. data->idToken.idToken,
  1087. data->idToken.type,
  1088. data->idTokenInfo.status,
  1089. data->idTokenInfo.cacheExpiryDateTime,
  1090. data->idTokenInfo.chargingPriority,
  1091. data->idTokenInfo.language1,
  1092. data->idTokenInfo.language2,
  1093. data->idTokenInfo.groupIdToken.idToken,
  1094. data->idTokenInfo.groupIdToken.type,
  1095. listVersion);
  1096. //* Execute SQL statement */
  1097. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  1098. {
  1099. DEBUG_INFO("SQL error: %s\n", errMsg);
  1100. result = FAIL;
  1101. }
  1102. else
  1103. {
  1104. memset(sql, 0, ARRAY_SIZE(sql));
  1105. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  1106. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  1107. {
  1108. DEBUG_INFO("SQL error: %s\n", errMsg);
  1109. result = FAIL;
  1110. }
  1111. }
  1112. return result;
  1113. }
  1114. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  1115. {
  1116. int result = PASS;
  1117. char sql[512];
  1118. char* errMsg = NULL;
  1119. 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;",
  1120. idToken->idToken,
  1121. idToken->type,
  1122. idTokenInfo->status,
  1123. idTokenInfo->cacheExpiryDateTime,
  1124. idTokenInfo->chargingPriority,
  1125. idTokenInfo->language1,
  1126. idTokenInfo->language2,
  1127. idTokenInfo->groupIdToken.idToken,
  1128. idTokenInfo->groupIdToken.type);
  1129. //* Execute SQL statement */
  1130. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  1131. {
  1132. DEBUG_INFO("SQL error: %s\n", errMsg);
  1133. result = FAIL;
  1134. }
  1135. return result;
  1136. }
  1137. int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  1138. {
  1139. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  1140. // printf("localversion=%d\n", localversion);
  1141. return 0;
  1142. }
  1143. void DB_deleteIdTag(char idTag[])
  1144. {
  1145. char sql[512];
  1146. char* errMsg = NULL;
  1147. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1148. //* Execute SQL statement */
  1149. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1150. {
  1151. DEBUG_INFO("SQL error: %s", errMsg);
  1152. }
  1153. }
  1154. int DB_cleanLocalList()
  1155. {
  1156. int result = PASS;
  1157. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1158. char *errMsg = 0;
  1159. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1160. {
  1161. DEBUG_INFO("%s\n", errMsg);
  1162. result = FAIL;
  1163. }
  1164. return result;
  1165. }
  1166. int DB_cleanLocalCache()
  1167. {
  1168. int result = PASS;
  1169. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1170. char *errMsg = 0;
  1171. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1172. {
  1173. DEBUG_INFO("%s\n", errMsg);
  1174. result = FAIL;
  1175. }
  1176. return result;
  1177. }
  1178. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1179. {
  1180. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1181. return 0;
  1182. }
  1183. void DB_getBooType()
  1184. {
  1185. char sql[256];
  1186. char* errMsg = NULL;
  1187. sprintf(sql,"select * from ocpp20_boot_type;");
  1188. /* Execute SQL statement */
  1189. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1190. {
  1191. DEBUG_INFO("SQL error: %s\n", errMsg);
  1192. }
  1193. }
  1194. int DB_cbUpdateBootType(void *para, int columnCount, char **columnValue, char **columnName)
  1195. {
  1196. for(int i = 0; i<columnCount; i++)
  1197. {
  1198. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1199. }
  1200. return 0;
  1201. }
  1202. int DB_updateBootType(BootReasonEnumType reason)
  1203. {
  1204. int result = PASS;
  1205. char sql[512];
  1206. char* errMsg = NULL;
  1207. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1208. //* Execute SQL statement */
  1209. if(sqlite3_exec(db, sql, DB_cbUpdateBootType, 0, &errMsg) != SQLITE_OK)
  1210. {
  1211. DEBUG_INFO("SQL error: %s\n", errMsg);
  1212. result = FAIL;
  1213. }
  1214. return result;
  1215. }
  1216. int SecurityEventTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1217. {
  1218. sprintf((char*)ShmOCPP20Data->SecurityEventNotification.type,"%s", columnValue[1] ? columnValue[1] : SecurityEventEnumTypeStr[SecurityEventEnumType_ResetOrReboot]);
  1219. return 0;
  1220. }
  1221. void DB_getSecurityEventType()
  1222. {
  1223. char sql[256];
  1224. char* errMsg = NULL;
  1225. sprintf(sql,"select * from ocpp20_securityevent_type;");
  1226. /* Execute SQL statement */
  1227. if(sqlite3_exec(db, sql, SecurityEventTypecallback, 0, &errMsg) != SQLITE_OK )
  1228. {
  1229. DEBUG_INFO("SQL error: %s\n", errMsg);
  1230. }
  1231. }
  1232. int DB_cbUpdateSecurityEventType(void *para, int columnCount, char **columnValue, char **columnName)
  1233. {
  1234. for(int i = 0; i<columnCount; i++)
  1235. {
  1236. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1237. }
  1238. return 0;
  1239. }
  1240. int DB_updateSecurityEventType(SecurityEventEnumType reason)
  1241. {
  1242. int result = PASS;
  1243. char sql[512];
  1244. char* errMsg = NULL;
  1245. sprintf(sql,"insert or replace into ocpp20_securityevent_type (idx, type) VALUES(1, '%s');", SecurityEventEnumTypeStr[reason]);
  1246. //* Execute SQL statement */
  1247. if(sqlite3_exec(db, sql, DB_cbUpdateSecurityEventType, 0, &errMsg) != SQLITE_OK)
  1248. {
  1249. DEBUG_INFO("SQL error: %s\n", errMsg);
  1250. result = FAIL;
  1251. }
  1252. return result;
  1253. }
  1254. int DB_variableClear()
  1255. {
  1256. int result = PASS;
  1257. char * sqlcleanLocalList = "delete from ocpp20_variable";
  1258. char *errMsg = 0;
  1259. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1260. {
  1261. DEBUG_INFO("%s\n", errMsg);
  1262. result = FAIL;
  1263. }
  1264. return result;
  1265. }
  1266. int DB_cbVariableSaveToDb(void *para, int columnCount, char **columnValue, char **columnName)
  1267. {
  1268. for(int i = 0; i<columnCount; i++)
  1269. {
  1270. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1271. }
  1272. return 0;
  1273. }
  1274. int DB_variableSaveToDb(struct ReportDataType *variable)
  1275. {
  1276. int result = FAIL;
  1277. char sql[4096];
  1278. char* errMsg = NULL;
  1279. 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;",
  1280. variable->component.name,
  1281. variable->component.instance,
  1282. variable->variable.name,
  1283. variable->variable.instance,
  1284. variable->variableCharacteristics.dataType,
  1285. variable->variableCharacteristics.unit,
  1286. variable->variableCharacteristics.maxLimit,
  1287. variable->variableAttribute[0].type,
  1288. variable->variableAttribute[0].mutability,
  1289. variable->variableAttribute[0].value,
  1290. variable->variableCharacteristics.minLimit);
  1291. //* Execute SQL statement */
  1292. if(sqlite3_exec(db, sql, DB_cbVariableSaveToDb, 0, &errMsg) != SQLITE_OK)
  1293. {
  1294. DEBUG_INFO("SQL error: %s\n", errMsg);
  1295. result = FAIL;
  1296. }
  1297. return result;
  1298. }
  1299. int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1300. {
  1301. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1302. if(atoi(columnValue[0]) == 0)
  1303. {
  1304. DB_updateBootType(BootReasonEnumType_PowerUp);
  1305. // Create variable table content
  1306. /* AlignedDataCtrlr Required item */
  1307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "false");
  1313. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "true");
  1320. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1324. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.maxLimit = 20;
  1325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1327. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,"
  1329. "Energy.Active.Import.Register,"
  1330. "Energy.Active.Import.Interval,"
  1331. "Power.Active.Import,"
  1332. "Voltage,"
  1333. "SoC,"
  1334. "Current.Offered,"
  1335. "Power.Offered");
  1336. else
  1337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,"
  1338. "Energy.Active.Import.Register,"
  1339. "Energy.Active.Import.Interval,"
  1340. "Power.Active.Import,"
  1341. "Voltage,"
  1342. "Current.Offered");
  1343. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1348. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.minLimit = 5;
  1349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1352. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "true");
  1359. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "false");
  1366. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1370. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.maxLimit = 10;
  1371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1373. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  1375. "Energy.Active.Import.Register,"
  1376. "Energy.Active.Import.Interval,"
  1377. "Power.Active.Import,"
  1378. "Voltage,"
  1379. "SoC");
  1380. else
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  1382. "Energy.Active.Import.Register,"
  1383. "Energy.Active.Import.Interval,"
  1384. "Power.Active.Import,"
  1385. "Voltage");
  1386. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1393. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1394. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1395. /* AuthCtrlrVariable Required item */
  1396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_ENABLE?"true":"false");
  1402. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AuthCtrlr");
  1404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1409. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "false");
  1416. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "false");
  1423. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1425. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "true");
  1430. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "true");
  1437. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1440. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1441. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1445. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1446. /* AuthCacheCtrlr Variable Required item*/
  1447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "false");
  1453. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "true");
  1460. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "true");
  1468. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1472. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*10);
  1473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "true");
  1476. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1483. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1484. /* ClockCtrlr Variable Required item */
  1485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1490. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1491. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1498. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1506. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1513. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1520. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1522. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1528. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1535. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1536. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1542. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1543. /* ChargingStation Required item */
  1544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "false");
  1550. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1551. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1557. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1559. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1564. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].component.name, "ChargingStation");
  1566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variable.name, "SystemUptimeSec");
  1567. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variableAttribute[0].value, "0");
  1571. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec]);
  1572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].component.name, "ChargingStation");
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variable.name, "FreeVend");
  1574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1575. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variableAttribute[0].value, (ShmSysConfigAndInfo->SysConfig.AuthorisationMode?"true":"false"));
  1578. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend]);
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].component.name, "ChargingStation");
  1580. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variable.name, "FreeVendIdtag");
  1581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1583. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variableAttribute[0].value, "FreeVendIdtag");
  1585. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag]);
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].component.name, "ChargingStation");
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].variable.name, "OffLineMaxChargingPower");
  1588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1590. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1591. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].variableAttribute[0].value, "0");
  1592. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower]);
  1593. /* Connector Required item */
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1598. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "false");
  1600. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1606. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1607. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1613. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1614. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1615. /* CustomizationCtrlr Required item */
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1621. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "false");
  1622. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1623. /* DeviceDataCtrlr Required item */
  1624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1631. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1635. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1639. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1643. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1645. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1646. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1647. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1651. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1653. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1654. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1655. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1657. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1658. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1659. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1660. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1661. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1663. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1666. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1667. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1668. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1671. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1673. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1674. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1675. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1676. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1679. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1682. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1683. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1684. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1687. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1688. /* DisplayMessageCtrlr Required item */
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1690. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1691. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1692. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1693. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "false");
  1695. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1696. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1697. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1698. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1699. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1700. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "false");
  1702. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1704. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1705. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1706. ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.maxLimit = 1;
  1707. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1708. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "1");
  1710. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1712. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1713. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1714. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1715. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1716. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1717. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1719. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1720. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1721. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1722. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1723. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1724. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1725. /* EVSE Required item */
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1727. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1728. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1729. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1730. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "false");
  1732. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1734. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1735. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1737. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1739. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1741. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1742. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1743. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1744. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1745. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1746. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1749. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1750. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1751. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1752. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1753. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1754. /* LocalAuthListCtrlr Required item */
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1757. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1758. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1759. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "true");
  1761. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1764. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1765. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.maxLimit = 5000;
  1766. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1767. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1768. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1769. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1772. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1773. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1774. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1775. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "true");
  1776. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1779. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1780. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1781. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1782. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1783. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "500");
  1784. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1787. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1788. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1789. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1791. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "20480");
  1792. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1793. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1795. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1796. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = (1024*10);
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "100000");
  1800. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1801. /* MonitoringCtrlr Required item */
  1802. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1803. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1804. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1805. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1807. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "false");
  1808. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1809. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1810. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1811. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1812. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1813. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1814. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "false");
  1815. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1816. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1817. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1819. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1820. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1821. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1822. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1823. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1824. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1825. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1828. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1829. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1831. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1833. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1835. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1836. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1839. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1842. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1843. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1844. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1845. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1847. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1848. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1849. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1850. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1851. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1854. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1855. /* OCPPCommCtrlr Required item */
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1857. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1858. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1859. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1862. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1864. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1865. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1866. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1869. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1870. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1871. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1872. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1873. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1874. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1876. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1877. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1878. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1879. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1880. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1882. ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.minLimit = 10;
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1884. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1885. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1886. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1887. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1888. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1891. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1892. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1893. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "[0]");
  1894. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1895. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1897. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1898. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1899. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1900. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1901. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1902. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1903. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1904. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1906. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  1907. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1908. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1909. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1911. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1912. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1913. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1914. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "false");
  1916. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1918. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1919. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1920. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1921. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1922. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1923. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1925. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1926. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1927. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1928. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1929. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1933. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "30");
  1934. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1935. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1936. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1937. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1940. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "true");
  1941. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1942. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1943. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1944. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1945. ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.minLimit = 10;
  1946. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1947. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1948. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1949. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1950. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1951. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1952. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1954. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1955. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1956. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1957. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1958. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1959. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1960. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1961. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1962. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1963. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1964. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1965. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].component.name, "OCPPCommCtrlr");
  1966. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variable.name, "VariableVersion");
  1967. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1968. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1969. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1970. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].value, "%d", variableVersion);
  1971. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion]);
  1972. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].component.name, "OCPPCommCtrlr");
  1973. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variable.name, "StatusNotificationPeriodically");
  1974. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1975. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1976. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1977. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].value, "false");
  1978. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically]);
  1979. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].component.name, "OCPPCommCtrlr");
  1980. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variable.name, "StatusNotificationInterval");
  1981. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableCharacteristics.unit, "Seconds");
  1982. ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableCharacteristics.minLimit = 10;
  1983. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1984. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1985. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1986. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].value, "120");
  1987. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval]);
  1988. /* ReservationCtrlr Required item */
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1990. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1991. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1992. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1993. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1994. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "true");
  1995. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1996. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1997. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1998. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1999. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2000. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2001. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "true");
  2002. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  2003. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2005. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2007. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2008. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "false");
  2009. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  2010. /* SampledDataCtrlr Required item */
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2012. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2014. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2015. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2016. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "true");
  2017. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  2018. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2019. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2020. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2021. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2022. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2023. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "true");
  2024. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2026. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2027. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2028. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2029. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2030. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "false");
  2031. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  2032. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2034. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  2035. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.maxLimit = 10;
  2036. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2037. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2038. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  2039. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  2040. "Energy.Active.Import.Register,"
  2041. "Energy.Active.Import.Interval,"
  2042. "Power.Active.Import,"
  2043. "Voltage,"
  2044. "SoC");
  2045. else
  2046. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,"
  2047. "Energy.Active.Import.Register,"
  2048. "Energy.Active.Import.Interval,"
  2049. "Power.Active.Import,"
  2050. "Voltage");
  2051. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  2052. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2053. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2054. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  2055. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2056. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  2059. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2062. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  2063. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.maxLimit = 10;
  2064. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2065. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2066. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  2067. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  2068. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2069. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2070. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  2071. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.maxLimit = 10;
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2073. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2074. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, "Current.Import,"
  2076. "Energy.Active.Import.Register,"
  2077. "Energy.Active.Import.Interval,"
  2078. "Power.Active.Import,"
  2079. "Voltage,"
  2080. "SoC,"
  2081. "Current.Offered,"
  2082. "Power.Offered");
  2083. else
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, "Current.Import,"
  2085. "Energy.Active.Import.Register,"
  2086. "Energy.Active.Import.Interval,"
  2087. "Power.Active.Import,"
  2088. "Voltage,"
  2089. "Current.Offered");
  2090. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  2091. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2092. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2095. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.minLimit = 3;
  2096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "30");
  2099. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  2100. /* SecurityCtrlr Required item */
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2104. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_WriteOnly]);
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, "%s", (strlen((char*)ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword)>0?(char*)ShmSysConfigAndInfo->SysConfig.OcppSecurityPassword:"00000000"));
  2108. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2110. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2112. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  2116. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  2117. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  2123. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  2124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2127. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.maxLimit = 1;
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  2131. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  2132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "%d", ShmSysConfigAndInfo->SysConfig.OcppSecurityProfile);
  2138. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  2139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "false");
  2145. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].component.name, "SecurityCtrlr");
  2147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variable.name, "MaxCertificateChainSize");
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2149. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableCharacteristics.maxLimit = 10000;
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variableAttribute[0].value, "10000");
  2153. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize]);
  2154. /* SmartChargingCtrlr Required item */
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "true");
  2161. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "true");
  2168. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  2169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "false");
  2175. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "3");
  2182. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  2183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  2189. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  2190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  2196. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  2197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "false");
  2203. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  2204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "false");
  2210. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  2211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "false");
  2217. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2221. ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.maxLimit = 10;
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "10");
  2225. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  2229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  2232. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  2233. /* TariffCostCtrlr Required item */
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "false");
  2241. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  2242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "false");
  2249. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2253. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  2257. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "false");
  2265. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "false");
  2273. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2277. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  2281. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  2285. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  2289. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  2290. /* TxCtrlr Required item */
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "false");
  2297. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  2305. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  2306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "true");
  2312. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  2313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "false");
  2319. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  2320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "PowerPathClosed");
  2326. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "PowerPathClosed");
  2333. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2340. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "0");
  2341. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Actual]);
  2346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "false");
  2348. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2349. }
  2350. else
  2351. {
  2352. // Variable name init
  2353. /* AlignedDataCtrlr Required item */
  2354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2370. /* AuthCtrlrVariable Required item */
  2371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2377. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2384. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2385. /* AuthCacheCtrlr Variable Required item */
  2386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2393. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2396. /* ClockCtrlr Variable Required item */
  2397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2415. /* ChargingStation Required item */
  2416. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].component.name, "ChargingStation");
  2423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SystemUptimeSec].variable.name, "SystemUptimeSec");
  2424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].component.name, "ChargingStation");
  2425. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVend].variable.name, "FreeVend");
  2426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].component.name, "ChargingStation");
  2427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_FreeVendIdtag].variable.name, "FreeVendIdtag");
  2428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].component.name, "ChargingStation");
  2429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_OffLineMaxChargingPower].variable.name, "OffLineMaxChargingPower");
  2430. /* Connector Required item */
  2431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2437. /* CustomizationCtrlr Required item */
  2438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  2439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  2440. /* DeviceDataCtrlr Required item */
  2441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2463. /* DisplayMessageCtrlr Required item */
  2464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2474. /* EVSE Required item */
  2475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2483. /* LocalAuthListCtrlr Required item */
  2484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2498. /* MonitoringCtrlr Required item */
  2499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2517. /* OCPPCommCtrlr Required item */
  2518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2522. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2535. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2536. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2543. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].component.name, "OCPPCommCtrlr");
  2550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variable.name, "VariableVersion");
  2551. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].component.name, "OCPPCommCtrlr");
  2552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variable.name, "StatusNotificationPeriodically");
  2553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].component.name, "OCPPCommCtrlr");
  2554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variable.name, "StatusNotificationInterval");
  2555. /* ReservationCtrlr Required item */
  2556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2559. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2562. /* SampledDataCtrlr Required item */
  2563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2567. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2575. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2579. /* SecurityCtrlr Required item */
  2580. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2583. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2590. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2591. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].component.name, "SecurityCtrlr");
  2593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_MaxCertificateChainSize].variable.name, "MaxCertificateChainSize");
  2594. /* SmartChargingCtrlr Required item */
  2595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2598. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2606. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2607. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2613. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2614. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2615. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2617. /* TariffCostCtrlr Required item */
  2618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2621. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2622. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2635. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2636. /* TxCtrlr Required item */
  2637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2643. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2645. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2646. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2651. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2653. }
  2654. return 0;
  2655. }
  2656. void DB_variableIsCreate()
  2657. {
  2658. char sql[512];
  2659. char* errMsg = NULL;
  2660. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2661. /* Execute SQL statement */
  2662. if(sqlite3_exec(db, sql, DB_cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2663. {
  2664. DEBUG_INFO("SQL error: %s\n", errMsg);
  2665. }
  2666. }
  2667. int DB_cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2668. {
  2669. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2670. {
  2671. if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) == 0) &&
  2672. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) == 0) &&
  2673. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) == 0) &&
  2674. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) == 0))
  2675. {
  2676. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2678. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2682. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.minLimit = strlen(columnValue[11])>=0?atoi(columnValue[11]):0;
  2683. }
  2684. }
  2685. return 0;
  2686. }
  2687. void DB_variableLoadFromDb()
  2688. {
  2689. char sql[512];
  2690. char* errMsg = NULL;
  2691. sprintf(sql,"select * from ocpp20_variable order by idx;");
  2692. /* Execute SQL statement */
  2693. if(sqlite3_exec(db, sql, DB_cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2694. {
  2695. DEBUG_INFO("SQL error: %s\n", errMsg);
  2696. }
  2697. }
  2698. int DB_cbGetNetworkProfileFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2699. {
  2700. memset(&ShmOCPP20Data->NetworkConnectionProfile[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile));
  2701. if(columnCount > 0)
  2702. {
  2703. for(int idx=0;idx<columnCount;idx++)
  2704. {
  2705. json_object *SetNetworkProfile;
  2706. SetNetworkProfile = json_tokener_parse(columnValue[2]);
  2707. if(!is_error(SetNetworkProfile))
  2708. {
  2709. // Required data
  2710. if(json_object_object_get(SetNetworkProfile, "ocppVersion") != NULL)
  2711. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppVersion")));
  2712. if(json_object_object_get(SetNetworkProfile, "ocppTransport") != NULL)
  2713. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppTransport")));
  2714. if(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl") != NULL)
  2715. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl")));
  2716. if(json_object_object_get(SetNetworkProfile, "messageTimeout") != NULL)
  2717. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.messageTimeout = json_object_get_int(json_object_object_get(SetNetworkProfile, "messageTimeout"));
  2718. if(json_object_object_get(SetNetworkProfile, "ocppInterface") != NULL)
  2719. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppInterface")));
  2720. if(json_object_object_get(SetNetworkProfile, "vpn") != NULL)
  2721. {
  2722. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server") != NULL)
  2723. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server")));
  2724. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user") != NULL)
  2725. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user")));
  2726. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group") != NULL)
  2727. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group")));
  2728. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password") != NULL)
  2729. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password")));
  2730. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key") != NULL)
  2731. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key")));
  2732. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type") != NULL)
  2733. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type")));
  2734. }
  2735. if(json_object_object_get(SetNetworkProfile, "apn") != NULL)
  2736. {
  2737. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn") != NULL)
  2738. {
  2739. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn));
  2740. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn")));
  2741. }
  2742. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName") != NULL)
  2743. {
  2744. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName));
  2745. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName")));
  2746. }
  2747. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword") != NULL)
  2748. {
  2749. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword));
  2750. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword")));
  2751. }
  2752. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin") != NULL)
  2753. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin"));
  2754. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork") != NULL)
  2755. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork")));
  2756. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork") != NULL)
  2757. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork"));
  2758. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication") != NULL)
  2759. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication")));
  2760. }
  2761. }
  2762. json_object_put(SetNetworkProfile);
  2763. ShmOCPP20Data->NetworkConnectionProfile[idx].slot = atoi(columnValue[1]);
  2764. }
  2765. }
  2766. return 0;
  2767. }
  2768. void DB_getNetworkProfileFromDb()
  2769. {
  2770. char sql[512];
  2771. char* errMsg = NULL;
  2772. sprintf(sql,"select * from ocpp20_networkprofile order by slot;");
  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. }
  2778. }
  2779. int DB_addNetworkProfile(int slot, char *data)
  2780. {
  2781. int result = PASS;
  2782. char sql[512];
  2783. char* errMsg = NULL;
  2784. sprintf(sql,"insert or replace into ocpp20_networkprofile (slot, connectionData) VALUES('%d', '%s'); SELECT * from ocpp20_networkprofile order by slot;",
  2785. slot,
  2786. data);
  2787. //* Execute SQL statement */
  2788. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK)
  2789. {
  2790. DEBUG_INFO("SQL error: %s\n", errMsg);
  2791. result = FAIL;
  2792. }
  2793. return result;
  2794. }
  2795. int DB_deleteNetworkProfile(int slot)
  2796. {
  2797. int result = PASS;
  2798. char sql[512];
  2799. char* errMsg = NULL;
  2800. sprintf(sql,"DELETE from ocpp20_networkprofile where slot=%d; SELECT * from ocpp20_networkprofile order by slot;", slot);
  2801. //* Execute SQL statement */
  2802. if( sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2803. {
  2804. DEBUG_INFO("SQL error: %s", errMsg);
  2805. result = FAIL;
  2806. }
  2807. return result;
  2808. }
  2809. int getCurrentYear()
  2810. {
  2811. int result = 0;
  2812. time_t CurrentTime;
  2813. struct tm *tm;
  2814. CurrentTime = time(NULL);
  2815. tm=localtime(&CurrentTime);
  2816. result = (tm->tm_year + 1900);
  2817. return result;
  2818. }
  2819. int OCPP_insert_transaction_msg(uint8_t isStartTransaction, char *transactionMsg)
  2820. {
  2821. int result = PASS;
  2822. char* errMsg = NULL;
  2823. char sqlStr[8192];
  2824. sprintf(sqlStr, "insert into ocpp20_transaction_record(occurDatetime, message_type, message_content) values(CURRENT_TIMESTAMP, '%s', '%s');", (isStartTransaction?"startTransaction":"stopTransaction"), transactionMsg);
  2825. if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
  2826. {
  2827. result = FAIL;
  2828. DEBUG_WARN( "Insert local transaction record error message: %s\n", errMsg);
  2829. }
  2830. 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));
  2831. if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK)
  2832. {
  2833. result = FAIL;
  2834. DEBUG_WARN( "delete local transaction record error message: %s\n", errMsg);
  2835. }
  2836. return result;
  2837. }
  2838. //==========================================
  2839. // Check time passed since today
  2840. //==========================================
  2841. long long DiffTimebWithNow(struct timeb ST)
  2842. {
  2843. //return milli-second
  2844. struct timeb ET;
  2845. long long StartTime,StopTime;
  2846. ftime(&ET);
  2847. StartTime=(long long)ST.time;
  2848. StopTime=(long long)ET.time;
  2849. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2850. }
  2851. int getTimePassSinceToday(uint8_t gun_index)
  2852. {
  2853. int result = -1;
  2854. static time_t lastTime[4];
  2855. time_t t;
  2856. struct tm *tmStartToday;
  2857. struct timeb tbStartToday;
  2858. t=time(NULL);
  2859. if(difftime(t, lastTime[gun_index])>0)
  2860. {
  2861. tmStartToday=localtime(&t);
  2862. tmStartToday->tm_hour = 0;
  2863. tmStartToday->tm_min = 0;
  2864. tmStartToday->tm_sec = 0;
  2865. tbStartToday.time = mktime(tmStartToday);
  2866. tbStartToday.millitm = 0;
  2867. result = DiffTimebWithNow(tbStartToday)/1000;
  2868. lastTime[gun_index] = t;
  2869. }
  2870. return result;
  2871. }
  2872. int syncDateTimeRTC(uint8_t *data)
  2873. {
  2874. struct ParsingResult
  2875. {
  2876. int result;
  2877. int scanedElement;
  2878. int year;
  2879. int month;
  2880. int mday;
  2881. int hour;
  2882. int min;
  2883. int sec;
  2884. int tz_hour;
  2885. int tz_min;
  2886. float minSec;
  2887. }result;
  2888. struct tm tmOrg;
  2889. struct tm *tmTarget;
  2890. struct timeb tbTarget;
  2891. char buf[128];
  2892. memset(&result, 0x00, sizeof(struct ParsingResult));
  2893. result.result = PASS;
  2894. if(strstr((char*)data, ".") != NULL)
  2895. {
  2896. // Original data with mini second
  2897. if(strstr((char*)data, "Z") != NULL)
  2898. {
  2899. // Original data with Z
  2900. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%fZ",
  2901. &result.year,
  2902. &result.month,
  2903. &result.mday,
  2904. &result.hour,
  2905. &result.min,
  2906. &result.sec,
  2907. &result.minSec);
  2908. }
  2909. else
  2910. {
  2911. // Original data without Z
  2912. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  2913. &result.year,
  2914. &result.month,
  2915. &result.mday,
  2916. &result.hour,
  2917. &result.min,
  2918. &result.sec,
  2919. &result.minSec,
  2920. &result.tz_hour,
  2921. &result.tz_min);
  2922. }
  2923. }
  2924. else
  2925. {
  2926. // Original data without mini second
  2927. if(strstr((char*)data, "Z") != NULL)
  2928. {
  2929. // Original data with Z
  2930. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%dZ",
  2931. &result.year,
  2932. &result.month,
  2933. &result.mday,
  2934. &result.hour,
  2935. &result.min,
  2936. &result.sec);
  2937. }
  2938. else
  2939. {
  2940. // Original data without Z
  2941. result.scanedElement = sscanf((char*)data, "%d-%d-%dT%d:%d:%d%d:%d",
  2942. &result.year,
  2943. &result.month,
  2944. &result.mday,
  2945. &result.hour,
  2946. &result.min,
  2947. &result.sec,
  2948. &result.tz_hour,
  2949. &result.tz_min);
  2950. }
  2951. }
  2952. tmOrg.tm_year = result.year - 1900;
  2953. tmOrg.tm_mon = result.month - 1;
  2954. tmOrg.tm_mday = result.mday;
  2955. tmOrg.tm_hour = result.hour;
  2956. tmOrg.tm_min = result.min;
  2957. tmOrg.tm_sec = result.sec;
  2958. tmOrg.tm_gmtoff = 0;
  2959. tbTarget.time = mktime(&tmOrg);
  2960. tbTarget.timezone = 0;
  2961. tbTarget.time -= (result.tz_hour*3600) + (result.tz_min*60*(result.tz_hour>=0?1:-1));
  2962. tmTarget = gmtime(&tbTarget.time);
  2963. 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);
  2964. //DEBUG_INFO(" org date time: %s\n", data);
  2965. //DEBUG_INFO("parse date time: %s\n", buf);
  2966. system(buf);
  2967. system("/sbin/hwclock -w --systohc");
  2968. if(result.scanedElement < 6)
  2969. result.result = FAIL;
  2970. return result.result;
  2971. }
  2972. //==========================================
  2973. // GetCompositeSchedule logic related function
  2974. //==========================================
  2975. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2976. {
  2977. //return milli-second
  2978. unsigned int StartTime,StopTime;
  2979. StartTime=(unsigned int)ST.time;
  2980. StopTime=(unsigned int)ET.time;
  2981. return (StopTime-StartTime);
  2982. }
  2983. int DiffTimebWithNowSec(struct timeb ST)
  2984. {
  2985. //return milli-second
  2986. struct timeb ET;
  2987. unsigned int StartTime,StopTime;
  2988. ftime(&ET);
  2989. StartTime=(unsigned int)ST.time;
  2990. StopTime=(unsigned int)ET.time;
  2991. return (StopTime-StartTime);
  2992. }
  2993. int getStartStop(uint8_t *start, uint8_t *stop)
  2994. {
  2995. struct ParsingResult
  2996. {
  2997. int result;
  2998. int scanedElement;
  2999. int year;
  3000. int month;
  3001. int mday;
  3002. int hour;
  3003. int min;
  3004. int sec;
  3005. int tz_hour;
  3006. int tz_min;
  3007. float minSec;
  3008. };
  3009. struct ParsingResult parseStart;
  3010. struct ParsingResult parseStop;
  3011. int result = -1;
  3012. struct tm tmStart;
  3013. struct timeb tbStart;
  3014. struct tm tmStop;
  3015. struct timeb tbStop;
  3016. memset(&parseStart, 0x00, sizeof(struct ParsingResult));
  3017. memset(&parseStop, 0x00, sizeof(struct ParsingResult));
  3018. // Scan start & stop date time
  3019. if(strstr((char*)start, ".") != NULL)
  3020. {
  3021. // Original data with mini second
  3022. if(strstr((char*)start, "Z") != NULL)
  3023. {
  3024. // Original data with Z
  3025. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%fZ",
  3026. &parseStart.year,
  3027. &parseStart.month,
  3028. &parseStart.mday,
  3029. &parseStart.hour,
  3030. &parseStart.min,
  3031. &parseStart.sec,
  3032. &parseStart.minSec);
  3033. }
  3034. else
  3035. {
  3036. // Original data without Z
  3037. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  3038. &parseStart.year,
  3039. &parseStart.month,
  3040. &parseStart.mday,
  3041. &parseStart.hour,
  3042. &parseStart.min,
  3043. &parseStart.sec,
  3044. &parseStart.minSec,
  3045. &parseStart.tz_hour,
  3046. &parseStart.tz_min);
  3047. }
  3048. }
  3049. else
  3050. {
  3051. // Original data without mini second
  3052. if(strstr((char*)start, "Z") != NULL)
  3053. {
  3054. // Original data with Z
  3055. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%dZ",
  3056. &parseStart.year,
  3057. &parseStart.month,
  3058. &parseStart.mday,
  3059. &parseStart.hour,
  3060. &parseStart.min,
  3061. &parseStart.sec);
  3062. }
  3063. else
  3064. {
  3065. // Original data without Z
  3066. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d%d:%d",
  3067. &parseStart.year,
  3068. &parseStart.month,
  3069. &parseStart.mday,
  3070. &parseStart.hour,
  3071. &parseStart.min,
  3072. &parseStart.sec,
  3073. &parseStart.tz_hour,
  3074. &parseStart.tz_min);
  3075. }
  3076. }
  3077. if(strstr((char*)stop, ".") != NULL)
  3078. {
  3079. // Original data with mini second
  3080. if(strstr((char*)stop, "Z") != NULL)
  3081. {
  3082. // Original data with Z
  3083. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d.%fZ",
  3084. &parseStop.year,
  3085. &parseStop.month,
  3086. &parseStop.mday,
  3087. &parseStop.hour,
  3088. &parseStop.min,
  3089. &parseStop.sec,
  3090. &parseStop.minSec);
  3091. }
  3092. else
  3093. {
  3094. // Original data without Z
  3095. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  3096. &parseStop.year,
  3097. &parseStop.month,
  3098. &parseStop.mday,
  3099. &parseStop.hour,
  3100. &parseStop.min,
  3101. &parseStop.sec,
  3102. &parseStop.minSec,
  3103. &parseStop.tz_hour,
  3104. &parseStop.tz_min);
  3105. }
  3106. }
  3107. else
  3108. {
  3109. // Original data without mini second
  3110. if(strstr((char*)stop, "Z") != NULL)
  3111. {
  3112. // Original data with Z
  3113. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%dZ",
  3114. &parseStop.year,
  3115. &parseStop.month,
  3116. &parseStop.mday,
  3117. &parseStop.hour,
  3118. &parseStop.min,
  3119. &parseStop.sec);
  3120. }
  3121. else
  3122. {
  3123. // Original data without Z
  3124. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d%d:%d",
  3125. &parseStop.year,
  3126. &parseStop.month,
  3127. &parseStop.mday,
  3128. &parseStop.hour,
  3129. &parseStop.min,
  3130. &parseStop.sec,
  3131. &parseStop.tz_hour,
  3132. &parseStop.tz_min);
  3133. }
  3134. }
  3135. // Calculate date time difference
  3136. if((parseStart.scanedElement >=6) &&
  3137. (parseStop.scanedElement >=6))
  3138. {
  3139. //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);
  3140. //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);
  3141. tmStart.tm_year = parseStart.year - 1900;
  3142. tmStart.tm_mon = parseStart.month - 1;
  3143. tmStart.tm_mday = parseStart.mday;
  3144. tmStart.tm_hour = parseStart.hour;
  3145. tmStart.tm_min = parseStart.min;
  3146. tmStart.tm_sec = parseStart.sec;
  3147. tmStart.tm_gmtoff = 0;
  3148. tbStart.time = mktime(&tmStart);
  3149. tbStart.timezone = 0;
  3150. tbStart.time -= (parseStart.tz_hour*3600) + (parseStart.tz_min*60*(parseStart.tz_hour>=0?1:-1));
  3151. tmStop.tm_year = parseStop.year - 1900;
  3152. tmStop.tm_mon = parseStop.month - 1;
  3153. tmStop.tm_mday = parseStop.mday;
  3154. tmStop.tm_hour = parseStop.hour;
  3155. tmStop.tm_min = parseStop.min;
  3156. tmStop.tm_sec = parseStop.sec;
  3157. tmStop.tm_gmtoff = 0;
  3158. tbStop.time = mktime(&tmStop);
  3159. tbStop.timezone = 0;
  3160. tbStop.time -= (parseStop.tz_hour*3600) + (parseStop.tz_min*60*(parseStop.tz_hour>=0?1:-1));
  3161. result = DiffTimebSec(tbStart, tbStop);
  3162. //DEBUG_INFO("getStartStop(): %d\n", result);
  3163. }
  3164. else
  3165. {
  3166. DEBUG_WARN("Start or stop date parsing error.\r\n");
  3167. }
  3168. return result;
  3169. }
  3170. int isOvertNow(uint8_t *start)
  3171. {
  3172. int result = NO;
  3173. struct ParsingResult
  3174. {
  3175. int result;
  3176. int scanedElement;
  3177. int year;
  3178. int month;
  3179. int mday;
  3180. int hour;
  3181. int min;
  3182. int sec;
  3183. int tz_hour;
  3184. int tz_min;
  3185. float minSec;
  3186. }parsingResult;
  3187. struct tm tmStart;
  3188. struct timeb tbStart;
  3189. memset(&parsingResult, 0x00, sizeof(struct ParsingResult));
  3190. if(strstr((char*)start, ".") != NULL)
  3191. {
  3192. // Original data with mini second
  3193. if(strstr((char*)start, "Z") != NULL)
  3194. {
  3195. // Original data with Z
  3196. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%fZ",
  3197. &parsingResult.year,
  3198. &parsingResult.month,
  3199. &parsingResult.mday,
  3200. &parsingResult.hour,
  3201. &parsingResult.min,
  3202. &parsingResult.sec,
  3203. &parsingResult.minSec);
  3204. }
  3205. else
  3206. {
  3207. // Original data without Z
  3208. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  3209. &parsingResult.year,
  3210. &parsingResult.month,
  3211. &parsingResult.mday,
  3212. &parsingResult.hour,
  3213. &parsingResult.min,
  3214. &parsingResult.sec,
  3215. &parsingResult.minSec,
  3216. &parsingResult.tz_hour,
  3217. &parsingResult.tz_min);
  3218. }
  3219. }
  3220. else
  3221. {
  3222. // Original data without mini second
  3223. if(strstr((char*)start, "Z") != NULL)
  3224. {
  3225. // Original data with Z
  3226. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%dZ",
  3227. &parsingResult.year,
  3228. &parsingResult.month,
  3229. &parsingResult.mday,
  3230. &parsingResult.hour,
  3231. &parsingResult.min,
  3232. &parsingResult.sec);
  3233. }
  3234. else
  3235. {
  3236. // Original data without Z
  3237. parsingResult.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d%d:%d",
  3238. &parsingResult.year,
  3239. &parsingResult.month,
  3240. &parsingResult.mday,
  3241. &parsingResult.hour,
  3242. &parsingResult.min,
  3243. &parsingResult.sec,
  3244. &parsingResult.tz_hour,
  3245. &parsingResult.tz_min);
  3246. }
  3247. }
  3248. if(parsingResult.scanedElement >= 6)
  3249. {
  3250. tmStart.tm_year = parsingResult.year - 1900;
  3251. tmStart.tm_mon = parsingResult.month - 1;
  3252. tmStart.tm_mday = parsingResult.mday;
  3253. tmStart.tm_hour = parsingResult.hour;
  3254. tmStart.tm_min = parsingResult.min;
  3255. tmStart.tm_sec = parsingResult.sec;
  3256. tmStart.tm_gmtoff = 0;
  3257. tbStart.time = mktime(&tmStart);
  3258. tbStart.timezone = 0;
  3259. tbStart.millitm = 0;
  3260. tbStart.time -= (parsingResult.tz_hour*3600) + (parsingResult.tz_min*60*(parsingResult.tz_hour>=0?1:-1));
  3261. if(DiffTimebWithNowSec(tbStart) <= 0)
  3262. result = NO;
  3263. else
  3264. result = YES;
  3265. }
  3266. else
  3267. {
  3268. DEBUG_WARN("Start date parsing error.\n");
  3269. }
  3270. return result;
  3271. }
  3272. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  3273. {
  3274. struct ParsingResult
  3275. {
  3276. int result;
  3277. int scanedElement;
  3278. int year;
  3279. int month;
  3280. int mday;
  3281. int hour;
  3282. int min;
  3283. int sec;
  3284. int tz_hour;
  3285. int tz_min;
  3286. float minSec;
  3287. };
  3288. struct ParsingResult parseStart;
  3289. struct ParsingResult parseStop;
  3290. int result = -1;
  3291. struct tm tmStart;
  3292. struct timeb tbStart;
  3293. struct tm tmStop;
  3294. struct timeb tbStop;
  3295. memset(&parseStart, 0x00, sizeof(struct ParsingResult));
  3296. memset(&parseStop, 0x00, sizeof(struct ParsingResult));
  3297. // Scan start & stop date time
  3298. if(strstr((char*)start, ".") != NULL)
  3299. {
  3300. // Original data with mini second
  3301. if(strstr((char*)start, "Z") != NULL)
  3302. {
  3303. // Original data with Z
  3304. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%fZ",
  3305. &parseStart.year,
  3306. &parseStart.month,
  3307. &parseStart.mday,
  3308. &parseStart.hour,
  3309. &parseStart.min,
  3310. &parseStart.sec,
  3311. &parseStart.minSec);
  3312. }
  3313. else
  3314. {
  3315. // Original data without Z
  3316. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  3317. &parseStart.year,
  3318. &parseStart.month,
  3319. &parseStart.mday,
  3320. &parseStart.hour,
  3321. &parseStart.min,
  3322. &parseStart.sec,
  3323. &parseStart.minSec,
  3324. &parseStart.tz_hour,
  3325. &parseStart.tz_min);
  3326. }
  3327. }
  3328. else
  3329. {
  3330. // Original data without mini second
  3331. if(strstr((char*)start, "Z") != NULL)
  3332. {
  3333. // Original data with Z
  3334. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%dZ",
  3335. &parseStart.year,
  3336. &parseStart.month,
  3337. &parseStart.mday,
  3338. &parseStart.hour,
  3339. &parseStart.min,
  3340. &parseStart.sec);
  3341. }
  3342. else
  3343. {
  3344. // Original data without Z
  3345. parseStart.scanedElement = sscanf((char*)start, "%d-%d-%dT%d:%d:%d%d:%d",
  3346. &parseStart.year,
  3347. &parseStart.month,
  3348. &parseStart.mday,
  3349. &parseStart.hour,
  3350. &parseStart.min,
  3351. &parseStart.sec,
  3352. &parseStart.tz_hour,
  3353. &parseStart.tz_min);
  3354. }
  3355. }
  3356. if(strstr((char*)stop, ".") != NULL)
  3357. {
  3358. // Original data with mini second
  3359. if(strstr((char*)stop, "Z") != NULL)
  3360. {
  3361. // Original data with Z
  3362. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d.%fZ",
  3363. &parseStop.year,
  3364. &parseStop.month,
  3365. &parseStop.mday,
  3366. &parseStop.hour,
  3367. &parseStop.min,
  3368. &parseStop.sec,
  3369. &parseStop.minSec);
  3370. }
  3371. else
  3372. {
  3373. // Original data without Z
  3374. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d.%f%d:%d",
  3375. &parseStop.year,
  3376. &parseStop.month,
  3377. &parseStop.mday,
  3378. &parseStop.hour,
  3379. &parseStop.min,
  3380. &parseStop.sec,
  3381. &parseStop.minSec,
  3382. &parseStop.tz_hour,
  3383. &parseStop.tz_min);
  3384. }
  3385. }
  3386. else
  3387. {
  3388. // Original data without mini second
  3389. if(strstr((char*)stop, "Z") != NULL)
  3390. {
  3391. // Original data with Z
  3392. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%dZ",
  3393. &parseStop.year,
  3394. &parseStop.month,
  3395. &parseStop.mday,
  3396. &parseStop.hour,
  3397. &parseStop.min,
  3398. &parseStop.sec);
  3399. }
  3400. else
  3401. {
  3402. // Original data without Z
  3403. parseStop.scanedElement = sscanf((char*)stop, "%d-%d-%dT%d:%d:%d%d:%d",
  3404. &parseStop.year,
  3405. &parseStop.month,
  3406. &parseStop.mday,
  3407. &parseStop.hour,
  3408. &parseStop.min,
  3409. &parseStop.sec,
  3410. &parseStop.tz_hour,
  3411. &parseStop.tz_min);
  3412. }
  3413. }
  3414. // Calculate date time difference
  3415. if((parseStart.scanedElement >=6) &&
  3416. (parseStop.scanedElement >=6))
  3417. {
  3418. //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);
  3419. //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);
  3420. tmStart.tm_year = parseStart.year - 1900;
  3421. tmStart.tm_mon = parseStart.month - 1;
  3422. tmStart.tm_mday = parseStart.mday;
  3423. tmStart.tm_hour = parseStart.hour;
  3424. tmStart.tm_min = parseStart.min;
  3425. tmStart.tm_sec = parseStart.sec;
  3426. tmStart.tm_gmtoff = 0;
  3427. tbStart.time = mktime(&tmStart);
  3428. tbStart.timezone = 0;
  3429. tbStart.time -= (parseStart.tz_hour*3600) + (parseStart.tz_min*60*(parseStart.tz_hour>=0?1:-1));
  3430. tmStop.tm_year = parseStop.year - 1900;
  3431. tmStop.tm_mon = parseStop.month - 1;
  3432. tmStop.tm_mday = parseStop.mday;
  3433. tmStop.tm_hour = parseStop.hour;
  3434. tmStop.tm_min = parseStop.min;
  3435. tmStop.tm_sec = parseStop.sec;
  3436. tmStop.tm_gmtoff = 0;
  3437. tbStop.time = mktime(&tmStop);
  3438. tbStop.timezone = 0;
  3439. tbStop.time -= (parseStop.tz_hour*3600) + (parseStop.tz_min*60*(parseStop.tz_hour>=0?1:-1));
  3440. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  3441. //DEBUG_INFO("getStartStop(): %d\n", result);
  3442. }
  3443. else
  3444. {
  3445. DEBUG_WARN("Start or stop date parsing error.\r\n");
  3446. }
  3447. return result;
  3448. }
  3449. void checkChargingStationMaxProfile(uint32_t durationReq, struct ChargingProfileType *targetCompositeProfile, uint8_t idxSchedule, uint8_t isUnitA)
  3450. {
  3451. FILE *fp;
  3452. char profileFileName[128];
  3453. char *line = NULL;
  3454. size_t len = 0;
  3455. time_t CurrentTime;
  3456. struct tm *tmComposite;
  3457. struct ChargingProfileType maxProfile;
  3458. struct ChargingProfileType compositeProfile;
  3459. uint8_t limitMax=0;
  3460. int compositePeriodIdx = 0;
  3461. CurrentTime = time(NULL);
  3462. tmComposite=localtime(&CurrentTime);
  3463. 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);
  3464. if(isUnitA)
  3465. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3466. else
  3467. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3468. compositeProfile.chargingSchedule[idxSchedule].duration = durationReq;
  3469. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3470. {
  3471. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3472. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3473. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3474. }
  3475. compositeProfile.id = 0;
  3476. compositeProfile.stackLevel = 99 ;
  3477. sprintf((char*)compositeProfile.chargingProfileKind ,"Absolute");
  3478. maxProfile.id = -1;
  3479. maxProfile.chargingSchedule[idxSchedule].duration = -1;
  3480. system("rm -f /tmp/*.json");
  3481. system("cp /Storage/OCPP/*.json /tmp 2>/dev/null");
  3482. // Search max profile
  3483. sprintf(profileFileName, "/tmp/ChargingStationMaxProfile_OCPP20.json");
  3484. if((access(profileFileName, F_OK))!=-1)
  3485. {
  3486. fp = fopen(profileFileName, "r");
  3487. while(getline(&line, &len, fp) != -1)
  3488. {
  3489. json_object *obj = NULL;
  3490. obj = json_tokener_parse(line);
  3491. if(is_error(obj))
  3492. {
  3493. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  3494. }
  3495. else
  3496. {
  3497. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != maxProfile.id) &&
  3498. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= maxProfile.stackLevel)
  3499. )
  3500. {
  3501. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  3502. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3503. )
  3504. {
  3505. struct tm tmFrom, tmTo;
  3506. struct timeb tbFrom, tbTo;
  3507. 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) &&
  3508. (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))
  3509. {
  3510. tmFrom.tm_year -= 1900;
  3511. tmFrom.tm_mon -= 1;
  3512. tbFrom.time = mktime(&tmFrom);
  3513. tmTo.tm_year -= 1900;
  3514. tmTo.tm_mon -= 1;
  3515. tbTo.time = mktime(&tmTo);
  3516. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3517. {
  3518. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3519. {
  3520. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3521. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3522. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3523. }
  3524. if(maxProfile.id == -1)
  3525. DEBUG_INFO("MaxProfile found.\n");
  3526. else
  3527. DEBUG_INFO("MaxProfile updated.\n");
  3528. // Required item
  3529. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3530. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3531. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3532. if(isUnitA)
  3533. {
  3534. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3535. 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++)
  3536. {
  3537. 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"));
  3538. 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?
  3539. 3:
  3540. 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")));
  3541. 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")));
  3542. }
  3543. }
  3544. else
  3545. {
  3546. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3547. 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++)
  3548. {
  3549. 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"));
  3550. 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?
  3551. 3:
  3552. 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")));
  3553. 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));
  3554. }
  3555. }
  3556. // Optional item
  3557. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3558. {
  3559. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3560. }
  3561. else
  3562. {
  3563. sprintf((char*)maxProfile.validFrom, " ");
  3564. }
  3565. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3566. {
  3567. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3568. }
  3569. else
  3570. {
  3571. sprintf((char*)maxProfile.validTo, " ");
  3572. }
  3573. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3574. {
  3575. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3576. }
  3577. else
  3578. {
  3579. sprintf((char*)maxProfile.recurrencyKind, " ");
  3580. }
  3581. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3582. {
  3583. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3584. }
  3585. else
  3586. {
  3587. sprintf((char*)maxProfile.transactionId, " ");
  3588. }
  3589. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  3590. {
  3591. 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"));
  3592. }
  3593. else
  3594. {
  3595. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3596. }
  3597. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  3598. {
  3599. 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")));
  3600. }
  3601. else
  3602. {
  3603. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
  3604. }
  3605. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  3606. {
  3607. 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"));
  3608. }
  3609. else
  3610. {
  3611. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3612. }
  3613. }
  3614. }
  3615. }
  3616. else
  3617. {
  3618. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3619. {
  3620. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3621. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3622. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3623. }
  3624. if(maxProfile.id == -1)
  3625. DEBUG_INFO("MaxProfile found.\n");
  3626. else
  3627. DEBUG_INFO("MaxProfile updated.\n");
  3628. // Required item
  3629. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  3630. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  3631. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  3632. if(isUnitA)
  3633. {
  3634. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3635. 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++)
  3636. {
  3637. 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"));
  3638. 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?
  3639. 3:
  3640. 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")));
  3641. 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")));
  3642. }
  3643. }
  3644. else
  3645. {
  3646. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3647. 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++)
  3648. {
  3649. 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"));
  3650. 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?
  3651. 3:
  3652. 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")));
  3653. 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));
  3654. }
  3655. }
  3656. // Optional item
  3657. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  3658. {
  3659. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  3660. }
  3661. else
  3662. {
  3663. sprintf((char*)maxProfile.validFrom, " ");
  3664. }
  3665. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3666. {
  3667. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  3668. }
  3669. else
  3670. {
  3671. sprintf((char*)maxProfile.validTo, " ");
  3672. }
  3673. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  3674. {
  3675. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  3676. }
  3677. else
  3678. {
  3679. sprintf((char*)maxProfile.recurrencyKind, " ");
  3680. }
  3681. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  3682. {
  3683. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  3684. }
  3685. else
  3686. {
  3687. sprintf((char*)maxProfile.transactionId, " ");
  3688. }
  3689. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  3690. {
  3691. 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"));
  3692. }
  3693. else
  3694. {
  3695. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  3696. }
  3697. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  3698. {
  3699. 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")));
  3700. }
  3701. else
  3702. {
  3703. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].startSchedule, "%s", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
  3704. }
  3705. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  3706. {
  3707. 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"));
  3708. }
  3709. else
  3710. {
  3711. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  3712. }
  3713. }
  3714. }
  3715. }
  3716. json_object_put(obj);
  3717. }
  3718. fclose(fp);
  3719. /*
  3720. if(maxProfile.id !=-1)
  3721. {
  3722. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  3723. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3724. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3725. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3726. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3727. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3728. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  3729. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[idxSchedule].StartSchedule);
  3730. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  3731. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3732. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3733. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3734. {
  3735. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3736. {
  3737. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3738. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3739. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3740. }
  3741. }
  3742. }
  3743. else
  3744. DEBUG_INFO("MaxProfile not found.\n");
  3745. DEBUG_INFO("------------------------------------\n");*/
  3746. }
  3747. if(maxProfile.id != -1)
  3748. {
  3749. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3750. {
  3751. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3752. {
  3753. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  3754. 0:
  3755. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  3756. }
  3757. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3758. {
  3759. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3760. {
  3761. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  3762. 0:
  3763. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  3764. if(idxPeriod > 0)
  3765. {
  3766. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3767. {
  3768. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3769. }
  3770. }
  3771. }
  3772. }
  3773. }
  3774. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3775. {
  3776. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3777. {
  3778. maxProfile.chargingSchedule[idxSchedule].duration = maxProfile.chargingSchedule[idxSchedule].duration;
  3779. }
  3780. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3781. {
  3782. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3783. {
  3784. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod;
  3785. if(idxPeriod > 0)
  3786. {
  3787. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3788. {
  3789. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3790. }
  3791. }
  3792. }
  3793. }
  3794. }
  3795. else
  3796. {
  3797. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3798. {
  3799. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3800. {
  3801. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3802. 0:
  3803. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3804. }
  3805. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3806. {
  3807. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3808. {
  3809. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  3810. 0:
  3811. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  3812. if(idxPeriod > 0)
  3813. {
  3814. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3815. {
  3816. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3817. }
  3818. }
  3819. }
  3820. }
  3821. }
  3822. else
  3823. {
  3824. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  3825. {
  3826. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3827. 0:
  3828. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3829. }
  3830. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3831. {
  3832. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3833. {
  3834. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  3835. 0:
  3836. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  3837. if(idxPeriod > 0)
  3838. {
  3839. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  3840. {
  3841. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  3842. }
  3843. }
  3844. }
  3845. }
  3846. }
  3847. }
  3848. /*
  3849. DEBUG_INFO("MaxProfile after align.\n");
  3850. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  3851. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3852. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3853. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3854. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3855. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3856. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  3857. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile.ChargingSchedule.StartSchedule);
  3858. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  3859. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  3860. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  3861. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  3862. {
  3863. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3864. {
  3865. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3866. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  3867. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3868. }
  3869. }
  3870. DEBUG_INFO("------------------------------------\n");*/
  3871. }
  3872. // Find each profile period quantity
  3873. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  3874. {
  3875. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  3876. limitMax = idx+1;
  3877. }
  3878. if(maxProfile.id != -1)
  3879. {
  3880. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3881. {
  3882. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3883. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3884. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  3885. {
  3886. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3887. {
  3888. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3889. compositePeriodIdx++;
  3890. }
  3891. else
  3892. {
  3893. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3894. }
  3895. }
  3896. }
  3897. }
  3898. DEBUG_INFO("ChargePointMaxProfile ready.\n");
  3899. DEBUG_INFO("Schedule start: %s\n", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
  3900. DEBUG_INFO("Schedule duration: %d\n", compositeProfile.chargingSchedule[idxSchedule].duration);
  3901. DEBUG_INFO("Rate unit: %s\n", compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit);
  3902. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3903. {
  3904. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  3905. {
  3906. compositeProfile.id = 1;
  3907. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  3908. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
  3909. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
  3910. }
  3911. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit == -1)
  3912. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit =0;
  3913. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  3914. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  3915. }
  3916. memcpy(targetCompositeProfile, &compositeProfile, sizeof(struct StructChargingProfile));
  3917. if(line)
  3918. free(line);
  3919. }
  3920. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *targetCompositeProfile, uint8_t idxSchedule, uint8_t isUnitA)
  3921. {
  3922. FILE *fp;
  3923. char profileFileName[128];
  3924. char *line = NULL;
  3925. size_t len = 0;
  3926. time_t CurrentTime;
  3927. struct tm *tmComposite;
  3928. struct ChargingProfileType maxProfile;
  3929. struct ChargingProfileType defaultTxProfile;
  3930. struct ChargingProfileType txProfile;
  3931. struct ChargingProfileType compositeProfile;
  3932. struct ChargingSchedulePeriodType tmpPeriod;
  3933. uint8_t limitMax=0;
  3934. uint8_t limitDef=0;
  3935. uint8_t limitTx=0;
  3936. int compositePeriodIdx = 0;
  3937. CurrentTime = time(NULL);
  3938. tmComposite=localtime(&CurrentTime);
  3939. 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);
  3940. if(isUnitA)
  3941. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  3942. else
  3943. sprintf((char*)compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  3944. compositeProfile.chargingSchedule[idxSchedule].duration = durationReq;
  3945. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  3946. {
  3947. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3948. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  3949. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3950. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  3951. }
  3952. compositeProfile.id = 0;
  3953. compositeProfile.stackLevel = 99 ;
  3954. sprintf((char*)compositeProfile.chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  3955. maxProfile.id = -1;
  3956. defaultTxProfile.id = -1;
  3957. txProfile.id = -1;
  3958. maxProfile.chargingSchedule[idxSchedule].duration = -1;
  3959. defaultTxProfile.chargingSchedule[idxSchedule].duration = -1;
  3960. txProfile.chargingSchedule[idxSchedule].duration = -1;
  3961. system("rm -f /tmp/*.json");
  3962. system("cp /Storage/OCPP/*.json /tmp 2>/dev/null");
  3963. /*
  3964. * Search valid charging profile
  3965. */
  3966. //DEBUG_INFO("====================================\n");
  3967. // Search tx profile
  3968. sprintf(profileFileName, "/tmp/TxProfile_%d_OCPP20.json", connectorId);
  3969. if((access(profileFileName, F_OK))!=-1)
  3970. {
  3971. fp = fopen(profileFileName, "r");
  3972. while(getline(&line, &len, fp) != -1)
  3973. {
  3974. json_object *obj = NULL;
  3975. obj = json_tokener_parse(line);
  3976. if(is_error(obj))
  3977. {
  3978. DEBUG_ERROR("Parse txProfile from file error.\n");
  3979. }
  3980. else
  3981. {
  3982. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != txProfile.id) &&
  3983. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= txProfile.stackLevel)
  3984. )
  3985. {
  3986. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  3987. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  3988. )
  3989. {
  3990. struct tm tmFrom, tmTo;
  3991. struct timeb tbFrom, tbTo;
  3992. 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) &&
  3993. (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))
  3994. {
  3995. tmFrom.tm_year -= 1900;
  3996. tmFrom.tm_mon -= 1;
  3997. tbFrom.time = mktime(&tmFrom);
  3998. tmTo.tm_year -= 1900;
  3999. tmTo.tm_mon -= 1;
  4000. tbTo.time = mktime(&tmTo);
  4001. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  4002. {
  4003. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4004. {
  4005. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4006. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4007. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4008. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  4009. }
  4010. if(txProfile.id == -1)
  4011. DEBUG_INFO("TxProfile found.\n");
  4012. else
  4013. DEBUG_INFO("TxProfile updated.\n");
  4014. // Required item
  4015. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4016. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4017. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4018. if(isUnitA)
  4019. {
  4020. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4021. 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++)
  4022. {
  4023. 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"));
  4024. 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?
  4025. 3:
  4026. 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")));
  4027. 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")));
  4028. }
  4029. }
  4030. else
  4031. {
  4032. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4033. 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++)
  4034. {
  4035. 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"));
  4036. 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?
  4037. 3:
  4038. 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")));
  4039. 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));
  4040. }
  4041. }
  4042. // Optional item
  4043. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4044. {
  4045. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4046. }
  4047. else
  4048. {
  4049. sprintf((char*)txProfile.validFrom, " ");
  4050. }
  4051. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4052. {
  4053. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4054. }
  4055. else
  4056. {
  4057. sprintf((char*)txProfile.validTo, " ");
  4058. }
  4059. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4060. {
  4061. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4062. }
  4063. else
  4064. {
  4065. sprintf((char*)txProfile.recurrencyKind, " ");
  4066. }
  4067. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4068. {
  4069. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4070. }
  4071. else
  4072. {
  4073. sprintf((char*)txProfile.transactionId, " ");
  4074. }
  4075. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  4076. {
  4077. 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"));
  4078. }
  4079. else
  4080. {
  4081. txProfile.chargingSchedule[idxSchedule].duration = 86400;
  4082. }
  4083. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  4084. {
  4085. 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")));
  4086. }
  4087. else
  4088. {
  4089. 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));
  4090. }
  4091. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  4092. {
  4093. 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"));
  4094. }
  4095. else
  4096. {
  4097. txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4098. }
  4099. }
  4100. }
  4101. }
  4102. else
  4103. {
  4104. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4105. {
  4106. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4107. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4108. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4109. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  4110. }
  4111. if(txProfile.id == -1)
  4112. DEBUG_INFO("TxProfile found.\n");
  4113. else
  4114. DEBUG_INFO("TxProfile updated.\n");
  4115. // Required item
  4116. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4117. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4118. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4119. if(isUnitA)
  4120. {
  4121. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4122. 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++)
  4123. {
  4124. 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"));
  4125. 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?
  4126. 3:
  4127. 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")));
  4128. 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")));
  4129. }
  4130. }
  4131. else
  4132. {
  4133. sprintf((char*)txProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4134. 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++)
  4135. {
  4136. 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"));
  4137. 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?
  4138. 3:
  4139. 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")));
  4140. 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));
  4141. }
  4142. }
  4143. // Optional item
  4144. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4145. {
  4146. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4147. }
  4148. else
  4149. {
  4150. sprintf((char*)txProfile.validFrom, " ");
  4151. }
  4152. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4153. {
  4154. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4155. }
  4156. else
  4157. {
  4158. sprintf((char*)txProfile.validTo, " ");
  4159. }
  4160. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4161. {
  4162. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4163. }
  4164. else
  4165. {
  4166. sprintf((char*)txProfile.recurrencyKind, " ");
  4167. }
  4168. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4169. {
  4170. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4171. }
  4172. else
  4173. {
  4174. sprintf((char*)txProfile.transactionId, " ");
  4175. }
  4176. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  4177. {
  4178. 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"));
  4179. }
  4180. else
  4181. {
  4182. txProfile.chargingSchedule[idxSchedule].duration = 86400;
  4183. }
  4184. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  4185. {
  4186. 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")));
  4187. }
  4188. else
  4189. {
  4190. 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));
  4191. }
  4192. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  4193. {
  4194. 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"));
  4195. }
  4196. else
  4197. {
  4198. txProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4199. }
  4200. }
  4201. }
  4202. }
  4203. json_object_put(obj);
  4204. }
  4205. fclose(fp);
  4206. /*
  4207. if(txProfile.id != -1)
  4208. {
  4209. DEBUG_INFO("Profile ID: %d\n", txProfile.id);
  4210. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  4211. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  4212. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  4213. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  4214. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  4215. DEBUG_INFO("Profile recurrencyKind: %s\n", txProfile.recurrencyKind);
  4216. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[idxSchedule].StartSchedule);
  4217. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
  4218. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4219. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4220. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4221. {
  4222. if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4223. {
  4224. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4225. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4226. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4227. }
  4228. }
  4229. }
  4230. else
  4231. DEBUG_INFO("TxProfile not found.\n");*/
  4232. }
  4233. // Search default tx profile
  4234. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d_OCPP20.json", connectorId);
  4235. if((access(profileFileName, F_OK))==-1)
  4236. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  4237. if((access(profileFileName, F_OK))!=-1)
  4238. {
  4239. fp = fopen(profileFileName, "r");
  4240. while(getline(&line, &len, fp) != -1)
  4241. {
  4242. json_object *obj = NULL;
  4243. obj = json_tokener_parse(line);
  4244. if(is_error(obj))
  4245. {
  4246. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  4247. }
  4248. else
  4249. {
  4250. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != defaultTxProfile.id) &&
  4251. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= defaultTxProfile.stackLevel)
  4252. )
  4253. {
  4254. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  4255. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4256. )
  4257. {
  4258. struct tm tmFrom, tmTo;
  4259. struct timeb tbFrom, tbTo;
  4260. 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) &&
  4261. (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))
  4262. {
  4263. tmFrom.tm_year -= 1900;
  4264. tmFrom.tm_mon -= 1;
  4265. tbFrom.time = mktime(&tmFrom);
  4266. tmTo.tm_year -= 1900;
  4267. tmTo.tm_mon -= 1;
  4268. tbTo.time = mktime(&tmTo);
  4269. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  4270. {
  4271. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4272. {
  4273. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4274. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4275. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4276. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  4277. }
  4278. if(defaultTxProfile.id == -1)
  4279. DEBUG_INFO("TxDefaultProfile found.\n");
  4280. else
  4281. DEBUG_INFO("TxDefaultProfile updated.\n");
  4282. // Required item
  4283. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4284. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4285. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4286. if(isUnitA)
  4287. {
  4288. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4289. 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++)
  4290. {
  4291. 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"));
  4292. 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?
  4293. 3:
  4294. 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")));
  4295. 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")));
  4296. }
  4297. }
  4298. else
  4299. {
  4300. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4301. 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++)
  4302. {
  4303. 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"));
  4304. 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?
  4305. 3:
  4306. 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")));
  4307. 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));
  4308. }
  4309. }
  4310. // Optional item
  4311. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4312. {
  4313. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4314. }
  4315. else
  4316. {
  4317. sprintf((char*)defaultTxProfile.validFrom, " ");
  4318. }
  4319. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4320. {
  4321. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4322. }
  4323. else
  4324. {
  4325. sprintf((char*)defaultTxProfile.validTo, " ");
  4326. }
  4327. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4328. {
  4329. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4330. }
  4331. else
  4332. {
  4333. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  4334. }
  4335. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4336. {
  4337. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4338. }
  4339. else
  4340. {
  4341. sprintf((char*)defaultTxProfile.transactionId, " ");
  4342. }
  4343. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  4344. {
  4345. 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"));
  4346. }
  4347. else
  4348. {
  4349. defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4350. }
  4351. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  4352. {
  4353. 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")));
  4354. }
  4355. else
  4356. {
  4357. 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));
  4358. }
  4359. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  4360. {
  4361. 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"));
  4362. }
  4363. else
  4364. {
  4365. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4366. }
  4367. }
  4368. }
  4369. }
  4370. else
  4371. {
  4372. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4373. {
  4374. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4375. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4376. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4377. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  4378. }
  4379. if(defaultTxProfile.id == -1)
  4380. DEBUG_INFO("TxDefaultProfile found.\n");
  4381. else
  4382. DEBUG_INFO("TxDefaultProfile updated.\n");
  4383. // Required item
  4384. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4385. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4386. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4387. if(isUnitA)
  4388. {
  4389. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4390. 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++)
  4391. {
  4392. 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"));
  4393. 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?
  4394. 3:
  4395. 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")));
  4396. 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")));
  4397. }
  4398. }
  4399. else
  4400. {
  4401. sprintf((char*)defaultTxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4402. 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++)
  4403. {
  4404. 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"));
  4405. 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?
  4406. 3:
  4407. 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")));
  4408. 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));
  4409. }
  4410. }
  4411. // Optional item
  4412. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4413. {
  4414. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4415. }
  4416. else
  4417. {
  4418. sprintf((char*)defaultTxProfile.validFrom, " ");
  4419. }
  4420. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4421. {
  4422. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4423. }
  4424. else
  4425. {
  4426. sprintf((char*)defaultTxProfile.validTo, " ");
  4427. }
  4428. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4429. {
  4430. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4431. }
  4432. else
  4433. {
  4434. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  4435. }
  4436. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4437. {
  4438. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4439. }
  4440. else
  4441. {
  4442. sprintf((char*)defaultTxProfile.transactionId, " ");
  4443. }
  4444. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  4445. {
  4446. 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"));
  4447. }
  4448. else
  4449. {
  4450. defaultTxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4451. }
  4452. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  4453. {
  4454. 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")));
  4455. }
  4456. else
  4457. {
  4458. 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));
  4459. }
  4460. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  4461. {
  4462. 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"));
  4463. }
  4464. else
  4465. {
  4466. defaultTxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4467. }
  4468. }
  4469. }
  4470. }
  4471. json_object_put(obj);
  4472. }
  4473. fclose(fp);
  4474. /*
  4475. if(defaultTxProfile.id != -1)
  4476. {
  4477. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.id);
  4478. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  4479. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  4480. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  4481. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  4482. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  4483. DEBUG_INFO("Profile recurrencyKind: %s\n", defaultTxProfile.recurrencyKind);
  4484. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].StartSchedule);
  4485. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
  4486. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4487. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4488. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4489. {
  4490. if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4491. {
  4492. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4493. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4494. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4495. }
  4496. }
  4497. }
  4498. else
  4499. DEBUG_INFO("TxDefaultProfile not found.\n");
  4500. DEBUG_INFO("------------------------------------\n");*/
  4501. }
  4502. // Search max profile
  4503. sprintf(profileFileName, "/tmp/ChargingStationMaxProfile_OCPP20.json");
  4504. if((access(profileFileName, F_OK))!=-1)
  4505. {
  4506. fp = fopen(profileFileName, "r");
  4507. while(getline(&line, &len, fp) != -1)
  4508. {
  4509. json_object *obj = NULL;
  4510. obj = json_tokener_parse(line);
  4511. if(is_error(obj))
  4512. {
  4513. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  4514. }
  4515. else
  4516. {
  4517. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != maxProfile.id) &&
  4518. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) >= maxProfile.stackLevel)
  4519. )
  4520. {
  4521. if((json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL) &&
  4522. (json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4523. )
  4524. {
  4525. struct tm tmFrom, tmTo;
  4526. struct timeb tbFrom, tbTo;
  4527. 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) &&
  4528. (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))
  4529. {
  4530. tmFrom.tm_year -= 1900;
  4531. tmFrom.tm_mon -= 1;
  4532. tbFrom.time = mktime(&tmFrom);
  4533. tmTo.tm_year -= 1900;
  4534. tmTo.tm_mon -= 1;
  4535. tbTo.time = mktime(&tmTo);
  4536. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  4537. {
  4538. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4539. {
  4540. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4541. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4542. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4543. }
  4544. if(maxProfile.id == -1)
  4545. DEBUG_INFO("MaxProfile found.\n");
  4546. else
  4547. DEBUG_INFO("MaxProfile updated.\n");
  4548. // Required item
  4549. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4550. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4551. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4552. if(isUnitA)
  4553. {
  4554. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4555. 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++)
  4556. {
  4557. 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"));
  4558. 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?
  4559. 3:
  4560. 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")));
  4561. 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")));
  4562. }
  4563. }
  4564. else
  4565. {
  4566. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4567. 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++)
  4568. {
  4569. 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"));
  4570. 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?
  4571. 3:
  4572. 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")));
  4573. 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));
  4574. }
  4575. }
  4576. // Optional item
  4577. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4578. {
  4579. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4580. }
  4581. else
  4582. {
  4583. sprintf((char*)maxProfile.validFrom, " ");
  4584. }
  4585. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4586. {
  4587. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4588. }
  4589. else
  4590. {
  4591. sprintf((char*)maxProfile.validTo, " ");
  4592. }
  4593. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4594. {
  4595. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4596. }
  4597. else
  4598. {
  4599. sprintf((char*)maxProfile.recurrencyKind, " ");
  4600. }
  4601. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4602. {
  4603. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4604. }
  4605. else
  4606. {
  4607. sprintf((char*)maxProfile.transactionId, " ");
  4608. }
  4609. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  4610. {
  4611. 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"));
  4612. }
  4613. else
  4614. {
  4615. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4616. }
  4617. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  4618. {
  4619. 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")));
  4620. }
  4621. else
  4622. {
  4623. 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));
  4624. }
  4625. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  4626. {
  4627. 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"));
  4628. }
  4629. else
  4630. {
  4631. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4632. }
  4633. }
  4634. }
  4635. }
  4636. else
  4637. {
  4638. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4639. {
  4640. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  4641. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit = -1;
  4642. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  4643. }
  4644. if(maxProfile.id == -1)
  4645. DEBUG_INFO("MaxProfile found.\n");
  4646. else
  4647. DEBUG_INFO("MaxProfile updated.\n");
  4648. // Required item
  4649. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id"));
  4650. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel"));
  4651. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingProfileKind")));
  4652. if(isUnitA)
  4653. {
  4654. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "A");
  4655. 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++)
  4656. {
  4657. 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"));
  4658. 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?
  4659. 3:
  4660. 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")));
  4661. 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")));
  4662. }
  4663. }
  4664. else
  4665. {
  4666. sprintf((char*)maxProfile.chargingSchedule[idxSchedule].chargingRateUnit, "W");
  4667. 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++)
  4668. {
  4669. 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"));
  4670. 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?
  4671. 3:
  4672. 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")));
  4673. 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));
  4674. }
  4675. }
  4676. // Optional item
  4677. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom") != NULL)
  4678. {
  4679. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validFrom")));
  4680. }
  4681. else
  4682. {
  4683. sprintf((char*)maxProfile.validFrom, " ");
  4684. }
  4685. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo") != NULL)
  4686. {
  4687. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "validTo")));
  4688. }
  4689. else
  4690. {
  4691. sprintf((char*)maxProfile.validTo, " ");
  4692. }
  4693. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind") != NULL)
  4694. {
  4695. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "recurrencyKind")));
  4696. }
  4697. else
  4698. {
  4699. sprintf((char*)maxProfile.recurrencyKind, " ");
  4700. }
  4701. if(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId") != NULL)
  4702. {
  4703. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "transactionId")));
  4704. }
  4705. else
  4706. {
  4707. sprintf((char*)maxProfile.transactionId, " ");
  4708. }
  4709. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "duration") != NULL)
  4710. {
  4711. 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"));
  4712. }
  4713. else
  4714. {
  4715. maxProfile.chargingSchedule[idxSchedule].duration = 86400;
  4716. }
  4717. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "startSchedule") != NULL)
  4718. {
  4719. 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")));
  4720. }
  4721. else
  4722. {
  4723. 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));
  4724. }
  4725. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "chargingSchedule"), 0), "minChargingRate") != NULL)
  4726. {
  4727. 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"));
  4728. }
  4729. else
  4730. {
  4731. maxProfile.chargingSchedule[idxSchedule].minChargingRate = -1;
  4732. }
  4733. }
  4734. }
  4735. }
  4736. json_object_put(obj);
  4737. }
  4738. fclose(fp);
  4739. /*
  4740. if(maxProfile.id !=-1)
  4741. {
  4742. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  4743. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  4744. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  4745. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  4746. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  4747. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  4748. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  4749. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[idxSchedule].StartSchedule);
  4750. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  4751. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4752. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4753. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4754. {
  4755. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4756. {
  4757. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4758. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4759. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4760. }
  4761. }
  4762. }
  4763. else
  4764. DEBUG_INFO("MaxProfile not found.\n");
  4765. DEBUG_INFO("------------------------------------\n");*/
  4766. }
  4767. /*
  4768. * Align found profile start schedule & periods
  4769. */
  4770. //DEBUG_INFO("====================================\n");
  4771. /*
  4772. // For local test usage, force modify found profile start schedule info
  4773. 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);
  4774. 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);
  4775. 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);
  4776. */
  4777. if(txProfile.id != -1)
  4778. {
  4779. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  4780. {
  4781. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4782. {
  4783. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4784. 0:
  4785. (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4786. }
  4787. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4788. {
  4789. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4790. {
  4791. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4792. 0:
  4793. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4794. if(idxPeriod > 0)
  4795. {
  4796. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4797. {
  4798. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4799. }
  4800. }
  4801. }
  4802. }
  4803. }
  4804. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  4805. {
  4806. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4807. {
  4808. 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?
  4809. 0:
  4810. (txProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4811. }
  4812. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4813. {
  4814. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4815. {
  4816. 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?
  4817. 0:
  4818. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4819. if(idxPeriod > 0)
  4820. {
  4821. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4822. {
  4823. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4824. }
  4825. }
  4826. }
  4827. }
  4828. }
  4829. else
  4830. {
  4831. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  4832. {
  4833. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4834. {
  4835. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4836. 0:
  4837. (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4838. }
  4839. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4840. {
  4841. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4842. {
  4843. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4844. 0:
  4845. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4846. if(idxPeriod > 0)
  4847. {
  4848. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4849. {
  4850. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4851. }
  4852. }
  4853. }
  4854. }
  4855. }
  4856. else
  4857. {
  4858. if(txProfile.chargingSchedule[idxSchedule].duration != -1)
  4859. {
  4860. txProfile.chargingSchedule[idxSchedule].duration = ((txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4861. 0:
  4862. (txProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4863. }
  4864. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4865. {
  4866. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4867. {
  4868. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4869. 0:
  4870. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4871. if(idxPeriod > 0)
  4872. {
  4873. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4874. {
  4875. txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4876. }
  4877. }
  4878. }
  4879. }
  4880. }
  4881. }
  4882. /*
  4883. DEBUG_INFO("txProfile after align.\n");
  4884. DEBUG_INFO("Profile ID: %d\n", txProfile.id);
  4885. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  4886. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  4887. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  4888. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  4889. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  4890. DEBUG_INFO("Profile recurrencyKind: %s\n", txProfile.recurrencyKind);
  4891. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile.ChargingSchedule.StartSchedule);
  4892. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[idxSchedule].Duration);
  4893. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  4894. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[idxSchedule].MinChargingRate);
  4895. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  4896. {
  4897. if(txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  4898. {
  4899. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  4900. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  4901. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  4902. }
  4903. }*/
  4904. }
  4905. if(defaultTxProfile.id != -1)
  4906. {
  4907. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  4908. {
  4909. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4910. {
  4911. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4912. 0:
  4913. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4914. }
  4915. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4916. {
  4917. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4918. {
  4919. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  4920. 0:
  4921. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4922. if(idxPeriod > 0)
  4923. {
  4924. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4925. {
  4926. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4927. }
  4928. }
  4929. }
  4930. }
  4931. }
  4932. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  4933. {
  4934. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4935. {
  4936. 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?
  4937. 0:
  4938. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4939. }
  4940. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4941. {
  4942. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4943. {
  4944. 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?
  4945. 0:
  4946. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  4947. if(idxPeriod > 0)
  4948. {
  4949. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4950. {
  4951. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4952. }
  4953. }
  4954. }
  4955. }
  4956. }
  4957. else
  4958. {
  4959. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  4960. {
  4961. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4962. {
  4963. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4964. 0:
  4965. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4966. }
  4967. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4968. {
  4969. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4970. {
  4971. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  4972. 0:
  4973. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  4974. if(idxPeriod > 0)
  4975. {
  4976. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  4977. {
  4978. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  4979. }
  4980. }
  4981. }
  4982. }
  4983. }
  4984. else
  4985. {
  4986. if(defaultTxProfile.chargingSchedule[idxSchedule].duration != -1)
  4987. {
  4988. defaultTxProfile.chargingSchedule[idxSchedule].duration = ((defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4989. 0:
  4990. (defaultTxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4991. }
  4992. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  4993. {
  4994. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  4995. {
  4996. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  4997. 0:
  4998. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  4999. if(idxPeriod > 0)
  5000. {
  5001. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  5002. {
  5003. defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  5004. }
  5005. }
  5006. }
  5007. }
  5008. }
  5009. }
  5010. /*
  5011. DEBUG_INFO("defaultTxProfile after align.\n");
  5012. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.id);
  5013. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  5014. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  5015. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  5016. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  5017. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  5018. DEBUG_INFO("Profile recurrencyKind: %s\n", defaultTxProfile.recurrencyKind);
  5019. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile.ChargingSchedule.StartSchedule);
  5020. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[idxSchedule].Duration);
  5021. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  5022. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  5023. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  5024. {
  5025. if(defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  5026. {
  5027. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  5028. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  5029. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  5030. }
  5031. }
  5032. DEBUG_INFO("------------------------------------\n");*/
  5033. }
  5034. if(maxProfile.id != -1)
  5035. {
  5036. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  5037. {
  5038. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  5039. {
  5040. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  5041. 0:
  5042. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  5043. }
  5044. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  5045. {
  5046. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  5047. {
  5048. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule))<0?
  5049. 0:
  5050. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  5051. if(idxPeriod > 0)
  5052. {
  5053. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  5054. {
  5055. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  5056. }
  5057. }
  5058. }
  5059. }
  5060. }
  5061. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  5062. {
  5063. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  5064. {
  5065. 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?
  5066. 0:
  5067. (maxProfile.chargingSchedule[idxSchedule].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[9].startSchedule)));
  5068. }
  5069. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  5070. {
  5071. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  5072. {
  5073. 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?
  5074. 0:
  5075. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile.chargingSchedule[idxSchedule].startSchedule)));
  5076. if(idxPeriod > 0)
  5077. {
  5078. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  5079. {
  5080. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  5081. }
  5082. }
  5083. }
  5084. }
  5085. }
  5086. else
  5087. {
  5088. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  5089. {
  5090. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  5091. {
  5092. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  5093. 0:
  5094. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  5095. }
  5096. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  5097. {
  5098. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  5099. {
  5100. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE))<0?
  5101. 0:
  5102. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, FALSE)));
  5103. if(idxPeriod > 0)
  5104. {
  5105. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  5106. {
  5107. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  5108. }
  5109. }
  5110. }
  5111. }
  5112. }
  5113. else
  5114. {
  5115. if(maxProfile.chargingSchedule[idxSchedule].duration != -1)
  5116. {
  5117. maxProfile.chargingSchedule[idxSchedule].duration = ((maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  5118. 0:
  5119. (maxProfile.chargingSchedule[idxSchedule].duration-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  5120. }
  5121. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  5122. {
  5123. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  5124. {
  5125. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE))<0?
  5126. 0:
  5127. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[idxSchedule].startSchedule, compositeProfile.chargingSchedule[idxSchedule].startSchedule, TRUE)));
  5128. if(idxPeriod > 0)
  5129. {
  5130. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod)
  5131. {
  5132. maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit;
  5133. }
  5134. }
  5135. }
  5136. }
  5137. }
  5138. }
  5139. /*
  5140. DEBUG_INFO("MaxProfile after align.\n");
  5141. DEBUG_INFO("Profile ID: %d\n", maxProfile.id);
  5142. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  5143. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  5144. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  5145. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  5146. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  5147. DEBUG_INFO("Profile recurrencyKind: %s\n", maxProfile.recurrencyKind);
  5148. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile.ChargingSchedule.StartSchedule);
  5149. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[idxSchedule].Duration);
  5150. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[idxSchedule].ChargingRateUnit);
  5151. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[idxSchedule].MinChargingRate);
  5152. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod);idxPeriod++)
  5153. {
  5154. if(maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  5155. {
  5156. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  5157. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].Limit);
  5158. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[idxSchedule].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  5159. }
  5160. }
  5161. DEBUG_INFO("------------------------------------\n");*/
  5162. }
  5163. /*
  5164. * Merge to conposite schedule
  5165. */
  5166. //DEBUG_INFO("====================================\n");
  5167. // Find each profile period quantity
  5168. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  5169. {
  5170. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  5171. limitMax = idx+1;
  5172. }
  5173. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  5174. {
  5175. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  5176. limitDef = idx+1;
  5177. }
  5178. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idx++)
  5179. {
  5180. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idx].limit != -1)
  5181. limitTx = idx+1;
  5182. }
  5183. // TxProfile found, composite schedule based on it
  5184. if(txProfile.id != -1)
  5185. {
  5186. compositeProfile.chargingSchedule[idxSchedule].duration = txProfile.chargingSchedule[idxSchedule].duration;
  5187. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  5188. {
  5189. if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  5190. (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  5191. (txProfile.chargingSchedule[idxSchedule].duration > 0))
  5192. {
  5193. if(maxProfile.id != -1)
  5194. {
  5195. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  5196. {
  5197. if((txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  5198. {
  5199. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5200. {
  5201. tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  5202. tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  5203. 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);
  5204. }
  5205. else
  5206. {
  5207. tmpPeriod.startPeriod = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  5208. tmpPeriod.numberPhases = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  5209. tmpPeriod.limit = txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].limit;
  5210. }
  5211. }
  5212. if(idxMaxPeriod == (limitMax-1))
  5213. {
  5214. if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  5215. {
  5216. if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5217. {
  5218. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5219. compositePeriodIdx++;
  5220. }
  5221. else
  5222. {
  5223. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5224. }
  5225. }
  5226. }
  5227. }
  5228. }
  5229. else
  5230. {
  5231. if(txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5232. {
  5233. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  5234. compositePeriodIdx++;
  5235. }
  5236. else
  5237. {
  5238. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  5239. }
  5240. }
  5241. }
  5242. if(idxTxPeriod == (limitTx-1))
  5243. {
  5244. if(defaultTxProfile.id != -1)
  5245. {
  5246. compositeProfile.chargingSchedule[idxSchedule].duration = (defaultTxProfile.chargingSchedule[idxSchedule].duration>compositeProfile.chargingSchedule[idxSchedule].duration)?defaultTxProfile.chargingSchedule[idxSchedule].duration:compositeProfile.chargingSchedule[idxSchedule].duration;
  5247. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  5248. {
  5249. if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[idxSchedule].duration-defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  5250. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  5251. (defaultTxProfile.chargingSchedule[idxSchedule].duration>0))
  5252. {
  5253. if(maxProfile.id != -1)
  5254. {
  5255. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  5256. {
  5257. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  5258. {
  5259. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5260. {
  5261. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  5262. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  5263. 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);
  5264. }
  5265. else
  5266. {
  5267. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  5268. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  5269. tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
  5270. }
  5271. if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  5272. {
  5273. if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5274. {
  5275. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5276. compositePeriodIdx++;
  5277. }
  5278. else
  5279. {
  5280. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5281. }
  5282. }
  5283. // Delete duplicate period
  5284. if(compositePeriodIdx > 1)
  5285. {
  5286. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  5287. {
  5288. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  5289. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  5290. compositePeriodIdx -= 1;
  5291. }
  5292. }
  5293. }
  5294. else
  5295. {
  5296. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5297. {
  5298. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5299. compositePeriodIdx++;
  5300. }
  5301. else
  5302. {
  5303. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5304. }
  5305. break;
  5306. }
  5307. }
  5308. }
  5309. else
  5310. {
  5311. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5312. {
  5313. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5314. compositePeriodIdx++;
  5315. }
  5316. else
  5317. {
  5318. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5319. }
  5320. }
  5321. }
  5322. }
  5323. }
  5324. }
  5325. }
  5326. }
  5327. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  5328. else if(defaultTxProfile.id != -1)
  5329. {
  5330. compositeProfile.chargingSchedule[idxSchedule].duration = defaultTxProfile.chargingSchedule[idxSchedule].duration;
  5331. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  5332. {
  5333. if((defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  5334. (defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  5335. (defaultTxProfile.chargingSchedule[idxSchedule].duration > 0))
  5336. {
  5337. if(maxProfile.id != -1)
  5338. {
  5339. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  5340. {
  5341. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  5342. {
  5343. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  5344. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  5345. if((maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5346. {
  5347. 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);
  5348. }
  5349. else
  5350. {
  5351. tmpPeriod.limit = defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].limit;
  5352. }
  5353. if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  5354. {
  5355. if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5356. {
  5357. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5358. compositePeriodIdx++;
  5359. }
  5360. else
  5361. {
  5362. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5363. }
  5364. }
  5365. // Delete duplicate period
  5366. if(compositePeriodIdx > 1)
  5367. {
  5368. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  5369. {
  5370. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  5371. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  5372. compositePeriodIdx -= 1;
  5373. }
  5374. }
  5375. }
  5376. else
  5377. {
  5378. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5379. {
  5380. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5381. compositePeriodIdx++;
  5382. }
  5383. else
  5384. {
  5385. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5386. }
  5387. break;
  5388. }
  5389. }
  5390. }
  5391. else
  5392. {
  5393. if(defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5394. {
  5395. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5396. compositePeriodIdx++;
  5397. }
  5398. else
  5399. {
  5400. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  5401. }
  5402. }
  5403. }
  5404. }
  5405. }
  5406. // Fill other period by MaxProfile
  5407. if(maxProfile.id != -1)
  5408. {
  5409. if(compositePeriodIdx==0)
  5410. {
  5411. compositeProfile.chargingSchedule[idxSchedule].duration = maxProfile.chargingSchedule[idxSchedule].duration;
  5412. for(int idxMaxPeriod=0;idxMaxPeriod<limitDef;idxMaxPeriod++)
  5413. {
  5414. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  5415. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  5416. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5417. {
  5418. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  5419. {
  5420. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct StructChargingSchedulePeriod));
  5421. compositePeriodIdx++;
  5422. }
  5423. else
  5424. {
  5425. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod],sizeof(struct StructChargingSchedulePeriod));
  5426. }
  5427. }
  5428. }
  5429. }
  5430. else
  5431. {
  5432. int lastCompositePeriodIdx = compositePeriodIdx;
  5433. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  5434. {
  5435. if((maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  5436. (maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  5437. (maxProfile.chargingSchedule[idxSchedule].duration > 0))
  5438. {
  5439. if((maxProfile.chargingSchedule[idxSchedule].duration >= compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod))
  5440. {
  5441. if(maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit > compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[lastCompositePeriodIdx-1].limit)
  5442. {
  5443. tmpPeriod.startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod;
  5444. tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  5445. tmpPeriod.limit = compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[lastCompositePeriodIdx-1].limit;
  5446. }
  5447. else
  5448. {
  5449. tmpPeriod.startPeriod = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].startPeriod;
  5450. tmpPeriod.numberPhases = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  5451. tmpPeriod.limit = maxProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxMaxPeriod].limit;
  5452. }
  5453. }
  5454. if(tmpPeriod.limit != -1)
  5455. {
  5456. if(tmpPeriod.limit != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)].limit)
  5457. {
  5458. if(tmpPeriod.startPeriod != compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)].startPeriod)
  5459. {
  5460. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5461. compositePeriodIdx++;
  5462. }
  5463. else
  5464. {
  5465. memcpy(&compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[(compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  5466. }
  5467. }
  5468. // Delete duplicate period
  5469. if(compositePeriodIdx > 1)
  5470. {
  5471. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit == compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-2].limit)
  5472. {
  5473. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].startPeriod = -1;
  5474. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[compositePeriodIdx-1].limit = -1;
  5475. compositePeriodIdx -= 1;
  5476. }
  5477. }
  5478. }
  5479. }
  5480. }
  5481. }
  5482. }
  5483. compositeProfile.chargingSchedule[idxSchedule].duration = durationReq;
  5484. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  5485. DEBUG_INFO("Schedule start: %s\n", compositeProfile.chargingSchedule[idxSchedule].startSchedule);
  5486. DEBUG_INFO("Schedule duration: %d\n", compositeProfile.chargingSchedule[idxSchedule].duration);
  5487. DEBUG_INFO("Rate unit: %s\n", compositeProfile.chargingSchedule[idxSchedule].chargingRateUnit);
  5488. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  5489. {
  5490. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  5491. {
  5492. compositeProfile.id = 1;
  5493. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod);
  5494. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit);
  5495. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases);
  5496. }
  5497. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit == -1)
  5498. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit =0;
  5499. if(compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  5500. compositeProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  5501. }
  5502. memcpy(targetCompositeProfile, &compositeProfile, sizeof(struct StructChargingProfile));
  5503. if(line)
  5504. free(line);
  5505. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  5506. }
  5507. //==========================================
  5508. // Init all share memory
  5509. //==========================================
  5510. int InitShareMemory()
  5511. {
  5512. int result = PASS;
  5513. int MeterSMId;
  5514. //creat ShmSysConfigAndInfo
  5515. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  5516. {
  5517. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  5518. result = FAIL;
  5519. }
  5520. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5521. {
  5522. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  5523. result = FAIL;
  5524. }
  5525. else
  5526. {}
  5527. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  5528. {
  5529. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  5530. result = FAIL;
  5531. }
  5532. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5533. {
  5534. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  5535. result = FAIL;
  5536. }
  5537. else
  5538. {}
  5539. //creat ShmPsuData
  5540. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  5541. {
  5542. DEBUG_ERROR("shmget ShmPsuData NG\n");
  5543. result = FAIL;
  5544. }
  5545. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5546. {
  5547. DEBUG_ERROR("shmat ShmPsuData NG\n");
  5548. result = FAIL;
  5549. }
  5550. else
  5551. {}
  5552. //creat ShmOCPP20Data
  5553. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  5554. {
  5555. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  5556. result = FAIL;
  5557. }
  5558. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  5559. {
  5560. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  5561. result = FAIL;
  5562. }
  5563. else
  5564. {}
  5565. /****************************** For Initial Settings************************************************/
  5566. /*
  5567. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  5568. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  5569. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  5570. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  5571. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  5572. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  5573. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  5574. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  5575. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  5576. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  5577. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  5578. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  5579. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  5580. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  5581. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  5582. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  5583. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  5584. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  5585. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  5586. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  5587. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  5588. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  5589. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  5590. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  5591. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  5592. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  5593. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  5594. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  5595. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  5596. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  5597. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  5598. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  5599. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  5600. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  5601. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  5602. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  5603. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  5604. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  5605. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  5606. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  5607. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  5608. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  5609. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  5610. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  5611. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  5612. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  5613. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  5614. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  5615. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  5616. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  5617. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  5618. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  5619. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  5620. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  5621. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  5622. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  5623. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  5624. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  5625. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  5626. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  5627. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  5628. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  5629. */
  5630. return result;
  5631. }
  5632. int ProcessShareMemory()
  5633. {
  5634. int result = PASS;
  5635. if(InitShareMemory() == FAIL)
  5636. {
  5637. DEBUG_ERROR("InitShareMemory NG\n");
  5638. if(ShmStatusCodeData!=NULL)
  5639. {
  5640. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  5641. }
  5642. result = FAIL;
  5643. }
  5644. if(RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo) != -1)
  5645. {
  5646. DEBUG_INFO("Model name rated power: %d\n", modelnameInfo.ratedPower);
  5647. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
  5648. ((ShmSysConfigAndInfo->SysConfig.ModelName[1]=='B') ||
  5649. (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='K') ||
  5650. (ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O'))
  5651. ) // 'D' means DC
  5652. {
  5653. // DO series
  5654. for(int gun_index=0; gun_index<GENERAL_GUN_QUANTITY ; gun_index++)
  5655. {
  5656. gunTotalNumber += 1;
  5657. gunType[gun_index] = GUN_TYPE_DO;
  5658. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5659. {
  5660. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == gun_index)
  5661. {
  5662. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  5663. periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  5664. DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption);
  5665. }
  5666. }
  5667. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  5668. {
  5669. case Gun_Type_Chademo:
  5670. DEBUG_INFO("Gun-%02d type: Cabinet CHAdeMO\n", gun_index);
  5671. for(int index = 0; index < CHAdeMO_QUANTITY; index++)
  5672. {
  5673. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == gun_index)
  5674. {
  5675. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  5676. periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  5677. DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption);
  5678. }
  5679. }
  5680. break;
  5681. case Gun_Type_CCS_2:
  5682. DEBUG_INFO("Gun-%02d type: Cabinet CCS\n", gun_index);
  5683. for (int index = 0; index < CCS_QUANTITY; index++)
  5684. {
  5685. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == gun_index)
  5686. {
  5687. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  5688. periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  5689. DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption);
  5690. }
  5691. }
  5692. break;
  5693. case Gun_Type_GB:
  5694. DEBUG_INFO("Gun-%02d type: Cabinet GBT\n", gun_index);
  5695. for (int index = 0; index < GB_QUANTITY; index++)
  5696. {
  5697. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == gun_index)
  5698. {
  5699. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  5700. periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  5701. DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption);
  5702. }
  5703. }
  5704. break;
  5705. case Gun_Type_AC:
  5706. DEBUG_INFO("Gun-%02d type: Cabinet AC\n", gun_index);
  5707. for (int index = 0; index < AC_QUANTITY; index++)
  5708. {
  5709. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == gun_index)
  5710. {
  5711. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  5712. periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  5713. DEBUG_INFO("Gun-%02d PowerConsumption: %.3f\n", gun_index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption);
  5714. }
  5715. }
  5716. break;
  5717. default:
  5718. DEBUG_WARN("Gun-%02d type: Cabinet unknown\n", gun_index);
  5719. break;
  5720. }
  5721. }
  5722. }
  5723. else
  5724. {
  5725. for(int gun_index=0;gun_index<modelnameInfo.GetGunCount;gun_index++)
  5726. {
  5727. gunTotalNumber += 1;
  5728. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  5729. {
  5730. case Gun_Type_Chademo:
  5731. gunType[gun_index] = GUN_TYPE_CHAdeMO;
  5732. DEBUG_INFO("Gun-%02d type: CHAdeMO\n", gun_index);
  5733. break;
  5734. case Gun_Type_CCS_2:
  5735. gunType[gun_index] = GUN_TYPE_CCS;
  5736. DEBUG_INFO("Gun-%02d type: CCS\n", gun_index);
  5737. break;
  5738. case Gun_Type_GB:
  5739. gunType[gun_index] = GUN_TYPE_GBT;
  5740. DEBUG_INFO("Gun-%02d type: GBT\n", gun_index);
  5741. break;
  5742. case Gun_Type_AC:
  5743. gunType[gun_index] = GUN_TYPE_AC;
  5744. DEBUG_INFO("Gun-%02d type: AC\n", gun_index);
  5745. break;
  5746. default:
  5747. DEBUG_WARN("Gun-%02d type: Unknown\n", gun_index);
  5748. break;
  5749. }
  5750. }
  5751. }
  5752. }
  5753. else
  5754. {
  5755. DEBUG_ERROR("Model name parsing fail.\n");
  5756. result = FAIL;
  5757. }
  5758. if(result != PASS)sleep(5);
  5759. return result;
  5760. }
  5761. //---------------------common routine---------------------------//
  5762. void checkNetworkProfile(void)
  5763. {
  5764. memcpy(ShmOCPP20Data->OcppServerURL, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  5765. json_object *priority;
  5766. priority = json_tokener_parse((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value);
  5767. if(!is_error(priority))
  5768. {
  5769. for(uint8_t idxPriority=0;idxPriority<json_object_array_length(priority);idxPriority++)
  5770. {
  5771. for(uint8_t idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile);idx++)
  5772. {
  5773. if((ShmOCPP20Data->NetworkConnectionProfile[idx].slot == json_object_get_int(json_object_array_get_idx(priority, idxPriority))) &&
  5774. (strlen((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl) > 0) &&
  5775. (ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount < 3))
  5776. {
  5777. memcpy(ShmOCPP20Data->OcppServerURL, ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl));
  5778. ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount++;
  5779. break;
  5780. }
  5781. }
  5782. }
  5783. }
  5784. json_object_put(priority);
  5785. DEBUG_INFO("Get network profile URL: %s\n", ShmOCPP20Data->OcppServerURL);
  5786. }
  5787. void checkRemoteStart(uint8_t connectorIdx)
  5788. {
  5789. uint8_t tempIndex;
  5790. int isAllowStart = TRUE;
  5791. char cmdBuf[512];
  5792. //check Transaction active
  5793. if(gunType[connectorIdx-1] == GUN_TYPE_CHAdeMO)
  5794. {
  5795. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5796. {
  5797. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  5798. }
  5799. else
  5800. {
  5801. tempIndex = (connectorIdx-1);
  5802. }
  5803. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5804. {
  5805. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex )
  5806. {
  5807. 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))
  5808. {
  5809. //Reserved
  5810. DEBUG_INFO("CHAdeMO connector already reserved and idTag match.\n");
  5811. }
  5812. 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))
  5813. {
  5814. //Reserved
  5815. DEBUG_INFO("CHAdeMO connector already reserved and idTag does not match.\n");
  5816. isAllowStart = FALSE;
  5817. }
  5818. else
  5819. {
  5820. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5821. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) //S_PRECHARGE
  5822. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) //S_PREPARING_FOR_EV
  5823. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE )) // S_PREPARING_FOR_EVSE
  5824. {
  5825. DEBUG_WARN("CHAdeMO connector not allow start cause busy.\n.");
  5826. isAllowStart = FALSE;
  5827. }
  5828. }//END FOR ELSE
  5829. }
  5830. }// END FOR CHAdeMO_QUANTITY
  5831. }
  5832. else if(gunType[connectorIdx-1] == GUN_TYPE_CCS)
  5833. {
  5834. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5835. {
  5836. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  5837. }
  5838. else
  5839. {
  5840. tempIndex = (connectorIdx-1);
  5841. }
  5842. for (int index = 0; index < CCS_QUANTITY; index++)
  5843. {
  5844. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5845. {
  5846. 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))
  5847. {
  5848. //Reserved
  5849. DEBUG_INFO("CCS connector already reserved and idTag match.\n");
  5850. }
  5851. 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))
  5852. {
  5853. //Reserved
  5854. DEBUG_INFO("CCS connector already reserved and idTag does not match.\n");
  5855. isAllowStart = FALSE;
  5856. }
  5857. else
  5858. {
  5859. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5860. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  5861. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  5862. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  5863. {
  5864. DEBUG_WARN("CCS connector not allow start cause busy.\n.");
  5865. isAllowStart = FALSE;
  5866. }
  5867. }// END FOR ELSE
  5868. }
  5869. }// END FOR CCS_QUANTITY
  5870. }
  5871. else if(gunType[connectorIdx-1] == GUN_TYPE_GBT)
  5872. {
  5873. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5874. {
  5875. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  5876. }
  5877. else
  5878. {
  5879. tempIndex = (connectorIdx-1);
  5880. }
  5881. for (int index = 0; index < GB_QUANTITY; index++)
  5882. {
  5883. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex )
  5884. {
  5885. 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))
  5886. {
  5887. //Reserved
  5888. DEBUG_INFO("GBT connector already reserved and idTag match.\n");
  5889. }
  5890. 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))
  5891. {
  5892. //Reserved
  5893. DEBUG_INFO("GBT connector already reserved and idTag does not match.\n");
  5894. isAllowStart = FALSE;
  5895. }
  5896. else
  5897. {
  5898. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5899. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  5900. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  5901. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  5902. {
  5903. DEBUG_WARN("GBT connector not allow start cause busy.\n");
  5904. isAllowStart = FALSE;
  5905. }
  5906. }// END FOR ELSE
  5907. }
  5908. } // END FOR GB_QUANTITY
  5909. }
  5910. else if(gunType[connectorIdx-1] == GUN_TYPE_DO)
  5911. {
  5912. tempIndex = (connectorIdx-1);
  5913. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5914. {
  5915. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex )
  5916. {
  5917. 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))
  5918. {
  5919. //Reserved
  5920. DEBUG_INFO("Dispenser connector already reserved and idTag match.\n");
  5921. }
  5922. 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))
  5923. {
  5924. //Reserved
  5925. DEBUG_INFO("Dispenser connector already reserved and idTag does not match.\n");
  5926. isAllowStart = FALSE;
  5927. }
  5928. else
  5929. {
  5930. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5931. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  5932. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  5933. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  5934. {
  5935. DEBUG_WARN("Dispenser connector not allow start cause busy.\n");
  5936. isAllowStart = FALSE;
  5937. }
  5938. }// END FOR ELSE
  5939. }
  5940. } // END FOR GB_QUANTITY
  5941. }
  5942. else
  5943. {
  5944. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  5945. {
  5946. tempIndex = 2;
  5947. }
  5948. else
  5949. {
  5950. tempIndex = (connectorIdx-1);
  5951. }
  5952. for (int index = 0; index < AC_QUANTITY; index++)
  5953. {
  5954. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex )
  5955. {
  5956. 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))
  5957. {
  5958. //Reserved
  5959. DEBUG_INFO("AC connector already reserved and idTag match.\n");
  5960. }
  5961. 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))
  5962. {
  5963. //Reserved
  5964. DEBUG_INFO("AC connector already reserved and idTag does not match.\n");
  5965. isAllowStart = FALSE;
  5966. }
  5967. else
  5968. {
  5969. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  5970. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  5971. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  5972. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  5973. {
  5974. DEBUG_WARN("AC connector not allow start cause busy.\n");
  5975. isAllowStart = FALSE;
  5976. }
  5977. }//END FOR ELSE
  5978. }
  5979. }// END FOR AC_QUANTITY
  5980. }
  5981. if(isAllowStart == TRUE)
  5982. {
  5983. if(ShmOCPP20Data->RequestStartTransaction[connectorIdx -1].chargingProfile.id > 0)
  5984. {
  5985. if((access("/Storage/OCPP/TxProfile_Tmp_OCPP20.json", F_OK))!=-1)
  5986. {
  5987. sprintf(cmdBuf, "mv /Storage/OCPP/TxProfile_Tmp_OCPP20.json /Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdx);
  5988. system(cmdBuf);
  5989. }
  5990. }
  5991. ShmOCPP20Data->CsMsg.bits[connectorIdx-1].RequestStartTransactionReq = ON;
  5992. }
  5993. }
  5994. void CheckSystemValue(void)
  5995. {
  5996. char filenmae[100]={0};
  5997. char str[100]={0};
  5998. int tempIndex = 0;
  5999. //===============================
  6000. // EVSE operation check
  6001. //===============================
  6002. //===============================
  6003. // Heartbeat check
  6004. //===============================
  6005. if((server_sign == TRUE) && (getDiffSecNow(clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  6006. {
  6007. //parameter for test
  6008. sendHeartbeatRequest(0);
  6009. //==============================================
  6010. // Reset Waiting Time
  6011. //==============================================
  6012. HeartBeatWithNOResponse += 1;
  6013. }
  6014. //===============================
  6015. // CSU Trigger Authorize Request
  6016. //===============================
  6017. if(isWebsocketSendable &&
  6018. (server_sign == TRUE) &&
  6019. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  6020. (authorizeRetryTimes < 3))
  6021. {
  6022. sendAuthorizeRequest(0);
  6023. authorizeRetryTimes = authorizeRetryTimes + 1;
  6024. if(authorizeRetryTimes < 3)
  6025. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6026. }
  6027. else if((server_sign == TRUE) &&
  6028. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  6029. (authorizeRetryTimes >= 3))
  6030. {
  6031. authorizeRetryTimes = 0;
  6032. SetOcppConnStatus(FALSE);
  6033. server_sign = FALSE;
  6034. }
  6035. else if((server_sign == FALSE) &&
  6036. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "true") == 0) &&
  6037. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "true") == 0) &&
  6038. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  6039. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  6040. {
  6041. sendAuthorizeRequest(0);
  6042. }
  6043. if(isWebsocketSendable &&
  6044. (server_sign == TRUE) &&
  6045. (ShmOCPP20Data->GetMonitoringReport.requestId > 0))
  6046. {
  6047. for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.monitoringCriteria);idxCriterion++)
  6048. {
  6049. if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_ThresholdMonitoring]) == 0)
  6050. {
  6051. /*
  6052. * TODO:
  6053. * 1. Report component that are ThresholdMonitoring
  6054. */
  6055. }
  6056. else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_DeltaMonitoring]) == 0)
  6057. {
  6058. /*
  6059. * TODO:
  6060. * 1. Report component that are DeltaMonitoring
  6061. */
  6062. }
  6063. else if(strcmp((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria[idxCriterion], MonitoringCriterionEnumTypeStr[MonitoringCriterionEnumType_PeriodicMonitoring]) == 0)
  6064. {
  6065. /*
  6066. * TODO:
  6067. * 1. Report component that are PeriodicMonitoring
  6068. */
  6069. }
  6070. else
  6071. {
  6072. /*
  6073. * TODO:
  6074. * 1. Process unknown criteria condition
  6075. */
  6076. }
  6077. }
  6078. ShmOCPP20Data->GetMonitoringReport.requestId = 0;
  6079. }
  6080. if(isWebsocketSendable &&
  6081. (server_sign == TRUE) &&
  6082. (ShmOCPP20Data->GetReport.requestId > 0))
  6083. {
  6084. for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetReport.componentCriteria);idxCriterion++)
  6085. {
  6086. if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Active]) == 0)
  6087. {
  6088. /*
  6089. * TODO:
  6090. * 1. Report component that are active
  6091. */
  6092. }
  6093. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Available]) == 0)
  6094. {
  6095. /*
  6096. * TODO:
  6097. * 1. Report component that are available
  6098. */
  6099. }
  6100. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Enabled]) == 0)
  6101. {
  6102. /*
  6103. * TODO:
  6104. * 1. Report component that are enable
  6105. */
  6106. }
  6107. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Problem]) == 0)
  6108. {
  6109. /*
  6110. * TODO:
  6111. * 1. Report component that are problem
  6112. */
  6113. }
  6114. else
  6115. {
  6116. /*
  6117. * TODO:
  6118. * 1. Process unknown criteria condition
  6119. */
  6120. }
  6121. }
  6122. ShmOCPP20Data->GetReport.requestId = 0;
  6123. }
  6124. if(isWebsocketSendable &&
  6125. (server_sign == TRUE) &&
  6126. (ShmOCPP20Data->GetBaseReport.requestId > 0))
  6127. {
  6128. uint8_t reportIdx = 0;
  6129. ShmOCPP20Data->NotifyReport.requestId = ShmOCPP20Data->GetBaseReport.requestId;
  6130. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_ConfigurationInventory]) == 0)
  6131. {
  6132. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  6133. {
  6134. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  6135. {
  6136. 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))
  6137. {
  6138. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  6139. reportIdx++;
  6140. }
  6141. }
  6142. else
  6143. {
  6144. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  6145. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  6146. ShmOCPP20Data->NotifyReport.seqNo += 1;
  6147. else
  6148. ShmOCPP20Data->NotifyReport.seqNo = 0;
  6149. sendNotifyReportRequest();
  6150. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  6151. reportIdx = 0;
  6152. idx_var--;
  6153. }
  6154. }
  6155. }
  6156. else if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_FullInventory]) == 0)
  6157. {
  6158. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  6159. {
  6160. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  6161. {
  6162. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  6163. reportIdx++;
  6164. }
  6165. else
  6166. {
  6167. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  6168. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  6169. ShmOCPP20Data->NotifyReport.seqNo += 1;
  6170. else
  6171. ShmOCPP20Data->NotifyReport.seqNo = 0;
  6172. sendNotifyReportRequest();
  6173. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  6174. reportIdx = 0;
  6175. idx_var--;
  6176. }
  6177. }
  6178. }
  6179. else
  6180. {
  6181. /*
  6182. * TODO:
  6183. * 1. Fill out summary inventory to response message, currently not support
  6184. */
  6185. }
  6186. if(reportIdx > 0)
  6187. {
  6188. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  6189. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  6190. ShmOCPP20Data->NotifyReport.seqNo += 1;
  6191. else
  6192. ShmOCPP20Data->NotifyReport.seqNo = 0;
  6193. sendNotifyReportRequest();
  6194. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  6195. reportIdx = 0;
  6196. }
  6197. ShmOCPP20Data->GetBaseReport.requestId = 0;
  6198. }
  6199. if(isWebsocketSendable &&
  6200. (server_sign == TRUE) &&
  6201. ShmOCPP20Data->SpMsg.bits.NotifyEventReq)
  6202. {
  6203. getNowDatetime(ShmOCPP20Data->NotifyEvent.generatedAt);
  6204. ShmOCPP20Data->NotifyEvent.tbc = FALSE;
  6205. if(ShmOCPP20Data->NotifyEvent.seqNo < INT_MAX)
  6206. ShmOCPP20Data->NotifyEvent.seqNo += 1;
  6207. else
  6208. ShmOCPP20Data->NotifyEvent.seqNo = 0;
  6209. sendNotifyEventRequest();
  6210. memset(&ShmOCPP20Data->NotifyEvent.eventData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)* sizeof(struct EventDataType ));
  6211. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  6212. }
  6213. if(isWebsocketSendable &&
  6214. (server_sign == TRUE) &&
  6215. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq)
  6216. {
  6217. if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Install]) == 0)
  6218. {
  6219. /*
  6220. * TODO:
  6221. * 1.
  6222. */
  6223. }
  6224. else if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Update]) == 0)
  6225. {
  6226. /*
  6227. * TODO:
  6228. * 1.
  6229. */
  6230. }
  6231. else
  6232. {
  6233. /*
  6234. * TODO:
  6235. * 1.
  6236. */
  6237. }
  6238. sendGet15118EVCertificateRequest();
  6239. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  6240. }
  6241. if(isWebsocketSendable &&
  6242. (server_sign == TRUE) &&
  6243. (ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq == ON))
  6244. {
  6245. sendSecurityEventNotificationRequest();
  6246. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  6247. }
  6248. if(isWebsocketSendable &&
  6249. (server_sign == TRUE) &&
  6250. (ShmOCPP20Data->SpMsg.bits.NotifyCustomerInformationReq == ON))
  6251. {
  6252. sendNotifyCustomerInformationRequest();
  6253. ShmOCPP20Data->SpMsg.bits.NotifyCustomerInformationReq = OFF;
  6254. }
  6255. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  6256. {
  6257. // ClockAlign MeterValue
  6258. 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))
  6259. {
  6260. //check Transaction active
  6261. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6262. {
  6263. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6264. {
  6265. tempIndex = ((gun_index==2) ? 1: 0);
  6266. }
  6267. else
  6268. {
  6269. tempIndex = gun_index;
  6270. }
  6271. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6272. {
  6273. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6274. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6275. {
  6276. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  6277. }
  6278. }// End for CHAdeMO
  6279. }
  6280. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6281. {
  6282. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6283. {
  6284. tempIndex = ((gun_index==2) ? 1: 0);
  6285. }
  6286. else
  6287. {
  6288. tempIndex = gun_index;
  6289. }
  6290. for (int index = 0; index < CCS_QUANTITY; index++)
  6291. {
  6292. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6293. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6294. {
  6295. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  6296. }
  6297. } // End for CCS
  6298. }
  6299. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6300. {
  6301. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6302. {
  6303. tempIndex = ((gun_index==2) ? 1: 0);
  6304. }
  6305. else
  6306. {
  6307. tempIndex = gun_index;
  6308. }
  6309. for (int index = 0; index < GB_QUANTITY; index++)
  6310. {
  6311. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6312. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6313. {
  6314. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6315. }
  6316. }// End for GB
  6317. }
  6318. else if(gunType[gun_index] == GUN_TYPE_DO)
  6319. {
  6320. tempIndex = gun_index;
  6321. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6322. {
  6323. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6324. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6325. {
  6326. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  6327. }
  6328. }
  6329. }
  6330. else
  6331. {
  6332. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6333. {
  6334. tempIndex = 2;
  6335. }
  6336. else
  6337. {
  6338. tempIndex = gun_index;
  6339. }
  6340. for (int index = 0; index < AC_QUANTITY; index++)
  6341. {
  6342. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6343. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6344. {
  6345. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  6346. }
  6347. }//End for AC
  6348. }
  6349. }
  6350. }
  6351. //===============================
  6352. // Each connector operation check
  6353. //===============================
  6354. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  6355. {
  6356. //==========================================
  6357. // Check remote start without connector id
  6358. //==========================================
  6359. if(ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq)
  6360. {
  6361. int connectorIdInt = -1;
  6362. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  6363. {
  6364. if(!cpinitateMsg.bits[gun_index].isOnCharging && (strstr((char*)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[ConnectorStatusEnumType_Occupied]) != NULL))
  6365. {
  6366. connectorIdInt = (gun_index+1);
  6367. DEBUG_INFO("Detect connector-%02d connected ready to start.\n", connectorIdInt);
  6368. checkRemoteStart(connectorIdInt);
  6369. ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq = OFF;
  6370. break;
  6371. }
  6372. }
  6373. if(getDiffSecNow(clientTime.RemoteStartWait) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value))
  6374. {
  6375. DEBUG_WARN("Remote start request without connector id wait link over %s seconds.\n", (char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value);
  6376. ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq = OFF;
  6377. }
  6378. }
  6379. //==========================================
  6380. // csu trigger DataTransferReq
  6381. //==========================================
  6382. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  6383. {
  6384. sendDataTransferRequest(gun_index);
  6385. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  6386. }
  6387. //==============================================
  6388. // Charger status notification & Transaction event report
  6389. //==============================================
  6390. //--- Check Mode Change ---//
  6391. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  6392. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6393. {
  6394. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6395. {
  6396. tempIndex = ((gun_index==2) ? 1: 0);
  6397. }
  6398. else
  6399. {
  6400. tempIndex = gun_index;
  6401. }
  6402. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6403. {
  6404. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6405. {
  6406. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  6407. {
  6408. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  6409. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  6410. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6411. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
  6412. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_COMPLETE) &&
  6413. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != AcPreviousSystemStatus[index]))
  6414. {
  6415. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6416. }
  6417. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  6418. {
  6419. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6420. if((access(filenmae,F_OK))!=-1)
  6421. {
  6422. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6423. sprintf(str,"rm -f %s",filenmae);
  6424. system(str);
  6425. }
  6426. }
  6427. }
  6428. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  6429. #if 1 // for TempStopTransaction
  6430. if(((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  6431. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6432. {
  6433. checkTempStopTransaction(gun_index);
  6434. }
  6435. #endif
  6436. }
  6437. }
  6438. }
  6439. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6440. {
  6441. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6442. {
  6443. tempIndex = ((gun_index==2) ? 1: 0);
  6444. }
  6445. else
  6446. {
  6447. tempIndex = gun_index;
  6448. }
  6449. for (int index = 0; index < CCS_QUANTITY; index++)
  6450. {
  6451. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6452. {
  6453. 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]*/ )
  6454. {
  6455. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  6456. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  6457. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6458. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
  6459. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_COMPLETE) &&
  6460. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != AcPreviousSystemStatus[index]))
  6461. {
  6462. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6463. }
  6464. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  6465. {
  6466. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6467. if((access(filenmae,F_OK))!=-1)
  6468. {
  6469. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6470. sprintf(str,"rm -f %s",filenmae);
  6471. system(str);
  6472. }
  6473. }
  6474. }
  6475. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  6476. #if 1 // for TempStopTransaction
  6477. if(((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  6478. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6479. {
  6480. checkTempStopTransaction(gun_index);
  6481. }
  6482. #endif
  6483. }
  6484. }
  6485. }
  6486. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6487. {
  6488. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6489. {
  6490. tempIndex = ((gun_index==2) ? 1: 0);
  6491. }
  6492. else
  6493. {
  6494. tempIndex = gun_index;
  6495. }
  6496. for (int index = 0; index < GB_QUANTITY; index++)
  6497. {
  6498. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6499. {
  6500. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  6501. {
  6502. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  6503. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  6504. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6505. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
  6506. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_COMPLETE) &&
  6507. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != AcPreviousSystemStatus[index]))
  6508. {
  6509. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6510. }
  6511. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  6512. {
  6513. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6514. if((access(filenmae,F_OK))!=-1)
  6515. {
  6516. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6517. sprintf(str,"rm -f %s",filenmae);
  6518. system(str);
  6519. }
  6520. }
  6521. }
  6522. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  6523. #if 1 // for TempStopTransaction
  6524. if(((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  6525. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6526. {
  6527. checkTempStopTransaction(gun_index);
  6528. }
  6529. #endif
  6530. }
  6531. }
  6532. }
  6533. else if(gunType[gun_index] == GUN_TYPE_DO)
  6534. {
  6535. tempIndex = gun_index;
  6536. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6537. {
  6538. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6539. {
  6540. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  6541. {
  6542. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  6543. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  6544. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6545. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CHARGING) &&
  6546. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_COMPLETE) &&
  6547. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != AcPreviousSystemStatus[index]))
  6548. {
  6549. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6550. }
  6551. 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
  6552. {
  6553. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6554. if((access(filenmae,F_OK))!=-1)
  6555. {
  6556. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6557. sprintf(str,"rm -f %s",filenmae);
  6558. system(str);
  6559. }
  6560. }
  6561. }
  6562. 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);
  6563. #if 1 // for TempStopTransaction
  6564. if(((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE)) &&
  6565. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6566. {
  6567. checkTempStopTransaction(gun_index);
  6568. }
  6569. #endif
  6570. }
  6571. }
  6572. }
  6573. else
  6574. {
  6575. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6576. {
  6577. tempIndex = 2;
  6578. }
  6579. else
  6580. {
  6581. tempIndex = gun_index;
  6582. }
  6583. for (int index = 0; index < AC_QUANTITY; index++)
  6584. {
  6585. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6586. {
  6587. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  6588. {
  6589. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_AUTHORIZING)
  6590. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  6591. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CHARGING) &&
  6592. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_COMPLETE) &&
  6593. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]))
  6594. {
  6595. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  6596. }
  6597. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  6598. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  6599. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_IDLE))) // complete
  6600. {
  6601. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d_OCPP20.json",(gun_index+1));
  6602. if((access(filenmae,F_OK))!=-1)
  6603. {
  6604. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  6605. sprintf(str,"rm -f %s",filenmae);
  6606. system(str);
  6607. }
  6608. }
  6609. }
  6610. cpinitateMsg.bits[gun_index].isOnCharging = ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)?1:0);
  6611. #if 1 // for TempStopTransaction
  6612. if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE)) &&
  6613. (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  6614. {
  6615. checkTempStopTransaction(gun_index);
  6616. }
  6617. #endif
  6618. }
  6619. }// END
  6620. }
  6621. if(isWebsocketSendable && (server_sign == TRUE) && (getDiffSecNow(clientTime.StatusNotification[gun_index]) >= 5) && (ShmOCPP20Data->MsMsg.bits.ResetConf != ON) &&
  6622. ((cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) || (cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq == ON) ||
  6623. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].value, "true") == 0) &&
  6624. (getDiffSecNow(clientTime.StatusNotification[gun_index]) >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationInterval].variableAttribute[0].value)))))
  6625. {
  6626. sendStatusNotificationRequest(gun_index);
  6627. refreshStartTimer(&clientTime.StatusNotification[gun_index]);
  6628. }
  6629. //==============================================
  6630. // CSU Trigger Smart Charging Profile
  6631. //==============================================
  6632. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  6633. {
  6634. checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
  6635. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index], 0, TRUE);
  6636. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  6637. }
  6638. //==============================================
  6639. // CSU transaction event
  6640. //==============================================
  6641. if(ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == ON || cpinitateMsg.bits[gun_index].TriggerTransactionEventReq == ON)
  6642. {
  6643. sendTransactionEventRequest(gun_index);
  6644. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  6645. cpinitateMsg.bits[gun_index].TriggerTransactionEventReq = OFF;
  6646. //storeTempStopTransaction(gun_index);
  6647. //memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], 0x00, sizeof(struct MeterValueType));
  6648. }
  6649. //==============================================
  6650. // Meter report
  6651. //==============================================
  6652. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  6653. {
  6654. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  6655. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  6656. }
  6657. if(isWebsocketSendable && (cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON))
  6658. {
  6659. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  6660. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  6661. }
  6662. // Sample period MeterValue
  6663. 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))
  6664. {
  6665. //check Transaction active
  6666. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  6667. {
  6668. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6669. {
  6670. tempIndex = ((gun_index==2) ? 1: 0);
  6671. }
  6672. else
  6673. {
  6674. tempIndex = gun_index;
  6675. }
  6676. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6677. {
  6678. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6679. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  6680. {
  6681. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  6682. {
  6683. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6684. }
  6685. }
  6686. }// End for CHAdeMO
  6687. }
  6688. else if(gunType[gun_index] == GUN_TYPE_CCS)
  6689. {
  6690. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6691. {
  6692. tempIndex = ((gun_index==2) ? 1: 0);
  6693. }
  6694. else
  6695. {
  6696. tempIndex = gun_index;
  6697. }
  6698. for (int index = 0; index < CCS_QUANTITY; index++)
  6699. {
  6700. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6701. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6702. {
  6703. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  6704. {
  6705. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6706. }
  6707. }
  6708. } // End for CCS
  6709. }
  6710. else if(gunType[gun_index] == GUN_TYPE_GBT)
  6711. {
  6712. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6713. {
  6714. tempIndex = ((gun_index==2) ? 1: 0);
  6715. }
  6716. else
  6717. {
  6718. tempIndex = gun_index;
  6719. }
  6720. for (int index = 0; index < GB_QUANTITY; index++)
  6721. {
  6722. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6723. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6724. {
  6725. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  6726. {
  6727. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6728. }
  6729. }
  6730. }// End for GB
  6731. }
  6732. else if(gunType[gun_index] == GUN_TYPE_DO)
  6733. {
  6734. tempIndex = gun_index;
  6735. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6736. {
  6737. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6738. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6739. {
  6740. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  6741. {
  6742. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6743. }
  6744. }
  6745. }
  6746. }
  6747. else
  6748. {
  6749. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6750. {
  6751. tempIndex = 2;
  6752. }
  6753. else
  6754. {
  6755. tempIndex = gun_index;
  6756. }
  6757. for (int index = 0; index < AC_QUANTITY; index++)
  6758. {
  6759. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  6760. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6761. {
  6762. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  6763. {
  6764. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  6765. }
  6766. }
  6767. }//End for AC
  6768. }
  6769. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  6770. {
  6771. if(atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value) > 0)
  6772. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  6773. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  6774. }
  6775. refreshStartTimer(&clientTime.MeterValues[gun_index]);
  6776. }
  6777. //==============================================
  6778. // Check Connector reserved
  6779. //==============================================
  6780. //===============================
  6781. // Check if Reserve is expired
  6782. //===============================
  6783. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0))
  6784. {
  6785. if(isOvertNow(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime))
  6786. {
  6787. DEBUG_INFO("reserve expired.\n");
  6788. ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId = ShmOCPP20Data->ReserveNow[gun_index].id;
  6789. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Expired]);
  6790. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = ON;
  6791. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  6792. }
  6793. }//END OF Check if Reserve is expired
  6794. //==========================================
  6795. // csu trigger FirmwareStatusNotificationReq
  6796. //==========================================
  6797. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  6798. {
  6799. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  6800. }
  6801. //==========================================
  6802. // csu cleared charging limit request
  6803. //==========================================
  6804. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq == ON))
  6805. {
  6806. sendClearedChargingLimitRequest(gun_index);
  6807. }
  6808. //==========================================
  6809. // csu trigger CancelReservationConf
  6810. //==========================================
  6811. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  6812. {
  6813. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  6814. }
  6815. //==========================================
  6816. // csu notify EV charging need request
  6817. //==========================================
  6818. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq == ON))
  6819. {
  6820. sendNotifyEVChargingNeedsRequest(gun_index);
  6821. }
  6822. //==========================================
  6823. // csu trigger ChangeAvailabilityConf
  6824. //==========================================
  6825. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  6826. {
  6827. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  6828. }
  6829. //==========================================
  6830. // csu trigger UnlockConnectorConf
  6831. //==========================================
  6832. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  6833. {
  6834. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  6835. }
  6836. //==========================================
  6837. // csu trigger ReserveNowConf
  6838. //==========================================
  6839. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  6840. {
  6841. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  6842. }
  6843. //==========================================
  6844. // csu trigger ReserveNowConf
  6845. //==========================================
  6846. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq == ON))
  6847. {
  6848. sendReservationStatusUpdateRequest(gun_index);
  6849. }
  6850. //==========================================
  6851. // csu trigger LogStatusNotificationReq
  6852. //==========================================
  6853. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq == ON))
  6854. {
  6855. if(isCancelUploadLog == TRUE)
  6856. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  6857. else
  6858. sendLogStatusNotificationRequest((char *)ShmOCPP20Data->LogStatusNotification.status);
  6859. }
  6860. //==========================================
  6861. // csu trigger SignCertificateReq
  6862. //==========================================
  6863. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.SignCertificateReq == ON))
  6864. {
  6865. if((access("/Storage/OCPP/certCP.csr",F_OK) != -1) &&
  6866. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) == 0) )
  6867. {
  6868. sendSignCertificateRequest(CertificateSignedStatusEnumType_ChargingStationCertificate);
  6869. }
  6870. else if((access("/Storage/OCPP/certV2G.csr",F_OK) != -1) &&
  6871. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0))
  6872. {
  6873. sendSignCertificateRequest(CertificateSignedStatusEnumType_V2GCertificate);
  6874. }
  6875. }
  6876. }
  6877. }
  6878. //==========================================
  6879. // send request routine
  6880. //==========================================
  6881. int sendAuthorizeRequest(int gun_index)
  6882. {
  6883. mtrace();
  6884. int result = FAIL;
  6885. char message[4096]={0};
  6886. char guid[37];
  6887. char tempdata[128]={0};
  6888. json_object *Authorize = json_object_new_object();
  6889. json_object *idToken = json_object_new_object();
  6890. DEBUG_INFO("sendAuthorizeRequest...\n");
  6891. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  6892. //Local Authorize
  6893. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "true")==0) && (ShmOCPP20Data->OcppConnStatus == 0))
  6894. {
  6895. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  6896. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  6897. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  6898. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  6899. result = PASS;
  6900. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6901. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6902. authorizeRetryTimes = 0;
  6903. return result;
  6904. }
  6905. 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)) ||
  6906. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "true") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "true") == 0)))
  6907. {
  6908. // Query idtag from cache
  6909. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  6910. // Query idtag from list
  6911. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  6912. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  6913. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  6914. {
  6915. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  6916. {
  6917. DEBUG_INFO("Card %s does not find in list or cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  6918. }
  6919. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  6920. {
  6921. DEBUG_INFO("Card %s does not accepted in list and cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  6922. }
  6923. // Return authorize result if does not connect to server
  6924. if(!ShmOCPP20Data->OcppConnStatus)
  6925. {
  6926. DEBUG_INFO("Local Authorization Fail.\n");
  6927. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  6928. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6929. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  6930. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  6931. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6932. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6933. authorizeRetryTimes = 0;
  6934. return result;
  6935. }
  6936. }
  6937. else
  6938. {
  6939. DEBUG_INFO("Local Authorization get result.\n");
  6940. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  6941. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6942. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  6943. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  6944. else
  6945. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  6946. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  6947. result = PASS;
  6948. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6949. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  6950. authorizeRetryTimes = 0;
  6951. return result;
  6952. }
  6953. }
  6954. //get data from shared memory
  6955. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  6956. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  6957. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  6958. json_object_object_add(Authorize, "idToken", idToken);
  6959. random_uuid(guid);
  6960. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  6961. json_object_put(Authorize);
  6962. LWS_Send(message);
  6963. sprintf(tempdata, "Authorize,%d", gun_index);
  6964. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6965. {
  6966. result = PASS;
  6967. }
  6968. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  6969. return result;
  6970. }
  6971. int sendBootNotificationRequest()
  6972. {
  6973. mtrace();
  6974. int result = FAIL;
  6975. char message[4096]={0};
  6976. char guid[37]={0};
  6977. char tempdata[128]={0};
  6978. json_object *BootNotification = json_object_new_object();
  6979. json_object *chargingStation = json_object_new_object();
  6980. json_object *modem = json_object_new_object();
  6981. DEBUG_INFO("sendBootNotificationRequest...\n");
  6982. // Fill BootNotification fields
  6983. DB_getBooType();
  6984. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  6985. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  6986. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  6987. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  6988. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  6989. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  6990. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  6991. {
  6992. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  6993. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  6994. json_object_object_add(chargingStation, "modem", modem);
  6995. }
  6996. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  6997. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  6998. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  6999. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  7000. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  7001. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  7002. random_uuid(guid);
  7003. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  7004. json_object_put(BootNotification);
  7005. LWS_Send(message);
  7006. sprintf(tempdata, "BootNotification,0");
  7007. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7008. {
  7009. result = PASS;
  7010. }
  7011. return result;
  7012. }
  7013. int sendClearedChargingLimitRequest(int gun_index)
  7014. {
  7015. mtrace();
  7016. int result = FAIL;
  7017. char message[4096]={0};
  7018. char guid[37]={0};
  7019. char tempdata[128]={0};
  7020. json_object *ClearedChargingLimit = json_object_new_object();
  7021. DEBUG_INFO("sendClearedChargingLimitRequest...\n");
  7022. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  7023. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  7024. random_uuid(guid);
  7025. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  7026. json_object_put(ClearedChargingLimit);
  7027. LWS_Send(message);
  7028. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  7029. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7030. {
  7031. result = PASS;
  7032. }
  7033. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  7034. return result;
  7035. }
  7036. int sendDataTransferRequest(int gun_index)
  7037. {
  7038. mtrace();
  7039. char message[1000]={0};
  7040. char guid[37]={0};
  7041. char tempdata[65]={0};
  7042. int result = FAIL;
  7043. DEBUG_INFO("sendDataTransferRequest...\n");
  7044. random_uuid(guid);
  7045. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  7046. MESSAGE_TYPE_CALL,
  7047. guid,
  7048. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  7049. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  7050. ShmOCPP20Data->DataTransfer[gun_index].data);
  7051. LWS_Send(message);
  7052. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  7053. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7054. {
  7055. result = PASS;
  7056. }
  7057. return result;
  7058. }
  7059. int sendFirmwareStatusNotificationRequest(char *status)
  7060. {
  7061. mtrace();
  7062. int result = FAIL;
  7063. char message[110]={0};
  7064. char guid[37]={0};
  7065. char tempdata[65]={0};
  7066. json_object *FirmwareStatusNotification = json_object_new_object();
  7067. DEBUG_INFO("sendFirmwareStatusNotificationRequest...\n");
  7068. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  7069. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  7070. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  7071. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  7072. random_uuid(guid);
  7073. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  7074. json_object_put(FirmwareStatusNotification);
  7075. LWS_SendNow(message);
  7076. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  7077. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7078. {
  7079. result = PASS;
  7080. }
  7081. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  7082. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  7083. //record status
  7084. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  7085. {
  7086. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  7087. }
  7088. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  7089. {
  7090. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  7091. }
  7092. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  7093. {
  7094. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  7095. }
  7096. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  7097. {
  7098. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  7099. }
  7100. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  7101. {
  7102. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  7103. }
  7104. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  7105. {
  7106. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  7107. }
  7108. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  7109. {
  7110. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  7111. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  7112. }
  7113. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  7114. {
  7115. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  7116. }
  7117. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  7118. {
  7119. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  7120. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  7121. DB_updateSecurityEventType(SecurityEventEnumType_FirmwareUpdated);
  7122. }
  7123. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  7124. {
  7125. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  7126. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  7127. DB_updateSecurityEventType(SecurityEventEnumType_FirmwareUpdated);
  7128. }
  7129. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  7130. {
  7131. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  7132. }
  7133. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  7134. {
  7135. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  7136. }
  7137. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  7138. {
  7139. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  7140. }
  7141. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  7142. {
  7143. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  7144. }
  7145. return result;
  7146. }
  7147. int sendGet15118EVCertificateRequest()
  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 *Get15118EVCertificate = json_object_new_object();
  7155. DEBUG_INFO("sendGet15118EVCertificateRequest...\n");
  7156. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  7157. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  7158. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  7159. random_uuid(guid);
  7160. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  7161. json_object_put(Get15118EVCertificate);
  7162. LWS_Send(message);
  7163. sprintf(tempdata, "Get15118EVCertificate,0");
  7164. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7165. {
  7166. result = PASS;
  7167. }
  7168. return result;
  7169. }
  7170. int sendGetCertificateStatusRequest()
  7171. {
  7172. mtrace();
  7173. int result = FAIL;
  7174. char message[4096]={0};
  7175. char guid[37]={0};
  7176. char tempdata[128]={0};
  7177. json_object *GetCertificateStatus = json_object_new_object();
  7178. json_object *ocspRequestData = json_object_new_object();
  7179. DEBUG_INFO("sendGetCertificateStatusRequest...\n");
  7180. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  7181. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  7182. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  7183. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  7184. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  7185. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  7186. random_uuid(guid);
  7187. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  7188. json_object_put(GetCertificateStatus);
  7189. LWS_Send(message);
  7190. sprintf(tempdata, "GetCertificateStatus,0");
  7191. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7192. {
  7193. result = PASS;
  7194. }
  7195. return result;
  7196. }
  7197. int sendHeartbeatRequest()
  7198. {
  7199. mtrace();
  7200. int result = FAIL;
  7201. char message[40096]={0};
  7202. char guid[37]={0};
  7203. char tempdata[128]={0};
  7204. DEBUG_INFO("sendHeartbeatRequest...\n");
  7205. random_uuid(guid);
  7206. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{}]"
  7207. , MESSAGE_TYPE_CALL
  7208. , guid );
  7209. LWS_Send(message);
  7210. sprintf(tempdata, "Heartbeat,%d", 0);
  7211. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7212. {
  7213. result = PASS;
  7214. }
  7215. return result;
  7216. }
  7217. int sendLogStatusNotificationRequest(char *status)
  7218. {
  7219. mtrace();
  7220. int result = FAIL;
  7221. char message[4096]={0};
  7222. char guid[37]={0};
  7223. char tempdata[128]={0};
  7224. json_object *LogStatusNotification = json_object_new_object();
  7225. DEBUG_INFO("sendLogStatusNotificationRequest...\n");
  7226. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  7227. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  7228. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  7229. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  7230. random_uuid(guid);
  7231. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  7232. json_object_put(LogStatusNotification);
  7233. LWS_SendNow(message);
  7234. sprintf(tempdata, "LogStatusNotification,%d", 0);
  7235. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7236. {
  7237. result = PASS;
  7238. }
  7239. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  7240. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  7241. //record status
  7242. if(strcmp(status,"BadMessage")==0)
  7243. {
  7244. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  7245. }
  7246. else if(strcmp(status,"Idle")==0)
  7247. {
  7248. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  7249. }
  7250. else if(strcmp(status,"NotSupportedOperation")==0)
  7251. {
  7252. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  7253. }
  7254. else if(strcmp(status,"PermissionDenied")==0)
  7255. {
  7256. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  7257. }
  7258. else if(strcmp(status,"Uploaded")==0)
  7259. {
  7260. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  7261. }
  7262. else if(strcmp(status,"UploadFailure")==0)
  7263. {
  7264. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  7265. }
  7266. else if(strcmp(status,"Uploading")==0)
  7267. {
  7268. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  7269. }
  7270. return result;
  7271. }
  7272. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  7273. {
  7274. mtrace();
  7275. int result = FAIL;
  7276. char guid[37]={0};
  7277. char tempdata[65]={0};
  7278. int tempIndex = 0;
  7279. json_object *MeterValueReq = json_object_new_object();
  7280. json_object *meterValues = json_object_new_array();
  7281. json_object *sampledValues = json_object_new_array();
  7282. DEBUG_INFO("sendMeterValuesRequest...\n");
  7283. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  7284. memset(&ShmOCPP20Data->MeterValues[gun_index], 0, sizeof(struct MeterValues_20));
  7285. //set value
  7286. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  7287. //UTC Date time
  7288. struct timeval tmnow;
  7289. struct tm *tm;
  7290. char buf[28];//, usec_buf[6];
  7291. gettimeofday(&tmnow, NULL);
  7292. time_t t;
  7293. t = time(NULL);
  7294. /*UTC time and date*/
  7295. tm = gmtime(&t);
  7296. if(dataType == ReadingContextEnumType_Sample_Clock)
  7297. {
  7298. struct tm *tmTarget;
  7299. struct timeb tbTarget;
  7300. tbTarget.time = mktime(tm);
  7301. tbTarget.time -= (atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value));
  7302. tmTarget = gmtime(&tbTarget.time);
  7303. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tmTarget);
  7304. }
  7305. else
  7306. {
  7307. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  7308. }
  7309. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  7310. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  7311. //idx_sample=0;
  7312. //********************************(1)Current.Import L1************************************************/
  7313. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7314. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7315. (dataType == ReadingContextEnumType_Trigger))
  7316. {
  7317. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7318. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7319. {
  7320. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7321. {
  7322. tempIndex = ((gun_index==2) ? 1: 0);
  7323. }
  7324. else
  7325. {
  7326. tempIndex = gun_index;
  7327. }
  7328. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7329. {
  7330. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7331. {
  7332. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent*100))/100.0;
  7333. }
  7334. }
  7335. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7336. }
  7337. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7338. {
  7339. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7340. {
  7341. tempIndex = ((gun_index==2) ? 1: 0);
  7342. }
  7343. else
  7344. {
  7345. tempIndex = gun_index;
  7346. }
  7347. for (int index = 0; index < CCS_QUANTITY; index++)
  7348. {
  7349. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7350. {
  7351. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent*100))/100.0;
  7352. }
  7353. }
  7354. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7355. }
  7356. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7357. {
  7358. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7359. {
  7360. tempIndex = ((gun_index==2) ? 1: 0);
  7361. }
  7362. else
  7363. {
  7364. tempIndex = gun_index;
  7365. }
  7366. for (int index = 0; index < GB_QUANTITY; index++)
  7367. {
  7368. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7369. {
  7370. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent*100))/100.0;
  7371. }
  7372. }
  7373. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7374. }
  7375. else if(gunType[gun_index] == GUN_TYPE_DO)
  7376. {
  7377. tempIndex = gun_index;
  7378. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7379. {
  7380. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7381. {
  7382. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*100))/100.0;
  7383. }
  7384. }
  7385. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7386. }
  7387. else
  7388. {
  7389. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7390. {
  7391. tempIndex = 2;
  7392. }
  7393. else
  7394. {
  7395. tempIndex = gun_index;
  7396. }
  7397. for (int index = 0; index < AC_QUANTITY; index++)
  7398. {
  7399. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7400. {
  7401. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent*100))/100.0;
  7402. }
  7403. }
  7404. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7405. }
  7406. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  7407. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  7408. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7409. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  7410. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  7411. }
  7412. //idx_sample=1;
  7413. //********************************(2)Energy.Active.Import.Register ************************************************/
  7414. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]) != NULL)) ||
  7415. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]) != NULL)) ||
  7416. (dataType == ReadingContextEnumType_Trigger))
  7417. {
  7418. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7419. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7420. {
  7421. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7422. {
  7423. tempIndex = ((gun_index==2) ? 1: 0);
  7424. }
  7425. else
  7426. {
  7427. tempIndex = gun_index;
  7428. }
  7429. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7430. {
  7431. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7432. {
  7433. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption*100))/100.0;
  7434. }
  7435. }
  7436. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7437. }
  7438. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7439. {
  7440. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7441. {
  7442. tempIndex = ((gun_index==2) ? 1: 0);
  7443. }
  7444. else
  7445. {
  7446. tempIndex = gun_index;
  7447. }
  7448. for (int index = 0; index < CCS_QUANTITY; index++)
  7449. {
  7450. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7451. {
  7452. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption*100))/100.0;
  7453. }
  7454. }
  7455. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7456. }
  7457. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7458. {
  7459. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7460. {
  7461. tempIndex = ((gun_index==2) ? 1: 0);
  7462. }
  7463. else
  7464. {
  7465. tempIndex = gun_index;
  7466. }
  7467. for (int index = 0; index < GB_QUANTITY; index++)
  7468. {
  7469. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7470. {
  7471. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption*100))/100.0;
  7472. }
  7473. }
  7474. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7475. }
  7476. else if(gunType[gun_index] == GUN_TYPE_DO)
  7477. {
  7478. tempIndex = gun_index;
  7479. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7480. {
  7481. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7482. {
  7483. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100))/100.0;
  7484. }
  7485. }
  7486. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7487. }
  7488. else
  7489. {
  7490. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7491. {
  7492. tempIndex = 2;
  7493. }
  7494. else
  7495. {
  7496. tempIndex = gun_index;
  7497. }
  7498. for (int index = 0; index < AC_QUANTITY; index++)
  7499. {
  7500. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7501. {
  7502. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption*100))/100.0;
  7503. }
  7504. }
  7505. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7506. }
  7507. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  7508. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  7509. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7510. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  7511. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  7512. }
  7513. //idx_sample=2;
  7514. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  7515. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]) != NULL)) ||
  7516. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]) != NULL)) ||
  7517. (dataType == ReadingContextEnumType_Trigger))
  7518. {
  7519. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7520. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7521. {
  7522. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7523. {
  7524. tempIndex = ((gun_index==2) ? 1: 0);
  7525. }
  7526. else
  7527. {
  7528. tempIndex = gun_index;
  7529. }
  7530. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7531. {
  7532. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7533. {
  7534. //ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy*100))/100.0;
  7535. if(dataType == ReadingContextEnumType_Sample_Clock)
  7536. {
  7537. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption - periousClockPowerConsumption[gun_index]);
  7538. periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  7539. }
  7540. else if(dataType == ReadingContextEnumType_Sample_Periodic)
  7541. {
  7542. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]);
  7543. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  7544. }
  7545. else
  7546. {
  7547. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = 0;
  7548. }
  7549. }
  7550. } // END OF FOR CHAdeMO_QUANTITY
  7551. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7552. }
  7553. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7554. {
  7555. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7556. {
  7557. tempIndex = ((gun_index==2) ? 1: 0);
  7558. }
  7559. else
  7560. {
  7561. tempIndex = gun_index;
  7562. }
  7563. for (int index = 0; index < CCS_QUANTITY; index++)
  7564. {
  7565. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7566. {
  7567. //ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy*100))/100.0;
  7568. if(dataType == ReadingContextEnumType_Sample_Clock)
  7569. {
  7570. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption - periousClockPowerConsumption[gun_index]);
  7571. periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  7572. }
  7573. else if(dataType == ReadingContextEnumType_Sample_Periodic)
  7574. {
  7575. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]);
  7576. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  7577. }
  7578. else
  7579. {
  7580. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = 0;
  7581. }
  7582. }
  7583. } // END OF CCS_QUANTITY
  7584. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7585. }
  7586. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7587. {
  7588. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7589. {
  7590. tempIndex = ((gun_index==2) ? 1: 0);
  7591. }
  7592. else
  7593. {
  7594. tempIndex = gun_index;
  7595. }
  7596. for (int index = 0; index < GB_QUANTITY; index++)
  7597. {
  7598. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7599. {
  7600. //ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy*100))/100.0;
  7601. if(dataType == ReadingContextEnumType_Sample_Clock)
  7602. {
  7603. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption - periousClockPowerConsumption[gun_index]);
  7604. periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  7605. }
  7606. else if(dataType == ReadingContextEnumType_Sample_Periodic)
  7607. {
  7608. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]);
  7609. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  7610. }
  7611. else
  7612. {
  7613. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = 0;
  7614. }
  7615. }
  7616. } // END OF GB_QUANTITY
  7617. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7618. }
  7619. else if(gunType[gun_index] == GUN_TYPE_DO)
  7620. {
  7621. tempIndex = gun_index;
  7622. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7623. {
  7624. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7625. {
  7626. //ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100))/100.0;
  7627. if(dataType == ReadingContextEnumType_Sample_Clock)
  7628. {
  7629. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption - periousClockPowerConsumption[gun_index]);
  7630. periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  7631. }
  7632. else if(dataType == ReadingContextEnumType_Sample_Periodic)
  7633. {
  7634. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption - periousPeriodicPowerConsumption[gun_index]);
  7635. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  7636. }
  7637. else
  7638. {
  7639. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = 0;
  7640. }
  7641. }
  7642. }
  7643. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7644. }
  7645. else
  7646. {
  7647. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7648. {
  7649. tempIndex = 2;
  7650. }
  7651. else
  7652. {
  7653. tempIndex = gun_index;
  7654. }
  7655. for (int index = 0; index < AC_QUANTITY; index++)
  7656. {
  7657. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7658. {
  7659. //ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy*100))/100.0;
  7660. if(dataType == ReadingContextEnumType_Sample_Clock)
  7661. {
  7662. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption - periousClockPowerConsumption[gun_index]);
  7663. periousClockPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  7664. }
  7665. else if(dataType == ReadingContextEnumType_Sample_Periodic)
  7666. {
  7667. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption - periousPeriodicPowerConsumption[gun_index]);
  7668. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  7669. }
  7670. else
  7671. {
  7672. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = 0;
  7673. }
  7674. }
  7675. }
  7676. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7677. }
  7678. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  7679. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  7680. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7681. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  7682. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  7683. }
  7684. //idx_sample=3;
  7685. //********************************(4)Power.Active.Import************************************************/
  7686. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]) != NULL)) ||
  7687. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]) != NULL)) ||
  7688. (dataType == ReadingContextEnumType_Trigger))
  7689. {
  7690. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7691. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7692. {
  7693. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7694. {
  7695. tempIndex = ((gun_index==2) ? 1: 0);
  7696. }
  7697. else
  7698. {
  7699. tempIndex = gun_index;
  7700. }
  7701. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7702. {
  7703. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7704. {
  7705. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower*100))/100.0;
  7706. }
  7707. } // END OF FOR
  7708. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7709. }
  7710. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7711. {
  7712. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7713. {
  7714. tempIndex = ((gun_index==2) ? 1: 0);
  7715. }
  7716. else
  7717. {
  7718. tempIndex = gun_index;
  7719. }
  7720. for (int index = 0; index < CCS_QUANTITY; index++)
  7721. {
  7722. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7723. {
  7724. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower*100))/100.0;
  7725. }
  7726. }
  7727. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7728. }
  7729. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7730. {
  7731. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7732. {
  7733. tempIndex = ((gun_index==2) ? 1: 0);
  7734. }
  7735. else
  7736. {
  7737. tempIndex = gun_index;
  7738. }
  7739. for (int index = 0; index < GB_QUANTITY; index++)
  7740. {
  7741. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7742. {
  7743. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7744. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower*100))/100.0;
  7745. }
  7746. }
  7747. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7748. }
  7749. else if(gunType[gun_index] == GUN_TYPE_DO)
  7750. {
  7751. tempIndex = gun_index;
  7752. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7753. {
  7754. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7755. {
  7756. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  7757. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower*100))/100.0;
  7758. }
  7759. }
  7760. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7761. }
  7762. else
  7763. {
  7764. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7765. {
  7766. tempIndex = 2;
  7767. }
  7768. else
  7769. {
  7770. tempIndex = gun_index;
  7771. }
  7772. for (int index = 0; index < AC_QUANTITY; index++)
  7773. {
  7774. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7775. {
  7776. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower*100))/100.0;
  7777. }
  7778. }
  7779. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7780. }
  7781. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  7782. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  7783. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7784. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  7785. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  7786. }
  7787. //idx_sample=4;
  7788. //***********************************************(5)VOLTAGE L1******************************************************/
  7789. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7790. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  7791. (dataType == ReadingContextEnumType_Trigger))
  7792. {
  7793. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7794. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7795. {
  7796. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7797. {
  7798. tempIndex = ((gun_index==2) ? 1: 0);
  7799. }
  7800. else
  7801. {
  7802. tempIndex = gun_index;
  7803. }
  7804. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7805. {
  7806. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7807. {
  7808. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage*100))/100.0;
  7809. }
  7810. }
  7811. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7812. }
  7813. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7814. {
  7815. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7816. {
  7817. tempIndex = ((gun_index==2) ? 1: 0);
  7818. }
  7819. else
  7820. {
  7821. tempIndex = gun_index;
  7822. }
  7823. for (int index = 0; index < CCS_QUANTITY; index++)
  7824. {
  7825. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7826. {
  7827. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage*100))/100.0;
  7828. }
  7829. }
  7830. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7831. }
  7832. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7833. {
  7834. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7835. {
  7836. tempIndex = ((gun_index==2) ? 1: 0);
  7837. }
  7838. else
  7839. {
  7840. tempIndex = gun_index;
  7841. }
  7842. for (int index = 0; index < GB_QUANTITY; index++)
  7843. {
  7844. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7845. {
  7846. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage*100))/100.0;
  7847. }
  7848. }
  7849. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7850. }
  7851. else if(gunType[gun_index] == GUN_TYPE_DO)
  7852. {
  7853. tempIndex = gun_index;
  7854. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7855. {
  7856. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7857. {
  7858. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage*100))/100.0;
  7859. }
  7860. }
  7861. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7862. }
  7863. else
  7864. {
  7865. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7866. {
  7867. tempIndex = 2;
  7868. }
  7869. else
  7870. {
  7871. tempIndex = gun_index;
  7872. }
  7873. for (int index = 0; index < AC_QUANTITY; index++)
  7874. {
  7875. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7876. {
  7877. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage*100))/100.0;
  7878. }
  7879. }
  7880. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  7881. }
  7882. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  7883. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  7884. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7885. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  7886. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  7887. }
  7888. //***********************************************(6)SOC******************************************************/
  7889. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) != NULL)) ||
  7890. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) != NULL)) ||
  7891. (dataType == ReadingContextEnumType_Trigger))
  7892. {
  7893. 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))
  7894. {
  7895. if((ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0') && (gunType[gun_index] != GUN_TYPE_DO))
  7896. {
  7897. tempIndex = ((gun_index==2) ? 1: 0);
  7898. }
  7899. else
  7900. {
  7901. tempIndex = gun_index;
  7902. }
  7903. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  7904. {
  7905. //tempIndex = ((gun_index==2) ? 1: 0);
  7906. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7907. {
  7908. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  7909. {
  7910. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  7911. }
  7912. }
  7913. }
  7914. else if(gunType[gun_index] == GUN_TYPE_CCS)
  7915. {
  7916. //tempIndex = ((gun_index==2) ? 1: 0);
  7917. for (int index = 0; index < CCS_QUANTITY; index++)
  7918. {
  7919. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7920. {
  7921. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  7922. }
  7923. }
  7924. }
  7925. else if(gunType[gun_index] == GUN_TYPE_GBT)
  7926. {
  7927. //tempIndex = ((gun_index==2) ? 1: 0);
  7928. for (int index = 0; index < GB_QUANTITY; index++)
  7929. {
  7930. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7931. {
  7932. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  7933. }
  7934. }
  7935. }
  7936. else if(gunType[gun_index] == GUN_TYPE_DO)
  7937. {
  7938. //tempIndex = ((gun_index==2) ? 1: 0);
  7939. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7940. {
  7941. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7942. {
  7943. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  7944. }
  7945. }
  7946. }
  7947. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  7948. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  7949. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  7950. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  7951. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  7952. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  7953. }
  7954. }
  7955. //********************************(7)Current.Import L2************************************************/
  7956. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7957. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7958. (dataType == ReadingContextEnumType_Trigger))
  7959. {
  7960. // Only for AC 3 phase
  7961. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7962. {
  7963. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7964. {
  7965. tempIndex = 2;
  7966. }
  7967. else
  7968. {
  7969. tempIndex = gun_index;
  7970. }
  7971. for (int index = 0; index < AC_QUANTITY; index++)
  7972. {
  7973. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7974. {
  7975. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2*100))/100.0;
  7976. }
  7977. }
  7978. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  7979. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  7980. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  7981. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  7982. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  7983. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  7984. }
  7985. }
  7986. //********************************(8)Current.Import L3************************************************/
  7987. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7988. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]) != NULL)) ||
  7989. (dataType == ReadingContextEnumType_Trigger))
  7990. {
  7991. // Only for AC 3 phase
  7992. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  7993. {
  7994. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7995. {
  7996. tempIndex = 2;
  7997. }
  7998. else
  7999. {
  8000. tempIndex = gun_index;
  8001. }
  8002. for (int index = 0; index < AC_QUANTITY; index++)
  8003. {
  8004. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  8005. {
  8006. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3*100))/100.0;
  8007. }
  8008. }
  8009. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  8010. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  8011. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  8012. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  8013. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  8014. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  8015. }
  8016. }
  8017. //***********************************************(9)VOLTAGE L2******************************************************/
  8018. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  8019. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  8020. (dataType == ReadingContextEnumType_Trigger))
  8021. {
  8022. if( (gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  8023. {
  8024. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8025. {
  8026. tempIndex = 2;
  8027. }
  8028. else
  8029. {
  8030. tempIndex = gun_index;
  8031. }
  8032. for (int index = 0; index < AC_QUANTITY; index++)
  8033. {
  8034. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  8035. {
  8036. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2*100))/100.0;
  8037. }
  8038. }
  8039. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  8040. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  8041. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  8042. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  8043. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  8044. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  8045. }
  8046. }
  8047. //***********************************************(10)VOLTAGE L3******************************************************/
  8048. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  8049. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]) != NULL)) ||
  8050. (dataType == ReadingContextEnumType_Trigger))
  8051. {
  8052. if((gunType[gun_index] == GUN_TYPE_AC) && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'D')))
  8053. {
  8054. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8055. {
  8056. tempIndex = 2;
  8057. }
  8058. else
  8059. {
  8060. tempIndex = gun_index;
  8061. }
  8062. for (int index = 0; index < AC_QUANTITY; index++)
  8063. {
  8064. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  8065. {
  8066. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3*100))/100.0;
  8067. }
  8068. }
  8069. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  8070. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  8071. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  8072. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  8073. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  8074. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  8075. }
  8076. }
  8077. //***********************************************(11)Current.Offered******************************************************/
  8078. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) != NULL)) ||
  8079. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]) != NULL)) ||
  8080. (dataType == ReadingContextEnumType_Trigger))
  8081. {
  8082. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  8083. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  8084. {
  8085. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8086. {
  8087. tempIndex = ((gun_index==2) ? 1: 0);
  8088. }
  8089. else
  8090. {
  8091. tempIndex = gun_index;
  8092. }
  8093. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8094. {
  8095. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  8096. {
  8097. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].AvailableChargingCurrent/10);
  8098. }
  8099. } // END OF FOR
  8100. }
  8101. else if(gunType[gun_index] == GUN_TYPE_CCS)
  8102. {
  8103. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8104. {
  8105. tempIndex = ((gun_index==2) ? 1: 0);
  8106. }
  8107. else
  8108. {
  8109. tempIndex = gun_index;
  8110. }
  8111. for (int index = 0; index < CCS_QUANTITY; index++)
  8112. {
  8113. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  8114. {
  8115. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].AvailableChargingCurrent/10);
  8116. }
  8117. }
  8118. }
  8119. else if(gunType[gun_index] == GUN_TYPE_GBT)
  8120. {
  8121. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8122. {
  8123. tempIndex = ((gun_index==2) ? 1: 0);
  8124. }
  8125. else
  8126. {
  8127. tempIndex = gun_index;
  8128. }
  8129. for (int index = 0; index < GB_QUANTITY; index++)
  8130. {
  8131. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  8132. {
  8133. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  8134. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].AvailableChargingCurrent/10);;
  8135. }
  8136. }
  8137. }
  8138. else if(gunType[gun_index] == GUN_TYPE_DO)
  8139. {
  8140. tempIndex = gun_index;
  8141. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8142. {
  8143. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  8144. {
  8145. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  8146. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.AvailableChargingCurrent/10);;
  8147. }
  8148. }
  8149. }
  8150. else
  8151. {
  8152. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8153. {
  8154. tempIndex = 2;
  8155. }
  8156. else
  8157. {
  8158. tempIndex = gun_index;
  8159. }
  8160. for (int index = 0; index < AC_QUANTITY; index++)
  8161. {
  8162. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  8163. {
  8164. uint16_t currentOffer;
  8165. if(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent == 0)
  8166. {
  8167. currentOffer = ShmSysConfigAndInfo->SysConfig.RatingCurrent;
  8168. }
  8169. else
  8170. {
  8171. currentOffer = ((ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent>ShmSysConfigAndInfo->SysConfig.RatingCurrent)?ShmSysConfigAndInfo->SysConfig.RatingCurrent:ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
  8172. }
  8173. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].value = currentOffer;
  8174. }
  8175. }
  8176. }
  8177. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].context, ReadingContextEnumTypeStr[dataType]);
  8178. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Offered]);
  8179. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  8180. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].unitOfMeasure.uint , "A");
  8181. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[10].unitOfMeasure.multiplier = 0;
  8182. }
  8183. //***********************************************(12)Power.Offered******************************************************/
  8184. if(((dataType == ReadingContextEnumType_Sample_Clock) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) != NULL)) ||
  8185. ((dataType == ReadingContextEnumType_Sample_Periodic) && (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]) != NULL)) ||
  8186. (dataType == ReadingContextEnumType_Trigger))
  8187. {
  8188. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  8189. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  8190. {
  8191. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8192. {
  8193. tempIndex = ((gun_index==2) ? 1: 0);
  8194. }
  8195. else
  8196. {
  8197. tempIndex = gun_index;
  8198. }
  8199. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8200. {
  8201. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  8202. {
  8203. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].AvailableChargingPower*100);
  8204. }
  8205. } // END OF FOR
  8206. }
  8207. else if(gunType[gun_index] == GUN_TYPE_CCS)
  8208. {
  8209. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8210. {
  8211. tempIndex = ((gun_index==2) ? 1: 0);
  8212. }
  8213. else
  8214. {
  8215. tempIndex = gun_index;
  8216. }
  8217. for (int index = 0; index < CCS_QUANTITY; index++)
  8218. {
  8219. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  8220. {
  8221. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].AvailableChargingPower*100);
  8222. }
  8223. }
  8224. }
  8225. else if(gunType[gun_index] == GUN_TYPE_GBT)
  8226. {
  8227. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8228. {
  8229. tempIndex = ((gun_index==2) ? 1: 0);
  8230. }
  8231. else
  8232. {
  8233. tempIndex = gun_index;
  8234. }
  8235. for (int index = 0; index < GB_QUANTITY; index++)
  8236. {
  8237. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  8238. {
  8239. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  8240. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].AvailableChargingPower*100);
  8241. }
  8242. }
  8243. }
  8244. else if(gunType[gun_index] == GUN_TYPE_DO)
  8245. {
  8246. tempIndex = gun_index;
  8247. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  8248. {
  8249. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  8250. {
  8251. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  8252. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].value = (uint16_t) (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.AvailableChargingPower*100);
  8253. }
  8254. }
  8255. }
  8256. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].context, ReadingContextEnumTypeStr[dataType]);
  8257. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Offered]);
  8258. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  8259. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].unitOfMeasure.uint , "W");
  8260. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[11].unitOfMeasure.multiplier = 0;
  8261. }
  8262. // Message create ====================================================================================================
  8263. random_uuid(guid);
  8264. for(uint8_t idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue);idxMeter++)
  8265. {
  8266. json_object *meterValue = json_object_new_object();
  8267. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  8268. {
  8269. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  8270. {
  8271. json_object *sampledValue = json_object_new_object();
  8272. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  8273. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  8274. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  8275. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  8276. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  8277. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  8278. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  8279. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  8280. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  8281. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  8282. {
  8283. json_object *unitOfMeasure = json_object_new_object();
  8284. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  8285. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  8286. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  8287. }
  8288. json_object_array_add(sampledValues, sampledValue);
  8289. }
  8290. }
  8291. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  8292. json_object_object_add(meterValue, "sampledValue", sampledValues);
  8293. json_object_array_add(meterValues, meterValue);
  8294. idxMeter++;
  8295. }
  8296. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  8297. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  8298. sprintf(queuedata,"[%d,\"%s\",\"MeterValues\",%s]"
  8299. ,MESSAGE_TYPE_CALL
  8300. ,guid
  8301. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  8302. json_object_put(MeterValueReq);
  8303. if((dataType != ReadingContextEnumType_Trigger) &&
  8304. (dataType != ReadingContextEnumType_Sample_Clock))
  8305. {
  8306. // Transaction meter value send by TransactionEvent message
  8307. memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
  8308. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = ON;
  8309. result = PASS;
  8310. }
  8311. else
  8312. {
  8313. // Put request guid to hash map
  8314. sprintf(tempdata, "MeterValues,%d", (gun_index));
  8315. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8316. {
  8317. result = PASS;
  8318. }
  8319. if((dataType != ReadingContextEnumType_Trigger) &&
  8320. (dataType != ReadingContextEnumType_Sample_Clock))
  8321. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  8322. else
  8323. {
  8324. if(FirstHeartBeat)
  8325. LWS_Send(queuedata);
  8326. }
  8327. }
  8328. return result;
  8329. }
  8330. int sendNotifyChargingLimitRequest(int gun_index)
  8331. {
  8332. mtrace();
  8333. int result = FAIL;
  8334. char message[4096]={0};
  8335. char guid[37]={0};
  8336. char tempdata[128]={0};
  8337. json_object *NotifyChargingLimit = json_object_new_object();
  8338. json_object *chargingLimit = json_object_new_object();
  8339. DEBUG_INFO("sendNotifyChargingLimitRequest...\n");
  8340. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  8341. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  8342. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  8343. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  8344. random_uuid(guid);
  8345. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  8346. json_object_put(NotifyChargingLimit);
  8347. LWS_Send(message);
  8348. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  8349. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8350. {
  8351. result = PASS;
  8352. }
  8353. return result;
  8354. }
  8355. int sendNotifyCustomerInformationRequest()
  8356. {
  8357. mtrace();
  8358. int result = FAIL;
  8359. char message[4096]={0};
  8360. char guid[37]={0};
  8361. char tempdata[128]={0};
  8362. json_object *NotifyCustomerInformation = json_object_new_object();
  8363. DEBUG_INFO("sendNotifyCustomerInformationRequest...\n");
  8364. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  8365. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  8366. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  8367. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  8368. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  8369. random_uuid(guid);
  8370. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  8371. json_object_put(NotifyCustomerInformation);
  8372. LWS_Send(message);
  8373. sprintf(tempdata, "NotifyCustomerInformation,0");
  8374. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8375. {
  8376. result = PASS;
  8377. }
  8378. return result;
  8379. }
  8380. int sendNotifyDisplayMessagesRequest()
  8381. {
  8382. mtrace();
  8383. int result = FAIL;
  8384. char message[4096]={0};
  8385. char guid[37]={0};
  8386. char tempdata[128]={0};
  8387. json_object *NotifyDisplayMessages = json_object_new_object();
  8388. json_object *messageInfos = json_object_new_array();
  8389. DEBUG_INFO("sendNotifyDisplayMessagesRequest...\n");
  8390. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  8391. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  8392. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  8393. {
  8394. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  8395. {
  8396. json_object *messageInfo = json_object_new_object();
  8397. json_object *message = json_object_new_object();
  8398. json_object *display = json_object_new_object();
  8399. json_object *evse = json_object_new_object();
  8400. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  8401. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  8402. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  8403. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  8404. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  8405. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  8406. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  8407. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  8408. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  8409. json_object_object_add(messageInfo, "message", message);
  8410. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  8411. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  8412. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  8413. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  8414. json_object_object_add(display, "evse",evse);
  8415. json_object_object_add(messageInfo, "evse", display);
  8416. json_object_array_add(messageInfos, messageInfo);
  8417. }
  8418. }
  8419. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  8420. random_uuid(guid);
  8421. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  8422. json_object_put(NotifyDisplayMessages);
  8423. LWS_Send(message);
  8424. sprintf(tempdata, "NotifyDisplayMessages,0");
  8425. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8426. {
  8427. result = PASS;
  8428. }
  8429. return result;
  8430. }
  8431. int sendNotifyEVChargingNeedsRequest(int gun_index)
  8432. {
  8433. mtrace();
  8434. int result = FAIL;
  8435. char message[4096]={0};
  8436. char guid[37]={0};
  8437. char tempdata[128]={0};
  8438. json_object *NotifyEVChargingNeeds = json_object_new_object();
  8439. json_object *chargingNeeds = json_object_new_object();
  8440. json_object *acChargingParameters = json_object_new_object();
  8441. json_object *dcChargingParameters = json_object_new_object();
  8442. DEBUG_INFO("sendNotifyEVChargingNeedsRequest...\n");
  8443. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  8444. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  8445. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  8446. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  8447. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  8448. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  8449. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  8450. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  8451. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  8452. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  8453. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  8454. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  8455. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  8456. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  8457. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  8458. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  8459. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  8460. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  8461. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  8462. random_uuid(guid);
  8463. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  8464. json_object_put(NotifyEVChargingNeeds);
  8465. LWS_Send(message);
  8466. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  8467. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8468. {
  8469. result = PASS;
  8470. }
  8471. return result;
  8472. }
  8473. int sendNotifyEVChargingScheduleRequest(int gun_index)
  8474. {
  8475. mtrace();
  8476. int result = FAIL;
  8477. char message[4096]={0};
  8478. char guid[37]={0};
  8479. char tempdata[128]={0};
  8480. json_object *NotifyEVChargingSchedule = json_object_new_object();
  8481. json_object *chargingSchedule = json_object_new_object();
  8482. json_object *periods = json_object_new_array();
  8483. DEBUG_INFO("sendNotifyEVChargingScheduleRequest...\n");
  8484. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  8485. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  8486. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  8487. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  8488. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  8489. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  8490. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  8491. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  8492. {
  8493. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  8494. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  8495. {
  8496. json_object *Period = json_object_new_object();
  8497. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  8498. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  8499. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  8500. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  8501. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  8502. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  8503. json_object_array_add(periods, Period);
  8504. }
  8505. }
  8506. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  8507. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  8508. random_uuid(guid);
  8509. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  8510. json_object_put(NotifyEVChargingSchedule);
  8511. LWS_Send(message);
  8512. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  8513. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8514. {
  8515. result = PASS;
  8516. }
  8517. return result;
  8518. }
  8519. int sendNotifyEventRequest()
  8520. {
  8521. mtrace();
  8522. int result = FAIL;
  8523. char message[4096]={0};
  8524. char guid[37]={0};
  8525. char tempdata[128]={0};
  8526. json_object *NotifyEvent = json_object_new_object();
  8527. json_object *eventDatas = json_object_new_array();
  8528. DEBUG_INFO("sendNotifyEventRequest...\n");
  8529. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  8530. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  8531. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  8532. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  8533. {
  8534. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  8535. {
  8536. json_object *eventData = json_object_new_object();
  8537. json_object *component = json_object_new_object();
  8538. json_object *evse = json_object_new_object();
  8539. json_object *variable = json_object_new_object();
  8540. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  8541. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  8542. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  8543. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  8544. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  8545. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  8546. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  8547. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  8548. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  8549. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  8550. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  8551. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  8552. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  8553. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  8554. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  8555. json_object_object_add(component, "evse",evse);
  8556. json_object_object_add(eventData, "component", component);
  8557. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  8558. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  8559. json_object_object_add(eventData, "variable", variable);
  8560. json_object_array_add(eventDatas, eventData);
  8561. }
  8562. }
  8563. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  8564. random_uuid(guid);
  8565. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  8566. json_object_put(NotifyEvent);
  8567. LWS_Send(message);
  8568. sprintf(tempdata, "NotifyEvent,0");
  8569. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8570. {
  8571. result = PASS;
  8572. }
  8573. return result;
  8574. }
  8575. int sendNotifyMonitoringReportRequest()
  8576. {
  8577. mtrace();
  8578. int result = FAIL;
  8579. char message[4096]={0};
  8580. char guid[37]={0};
  8581. char tempdata[128]={0};
  8582. json_object *NotifyMonitoringReport = json_object_new_object();
  8583. json_object *monitors = json_object_new_array();
  8584. DEBUG_INFO("sendNotifyMonitoringReportRequest...\n");
  8585. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  8586. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  8587. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  8588. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  8589. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  8590. {
  8591. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  8592. {
  8593. json_object *monitor = json_object_new_object();
  8594. json_object *component = json_object_new_object();
  8595. json_object *evse = json_object_new_object();
  8596. json_object *variable = json_object_new_object();
  8597. json_object *variableMonitorings = json_object_new_array();
  8598. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  8599. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  8600. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  8601. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  8602. json_object_object_add(component, "evse",evse);
  8603. json_object_object_add(monitor, "component", component);
  8604. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  8605. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  8606. json_object_object_add(monitor, "variable", variable);
  8607. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  8608. {
  8609. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  8610. {
  8611. json_object *variableMonitoring = json_object_new_object();
  8612. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  8613. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  8614. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  8615. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  8616. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  8617. json_object_array_add(variableMonitorings, variableMonitoring);
  8618. }
  8619. }
  8620. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  8621. json_object_array_add(monitors, monitor);
  8622. }
  8623. }
  8624. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  8625. random_uuid(guid);
  8626. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  8627. json_object_put(NotifyMonitoringReport);
  8628. LWS_Send(message);
  8629. sprintf(tempdata, "NotifyMonitoringReport,0");
  8630. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8631. {
  8632. result = PASS;
  8633. }
  8634. return result;
  8635. }
  8636. int sendNotifyReportRequest()
  8637. {
  8638. mtrace();
  8639. int result = FAIL;
  8640. char message[4096]={0};
  8641. char guid[37]={0};
  8642. char tempdata[128]={0};
  8643. json_object *NotifyReport = json_object_new_object();
  8644. json_object *reportDatas = json_object_new_array();
  8645. DEBUG_INFO("sendNotifyReportRequest...\n");
  8646. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  8647. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  8648. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  8649. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  8650. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  8651. {
  8652. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  8653. {
  8654. json_object *reportData = json_object_new_object();
  8655. json_object *component = json_object_new_object();
  8656. json_object *evse = json_object_new_object();
  8657. json_object *variable = json_object_new_object();
  8658. json_object *variableAttributes = json_object_new_array();
  8659. json_object *variableCharacteristics = json_object_new_object();
  8660. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  8661. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  8662. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  8663. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  8664. json_object_object_add(component, "evse",evse);
  8665. json_object_object_add(reportData, "component", component);
  8666. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  8667. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  8668. json_object_object_add(reportData, "variable",variable);
  8669. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  8670. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  8671. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  8672. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  8673. json_object_object_add(variableCharacteristics, "supportsMonitoring", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.supportsMonitoring));
  8674. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  8675. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  8676. {
  8677. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  8678. {
  8679. json_object *variableAttribute = json_object_new_object();
  8680. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  8681. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  8682. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  8683. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  8684. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  8685. json_object_array_add(variableAttributes, variableAttribute);
  8686. }
  8687. }
  8688. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  8689. json_object_array_add(reportDatas, reportData);
  8690. }
  8691. }
  8692. json_object_object_add(NotifyReport, "reportData", reportDatas);
  8693. random_uuid(guid);
  8694. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  8695. json_object_put(NotifyReport);
  8696. LWS_SendNow(message);
  8697. sprintf(tempdata, "NotifyReport,0");
  8698. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8699. {
  8700. result = PASS;
  8701. }
  8702. return result;
  8703. }
  8704. int sendPublishFirmwareStatusNotificationRequest()
  8705. {
  8706. mtrace();
  8707. int result = FAIL;
  8708. char message[4096]={0};
  8709. char guid[37]={0};
  8710. char tempdata[128]={0};
  8711. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  8712. json_object *locations = json_object_new_array();
  8713. DEBUG_INFO("sendPublishFirmwareStatusNotificationRequest...\n");
  8714. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  8715. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  8716. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  8717. {
  8718. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  8719. }
  8720. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  8721. random_uuid(guid);
  8722. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  8723. json_object_put(PublishFirmwareStatusNotification);
  8724. LWS_Send(message);
  8725. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  8726. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8727. {
  8728. result = PASS;
  8729. }
  8730. return result;
  8731. }
  8732. int sendReportChargingProfilesRequest(int gun_index)
  8733. {
  8734. mtrace();
  8735. int result = FAIL;
  8736. char message[4096]={0};
  8737. char guid[37]={0};
  8738. char tempdata[128]={0};
  8739. json_object *ReportChargingProfiles = json_object_new_object();
  8740. json_object *chargingProfiles = json_object_new_array();
  8741. DEBUG_INFO("sendReportChargingProfilesRequest...\n");
  8742. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  8743. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  8744. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  8745. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  8746. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  8747. {
  8748. json_object *chargingProfile = json_object_new_object();
  8749. json_object *chargingSchedules = json_object_new_array();
  8750. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  8751. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  8752. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  8753. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  8754. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  8755. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  8756. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  8757. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  8758. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  8759. {
  8760. json_object *chargingSchedule = json_object_new_object();
  8761. json_object *chargingSchedulePeriods = json_object_new_array();
  8762. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  8763. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  8764. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  8765. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  8766. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  8767. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  8768. {
  8769. json_object *chargingSchedulePeriod = json_object_new_object();
  8770. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  8771. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  8772. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  8773. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  8774. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  8775. }
  8776. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  8777. json_object_array_add(chargingSchedules, chargingSchedule);
  8778. }
  8779. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  8780. json_object_array_add(chargingProfiles, chargingProfile);
  8781. }
  8782. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  8783. random_uuid(guid);
  8784. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  8785. json_object_put(ReportChargingProfiles);
  8786. LWS_Send(message);
  8787. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  8788. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8789. {
  8790. result = PASS;
  8791. }
  8792. return result;
  8793. }
  8794. int sendReservationStatusUpdateRequest(int gun_index)
  8795. {
  8796. mtrace();
  8797. int result = FAIL;
  8798. char message[4096]={0};
  8799. char guid[37]={0};
  8800. char tempdata[128]={0};
  8801. json_object *ReservationStatusUpdate = json_object_new_object();
  8802. DEBUG_INFO("sendReservationStatusUpdateRequest...\n");
  8803. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  8804. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  8805. random_uuid(guid);
  8806. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  8807. json_object_put(ReservationStatusUpdate);
  8808. LWS_Send(message);
  8809. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  8810. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8811. {
  8812. result = PASS;
  8813. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  8814. }
  8815. return result;
  8816. }
  8817. int sendSecurityEventNotificationRequest()
  8818. {
  8819. mtrace();
  8820. int result = FAIL;
  8821. char message[4096]={0};
  8822. char guid[37]={0};
  8823. char tempdata[128]={0};
  8824. struct timeval tmnow;
  8825. struct tm *tm;
  8826. char buf[28];//, usec_buf[6];
  8827. json_object *SecurityEventNotification = json_object_new_object();
  8828. DEBUG_INFO("sendSecurityEventNotificationRequest...\n");
  8829. DB_getSecurityEventType();
  8830. gettimeofday(&tmnow, NULL);
  8831. time_t t;
  8832. t = time(NULL);
  8833. /*UTC time and date*/
  8834. tm = gmtime(&t);
  8835. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  8836. #if 0 // remove temporally
  8837. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  8838. strcat(buf,".");
  8839. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  8840. strcat(buf,usec_buf);
  8841. #endif
  8842. printf("%s",buf);
  8843. strcpy((char *)ShmOCPP20Data->SecurityEventNotification.timestamp, buf);
  8844. if(strlen((char *)ShmOCPP20Data->SecurityEventNotification.techInfo)==0)
  8845. sprintf((char*)ShmOCPP20Data->SecurityEventNotification.type,"%s", SecurityEventEnumTypeStr[SecurityEventEnumType_ResetOrReboot]);
  8846. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  8847. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  8848. if(strlen((char *)ShmOCPP20Data->SecurityEventNotification.techInfo)>0)
  8849. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techInfo));
  8850. random_uuid(guid);
  8851. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  8852. json_object_put(SecurityEventNotification);
  8853. LWS_Send(message);
  8854. sprintf(tempdata, "SecurityEventNotification,0");
  8855. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8856. {
  8857. result = PASS;
  8858. }
  8859. return result;
  8860. }
  8861. int sendSignCertificateRequest(CertificateSigningUseEnumType certType)
  8862. {
  8863. mtrace();
  8864. int result = FAIL;
  8865. char message[4096]={0};
  8866. char guid[37]={0};
  8867. char tempdata[128]={0};
  8868. json_object *SignCertificate = json_object_new_object();
  8869. DEBUG_INFO("sendSignCertificateRequest...\n");
  8870. // Read csr file content
  8871. memset(ShmOCPP20Data->SignCertificate.csr, 0x00, ARRAY_SIZE(ShmOCPP20Data->SignCertificate.csr));
  8872. FILE *fp=fopen(((certType == CertificateSignedStatusEnumType_V2GCertificate)?"/Storage/OCPP/certV2G.csr":"/Storage/OCPP/certCP.csr"),"r");
  8873. char *line = NULL;
  8874. size_t len = 0;
  8875. while(getline(&line, &len, fp) != -1)
  8876. {
  8877. if((strstr(line, "BEGIN CERTIFICATE REQUEST") == NULL) && (strstr(line, "END CERTIFICATE REQUEST") == NULL))
  8878. {
  8879. memcpy(&ShmOCPP20Data->SignCertificate.csr[strlen((char*)ShmOCPP20Data->SignCertificate.csr)], line, (strlen(line)-1));
  8880. }
  8881. }
  8882. fclose(fp);
  8883. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  8884. sprintf((char*)ShmOCPP20Data->SignCertificate.certificateType, CertificateSigningUseEnumTypeStr[certType]);
  8885. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  8886. random_uuid(guid);
  8887. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  8888. json_object_put(SignCertificate);
  8889. LWS_Send(message);
  8890. sprintf(tempdata, "SignCertificate,0");
  8891. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  8892. {
  8893. result = PASS;
  8894. }
  8895. return result;
  8896. }
  8897. int sendStatusNotificationRequest(int gun_index)
  8898. {
  8899. mtrace();
  8900. int result = FAIL;
  8901. char message[600]={0};
  8902. char guid[37];
  8903. int currentStatus = 0;
  8904. struct timeval tmnow;
  8905. struct tm *tm;
  8906. char buf[28];//, usec_buf[6];
  8907. char tempdata[65]={0};
  8908. int tempIndex = 0;
  8909. uint8_t isStateChanged = TRUE;
  8910. DEBUG_INFO("sendStatusNotificationRequest...\n");
  8911. gettimeofday(&tmnow, NULL);
  8912. time_t t;
  8913. t = time(NULL);
  8914. /*UTC time and date*/
  8915. tm = gmtime(&t);
  8916. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  8917. #if 0 // remove temporally
  8918. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  8919. strcat(buf,".");
  8920. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  8921. strcat(buf,usec_buf);
  8922. #endif
  8923. printf("%s",buf);
  8924. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  8925. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  8926. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  8927. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  8928. /*
  8929. enum _SYSTEM_STATUS
  8930. {
  8931. S_BOOTING = 0,
  8932. S_IDLE, = 1
  8933. S_AUTHORIZING, =2
  8934. S_REASSIGN_CHECK, =3
  8935. S_REASSIGN, =4
  8936. S_PRECHARGE, =5
  8937. S_PREPARING_FOR_EV, =6
  8938. S_PREPARING_FOR_EVSE, =7
  8939. S_CHARGING, =8
  8940. S_TERMINATING, =9
  8941. S_COMPLETE, =10
  8942. S_ALARM, =11
  8943. S_FAULT =12
  8944. }
  8945. */
  8946. //check Transaction active
  8947. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  8948. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  8949. {
  8950. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  8951. {
  8952. tempIndex = ((gun_index==2) ? 1: 0);
  8953. }
  8954. else
  8955. {
  8956. tempIndex = gun_index;
  8957. }
  8958. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8959. {
  8960. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  8961. {
  8962. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  8963. {
  8964. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  8965. {
  8966. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8967. }
  8968. else
  8969. {
  8970. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  8971. }
  8972. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  8973. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  8974. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  8975. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  8976. }
  8977. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  8978. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  8979. ) //S_PRECHARGE
  8980. {
  8981. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  8982. }
  8983. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  8984. {
  8985. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  8986. }
  8987. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  8988. {
  8989. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  8990. }
  8991. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  8992. {
  8993. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  8994. }
  8995. 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
  8996. {
  8997. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  8998. }
  8999. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9000. {
  9001. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  9002. }
  9003. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9004. {
  9005. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  9006. }
  9007. } //end of the same index
  9008. }//end of for CHAdeMO_QUANTITY
  9009. }
  9010. else if(gunType[gun_index] == GUN_TYPE_CCS)
  9011. {
  9012. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  9013. {
  9014. tempIndex = ((gun_index==2) ? 1: 0);
  9015. }
  9016. else
  9017. {
  9018. tempIndex = gun_index;
  9019. }
  9020. for (int index = 0; index < CCS_QUANTITY; index++)
  9021. {
  9022. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  9023. {
  9024. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  9025. {
  9026. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  9027. {
  9028. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  9029. }
  9030. else
  9031. {
  9032. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  9033. }
  9034. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  9035. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  9036. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  9037. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  9038. }
  9039. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9040. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9041. ) //S_PRECHARGE
  9042. {
  9043. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  9044. }
  9045. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9046. {
  9047. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  9048. }
  9049. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9050. {
  9051. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  9052. }
  9053. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  9054. {
  9055. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  9056. }
  9057. 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
  9058. {
  9059. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  9060. }
  9061. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  9062. {
  9063. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  9064. }
  9065. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9066. {
  9067. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  9068. }
  9069. } //end of the same index
  9070. } // end of for CCS_QUANTITY
  9071. }
  9072. else if(gunType[gun_index] == GUN_TYPE_GBT)
  9073. {
  9074. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  9075. {
  9076. tempIndex = ((gun_index==2) ? 1: 0);
  9077. }
  9078. else
  9079. {
  9080. tempIndex = gun_index;
  9081. }
  9082. for (int index = 0; index < GB_QUANTITY; index++)
  9083. {
  9084. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  9085. {
  9086. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  9087. {
  9088. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  9089. {
  9090. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  9091. }
  9092. else
  9093. {
  9094. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  9095. }
  9096. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  9097. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  9098. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  9099. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  9100. }
  9101. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9102. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9103. ) //S_PRECHARGE
  9104. {
  9105. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  9106. }
  9107. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9108. {
  9109. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  9110. }
  9111. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9112. {
  9113. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  9114. }
  9115. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9116. {
  9117. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  9118. }
  9119. 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
  9120. {
  9121. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  9122. }
  9123. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  9124. {
  9125. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  9126. }
  9127. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9128. {
  9129. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  9130. }
  9131. } //end of the same index
  9132. } // end of for GB_QUANTITY
  9133. }
  9134. else if(gunType[gun_index] == GUN_TYPE_DO)
  9135. {
  9136. tempIndex = gun_index;
  9137. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  9138. {
  9139. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  9140. {
  9141. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  9142. {
  9143. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  9144. {
  9145. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  9146. }
  9147. else
  9148. {
  9149. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  9150. }
  9151. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  9152. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  9153. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  9154. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  9155. }
  9156. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9157. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9158. ) //S_PRECHARGE
  9159. {
  9160. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  9161. }
  9162. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9163. {
  9164. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  9165. }
  9166. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9167. {
  9168. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  9169. }
  9170. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9171. {
  9172. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  9173. }
  9174. 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
  9175. {
  9176. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  9177. }
  9178. 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
  9179. {
  9180. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  9181. }
  9182. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9183. {
  9184. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  9185. }
  9186. } //end of the same index
  9187. }
  9188. }
  9189. else
  9190. {
  9191. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  9192. {
  9193. tempIndex = 2;
  9194. }
  9195. else
  9196. {
  9197. tempIndex = gun_index;
  9198. }
  9199. for (int index = 0; index < AC_QUANTITY; index++)
  9200. {
  9201. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  9202. {
  9203. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  9204. {
  9205. 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))
  9206. {
  9207. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  9208. }
  9209. else
  9210. {
  9211. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  9212. }
  9213. memset(&ShmOCPP20Data->TransactionEvent[gun_index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  9214. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  9215. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  9216. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  9217. }
  9218. else if (/*(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || */(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  9219. {
  9220. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  9221. }
  9222. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  9223. {
  9224. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  9225. }
  9226. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  9227. {
  9228. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  9229. }
  9230. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9231. {
  9232. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  9233. }
  9234. 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
  9235. {
  9236. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  9237. }
  9238. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9239. {
  9240. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  9241. }
  9242. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9243. {
  9244. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  9245. }
  9246. }//end of the same index
  9247. }//end of for AC_QUANTITY
  9248. }
  9249. //it's option
  9250. if((strstr((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]) != NULL) &&
  9251. !cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq &&
  9252. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_StatusNotificationPeriodically].variableAttribute[0].value, "true") != 0))
  9253. {
  9254. isStateChanged = FALSE;
  9255. }
  9256. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  9257. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  9258. random_uuid(guid);
  9259. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  9260. , MESSAGE_TYPE_CALL
  9261. , guid
  9262. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  9263. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  9264. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  9265. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  9266. if((server_sign == TRUE) && isStateChanged)
  9267. {
  9268. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  9269. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  9270. LWS_Send(message);
  9271. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  9272. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  9273. {
  9274. result = PASS;
  9275. }
  9276. }
  9277. else
  9278. {
  9279. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  9280. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  9281. result = PASS;
  9282. }
  9283. return result;
  9284. }
  9285. int sendTransactionEventRequest(int gun_index)
  9286. {
  9287. mtrace();
  9288. int result = FAIL;
  9289. char message[1024*20]={0};
  9290. char guid[37]={0};
  9291. char tempdata[128]={0};
  9292. uint8_t tempIndex;
  9293. json_object *TransactionEvent = json_object_new_object();
  9294. json_object *transactionInfo = json_object_new_object();
  9295. json_object *idToken = json_object_new_object();
  9296. json_object *evse = json_object_new_object();
  9297. json_object *meterValues = json_object_new_array();
  9298. char TempStopTransaction[256];
  9299. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
  9300. DEBUG_INFO("sendTransactionEventRequest...\n");
  9301. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  9302. {
  9303. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  9304. {
  9305. tempIndex = ((gun_index==2) ? 1: 0);
  9306. }
  9307. else
  9308. {
  9309. tempIndex = gun_index;
  9310. }
  9311. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  9312. {
  9313. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  9314. {
  9315. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  9316. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  9317. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  9318. else
  9319. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  9320. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  9321. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  9322. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  9323. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  9324. {
  9325. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9326. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9327. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  9328. {
  9329. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  9330. }
  9331. else
  9332. {
  9333. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  9334. }
  9335. }
  9336. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  9337. {
  9338. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9339. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9340. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  9341. }
  9342. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9343. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9344. ) //S_PRECHARGE
  9345. {
  9346. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9347. {
  9348. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9349. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  9350. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartIdType]);
  9351. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9352. }
  9353. else
  9354. {
  9355. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9356. }
  9357. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  9358. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9359. }
  9360. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9361. {
  9362. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9363. {
  9364. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartMethod == 2)
  9365. {
  9366. ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
  9367. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
  9368. }
  9369. else
  9370. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9371. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9372. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  9373. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartIdType]);
  9374. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9375. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9376. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  9377. }
  9378. else
  9379. {
  9380. storeTempStopTransaction(gun_index);
  9381. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9382. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9383. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  9384. }
  9385. }
  9386. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9387. {
  9388. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  9389. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9390. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9391. if((access(TempStopTransaction,F_OK))!=-1)
  9392. {
  9393. remove(TempStopTransaction); // remove file "TempStopTransaction"
  9394. }
  9395. }
  9396. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9397. {
  9398. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9399. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  9400. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9401. }
  9402. 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
  9403. {
  9404. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9405. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9406. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9407. }
  9408. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9409. {
  9410. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9411. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9412. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9413. }
  9414. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9415. {
  9416. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9417. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9418. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9419. }
  9420. } //end of the same index
  9421. }//end of for CHAdeMO_QUANTITY
  9422. }
  9423. else if(gunType[gun_index] == GUN_TYPE_CCS)
  9424. {
  9425. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  9426. {
  9427. tempIndex = ((gun_index==2) ? 1: 0);
  9428. }
  9429. else
  9430. {
  9431. tempIndex = gun_index;
  9432. }
  9433. for (int index = 0; index < CCS_QUANTITY; index++)
  9434. {
  9435. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  9436. {
  9437. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  9438. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  9439. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  9440. else
  9441. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  9442. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  9443. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  9444. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  9445. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  9446. {
  9447. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9448. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9449. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  9450. {
  9451. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  9452. }
  9453. else
  9454. {
  9455. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  9456. }
  9457. }
  9458. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  9459. {
  9460. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9461. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9462. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  9463. }
  9464. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9465. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9466. ) //S_PRECHARGE
  9467. {
  9468. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9469. {
  9470. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9471. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  9472. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartIdType]);
  9473. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9474. }
  9475. else
  9476. {
  9477. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9478. }
  9479. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  9480. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9481. }
  9482. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9483. {
  9484. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9485. {
  9486. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartMethod == 2)
  9487. {
  9488. ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
  9489. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
  9490. }
  9491. else
  9492. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9493. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9494. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  9495. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartIdType]);
  9496. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9497. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9498. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  9499. }
  9500. else
  9501. {
  9502. storeTempStopTransaction(gun_index);
  9503. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9504. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9505. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  9506. }
  9507. }
  9508. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9509. {
  9510. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  9511. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9512. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9513. if((access(TempStopTransaction,F_OK))!=-1)
  9514. {
  9515. remove(TempStopTransaction); // remove file "TempStopTransaction"
  9516. }
  9517. }
  9518. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9519. {
  9520. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9521. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  9522. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9523. }
  9524. 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
  9525. {
  9526. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9527. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9528. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9529. }
  9530. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9531. {
  9532. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9533. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9534. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9535. }
  9536. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9537. {
  9538. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9539. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9540. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9541. }
  9542. } //end of the same index
  9543. } // end of for CCS_QUANTITY
  9544. }
  9545. else if(gunType[gun_index] == GUN_TYPE_GBT)
  9546. {
  9547. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  9548. {
  9549. tempIndex = ((gun_index==2) ? 1: 0);
  9550. }
  9551. else
  9552. {
  9553. tempIndex = gun_index;
  9554. }
  9555. for (int index = 0; index < GB_QUANTITY; index++)
  9556. {
  9557. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  9558. {
  9559. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  9560. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  9561. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  9562. else
  9563. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  9564. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  9565. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  9566. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  9567. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  9568. {
  9569. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9570. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9571. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  9572. {
  9573. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  9574. }
  9575. else
  9576. {
  9577. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  9578. }
  9579. }
  9580. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  9581. {
  9582. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9583. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9584. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  9585. }
  9586. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9587. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9588. ) //S_PRECHARGE
  9589. {
  9590. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9591. {
  9592. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9593. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  9594. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartIdType]);
  9595. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9596. }
  9597. else
  9598. {
  9599. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9600. }
  9601. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  9602. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9603. }
  9604. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9605. {
  9606. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9607. {
  9608. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartMethod == 2)
  9609. {
  9610. ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
  9611. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
  9612. }
  9613. else
  9614. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9615. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9616. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  9617. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartIdType]);
  9618. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9619. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9620. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  9621. }
  9622. else
  9623. {
  9624. storeTempStopTransaction(gun_index);
  9625. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9626. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9627. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  9628. }
  9629. }
  9630. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9631. {
  9632. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  9633. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9634. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9635. if((access(TempStopTransaction,F_OK))!=-1)
  9636. {
  9637. remove(TempStopTransaction); // remove file "TempStopTransaction"
  9638. }
  9639. }
  9640. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9641. {
  9642. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9643. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  9644. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9645. }
  9646. 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
  9647. {
  9648. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9649. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9650. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9651. }
  9652. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9653. {
  9654. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9655. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9656. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9657. }
  9658. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9659. {
  9660. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9661. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9662. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9663. }
  9664. } //end of the same index
  9665. } // end of for GB_QUANTITY
  9666. }
  9667. else if(gunType[gun_index] == GUN_TYPE_DO)
  9668. {
  9669. tempIndex = gun_index;
  9670. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  9671. {
  9672. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.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.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_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.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  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.ConnectorInfo[index].GeneralChargingData.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.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9702. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.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.ConnectorInfo[index].GeneralChargingData.StartUserId);
  9709. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.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.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9720. {
  9721. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9722. {
  9723. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.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.ConnectorInfo[index].GeneralChargingData.StartUserId);
  9732. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.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. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  9736. }
  9737. else
  9738. {
  9739. storeTempStopTransaction(gun_index);
  9740. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9741. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9742. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  9743. }
  9744. }
  9745. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9746. {
  9747. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  9748. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9749. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9750. if((access(TempStopTransaction,F_OK))!=-1)
  9751. {
  9752. remove(TempStopTransaction); // remove file "TempStopTransaction"
  9753. }
  9754. }
  9755. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9756. {
  9757. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9758. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  9759. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9760. }
  9761. 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
  9762. {
  9763. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9764. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9765. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9766. }
  9767. 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
  9768. {
  9769. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9770. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9771. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9772. }
  9773. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9774. {
  9775. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9776. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9777. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9778. }
  9779. } //end of the same index
  9780. }
  9781. }
  9782. else
  9783. {
  9784. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  9785. {
  9786. tempIndex = 2;
  9787. }
  9788. else
  9789. {
  9790. tempIndex = gun_index;
  9791. }
  9792. for (int index = 0; index < AC_QUANTITY; index++)
  9793. {
  9794. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  9795. {
  9796. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  9797. if((ShmOCPP20Data->TransactionEvent[gun_index].seqNo + 1) < INT_MAX)
  9798. ShmOCPP20Data->TransactionEvent[gun_index].seqNo++;
  9799. else
  9800. ShmOCPP20Data->TransactionEvent[gun_index].seqNo = 0;
  9801. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  9802. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  9803. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  9804. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  9805. {
  9806. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9807. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9808. 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))
  9809. {
  9810. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  9811. }
  9812. else
  9813. {
  9814. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  9815. }
  9816. }
  9817. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  9818. {
  9819. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9820. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  9821. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  9822. }
  9823. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  9824. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  9825. ) //S_PRECHARGE
  9826. {
  9827. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9828. {
  9829. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9830. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  9831. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartIdType]);
  9832. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9833. }
  9834. else
  9835. {
  9836. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9837. }
  9838. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  9839. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9840. }
  9841. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  9842. {
  9843. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId) == 0)
  9844. {
  9845. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == 2)
  9846. {
  9847. ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId = ShmOCPP20Data->RequestStartTransaction[index].remoteStartId;
  9848. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, (char*)ShmOCPP20Data->RequestStartTransaction[index].Response_transactionId);
  9849. }
  9850. else
  9851. random_uuid((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId);
  9852. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9853. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  9854. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type, "%s", IdTokenEnumTypeStr[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartIdType]);
  9855. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9856. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9857. periousPeriodicPowerConsumption[gun_index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  9858. }
  9859. else
  9860. {
  9861. storeTempStopTransaction(gun_index);
  9862. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9863. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  9864. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_MeterValuePeriodic]);
  9865. }
  9866. }
  9867. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  9868. {
  9869. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  9870. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9871. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9872. if((access(TempStopTransaction,F_OK))!=-1)
  9873. {
  9874. remove(TempStopTransaction); // remove file "TempStopTransaction"
  9875. }
  9876. }
  9877. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  9878. {
  9879. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9880. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  9881. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  9882. }
  9883. 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
  9884. {
  9885. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9886. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9887. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9888. }
  9889. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  9890. {
  9891. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9892. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9893. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9894. }
  9895. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  9896. {
  9897. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  9898. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  9899. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  9900. }
  9901. }//end of the same index
  9902. }//end of for AC_QUANTITY
  9903. }
  9904. // Check if this message is triggered by TriggerMessage
  9905. if(cpinitateMsg.bits[gun_index].TriggerTransactionEventReq == ON)
  9906. {
  9907. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  9908. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Trigger]);
  9909. }
  9910. // Message
  9911. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  9912. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  9913. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  9914. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  9915. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  9916. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  9917. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  9918. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  9919. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  9920. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  9921. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  9922. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  9923. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  9924. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  9925. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  9926. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0) && (strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL))
  9927. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  9928. //if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  9929. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartMethod == 2)
  9930. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  9931. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  9932. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  9933. {
  9934. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  9935. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  9936. json_object_object_add(TransactionEvent, "idToken", idToken);
  9937. }
  9938. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  9939. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  9940. json_object_object_add(TransactionEvent, "evse", evse);
  9941. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  9942. {
  9943. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  9944. {
  9945. json_object *meterValue = json_object_new_object();
  9946. json_object *sampledValues = json_object_new_array();
  9947. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  9948. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  9949. {
  9950. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  9951. ((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)))
  9952. {
  9953. 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)) ||
  9954. (strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) == NULL))
  9955. {
  9956. json_object *sampledValue = json_object_new_object();
  9957. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  9958. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  9959. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  9960. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  9961. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  9962. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  9963. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  9964. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  9965. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  9966. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  9967. {
  9968. json_object *unitOfMeasure = json_object_new_object();
  9969. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  9970. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  9971. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  9972. }
  9973. json_object_array_add(sampledValues, sampledValue);
  9974. }
  9975. }
  9976. }
  9977. json_object_object_add(meterValue, "sampledValue", sampledValues);
  9978. json_object_array_add(meterValues, meterValue);
  9979. }
  9980. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  9981. }
  9982. random_uuid(guid);
  9983. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  9984. json_object_put(TransactionEvent);
  9985. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  9986. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  9987. {
  9988. result = PASS;
  9989. }
  9990. queue_operation(QUEUE_OPERATION_ADD, guid, message);
  9991. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Started]) != NULL)
  9992. OCPP_insert_transaction_msg(YES, message);
  9993. else if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]) != NULL)
  9994. {
  9995. OCPP_insert_transaction_msg(NO, message);
  9996. memset(&ShmOCPP20Data->SessionTarget[gun_index], 0x00, sizeof(struct StructSessionTarget));
  9997. memset(&ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo, 0x00, sizeof(struct TransactionType));
  9998. memset(&ShmOCPP20Data->TransactionEvent[gun_index].idToken, 0x00, sizeof(struct IdTokenType));
  9999. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue, 0x00, sizeof(struct MeterValueType));
  10000. }
  10001. return result;
  10002. }
  10003. //==========================================
  10004. // send confirm routine
  10005. //==========================================
  10006. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  10007. {
  10008. mtrace();
  10009. int result = FAIL;
  10010. char message[4096]={0};
  10011. json_object *CancelReservation = json_object_new_object();
  10012. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  10013. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  10014. sprintf(message,"[%d,\"%s\",%s]"
  10015. ,MESSAGE_TYPE_CALLRESULT
  10016. ,uuid
  10017. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  10018. json_object_put(CancelReservation);
  10019. ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf = OFF;
  10020. LWS_Send(message);
  10021. result = TRUE;
  10022. return result;
  10023. }
  10024. int sendCertificateSignedConfirmation(char *uuid)
  10025. {
  10026. mtrace();
  10027. int result = FAIL;
  10028. char message[4096]={0};
  10029. json_object *CertificateSigned = json_object_new_object();
  10030. json_object *statusInfo = json_object_new_object();
  10031. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  10032. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  10033. if(strlen((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.reasonCode) > 0)
  10034. {
  10035. json_object_object_add(statusInfo, "reasonCode", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.reasonCode));
  10036. if(strlen((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.additionalInfo) > 0)
  10037. json_object_object_add(statusInfo, "statadditionalInfous", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_statusInfo.additionalInfo));
  10038. }
  10039. json_object_object_add(CertificateSigned, "statusInfo", statusInfo);
  10040. sprintf(message,"[%d,\"%s\",%s]"
  10041. ,MESSAGE_TYPE_CALLRESULT
  10042. ,uuid
  10043. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  10044. json_object_put(CertificateSigned);
  10045. LWS_Send(message);
  10046. result = TRUE;
  10047. return result;
  10048. }
  10049. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  10050. {
  10051. mtrace();
  10052. int result = FAIL;
  10053. char message[4096]={0};
  10054. json_object *ChangeAvailability = json_object_new_object();
  10055. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  10056. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  10057. sprintf(message,"[%d,\"%s\",%s]"
  10058. ,MESSAGE_TYPE_CALLRESULT
  10059. ,uuid
  10060. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  10061. json_object_put(ChangeAvailability);
  10062. LWS_Send(message);
  10063. result = TRUE;
  10064. return result;
  10065. }
  10066. int sendClearCacheConfirmation(char *uuid)
  10067. {
  10068. mtrace();
  10069. int result = FAIL;
  10070. char message[4096]={0};
  10071. json_object *ClearCache = json_object_new_object();
  10072. DEBUG_INFO("sendClearCacheConfirmation...\n");
  10073. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  10074. sprintf(message,"[%d,\"%s\",%s]"
  10075. ,MESSAGE_TYPE_CALLRESULT
  10076. ,uuid
  10077. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  10078. json_object_put(ClearCache);
  10079. LWS_Send(message);
  10080. result = TRUE;
  10081. return result;
  10082. }
  10083. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  10084. {
  10085. mtrace();
  10086. int result = FAIL;
  10087. char message[500]={0};
  10088. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  10089. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  10090. LWS_Send(message);
  10091. return result;
  10092. }
  10093. int sendClearDisplayMessageConfirmation(char *uuid)
  10094. {
  10095. mtrace();
  10096. int result = FAIL;
  10097. char message[4096]={0};
  10098. json_object *ClearDisplayMessage = json_object_new_object();
  10099. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  10100. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  10101. sprintf(message,"[%d,\"%s\",%s]"
  10102. ,MESSAGE_TYPE_CALLRESULT
  10103. ,uuid
  10104. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  10105. json_object_put(ClearDisplayMessage);
  10106. LWS_Send(message);
  10107. result = TRUE;
  10108. return result;
  10109. }
  10110. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  10111. {
  10112. mtrace();
  10113. int result = FAIL;
  10114. char message[4096]={0};
  10115. json_object *ClearVariableMonitoring = json_object_new_object();
  10116. json_object *clearMonitoringResults = json_object_new_array();
  10117. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  10118. for(int idx=0;idx<variableQuantity;idx++)
  10119. {
  10120. json_object *clearMonitoringResult = json_object_new_object();
  10121. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  10122. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  10123. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  10124. }
  10125. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  10126. sprintf(message,"[%d,\"%s\",%s]"
  10127. ,MESSAGE_TYPE_CALLRESULT
  10128. ,uuid
  10129. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  10130. json_object_put(ClearVariableMonitoring);
  10131. LWS_Send(message);
  10132. result = TRUE;
  10133. return result;
  10134. }
  10135. int sendCostUpdatedConfirmation(char *uuid)
  10136. {
  10137. mtrace();
  10138. int result = FAIL;
  10139. char message[4096]={0};
  10140. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  10141. sprintf(message,"[%d,\"%s\",{}]"
  10142. ,MESSAGE_TYPE_CALLRESULT
  10143. ,uuid);
  10144. LWS_Send(message);
  10145. result = TRUE;
  10146. return result;
  10147. }
  10148. int sendCustomerInformationConfirmation(char *uuid)
  10149. {
  10150. mtrace();
  10151. int result = FAIL;
  10152. char message[4096]={0};
  10153. json_object *CustomerInformation = json_object_new_object();
  10154. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  10155. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  10156. sprintf(message,"[%d,\"%s\",%s]"
  10157. ,MESSAGE_TYPE_CALLRESULT
  10158. ,uuid
  10159. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  10160. json_object_put(CustomerInformation);
  10161. LWS_Send(message);
  10162. result = TRUE;
  10163. return result;
  10164. }
  10165. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  10166. {
  10167. mtrace();
  10168. int result = FAIL;
  10169. char message[4096]={0};
  10170. json_object *DataTransfer = json_object_new_object();
  10171. DEBUG_INFO("sendDataTransferConfirmation...\n");
  10172. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  10173. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  10174. sprintf(message,"[%d,\"%s\",%s]"
  10175. ,MESSAGE_TYPE_CALLRESULT
  10176. ,uuid
  10177. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  10178. json_object_put(DataTransfer);
  10179. LWS_Send(message);
  10180. result = TRUE;
  10181. return result;
  10182. }
  10183. int sendDeleteCertificateConfirmation(char *uuid)
  10184. {
  10185. mtrace();
  10186. int result = FAIL;
  10187. char message[4096]={0};
  10188. json_object *DeleteCertificate = json_object_new_object();
  10189. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  10190. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  10191. sprintf(message,"[%d,\"%s\",%s]"
  10192. ,MESSAGE_TYPE_CALLRESULT
  10193. ,uuid
  10194. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  10195. json_object_put(DeleteCertificate);
  10196. LWS_Send(message);
  10197. result = TRUE;
  10198. return result;
  10199. }
  10200. int sendGetBaseReportConfirmation(char *uuid)
  10201. {
  10202. mtrace();
  10203. int result = FAIL;
  10204. char message[4096]={0};
  10205. json_object *GetBaseReport = json_object_new_object();
  10206. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  10207. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  10208. sprintf(message,"[%d,\"%s\",%s]"
  10209. ,MESSAGE_TYPE_CALLRESULT
  10210. ,uuid
  10211. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  10212. json_object_put(GetBaseReport);
  10213. LWS_Send(message);
  10214. result = TRUE;
  10215. return result;
  10216. }
  10217. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  10218. {
  10219. mtrace();
  10220. int result = FAIL;
  10221. char message[4096]={0};
  10222. json_object *GetChargingProfiles = json_object_new_object();
  10223. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  10224. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  10225. sprintf(message,"[%d,\"%s\",%s]"
  10226. ,MESSAGE_TYPE_CALLRESULT
  10227. ,uuid
  10228. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  10229. json_object_put(GetChargingProfiles);
  10230. LWS_Send(message);
  10231. result = TRUE;
  10232. return result;
  10233. }
  10234. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  10235. {
  10236. mtrace();
  10237. int result = FAIL;
  10238. char message[4096]={0};
  10239. int CompositeScheduleIndex = 0;
  10240. json_object *GetCompositeSchedule = json_object_new_object();
  10241. json_object *schedule = json_object_new_object();
  10242. json_object *chargingSchedule = json_object_new_object();
  10243. json_object *chargingSchedulePeriod = json_object_new_array();
  10244. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  10245. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  10246. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  10247. json_object_object_add(schedule, "evseId", json_object_new_int(connectorIdInt));
  10248. if(nPeriod == 0)
  10249. {
  10250. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  10251. {
  10252. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  10253. json_object_object_add(schedule, "scheduleStart", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  10254. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  10255. json_object_object_add(schedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  10256. json_object_object_add(schedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  10257. //if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  10258. //json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  10259. //json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  10260. uint8_t isNullSchedulePeriod = TRUE;
  10261. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  10262. {
  10263. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  10264. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  10265. {
  10266. json_object *Period = json_object_new_object();
  10267. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  10268. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  10269. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  10270. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  10271. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  10272. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  10273. json_object_array_add(chargingSchedulePeriod, Period);
  10274. isNullSchedulePeriod = FALSE;
  10275. }
  10276. }
  10277. if(isNullSchedulePeriod == TRUE)
  10278. {
  10279. json_object *Period = json_object_new_object();
  10280. json_object_object_add(Period, "startPeriod", json_object_new_int(0));
  10281. float limit = ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit[0]=='W'?modelnameInfo.ratedPower:(ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent==0?ShmSysConfigAndInfo->SysConfig.RatingCurrent:ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
  10282. json_object_object_add(Period, "limit", json_object_new_double(limit));
  10283. json_object_array_add(chargingSchedulePeriod, Period);
  10284. }
  10285. json_object_object_add(schedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  10286. //json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  10287. //json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  10288. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  10289. }
  10290. }
  10291. else
  10292. {
  10293. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  10294. json_object_object_add(chargingSchedule, "scheduleStart", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  10295. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  10296. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  10297. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  10298. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  10299. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  10300. //json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  10301. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  10302. {
  10303. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  10304. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  10305. {
  10306. json_object *Period = json_object_new_object();
  10307. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  10308. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  10309. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  10310. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  10311. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  10312. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  10313. json_object_array_add(chargingSchedulePeriod, Period);
  10314. }
  10315. }
  10316. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  10317. //json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  10318. //json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  10319. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  10320. }
  10321. sprintf(message,"[%d,\"%s\",%s]"
  10322. ,MESSAGE_TYPE_CALLRESULT
  10323. ,uuid
  10324. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  10325. json_object_put(GetCompositeSchedule);
  10326. LWS_Send(message);
  10327. result = TRUE;
  10328. return result;
  10329. }
  10330. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  10331. {
  10332. mtrace();
  10333. int result = FAIL;
  10334. char message[4096]={0};
  10335. json_object *GetGetDisplayMessages = json_object_new_object();
  10336. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  10337. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  10338. sprintf(message,"[%d,\"%s\",%s]"
  10339. ,MESSAGE_TYPE_CALLRESULT
  10340. ,uuid
  10341. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  10342. json_object_put(GetGetDisplayMessages);
  10343. LWS_Send(message);
  10344. result = TRUE;
  10345. return result;
  10346. }
  10347. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  10348. {
  10349. mtrace();
  10350. int result = FAIL;
  10351. char message[4096]={0};
  10352. json_object *GetInstalledCertificateIds = json_object_new_object();
  10353. json_object *certificateHashDataChains = json_object_new_array();
  10354. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  10355. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  10356. for(int idx=0;idx<certQuantity;idx++)
  10357. {
  10358. json_object *cert = json_object_new_object();
  10359. json_object *certificateHashData = json_object_new_object();
  10360. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  10361. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  10362. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  10363. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  10364. json_object_object_add(cert, "certificateHashData", certificateHashData);
  10365. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  10366. json_object_array_add(certificateHashDataChains, cert);
  10367. }
  10368. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  10369. sprintf(message,"[%d,\"%s\",%s]"
  10370. ,MESSAGE_TYPE_CALLRESULT
  10371. ,uuid
  10372. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  10373. json_object_put(GetInstalledCertificateIds);
  10374. LWS_Send(message);
  10375. result = TRUE;
  10376. return result;
  10377. }
  10378. int sendGetLocalListVersionConfirmation(char *uuid)
  10379. {
  10380. mtrace();
  10381. int result = FAIL;
  10382. char message[4096]={0};
  10383. json_object *GetLocalListVersion = json_object_new_object();
  10384. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  10385. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  10386. sprintf(message,"[%d,\"%s\",%s]"
  10387. ,MESSAGE_TYPE_CALLRESULT
  10388. ,uuid
  10389. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  10390. json_object_put(GetLocalListVersion);
  10391. LWS_Send(message);
  10392. result = TRUE;
  10393. return result;
  10394. }
  10395. int sendGetLogConfirmation(char *uuid)
  10396. {
  10397. mtrace();
  10398. int result = FAIL;
  10399. char message[4096]={0};
  10400. json_object *GetLog = json_object_new_object();
  10401. DEBUG_INFO("sendGetLogConfirmation...\n");
  10402. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  10403. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  10404. sprintf(message,"[%d,\"%s\",%s]"
  10405. ,MESSAGE_TYPE_CALLRESULT
  10406. ,uuid
  10407. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  10408. json_object_put(GetLog);
  10409. LWS_Send(message);
  10410. result = TRUE;
  10411. return result;
  10412. }
  10413. int sendGetMonitoringReportConfirmation(char *uuid)
  10414. {
  10415. mtrace();
  10416. int result = FAIL;
  10417. char message[4096]={0};
  10418. json_object *GetMonitoringReport = json_object_new_object();
  10419. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  10420. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  10421. sprintf(message,"[%d,\"%s\",%s]"
  10422. ,MESSAGE_TYPE_CALLRESULT
  10423. ,uuid
  10424. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  10425. json_object_put(GetMonitoringReport);
  10426. LWS_Send(message);
  10427. result = TRUE;
  10428. return result;
  10429. }
  10430. int sendGetReportConfirmation(char *uuid)
  10431. {
  10432. mtrace();
  10433. int result = FAIL;
  10434. char message[4096]={0};
  10435. json_object *GetReport = json_object_new_object();
  10436. DEBUG_INFO("sendGetReportConfirmation...\n");
  10437. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  10438. sprintf(message,"[%d,\"%s\",%s]"
  10439. ,MESSAGE_TYPE_CALLRESULT
  10440. ,uuid
  10441. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  10442. json_object_put(GetReport);
  10443. LWS_Send(message);
  10444. result = TRUE;
  10445. return result;
  10446. }
  10447. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  10448. {
  10449. mtrace();
  10450. int result = FAIL;
  10451. char message[4096]={0};
  10452. json_object *GetTransactionStatus = json_object_new_object();
  10453. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  10454. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  10455. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  10456. sprintf(message,"[%d,\"%s\",%s]"
  10457. ,MESSAGE_TYPE_CALLRESULT
  10458. ,uuid
  10459. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  10460. json_object_put(GetTransactionStatus);
  10461. LWS_Send(message);
  10462. result = TRUE;
  10463. return result;
  10464. }
  10465. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  10466. {
  10467. mtrace();
  10468. int result = FAIL;
  10469. char message[4096]={0};
  10470. json_object *GetVariables = json_object_new_object();
  10471. json_object *getVariableResults = json_object_new_array();
  10472. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  10473. for(int idx=0;idx<variableQuantity;idx++)
  10474. {
  10475. json_object *variableResult = json_object_new_object();
  10476. json_object *component = json_object_new_object();
  10477. json_object *variable = json_object_new_object();
  10478. json_object *evse = json_object_new_object();
  10479. if(strlen((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType) > 0)
  10480. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  10481. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  10482. if(strlen((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue) > 0)
  10483. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  10484. if(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id > 0)
  10485. {
  10486. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  10487. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  10488. json_object_object_add(component, "evse", evse);
  10489. }
  10490. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  10491. if(strlen((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance) > 0)
  10492. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  10493. json_object_object_add(variableResult, "component", component);
  10494. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  10495. if(strlen((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance) > 0)
  10496. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  10497. json_object_object_add(variableResult, "variable", variable);
  10498. json_object_array_add(getVariableResults, variableResult);
  10499. }
  10500. json_object_object_add(GetVariables , "getVariableResult", getVariableResults);
  10501. sprintf(message,"[%d,\"%s\",%s]"
  10502. ,MESSAGE_TYPE_CALLRESULT
  10503. ,uuid
  10504. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  10505. json_object_put(GetVariables);
  10506. LWS_Send(message);
  10507. result = TRUE;
  10508. return result;
  10509. }
  10510. int sendInstallCertificateConfirmation(char *uuid)
  10511. {
  10512. mtrace();
  10513. int result = FAIL;
  10514. char message[4096]={0};
  10515. json_object *InstallCertificate = json_object_new_object();
  10516. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  10517. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  10518. sprintf(message,"[%d,\"%s\",%s]"
  10519. ,MESSAGE_TYPE_CALLRESULT
  10520. ,uuid
  10521. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  10522. json_object_put(InstallCertificate);
  10523. LWS_Send(message);
  10524. result = TRUE;
  10525. return result;
  10526. }
  10527. int sendPublishFirmwareConfirmation(char *uuid)
  10528. {
  10529. mtrace();
  10530. int result = FAIL;
  10531. char message[4096]={0};
  10532. json_object *PublishFirmware = json_object_new_object();
  10533. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  10534. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  10535. sprintf(message,"[%d,\"%s\",%s]"
  10536. ,MESSAGE_TYPE_CALLRESULT
  10537. ,uuid
  10538. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  10539. json_object_put(PublishFirmware);
  10540. LWS_Send(message);
  10541. result = TRUE;
  10542. return result;
  10543. }
  10544. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  10545. {
  10546. mtrace();
  10547. int result = FAIL;
  10548. char message[4096]={0};
  10549. json_object *RemoteStartTransaction = json_object_new_object();
  10550. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  10551. if((strstr((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]) != NULL) &&
  10552. (strlen((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId) > 0))
  10553. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  10554. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  10555. sprintf(message,"[%d,\"%s\",%s]"
  10556. ,MESSAGE_TYPE_CALLRESULT
  10557. ,uuid
  10558. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  10559. json_object_put(RemoteStartTransaction);
  10560. LWS_Send(message);
  10561. result = TRUE;
  10562. return result;
  10563. }
  10564. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  10565. {
  10566. mtrace();
  10567. int result = FAIL;
  10568. char message[4096]={0};
  10569. json_object *RemoteStopTransaction = json_object_new_object();
  10570. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  10571. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  10572. sprintf(message,"[%d,\"%s\",%s]"
  10573. ,MESSAGE_TYPE_CALLRESULT
  10574. ,uuid
  10575. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  10576. json_object_put(RemoteStopTransaction);
  10577. LWS_Send(message);
  10578. result = TRUE;
  10579. return result;
  10580. }
  10581. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  10582. {
  10583. mtrace();
  10584. int result = FAIL;
  10585. char message[4096]={0};
  10586. json_object *ReserveNow = json_object_new_object();
  10587. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  10588. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  10589. sprintf(message,"[%d,\"%s\",%s]"
  10590. ,MESSAGE_TYPE_CALLRESULT
  10591. ,uuid
  10592. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  10593. json_object_put(ReserveNow);
  10594. LWS_Send(message);
  10595. result = TRUE;
  10596. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  10597. return result;
  10598. }
  10599. int sendResetConfirmation(char *uuid)
  10600. {
  10601. mtrace();
  10602. int result = FAIL;
  10603. char message[4096]={0};
  10604. json_object *Reset = json_object_new_object();
  10605. DEBUG_INFO("sendResetConfirmation...\n");
  10606. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  10607. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  10608. sprintf(message,"[%d,\"%s\",%s]"
  10609. ,MESSAGE_TYPE_CALLRESULT
  10610. ,uuid
  10611. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  10612. json_object_put(Reset);
  10613. LWS_Send(message);
  10614. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  10615. {
  10616. DB_updateBootType(BootReasonEnumType_RemoteReset);
  10617. DB_updateSecurityEventType(SecurityEventEnumType_ResetOrReboot);
  10618. }
  10619. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  10620. {
  10621. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  10622. DB_updateSecurityEventType(SecurityEventEnumType_ResetOrReboot);
  10623. }
  10624. result = TRUE;
  10625. return result;
  10626. }
  10627. int sendSendLocalListConfirmation(char *uuid)
  10628. {
  10629. mtrace();
  10630. int result = FAIL;
  10631. char message[4096]={0};
  10632. json_object *SendLocalList = json_object_new_object();
  10633. DEBUG_INFO("sendSendLocalListConfirmation...\n");
  10634. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  10635. sprintf(message,"[%d,\"%s\",%s]"
  10636. ,MESSAGE_TYPE_CALLRESULT
  10637. ,uuid
  10638. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  10639. json_object_put(SendLocalList);
  10640. LWS_Send(message);
  10641. result = TRUE;
  10642. return result;
  10643. }
  10644. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  10645. {
  10646. mtrace();
  10647. int result = FAIL;
  10648. char message[4096]={0};
  10649. json_object *SetChargingProfile = json_object_new_object();
  10650. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  10651. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  10652. sprintf(message,"[%d,\"%s\",%s]"
  10653. ,MESSAGE_TYPE_CALLRESULT
  10654. ,uuid
  10655. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  10656. json_object_put(SetChargingProfile);
  10657. LWS_Send(message);
  10658. result = TRUE;
  10659. return result;
  10660. }
  10661. int sendSetDisplayMessagesConfirmation(char *uuid)
  10662. {
  10663. mtrace();
  10664. int result = FAIL;
  10665. char message[4096]={0};
  10666. json_object *SetDisplayMessage = json_object_new_object();
  10667. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  10668. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  10669. sprintf(message,"[%d,\"%s\",%s]"
  10670. ,MESSAGE_TYPE_CALLRESULT
  10671. ,uuid
  10672. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  10673. json_object_put(SetDisplayMessage);
  10674. LWS_Send(message);
  10675. result = TRUE;
  10676. return result;
  10677. }
  10678. int sendSetMonitoringBaseConfirmation(char *uuid)
  10679. {
  10680. mtrace();
  10681. int result = FAIL;
  10682. char message[4096]={0};
  10683. json_object *SetMonitoringBase = json_object_new_object();
  10684. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  10685. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  10686. sprintf(message,"[%d,\"%s\",%s]"
  10687. ,MESSAGE_TYPE_CALLRESULT
  10688. ,uuid
  10689. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  10690. json_object_put(SetMonitoringBase);
  10691. LWS_Send(message);
  10692. result = TRUE;
  10693. return result;
  10694. }
  10695. int sendSetMonitoringLevelConfirmation(char *uuid)
  10696. {
  10697. mtrace();
  10698. int result = FAIL;
  10699. char message[4096]={0};
  10700. json_object *SetMonitoringLevel = json_object_new_object();
  10701. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  10702. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  10703. sprintf(message,"[%d,\"%s\",%s]"
  10704. ,MESSAGE_TYPE_CALLRESULT
  10705. ,uuid
  10706. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  10707. json_object_put(SetMonitoringLevel);
  10708. LWS_Send(message);
  10709. result = TRUE;
  10710. return result;
  10711. }
  10712. int sendSetNetworkProfileConfirmation(char *uuid)
  10713. {
  10714. mtrace();
  10715. int result = FAIL;
  10716. char message[4096]={0};
  10717. json_object *SetNetworkProfile = json_object_new_object();
  10718. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  10719. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  10720. sprintf(message,"[%d,\"%s\",%s]"
  10721. ,MESSAGE_TYPE_CALLRESULT
  10722. ,uuid
  10723. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  10724. json_object_put(SetNetworkProfile);
  10725. LWS_Send(message);
  10726. result = TRUE;
  10727. return result;
  10728. }
  10729. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  10730. {
  10731. mtrace();
  10732. int result = FAIL;
  10733. char message[4096]={0};
  10734. json_object *SetVariableMonitoring = json_object_new_object();
  10735. json_object *setMonitoringResults = json_object_new_array();
  10736. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  10737. for(int idx=0;idx<variableQuantity;idx++)
  10738. {
  10739. json_object *variableMonitorResult = json_object_new_object();
  10740. json_object *component = json_object_new_object();
  10741. json_object *variable = json_object_new_object();
  10742. json_object *evse = json_object_new_object();
  10743. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  10744. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  10745. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  10746. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  10747. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  10748. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  10749. json_object_object_add(component, "evse", evse);
  10750. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  10751. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  10752. json_object_object_add(variableMonitorResult, "component", component);
  10753. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  10754. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  10755. json_object_object_add(variableMonitorResult, "variable", variable);
  10756. json_object_array_add(setMonitoringResults, variableMonitorResult);
  10757. }
  10758. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  10759. sprintf(message,"[%d,\"%s\",%s]"
  10760. ,MESSAGE_TYPE_CALLRESULT
  10761. ,uuid
  10762. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  10763. json_object_put(SetVariableMonitoring);
  10764. LWS_Send(message);
  10765. result = TRUE;
  10766. return result;
  10767. }
  10768. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  10769. {
  10770. mtrace();
  10771. int result = FAIL;
  10772. char message[4096]={0};
  10773. json_object *SetVariable = json_object_new_object();
  10774. json_object *setVariableResults = json_object_new_array();
  10775. DEBUG_INFO("sendSetVariableConfirmation...\n");
  10776. for(int idx=0;idx<variableQuantity;idx++)
  10777. {
  10778. json_object *variableResult = json_object_new_object();
  10779. json_object *component = json_object_new_object();
  10780. json_object *variable = json_object_new_object();
  10781. json_object *evse = json_object_new_object();
  10782. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  10783. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  10784. if(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id > 0)
  10785. {
  10786. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  10787. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  10788. json_object_object_add(component, "evse", evse);
  10789. }
  10790. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  10791. if(strlen((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance) > 0)
  10792. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  10793. json_object_object_add(variableResult, "component", component);
  10794. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  10795. if(strlen((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance)>0)
  10796. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  10797. json_object_object_add(variableResult, "variable", variable);
  10798. json_object_array_add(setVariableResults, variableResult);
  10799. }
  10800. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  10801. sprintf(message,"[%d,\"%s\",%s]"
  10802. ,MESSAGE_TYPE_CALLRESULT
  10803. ,uuid
  10804. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  10805. json_object_put(SetVariable);
  10806. LWS_Send(message);
  10807. result = TRUE;
  10808. return result;
  10809. }
  10810. int sendTriggerMessageConfirmation(char *uuid)
  10811. {
  10812. mtrace();
  10813. int result = FAIL;
  10814. char message[4096]={0};
  10815. json_object *TriggerMessage = json_object_new_object();
  10816. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  10817. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  10818. sprintf(message,"[%d,\"%s\",%s]",
  10819. MESSAGE_TYPE_CALLRESULT,
  10820. uuid,
  10821. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  10822. json_object_put(TriggerMessage);
  10823. LWS_Send(message);
  10824. result = TRUE;
  10825. return result;
  10826. }
  10827. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  10828. {
  10829. mtrace();
  10830. int result = FAIL;
  10831. char message[4096]={0};
  10832. json_object *UnlockConnector = json_object_new_object();
  10833. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  10834. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  10835. sprintf(message,"[%d,\"%s\",%s]",
  10836. MESSAGE_TYPE_CALLRESULT,
  10837. uuid,
  10838. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  10839. json_object_put(UnlockConnector);
  10840. LWS_Send(message);
  10841. result = TRUE;
  10842. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  10843. return result;
  10844. }
  10845. int sendUnpublishFirmwareConfirmation(char *uuid)
  10846. {
  10847. mtrace();
  10848. int result = FAIL;
  10849. char message[4096]={0};
  10850. json_object *UnpublishFirmware = json_object_new_object();
  10851. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  10852. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  10853. sprintf(message,"[%d,\"%s\",%s]"
  10854. ,MESSAGE_TYPE_CALLRESULT
  10855. ,uuid
  10856. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  10857. json_object_put(UnpublishFirmware);
  10858. LWS_Send(message);
  10859. result = TRUE;
  10860. return result;
  10861. }
  10862. int sendUpdateFirmwareConfirmation(char *uuid)
  10863. {
  10864. mtrace();
  10865. int result = FAIL;
  10866. char message[4096]={0};
  10867. json_object *UpdateFirmware = json_object_new_object();
  10868. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  10869. sprintf((char*)ShmOCPP20Data->UpdateFirmware.Response_status, "%s", UpdateFirmwareStatusEnumTypeStr[UpdateFirmwareStatusEnumType_Accepted]);
  10870. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  10871. sprintf(message,"[%d,\"%s\",%s]"
  10872. ,MESSAGE_TYPE_CALLRESULT
  10873. ,uuid
  10874. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  10875. json_object_put(UpdateFirmware);
  10876. LWS_Send(message);
  10877. result = TRUE;
  10878. return result;
  10879. }
  10880. int sendUnknownConfirmation(char *uuid)
  10881. {
  10882. mtrace();
  10883. int result = FAIL;
  10884. char message[256]={0};
  10885. //[ 3, "ba1cbd49-2a76-493a-8f76-fa23e7606532", { "status": "Unlocked" } ]
  10886. DEBUG_INFO("sendUnknownConfirmation...\n");
  10887. sprintf(message,"[%d,\"%s\",\"NotImplemented\",\"Requested Action is not known by receiver\",{}]", MESSAGE_TYPE_CALLERROR, uuid);
  10888. LWS_Send(message);
  10889. result = TRUE;
  10890. return result;
  10891. }
  10892. //==========================================
  10893. // send CallError routine
  10894. //==========================================
  10895. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  10896. {
  10897. mtrace();
  10898. char message[220]={0};
  10899. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  10900. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  10901. LWS_Send(message);
  10902. }
  10903. //==========================================
  10904. // Handle server request routine Start
  10905. //==========================================
  10906. int handleCancelReservationRequest(char *uuid, char *payload)
  10907. {
  10908. mtrace();
  10909. int result = FAIL;
  10910. int gunNO = 0;
  10911. int reservationIdInt = -1;
  10912. DEBUG_INFO("handleCancelReservationRequest...\n");
  10913. json_object *CancelReservation;
  10914. CancelReservation = json_tokener_parse(payload);
  10915. if(!is_error(CancelReservation))
  10916. {
  10917. // Required data
  10918. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  10919. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  10920. }
  10921. json_object_put(CancelReservation);
  10922. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  10923. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  10924. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  10925. if(reservationIdInt != -1)
  10926. {
  10927. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  10928. //check Transaction active
  10929. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  10930. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10931. {
  10932. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  10933. {
  10934. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10935. if(gunType[2] == GUN_TYPE_CHAdeMO)
  10936. {
  10937. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  10938. }
  10939. else
  10940. {
  10941. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  10942. }
  10943. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10944. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10945. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10946. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10947. goto end;
  10948. }
  10949. }
  10950. for (int index = 0; index < CCS_QUANTITY; index++)
  10951. {
  10952. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  10953. {
  10954. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10955. if(gunType[2] == GUN_TYPE_CCS)
  10956. {
  10957. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  10958. }
  10959. else
  10960. {
  10961. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  10962. }
  10963. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10964. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10965. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10966. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10967. goto end;
  10968. }
  10969. }
  10970. for (int index = 0; index < GB_QUANTITY; index++)
  10971. {
  10972. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  10973. {
  10974. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10975. if(gunType[2] == GUN_TYPE_GBT)
  10976. {
  10977. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  10978. }
  10979. else
  10980. {
  10981. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  10982. }
  10983. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10984. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10985. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10986. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  10987. goto end;
  10988. }
  10989. }
  10990. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10991. {
  10992. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId == reservationIdInt)
  10993. {
  10994. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  10995. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  10996. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  10997. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  10998. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  10999. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  11000. goto end;
  11001. }
  11002. }
  11003. for (int index = 0; index < AC_QUANTITY; index++)
  11004. {
  11005. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  11006. {
  11007. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  11008. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  11009. {
  11010. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  11011. }
  11012. else
  11013. {
  11014. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  11015. }
  11016. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  11017. ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationId = reservationIdInt;
  11018. sprintf((char*)ShmOCPP20Data->ReservationStatusUpdate[gunNO].reservationUpdateStatus, ReservationUpdateStatusEnumTypeStr[ReservationUpdateStatusEnumType_Removed]);
  11019. ShmOCPP20Data->CpMsg.bits[gunNO].ReservationStatusUpdateReq = ON;
  11020. goto end;
  11021. }
  11022. }
  11023. }
  11024. //The reservationId does NOT match the reservationId
  11025. sendCancelReservationConfirmation(uuid, gunNO);
  11026. end:
  11027. // Fill in ocpp packet uuid
  11028. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  11029. return result;
  11030. }
  11031. int handleCertificateSignedRequest(char *uuid, char *payload)
  11032. {
  11033. mtrace();
  11034. int result = FAIL;
  11035. json_object *CertificateSigned;
  11036. DEBUG_INFO("handleCertificateSignedRequest...\n");
  11037. CertificateSigned = json_tokener_parse(payload);
  11038. if(!is_error(CertificateSigned))
  11039. {
  11040. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  11041. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  11042. // Required data
  11043. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateChain, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateChain")));
  11044. // Optional data
  11045. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  11046. {
  11047. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  11048. if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_ChargingStationCertificate]) == 0)
  11049. {
  11050. FILE *fp = fopen("/Storage/OCPP/certCP.crt", "w");
  11051. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  11052. fclose(fp);
  11053. }
  11054. else if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0)
  11055. {
  11056. FILE *fp = fopen("/Storage/OCPP/certV2G.crt", "w");
  11057. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  11058. fclose(fp);
  11059. }
  11060. }
  11061. else
  11062. {
  11063. FILE *fp = fopen("/Storage/OCPP/certCP.crt", "w");
  11064. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  11065. fclose(fp);
  11066. fp = fopen("/Storage/OCPP/certV2G.crt", "w");
  11067. fprintf(fp, "%s", ShmOCPP20Data->CertificateSigned.certificateChain);
  11068. fclose(fp);
  11069. }
  11070. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  11071. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  11072. }
  11073. else
  11074. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  11075. json_object_put(CertificateSigned);
  11076. sendCertificateSignedConfirmation(uuid);
  11077. return result;
  11078. }
  11079. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  11080. {
  11081. mtrace();
  11082. int result = FAIL;
  11083. int evseId = 0, gunIndex = 0;
  11084. char operationalStatus[16]={0};
  11085. char comfirmstr[20];
  11086. int specificId = FALSE;
  11087. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  11088. json_object *ChangeAvailability;
  11089. ChangeAvailability = json_tokener_parse(payload);
  11090. if(!is_error(ChangeAvailability))
  11091. {
  11092. // Required data
  11093. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  11094. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  11095. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  11096. {
  11097. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  11098. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  11099. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  11100. }
  11101. }
  11102. json_object_put(ChangeAvailability);
  11103. if((evseId != 0) && (evseId <= gunTotalNumber))
  11104. {
  11105. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  11106. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  11107. }
  11108. else if(evseId == 0)
  11109. {
  11110. for(int i=0; i < gunTotalNumber; i++)
  11111. {
  11112. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  11113. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  11114. }
  11115. }
  11116. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  11117. {
  11118. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  11119. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  11120. }
  11121. else if(gunIndex == 0)
  11122. {
  11123. for(int i=0; i < gunTotalNumber; i++)
  11124. {
  11125. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  11126. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  11127. }
  11128. }
  11129. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  11130. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11131. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  11132. {
  11133. specificId = TRUE;
  11134. }
  11135. if(specificId == FALSE)
  11136. goto end;
  11137. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  11138. {
  11139. //----------------------gunIndex is 0 ------------------------------------------------//
  11140. if(gunIndex == 0)
  11141. {
  11142. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11143. {
  11144. for(int i=0; i < gunTotalNumber; i++)
  11145. {
  11146. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11147. {
  11148. if ((gunType[i] == GUN_TYPE_CHAdeMO)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  11149. {
  11150. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  11151. {
  11152. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11153. goto end;
  11154. }
  11155. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11156. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11157. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11158. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11159. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11160. {
  11161. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11162. goto end;
  11163. }
  11164. }
  11165. }//END FOR CHAdeMO_QUANTITY
  11166. for (int index = 0; index < CCS_QUANTITY; index++)
  11167. {
  11168. if ((gunType[i] == GUN_TYPE_CCS)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  11169. {
  11170. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  11171. {
  11172. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11173. goto end;
  11174. }
  11175. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11176. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11177. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11178. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11179. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11180. {
  11181. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11182. goto end;
  11183. }
  11184. }
  11185. }//END FOR CCS_QUANTITY
  11186. for (int index = 0; index < GB_QUANTITY; index++)
  11187. {
  11188. if ((gunType[i] == GUN_TYPE_GBT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  11189. {
  11190. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  11191. {
  11192. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11193. goto end;
  11194. }
  11195. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11196. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11197. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11198. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11199. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11200. {
  11201. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11202. goto end;
  11203. }
  11204. }
  11205. }// END FOR GB_QUANTITY
  11206. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11207. {
  11208. if ((gunType[i] == GUN_TYPE_DO)&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == i))
  11209. {
  11210. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  11211. {
  11212. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11213. goto end;
  11214. }
  11215. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  11216. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  11217. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  11218. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  11219. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11220. {
  11221. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11222. goto end;
  11223. }
  11224. }
  11225. }// END FOR DO_QUANTITY
  11226. for (int index = 0; index < AC_QUANTITY; index++)
  11227. {
  11228. if ((gunType[i] == GUN_TYPE_AC)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  11229. {
  11230. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  11231. {
  11232. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11233. goto end;
  11234. }
  11235. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11236. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11237. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11238. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11239. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11240. {
  11241. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11242. goto end;
  11243. }
  11244. }
  11245. }//END FOR AC_QUANTITY
  11246. }// END FOR gunTotalNumber
  11247. }
  11248. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  11249. {
  11250. for(int i=0; i < gunTotalNumber; i++)
  11251. {
  11252. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  11253. {
  11254. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11255. goto end;
  11256. }
  11257. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11258. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  11259. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  11260. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  11261. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11262. {
  11263. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11264. goto end;
  11265. }
  11266. }
  11267. }
  11268. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11269. goto end;
  11270. }
  11271. //----------------------gunIndex is not 0 ------------------------------------------------//
  11272. //check Transaction active
  11273. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11274. {
  11275. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO))
  11276. {
  11277. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  11278. {
  11279. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11280. goto end;
  11281. }
  11282. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11283. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11284. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11285. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11286. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11287. {
  11288. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11289. goto end;
  11290. }
  11291. else
  11292. {
  11293. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  11294. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11295. goto end;
  11296. }
  11297. }
  11298. }//END FOR CHAdeMO_QUANTITY
  11299. for (int index = 0; index < CCS_QUANTITY; index++)
  11300. {
  11301. if ((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS))
  11302. {
  11303. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  11304. {
  11305. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11306. goto end;
  11307. }
  11308. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11309. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11310. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11311. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11312. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11313. {
  11314. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11315. goto end;
  11316. }
  11317. else
  11318. {
  11319. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  11320. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11321. goto end;
  11322. }
  11323. }
  11324. }//END FOR CCS_QUANTITY
  11325. for (int index = 0; index < GB_QUANTITY; index++)
  11326. {
  11327. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))
  11328. {
  11329. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  11330. {
  11331. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11332. goto end;
  11333. }
  11334. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11335. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11336. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11337. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11338. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11339. {
  11340. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11341. goto end;
  11342. }
  11343. else
  11344. {
  11345. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  11346. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11347. goto end;
  11348. }
  11349. }
  11350. }// END FOR GB_QUANTITY
  11351. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11352. {
  11353. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))
  11354. {
  11355. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  11356. {
  11357. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11358. goto end;
  11359. }
  11360. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) ||
  11361. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) ||
  11362. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
  11363. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) ||
  11364. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11365. {
  11366. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11367. goto end;
  11368. }
  11369. else
  11370. {
  11371. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  11372. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11373. goto end;
  11374. }
  11375. }
  11376. }// END FOR DO_QUANTITY
  11377. for (int index = 0; index < AC_QUANTITY; index++)
  11378. {
  11379. if ((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC))
  11380. {
  11381. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  11382. {
  11383. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11384. goto end;
  11385. }
  11386. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  11387. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  11388. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  11389. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  11390. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  11391. {
  11392. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  11393. goto end;
  11394. }
  11395. else
  11396. {
  11397. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  11398. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11399. goto end;
  11400. }
  11401. }
  11402. }//END FOR AC_QUANTITY
  11403. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  11404. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  11405. {
  11406. //----------------------gunIndex is 0 ------------------------------------------------//
  11407. if(gunIndex == 0)
  11408. {
  11409. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11410. {
  11411. for(int i=0; i < gunTotalNumber; i++)
  11412. {
  11413. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11414. {
  11415. 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
  11416. {
  11417. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11418. goto end;
  11419. }
  11420. }//END FOR CHAdeMO_QUANTITY
  11421. for (int index = 0; index < CCS_QUANTITY; index++)
  11422. {
  11423. 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
  11424. {
  11425. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11426. goto end;
  11427. }
  11428. }//END FOR CCS_QUANTITY
  11429. for (int index = 0; index < GB_QUANTITY; index++)
  11430. {
  11431. 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
  11432. {
  11433. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  11434. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11435. goto end;
  11436. }
  11437. }// END FOR GB_QUANTITY
  11438. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11439. {
  11440. 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
  11441. {
  11442. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  11443. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11444. goto end;
  11445. }
  11446. }// END FOR DO_QUANTITY
  11447. for (int index = 0; index < AC_QUANTITY; index++)
  11448. {
  11449. 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
  11450. {
  11451. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11452. goto end;
  11453. }
  11454. }//END FOR CHAdeMO_QUANTITY
  11455. }// END FOR gunTotalNumber
  11456. }
  11457. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  11458. {
  11459. for(int i=0; i < gunTotalNumber; i++)
  11460. {
  11461. for (int index = 0; index < AC_QUANTITY; index++)
  11462. {
  11463. 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
  11464. {
  11465. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  11466. goto end;
  11467. }
  11468. }//END FOR CHAdeMO_QUANTITY
  11469. } // END FOR gunTotalNumber
  11470. }
  11471. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11472. goto end;
  11473. }
  11474. //----------------------gunIndex is not 0 ------------------------------------------------//
  11475. //check Transaction active
  11476. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11477. {
  11478. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_CHAdeMO) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11479. {
  11480. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11481. goto end;
  11482. }
  11483. }//END FOR CHAdeMO_QUANTITY
  11484. for (int index = 0; index < CCS_QUANTITY; index++)
  11485. {
  11486. if ((((gunIndex > 0)&&(gunType[gunIndex - 1] == GUN_TYPE_CCS)) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11487. {
  11488. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11489. goto end;
  11490. }
  11491. }//END FOR CCS_QUANTITY
  11492. for (int index = 0; index < GB_QUANTITY; index++)
  11493. {
  11494. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_GBT))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11495. {
  11496. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11497. goto end;
  11498. }
  11499. }// END FOR GB_QUANTITY
  11500. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11501. {
  11502. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_DO))&&(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11503. {
  11504. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11505. goto end;
  11506. }
  11507. }// END FOR DO_QUANTITY
  11508. for (int index = 0; index < AC_QUANTITY; index++)
  11509. {
  11510. if (((gunIndex > 0)&&(gunType[gunIndex-1] == GUN_TYPE_AC)) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  11511. {
  11512. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  11513. goto end;
  11514. }
  11515. }//END FOR AC_QUANTITY
  11516. }//END FOR AvailabilityEnumTypeStr[Operative]
  11517. end:
  11518. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  11519. {
  11520. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  11521. }
  11522. else
  11523. {
  11524. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  11525. }
  11526. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  11527. {
  11528. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  11529. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  11530. }
  11531. else if(gunIndex == 0)
  11532. {
  11533. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  11534. {
  11535. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  11536. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  11537. }
  11538. }
  11539. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  11540. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  11541. return result;
  11542. }
  11543. int handleClearCacheRequest(char *uuid, char *payload)
  11544. {
  11545. mtrace();
  11546. int result = FAIL;
  11547. char rmFileCmd[100]={0};
  11548. struct stat stats;
  11549. DEBUG_INFO("handleClearCacheRequest...\n");
  11550. stat("/Storage/OCPP", &stats);
  11551. // Check for directory existence
  11552. if (S_ISDIR(stats.st_mode) == 1)
  11553. {}
  11554. else
  11555. {
  11556. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  11557. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  11558. system(rmFileCmd);
  11559. }
  11560. if(DB_cleanLocalCache() != PASS)
  11561. {
  11562. DEBUG_INFO("open AuthorizationCache file failed\n");
  11563. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  11564. }
  11565. else
  11566. {
  11567. DEBUG_INFO("open AuthorizationCache file successful\n");
  11568. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  11569. }
  11570. sendClearCacheConfirmation(uuid);
  11571. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  11572. return result;
  11573. }
  11574. int handleClearChargingProfileRequest(char *uuid, char *payload)
  11575. {
  11576. mtrace();
  11577. int result = FAIL;
  11578. int resultRename;
  11579. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  11580. char chargingProfilePurposeStr[26]={0};
  11581. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  11582. char tempchargingProfilePurposeStr[26]={0};
  11583. char sstr[160]={0};
  11584. char str[100]={0};
  11585. int c = 0;
  11586. char *loc;
  11587. char fname[200]={0};
  11588. char comfirmstr[20]={0};
  11589. char word[1600]={0};
  11590. int clearflag = FALSE;
  11591. int chargingProfileIdIsNULL = FALSE;
  11592. int connectorIsNULL = FALSE;
  11593. int chargingProfilePurposeIsNULL = FALSE;
  11594. int stackLevelIsNULL = FALSE;
  11595. //int GotoEnd = FALSE;
  11596. FILE *fptr1, *fptr2;
  11597. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  11598. int n_chargingProfile=0;
  11599. int isEmptyFile = FALSE;
  11600. char sLineWord[1600]={0};
  11601. char chargingProfiles[10][100]={0};
  11602. int ChargeProfileCount = 0;
  11603. int ch;
  11604. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  11605. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  11606. json_object *ClearChargingProfile;
  11607. ClearChargingProfile = json_tokener_parse(payload);
  11608. if(!is_error(ClearChargingProfile))
  11609. {
  11610. // Optional data
  11611. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  11612. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  11613. else
  11614. chargingProfileIdIsNULL = TRUE;
  11615. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  11616. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  11617. else
  11618. connectorIsNULL = TRUE;
  11619. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  11620. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  11621. else
  11622. chargingProfilePurposeIsNULL = TRUE;
  11623. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  11624. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  11625. else
  11626. stackLevelIsNULL = TRUE;
  11627. }
  11628. json_object_put(ClearChargingProfile);
  11629. if(connectorIsNULL == FALSE)
  11630. {
  11631. switch(connectorIdInt)
  11632. {
  11633. case 0:
  11634. if(chargingProfilePurposeIsNULL == TRUE)
  11635. {
  11636. int l = 0;
  11637. strcpy(fname, ChargingStationMaxProfile_JSON);
  11638. if((access(fname,F_OK))!=-1)
  11639. {
  11640. strcpy(chargingProfiles[l], fname);
  11641. l = l + 1;
  11642. }
  11643. strcpy(fname, TxDefaultProfile_0_JSON);
  11644. if((access(fname,F_OK))!=-1)
  11645. {
  11646. strcpy(chargingProfiles[l], fname);
  11647. l = l + 1;
  11648. }
  11649. ChargeProfileCount = l;
  11650. }
  11651. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  11652. {
  11653. strcpy(fname, ChargingStationMaxProfile_JSON);
  11654. if((access(fname,F_OK))!=-1)
  11655. {
  11656. strcpy(chargingProfiles[0], fname);
  11657. ChargeProfileCount = 1;
  11658. }
  11659. }
  11660. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  11661. {
  11662. strcpy(fname, TxDefaultProfile_0_JSON);
  11663. if((access(fname,F_OK))!=-1)
  11664. {
  11665. strcpy(chargingProfiles[0], fname);
  11666. ChargeProfileCount = 1;
  11667. }
  11668. }
  11669. break;
  11670. default:
  11671. if(chargingProfilePurposeIsNULL == TRUE)
  11672. {
  11673. int m = 0;
  11674. memset(fname, 0, ARRAY_SIZE(fname));
  11675. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", connectorIdInt);
  11676. if((access(fname,F_OK))!=-1)
  11677. {
  11678. strcpy(chargingProfiles[m], fname);
  11679. m = m + 1;
  11680. }
  11681. memset(fname, 0, ARRAY_SIZE(fname));
  11682. sprintf(fname, "/Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdInt);
  11683. if((access(fname,F_OK))!=-1)
  11684. {
  11685. strcpy(chargingProfiles[m], fname);
  11686. m = m + 1;
  11687. }
  11688. ChargeProfileCount = m;
  11689. }
  11690. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  11691. {
  11692. //strcpy(fname, TxDefaultProfile_1_JSON);
  11693. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", connectorIdInt);
  11694. if((access(fname,F_OK))!=-1)
  11695. {
  11696. strcpy(chargingProfiles[0], fname);
  11697. ChargeProfileCount = 1;
  11698. }
  11699. }
  11700. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  11701. {
  11702. sprintf(fname, "/Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdInt);
  11703. if((access(fname,F_OK))!=-1)
  11704. {
  11705. strcpy(chargingProfiles[0], fname);
  11706. ChargeProfileCount = 1;
  11707. }
  11708. }
  11709. //strcpy(fname, ChargePointMaxProfile_JSON );
  11710. break;
  11711. }
  11712. }
  11713. else // Check all Charging Profiles
  11714. {
  11715. int i = 0;
  11716. char fnametemp[200]={0};
  11717. ChargeProfileCount = 0;
  11718. //Check ChargePointMaxProfile.json exit
  11719. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  11720. {
  11721. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  11722. i = i + 1;
  11723. }
  11724. //Check TxDefaultProfile_%d.json
  11725. for(int j=1; j <= gunTotalNumber; j++)
  11726. {
  11727. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  11728. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", j);
  11729. if((access(fnametemp,F_OK))!=-1)
  11730. {
  11731. strcpy(chargingProfiles[i], fnametemp);
  11732. i = i + 1;
  11733. }
  11734. }
  11735. //Check TxProfile_%d.json
  11736. for(int j=1; j <= gunTotalNumber; j++)
  11737. {
  11738. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  11739. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d_OCPP20.json", j);
  11740. if((access(fnametemp,F_OK))!=-1)
  11741. {
  11742. strcpy(chargingProfiles[i], fnametemp);
  11743. i = i + 1;
  11744. }
  11745. }
  11746. ChargeProfileCount = i;
  11747. }// End connectorIsNULL is TRUE
  11748. if(ChargeProfileCount == 0)
  11749. {
  11750. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  11751. goto end;
  11752. }
  11753. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  11754. {
  11755. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  11756. goto end;
  11757. }
  11758. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  11759. {
  11760. memset(str, 0, ARRAY_SIZE(str));
  11761. // clear temp file
  11762. sprintf(str,"rm -f %s",temp);
  11763. system(str);
  11764. for(int k=0; k < ChargeProfileCount; k++)
  11765. {
  11766. memset(str, 0, ARRAY_SIZE(str));
  11767. //clear file in C
  11768. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11769. system(str);
  11770. }
  11771. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11772. goto end;
  11773. }
  11774. else if(connectorIsNULL == TRUE)
  11775. {
  11776. for(int k=0; k < ChargeProfileCount; k++)
  11777. {
  11778. fptr1 = fopen(chargingProfiles[k], "r");
  11779. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  11780. //Check Charging Profile Count
  11781. while(fscanf(fptr1, "%s", word) != EOF)
  11782. {
  11783. //DEBUG_INFO("word=%s\n",word);
  11784. if(strstr(word, "id")!= NULL)
  11785. {
  11786. //DEBUG_INFO("test id \n");
  11787. n_chargingProfile = n_chargingProfile + 1;
  11788. //DEBUG_INFO("id Found\n");
  11789. }
  11790. }
  11791. rewind(fptr1);
  11792. //search Charging Profile Element
  11793. //int i= 0;
  11794. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  11795. {
  11796. //------------------------tempconnectorIdInt------------------------//
  11797. loc = strstr(sLineWord, "connectorId");
  11798. c = 0;
  11799. memset(sstr ,0, sizeof(sstr) );
  11800. while (loc[strlen("connectorId")+2+c] != ',')
  11801. {
  11802. sstr[c] = loc[strlen("connectorId")+2+c];
  11803. c++;
  11804. }
  11805. sstr[c] = '\0';
  11806. tempconnectorIdInt = atoi(sstr);
  11807. printf("file's gun number is %d\n", tempconnectorIdInt);
  11808. //--------------------------id--------------------//
  11809. c = 0;
  11810. loc = strstr(sLineWord, "id");
  11811. memset(sstr ,0, ARRAY_SIZE(sstr));
  11812. while (loc[strlen("id")+2+c] != ',')
  11813. {
  11814. sstr[c] = loc[strlen("id")+2+c];
  11815. //printf("i=%d sstr=%c\n",c, sstr[c]);
  11816. c++;
  11817. }
  11818. sstr[c] = '\0';
  11819. tempchargingProfileIdInt = atoi(sstr);
  11820. //stackLevel
  11821. c = 0;
  11822. loc = strstr(sLineWord, "stackLevel");
  11823. memset(sstr ,0, ARRAY_SIZE(sstr));
  11824. while (loc[strlen("stackLevel")+2+c] != ',')
  11825. {
  11826. sstr[c] = loc[strlen("stackLevel")+2+c];
  11827. //printf("i=%d sstr=%c\n",c, sstr[c]);
  11828. c++;
  11829. }
  11830. sstr[c] = '\0';
  11831. tempstackLevelInt = atoi(sstr);
  11832. c = 0;
  11833. loc = strstr(sLineWord, "chargingProfilePurpose");
  11834. memset(sstr ,0, ARRAY_SIZE(sstr));
  11835. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  11836. {
  11837. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  11838. c++;
  11839. }
  11840. sstr[c] = '\0';
  11841. strcpy(tempchargingProfilePurposeStr, sstr);
  11842. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  11843. {
  11844. //------- not write to fptr2-------//
  11845. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11846. //clearflag = TRUE;
  11847. }
  11848. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  11849. {
  11850. //------- not write to fptr2-------//
  11851. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11852. }
  11853. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  11854. {
  11855. //------- not write to fptr2-------//
  11856. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11857. }
  11858. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  11859. {
  11860. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  11861. }
  11862. else
  11863. {
  11864. fprintf(fptr2, sLineWord);//writing data into file
  11865. }
  11866. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  11867. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  11868. if(clearflag == TRUE)
  11869. {
  11870. fclose(fptr1);
  11871. fclose(fptr2);
  11872. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11873. system(str);
  11874. // clear temp file
  11875. sprintf(str,"rm -f %s",temp);
  11876. system(str);
  11877. }
  11878. else
  11879. {
  11880. fclose(fptr1);
  11881. fclose(fptr2);
  11882. memset(str, 0, ARRAY_SIZE(str));
  11883. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11884. system(str);
  11885. resultRename = rename(temp, chargingProfiles[k]);
  11886. if(resultRename == 0)
  11887. {
  11888. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  11889. }
  11890. else
  11891. {
  11892. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  11893. }
  11894. if(comfirmstr[0]== 0)
  11895. {
  11896. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  11897. }
  11898. //Check chargingProfile is empty file
  11899. /*------ Read the file ----------------*/
  11900. fptr1=fopen(chargingProfiles[k],"r");
  11901. ch=fgetc(fptr1);
  11902. rewind(fptr1);
  11903. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  11904. if(ch!=EOF)
  11905. {
  11906. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  11907. {
  11908. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  11909. if(sLineWord[0]=='\0')
  11910. {
  11911. isEmptyFile = TRUE;
  11912. break;
  11913. }
  11914. else
  11915. {
  11916. isEmptyFile = FALSE;
  11917. break;
  11918. }
  11919. }
  11920. }
  11921. else
  11922. isEmptyFile = TRUE;
  11923. fclose(fptr1);
  11924. if(isEmptyFile == TRUE)
  11925. {
  11926. memset(str, 0, ARRAY_SIZE(str));
  11927. sprintf(str,"rm -f %s",chargingProfiles[k]);
  11928. system(str);
  11929. }
  11930. }
  11931. }// End of while(int k=0; k < ChargePointCount; k++)
  11932. }
  11933. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  11934. {
  11935. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  11936. for(int k=0; k < ChargeProfileCount; k++)
  11937. {
  11938. fptr1 = fopen(chargingProfiles[k], "r");
  11939. fptr2 = fopen(temp, "w+");
  11940. //Check Charging Profile Count
  11941. while(fscanf(fptr1, "%s", word) != EOF)
  11942. {
  11943. //DEBUG_INFO("word=%s\n",word);
  11944. if(strstr(word, "id")!= NULL)
  11945. {
  11946. n_chargingProfile = n_chargingProfile + 1;
  11947. }
  11948. }
  11949. rewind(fptr1);
  11950. //search Charging Profile Element
  11951. //int i= 0;
  11952. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  11953. {
  11954. //*************************tempconnectorIdInt*********************************/
  11955. loc = strstr(sLineWord, "connectorId");
  11956. c = 0;
  11957. memset(sstr ,0, ARRAY_SIZE(sstr));
  11958. while (loc[strlen("connectorId")+2+c] != ',')
  11959. {
  11960. sstr[c] = loc[strlen("connectorId")+2+c];
  11961. c++;
  11962. }
  11963. sstr[c] = '\0';
  11964. tempconnectorIdInt = atoi(sstr);
  11965. //id
  11966. c = 0;
  11967. loc = strstr(sLineWord, "id");
  11968. memset(sstr ,0, ARRAY_SIZE(sstr));
  11969. while (loc[strlen("id")+2+c] != ',')
  11970. {
  11971. sstr[c] = loc[strlen("id")+2+c];
  11972. //printf("i=%d sstr=%c\n",c, sstr[c]);
  11973. c++;
  11974. }
  11975. sstr[c] = '\0';
  11976. tempchargingProfileIdInt = atoi(sstr);
  11977. //stackLevel
  11978. c = 0;
  11979. loc = strstr(sLineWord, "stackLevel");
  11980. memset(sstr ,0, ARRAY_SIZE(sstr));
  11981. while (loc[strlen("stackLevel")+2+c] != ',')
  11982. {
  11983. sstr[c] = loc[strlen("stackLevel")+2+c];
  11984. //printf("i=%d sstr=%c\n",c, sstr[c]);
  11985. c++;
  11986. }
  11987. sstr[c] = '\0';
  11988. tempstackLevelInt = atoi(sstr);
  11989. c = 0;
  11990. loc = strstr(sLineWord, "chargingProfilePurpose");
  11991. memset(sstr ,0, ARRAY_SIZE(sstr));
  11992. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  11993. {
  11994. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  11995. c++;
  11996. }
  11997. sstr[c] = '\0';
  11998. strcpy(tempchargingProfilePurposeStr, sstr);
  11999. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  12000. {
  12001. //------- not write to fptr2-------//
  12002. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  12003. //clearflag = TRUE;
  12004. }
  12005. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  12006. {
  12007. //------- not write to fptr2-------//
  12008. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  12009. }
  12010. else if(stackLevelIsNULL == TRUE)
  12011. {
  12012. //Clear Whole File
  12013. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  12014. clearflag = TRUE;
  12015. break;
  12016. }
  12017. else
  12018. {
  12019. fprintf(fptr2, sLineWord);//writing data into file
  12020. }
  12021. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  12022. }
  12023. if(clearflag == TRUE)
  12024. {
  12025. fclose(fptr1);
  12026. fclose(fptr2);
  12027. sprintf(str,"rm -f %s",chargingProfiles[k]);
  12028. system(str);
  12029. // clear temp file
  12030. sprintf(str,"rm -f %s",temp);
  12031. system(str);
  12032. }
  12033. else
  12034. {
  12035. fclose(fptr1);
  12036. fclose(fptr2);
  12037. sprintf(str,"rm -f %s",chargingProfiles[k]);
  12038. system(str);
  12039. resultRename = rename(temp, chargingProfiles[k]);
  12040. if(resultRename == 0)
  12041. {
  12042. DEBUG_INFO("File ChargingProfile renamed successfully");
  12043. }
  12044. else
  12045. {
  12046. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  12047. }
  12048. if(comfirmstr[0]== 0)
  12049. {
  12050. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  12051. }
  12052. //Check chargingProfile is empty file
  12053. /*------ Read the file ----------------*/
  12054. fptr1=fopen(chargingProfiles[k],"r");
  12055. ch=fgetc(fptr1);
  12056. rewind(fptr1);
  12057. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  12058. if(ch!=EOF)
  12059. {
  12060. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  12061. {
  12062. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  12063. if(sLineWord[0]=='\0')
  12064. {
  12065. isEmptyFile = TRUE;
  12066. break;
  12067. }
  12068. else
  12069. {
  12070. isEmptyFile = FALSE;
  12071. break;
  12072. }
  12073. }
  12074. }
  12075. else
  12076. isEmptyFile = TRUE;
  12077. fclose(fptr1);
  12078. if(isEmptyFile == TRUE)
  12079. {
  12080. memset(str, 0, ARRAY_SIZE(str));
  12081. sprintf(str,"rm -f %s",chargingProfiles[k]);
  12082. system(str);
  12083. }
  12084. /*------- End of reading ---------------*/
  12085. }
  12086. } // while(int k=0; k < ChargeProfileCount; k++)
  12087. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  12088. end:
  12089. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  12090. {
  12091. if(connectorIdInt == 0)
  12092. {
  12093. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  12094. {
  12095. checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
  12096. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
  12097. }
  12098. }
  12099. else
  12100. {
  12101. checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
  12102. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1], 0, TRUE);
  12103. }
  12104. }
  12105. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  12106. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  12107. return result;
  12108. }
  12109. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  12110. {
  12111. mtrace();
  12112. int result = FAIL;
  12113. json_object *ClearDisplayMessage;
  12114. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  12115. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  12116. ClearDisplayMessage = json_tokener_parse(payload);
  12117. if(!is_error(ClearDisplayMessage))
  12118. {
  12119. // Required data
  12120. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  12121. {
  12122. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  12123. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  12124. }
  12125. }
  12126. json_object_put(ClearDisplayMessage);
  12127. sendCostUpdatedConfirmation(uuid);
  12128. return result;
  12129. }
  12130. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  12131. {
  12132. mtrace();
  12133. int result = FAIL;
  12134. json_object *ClearVariableMonitorin;
  12135. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  12136. ClearVariableMonitorin = json_tokener_parse(payload);
  12137. if(!is_error(ClearVariableMonitorin))
  12138. {
  12139. // Required data
  12140. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  12141. {
  12142. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  12143. {
  12144. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  12145. /*
  12146. * TODO:
  12147. * 1. Check response
  12148. */
  12149. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  12150. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  12151. }
  12152. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  12153. }
  12154. }
  12155. json_object_put(ClearVariableMonitorin);
  12156. return result;
  12157. }
  12158. int handleCostUpdatedRequest(char *uuid, char *payload)
  12159. {
  12160. mtrace();
  12161. int result = FAIL;
  12162. json_object *CostUpdate;
  12163. DEBUG_INFO("handleCostUpdatedRequest...\n");
  12164. CostUpdate = json_tokener_parse(payload);
  12165. if(!is_error(CostUpdate))
  12166. {
  12167. // Required data
  12168. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  12169. {
  12170. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  12171. }
  12172. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  12173. {
  12174. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  12175. }
  12176. }
  12177. json_object_put(CostUpdate);
  12178. sendCostUpdatedConfirmation(uuid);
  12179. return result;
  12180. }
  12181. int handleCustomerInformationRequest(char *uuid, char *payload)
  12182. {
  12183. mtrace();
  12184. int result = FAIL;
  12185. json_object *CustomerInformation;
  12186. DEBUG_INFO("handleCustomerInformationRequest...\n");
  12187. CustomerInformation = json_tokener_parse(payload);
  12188. if(!is_error(CustomerInformation))
  12189. {
  12190. // Required data
  12191. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  12192. {
  12193. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  12194. }
  12195. if(json_object_object_get(CustomerInformation, "report") != NULL)
  12196. {
  12197. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  12198. }
  12199. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  12200. {
  12201. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  12202. }
  12203. // Optional data
  12204. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  12205. {
  12206. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  12207. {
  12208. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  12209. }
  12210. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  12211. {
  12212. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  12213. }
  12214. }
  12215. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  12216. {
  12217. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  12218. {
  12219. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  12220. }
  12221. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  12222. {
  12223. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  12224. }
  12225. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  12226. {
  12227. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  12228. }
  12229. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  12230. {
  12231. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  12232. }
  12233. }
  12234. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  12235. ShmOCPP20Data->SpMsg.bits.NotifyCustomerInformationReq = ON;
  12236. }
  12237. else
  12238. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  12239. json_object_put(CustomerInformation);
  12240. sendCustomerInformationConfirmation(uuid);
  12241. return result;
  12242. }
  12243. void createFirmwareVersionByDataTransfer(void)
  12244. {
  12245. json_object *FirmwareDataTransfer = json_object_new_object();
  12246. // AC & DC model
  12247. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  12248. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  12249. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  12250. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  12251. // DC model
  12252. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  12253. {
  12254. if((gunType[1] != GUN_TYPE_UNKNOWN) ||
  12255. (gunType[2] != GUN_TYPE_UNKNOWN) ||
  12256. (gunType[3] != GUN_TYPE_UNKNOWN))
  12257. {
  12258. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  12259. }
  12260. if((ShmSysConfigAndInfo->SysConfig.ModelName[1]!='B') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='K') && (ShmSysConfigAndInfo->SysConfig.ModelName[1]!='O'))
  12261. {
  12262. // DS DM DW
  12263. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  12264. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  12265. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  12266. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  12267. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  12268. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  12269. }
  12270. else
  12271. {
  12272. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  12273. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  12274. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  12275. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  12276. json_object_object_add(FirmwareDataTransfer, "DD0_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuBootLoadFwRev));
  12277. json_object_object_add(FirmwareDataTransfer, "DD0_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuKernelFwRev));
  12278. json_object_object_add(FirmwareDataTransfer, "DD0_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuRootFsFwRev));
  12279. json_object_object_add(FirmwareDataTransfer, "DD0_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuPrimFwRev));
  12280. json_object_object_add(FirmwareDataTransfer, "DD0_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].FanModuleFwRev));
  12281. json_object_object_add(FirmwareDataTransfer, "DD0_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].RelayModuleFwRev));
  12282. json_object_object_add(FirmwareDataTransfer, "DD0_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].LedModuleFwRev));
  12283. json_object_object_add(FirmwareDataTransfer, "DD0_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector1FwRev));
  12284. json_object_object_add(FirmwareDataTransfer, "DD0_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector2FwRev));
  12285. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev) > 0)
  12286. json_object_object_add(FirmwareDataTransfer, "DD1_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev));
  12287. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev) > 0)
  12288. json_object_object_add(FirmwareDataTransfer, "DD1_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev));
  12289. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev) > 0)
  12290. json_object_object_add(FirmwareDataTransfer, "DD1_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev));
  12291. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev) > 0)
  12292. json_object_object_add(FirmwareDataTransfer, "DD1_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev));
  12293. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev) > 0)
  12294. json_object_object_add(FirmwareDataTransfer, "DD1_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev));
  12295. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev) > 0)
  12296. json_object_object_add(FirmwareDataTransfer, "DD1_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev));
  12297. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev) > 0)
  12298. json_object_object_add(FirmwareDataTransfer, "DD1_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev));
  12299. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev) > 0)
  12300. json_object_object_add(FirmwareDataTransfer, "DD1_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev));
  12301. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev) > 0)
  12302. json_object_object_add(FirmwareDataTransfer, "D11_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev));
  12303. }
  12304. }
  12305. // 4G model
  12306. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  12307. {
  12308. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  12309. }
  12310. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, json_object_to_json_string_ext(FirmwareDataTransfer, JSON_C_TO_STRING_PLAIN));
  12311. json_object_put(FirmwareDataTransfer);
  12312. }
  12313. int handleDataTransferRequest(char *uuid, char *payload)
  12314. {
  12315. mtrace();
  12316. int result = PASS;
  12317. DEBUG_INFO("handleDataTransferRequest...\n");
  12318. if((uuid != NULL) && (payload != NULL))
  12319. {
  12320. json_object *DataTransfer;
  12321. DataTransfer = json_tokener_parse(payload);
  12322. if(!is_error(DataTransfer))
  12323. {
  12324. // Required data
  12325. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  12326. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  12327. // Optional data
  12328. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  12329. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  12330. if(json_object_object_get(DataTransfer, "data") != NULL)
  12331. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  12332. result = PASS;
  12333. }
  12334. json_object_put(DataTransfer);
  12335. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  12336. {
  12337. // Send all moudle firmware version on EVSE
  12338. createFirmwareVersionByDataTransfer();
  12339. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12340. }
  12341. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_Tmate") != NULL)
  12342. {
  12343. system("/usr/bin/run_tmate_restart.sh &");
  12344. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12345. }
  12346. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_ChargingPreference") != NULL)
  12347. {
  12348. json_object *data;
  12349. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  12350. if(!is_error(data))
  12351. {
  12352. 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))
  12353. {
  12354. DEBUG_INFO("ChargeingPreference connector id: %d\n", json_object_get_int(json_object_object_get(data, "ConnectorId")));
  12355. memset(&ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))], 0x00, sizeof(struct StructSessionTarget));
  12356. if(json_object_object_get(data, "SOC") != NULL)
  12357. {
  12358. ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))].targetSoc = json_object_get_int(json_object_object_get(data, "SOC"));
  12359. DEBUG_INFO("ChargeingPreference target soc: %d\n", json_object_get_int(json_object_object_get(data, "SOC")));
  12360. }
  12361. if(json_object_object_get(data, "Energy") != NULL)
  12362. {
  12363. ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))].targetEnergy = json_object_get_int(json_object_object_get(data, "Energy"));
  12364. DEBUG_INFO("ChargeingPreference target energy: %d KWH\n", json_object_get_int(json_object_object_get(data, "Energy")));
  12365. }
  12366. if(json_object_object_get(data, "Duration") != NULL)
  12367. {
  12368. ShmOCPP20Data->SessionTarget[json_object_get_int(json_object_object_get(data, "ConnectorId"))].targetDuration = json_object_get_int(json_object_object_get(data, "Duration"));
  12369. DEBUG_INFO("ChargeingPreference target duration: %d minutes\n", json_object_get_int(json_object_object_get(data, "Duration")));
  12370. }
  12371. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12372. }
  12373. else
  12374. {
  12375. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12376. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Connector id must > 0.");
  12377. }
  12378. }
  12379. else
  12380. {
  12381. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12382. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12383. }
  12384. json_object_put(data);
  12385. }
  12386. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  12387. {
  12388. json_object *data;
  12389. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  12390. if(!is_error(data))
  12391. {
  12392. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  12393. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  12394. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  12395. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  12396. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  12397. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  12398. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  12399. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  12400. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  12401. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  12402. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12403. }
  12404. else
  12405. {
  12406. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12407. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12408. }
  12409. json_object_put(data);
  12410. }
  12411. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_ConfigQR") != NULL)
  12412. {
  12413. json_object *data;
  12414. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  12415. if(!is_error(data))
  12416. {
  12417. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12418. if(json_object_object_get(data, "Content_Type") != NULL)
  12419. {
  12420. 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))
  12421. {
  12422. ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode = json_object_get_int(json_object_object_get(data, "Content_Type"));
  12423. if(json_object_object_get(data, "Customization_Conent") != NULL)
  12424. {
  12425. sprintf((char*)ShmSysConfigAndInfo->SysConfig.QRCodeContent, "%s", json_object_get_string(json_object_object_get(data, "Customization_Conent")));
  12426. }
  12427. }
  12428. else
  12429. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12430. }
  12431. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  12432. }
  12433. else
  12434. {
  12435. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12436. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12437. }
  12438. json_object_put(data);
  12439. }
  12440. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_DisplayLcdPage") != NULL)
  12441. {
  12442. json_object *data;
  12443. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  12444. if(!is_error(data))
  12445. {
  12446. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12447. if(json_object_object_get(data, "ConnectorId") != NULL)
  12448. {
  12449. ShmSysConfigAndInfo->SysInfo.LcdOveride.connectorId = json_object_get_int(json_object_object_get(data, "ConnectorId"));
  12450. }
  12451. if(json_object_object_get(data, "Page_Index") != NULL)
  12452. {
  12453. ShmSysConfigAndInfo->SysInfo.LcdOveride.page_index = json_object_get_int(json_object_object_get(data, "Page_Index"));
  12454. }
  12455. if(json_object_object_get(data, "Duration") != NULL)
  12456. {
  12457. ShmSysConfigAndInfo->SysInfo.LcdOveride.duration = json_object_get_int(json_object_object_get(data, "Duration"));
  12458. }
  12459. ShmSysConfigAndInfo->SysInfo.LcdOveride.isOverideReq = ON;
  12460. }
  12461. else
  12462. {
  12463. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12464. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12465. }
  12466. json_object_put(data);
  12467. }
  12468. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_CpConfiguration") != NULL)
  12469. {
  12470. json_object *data;
  12471. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  12472. if(!is_error(data))
  12473. {
  12474. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  12475. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, " ");
  12476. if(json_object_object_get(data, "MaxChargingCurrent") != NULL)
  12477. {
  12478. if(json_object_get_int(json_object_object_get(data, "MaxChargingCurrent")) >= 0)
  12479. ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent = json_object_get_int(json_object_object_get(data, "MaxChargingCurrent"));
  12480. else
  12481. {
  12482. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12483. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12484. }
  12485. }
  12486. if(json_object_object_get(data, "MaxChargingDuration") != NULL)
  12487. {
  12488. if(json_object_get_int(json_object_object_get(data, "MaxChargingDuration")) >= 0)
  12489. ShmSysConfigAndInfo->SysConfig.MaxChargingDuration = json_object_get_int(json_object_object_get(data, "MaxChargingDuration"));
  12490. else
  12491. {
  12492. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12493. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12494. }
  12495. }
  12496. if(json_object_object_get(data, "MaxChargingEnergy") != NULL)
  12497. {
  12498. if(json_object_get_int(json_object_object_get(data, "MaxChargingEnergy")) >= 0)
  12499. ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy = json_object_get_int(json_object_object_get(data, "MaxChargingEnergy"));
  12500. else
  12501. {
  12502. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12503. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12504. }
  12505. }
  12506. if(json_object_object_get(data, "MaxChargingPower") != NULL)
  12507. {
  12508. if(json_object_get_int(json_object_object_get(data, "MaxChargingPower")) >= 0)
  12509. ShmSysConfigAndInfo->SysConfig.MaxChargingPower = json_object_get_int(json_object_object_get(data, "MaxChargingPower"));
  12510. else
  12511. {
  12512. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12513. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12514. }
  12515. }
  12516. if(json_object_object_get(data, "OfflineMaxChargeEnergy") != NULL)
  12517. {
  12518. if(json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy")) >= 0)
  12519. ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy = json_object_get_int(json_object_object_get(data, "OfflineMaxChargeEnergy"));
  12520. else
  12521. {
  12522. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12523. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12524. }
  12525. }
  12526. if(json_object_object_get(data, "OfflinePolicy") != NULL)
  12527. {
  12528. if((json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 0) ||
  12529. (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 2) ||
  12530. (json_object_get_int(json_object_object_get(data, "OfflinePolicy")) == 3))
  12531. ShmSysConfigAndInfo->SysConfig.OfflinePolicy = json_object_get_int(json_object_object_get(data, "OfflinePolicy"));
  12532. else
  12533. {
  12534. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12535. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12536. }
  12537. }
  12538. if(json_object_object_get(data, "isAuthentication") != NULL)
  12539. {
  12540. switch(json_object_get_int(json_object_object_get(data, "isAuthentication")))
  12541. {
  12542. case 0:
  12543. case 1:
  12544. ShmSysConfigAndInfo->SysConfig.AuthorisationMode = json_object_get_int(json_object_object_get(data, "isAuthentication"))^1;
  12545. break;
  12546. default:
  12547. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12548. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12549. break;
  12550. }
  12551. }
  12552. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]) != NULL)
  12553. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  12554. }
  12555. else
  12556. {
  12557. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  12558. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  12559. }
  12560. json_object_put(data);
  12561. }
  12562. else
  12563. {
  12564. // Can not find valid message id
  12565. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  12566. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  12567. ,ShmOCPP20Data->DataTransfer[0].vendorId
  12568. ,ShmOCPP20Data->DataTransfer[0].messageId
  12569. ,ShmOCPP20Data->DataTransfer[0].data);
  12570. }
  12571. }
  12572. else
  12573. {
  12574. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  12575. result = FAIL;
  12576. }
  12577. sendDataTransferConfirmation(uuid, 0);
  12578. return result;
  12579. }
  12580. int handleDeleteCertificateRequest(char *uuid, char *payload)
  12581. {
  12582. mtrace();
  12583. int result = FAIL;
  12584. json_object *DeleteCertificate;
  12585. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  12586. DeleteCertificate = json_tokener_parse(payload);
  12587. if(!is_error(DeleteCertificate))
  12588. {
  12589. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  12590. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  12591. // Required data
  12592. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  12593. {
  12594. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  12595. {
  12596. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  12597. }
  12598. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  12599. {
  12600. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  12601. }
  12602. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  12603. {
  12604. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  12605. }
  12606. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  12607. {
  12608. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  12609. }
  12610. /*
  12611. * TODO:
  12612. * 1. Delete certification and response
  12613. */
  12614. if(strstr((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, HashAlgorithmEnumTypeStr[HashAlgorithmEnumType_SHA256]) != NULL)
  12615. {
  12616. }
  12617. else if(strstr((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, HashAlgorithmEnumTypeStr[HashAlgorithmEnumType_SHA384]) != NULL)
  12618. {
  12619. }
  12620. else
  12621. {
  12622. }
  12623. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  12624. }
  12625. }
  12626. else
  12627. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  12628. json_object_put(DeleteCertificate);
  12629. sendDeleteCertificateConfirmation(uuid);
  12630. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  12631. return result;
  12632. }
  12633. int handleGetBaseReportRequest(char *uuid, char *payload)
  12634. {
  12635. mtrace();
  12636. int result = FAIL;
  12637. json_object *GetBaseRepor;
  12638. DEBUG_INFO("handleGetBaseReportRequest...\n");
  12639. GetBaseRepor = json_tokener_parse(payload);
  12640. if(!is_error(GetBaseRepor))
  12641. {
  12642. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  12643. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  12644. // Required data
  12645. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  12646. {
  12647. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  12648. }
  12649. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  12650. {
  12651. sprintf((char*)ShmOCPP20Data->GetBaseReport.reportBase, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  12652. }
  12653. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_SummaryInventory]) == 0)
  12654. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  12655. else
  12656. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  12657. }
  12658. else
  12659. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  12660. json_object_put(GetBaseRepor);
  12661. sendGetBaseReportConfirmation(uuid);
  12662. return result;
  12663. }
  12664. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  12665. {
  12666. mtrace();
  12667. int result = FAIL;
  12668. int gun_index = -1;
  12669. json_object *GetChargingProfiles;
  12670. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  12671. GetChargingProfiles = json_tokener_parse(payload);
  12672. if(!is_error(GetChargingProfiles))
  12673. {
  12674. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  12675. {
  12676. 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;
  12677. }
  12678. if(gun_index >-1)
  12679. {
  12680. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  12681. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  12682. // Required data
  12683. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  12684. {
  12685. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  12686. }
  12687. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  12688. {
  12689. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  12690. {
  12691. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  12692. }
  12693. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  12694. {
  12695. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  12696. }
  12697. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  12698. {
  12699. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  12700. {
  12701. 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)));
  12702. }
  12703. }
  12704. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  12705. {
  12706. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  12707. {
  12708. 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));
  12709. }
  12710. }
  12711. }
  12712. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  12713. }
  12714. else
  12715. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  12716. }
  12717. json_object_put(GetChargingProfiles);
  12718. sendGetChargingProfilesConfirmation(uuid, gun_index);
  12719. return result;
  12720. }
  12721. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  12722. {
  12723. mtrace();
  12724. int result = FAIL;
  12725. int connectorIdInt, durationInt;
  12726. char chargingRateUnitStr[4]={0};
  12727. char comfirmstr[20];
  12728. int confirmPeriods = 0;
  12729. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  12730. json_object *GetCompositeSchedule;
  12731. GetCompositeSchedule = json_tokener_parse(payload);
  12732. if(!is_error(GetCompositeSchedule))
  12733. {
  12734. // Required data
  12735. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  12736. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  12737. else
  12738. connectorIdInt = -1;
  12739. if(json_object_object_get(GetCompositeSchedule, "duration"))
  12740. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  12741. else
  12742. durationInt = 86400;
  12743. // Optional data
  12744. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  12745. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  12746. }
  12747. json_object_put(GetCompositeSchedule);
  12748. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  12749. if((connectorIdInt == 0) ||
  12750. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  12751. {
  12752. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  12753. struct ChargingProfileType tmpProfile[1];
  12754. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  12755. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  12756. if(strstr(chargingRateUnitStr, "W") != NULL || strlen(chargingRateUnitStr) == 0)
  12757. {
  12758. sprintf((char*)ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingRateUnit, "W");
  12759. checkChargingStationMaxProfile(durationInt, &tmpProfile[0], 0, FALSE);
  12760. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0], 0, FALSE);
  12761. }
  12762. else
  12763. {
  12764. sprintf((char*)ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingRateUnit, "A");
  12765. checkChargingStationMaxProfile(durationInt, &tmpProfile[0], 0, TRUE);
  12766. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0], 0, TRUE);
  12767. }
  12768. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  12769. {
  12770. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  12771. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  12772. }
  12773. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct ChargingScheduleType));
  12774. strcpy((char *)ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.startDateTime, (char *)tmpProfile[0].chargingSchedule[0].startSchedule);
  12775. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  12776. {
  12777. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  12778. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  12779. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  12780. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0) &&
  12781. (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))
  12782. {
  12783. confirmPeriods = idx;
  12784. break;
  12785. }
  12786. }
  12787. if((confirmPeriods == 0) && (tmpProfile[0].id > 0))
  12788. {
  12789. confirmPeriods += 1;
  12790. }
  12791. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  12792. }
  12793. else
  12794. {
  12795. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  12796. }
  12797. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  12798. return result;
  12799. }
  12800. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  12801. {
  12802. mtrace();
  12803. int result = FAIL;
  12804. json_object *GetDisplayMessages;
  12805. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  12806. GetDisplayMessages = json_tokener_parse(payload);
  12807. if(!is_error(GetDisplayMessages))
  12808. {
  12809. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  12810. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  12811. // Required data
  12812. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  12813. {
  12814. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  12815. }
  12816. // Optional data
  12817. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  12818. {
  12819. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  12820. }
  12821. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  12822. {
  12823. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  12824. }
  12825. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  12826. {
  12827. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  12828. {
  12829. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  12830. }
  12831. strcpy((char*)ShmOCPP20Data->GetDisplayMessages.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  12832. ShmOCPP20Data->MsMsg.bits.GetDisplayMessagesReq = ON;
  12833. }
  12834. else
  12835. strcpy((char*)ShmOCPP20Data->GetDisplayMessages.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  12836. }
  12837. json_object_put(GetDisplayMessages);
  12838. return result;
  12839. }
  12840. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  12841. {
  12842. mtrace();
  12843. int result = FAIL;
  12844. json_object *GetInstalledCertificateIds;
  12845. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  12846. GetInstalledCertificateIds = json_tokener_parse(payload);
  12847. if(!is_error(GetInstalledCertificateIds))
  12848. {
  12849. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  12850. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  12851. // Optional data
  12852. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  12853. {
  12854. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  12855. {
  12856. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  12857. /*
  12858. * TODO:
  12859. * 1. Get installed certificate info for response
  12860. */
  12861. if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_V2GRootCertificate]) != NULL)
  12862. {
  12863. }
  12864. else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_MORootCertificate]) != NULL)
  12865. {
  12866. }
  12867. else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_CSMSRootCertificate]) != NULL)
  12868. {
  12869. }
  12870. else if(strstr((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], GetCertificateIdUseEnumTypeStr[GetCertificateIdUseEnumType_V2GCertificateChain]) != NULL)
  12871. {
  12872. }
  12873. else
  12874. {
  12875. }
  12876. }
  12877. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  12878. }
  12879. else
  12880. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  12881. }
  12882. json_object_put(GetInstalledCertificateIds);
  12883. sendInstallCertificateConfirmation(uuid);
  12884. return result;
  12885. }
  12886. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  12887. {
  12888. mtrace();
  12889. int result = FAIL;
  12890. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  12891. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "false") == 0)
  12892. {
  12893. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  12894. localversion = 0;
  12895. }
  12896. else
  12897. {
  12898. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  12899. localversion = 0;
  12900. DB_getListVerion();
  12901. }
  12902. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  12903. sendGetLocalListVersionConfirmation(uuid);
  12904. return result;
  12905. }
  12906. static char fnamePlusPath[100]={0};
  12907. static char fnamePWithNoPath[60]={0};
  12908. void checkUploadLog(void)
  12909. {
  12910. FILE *fp;
  12911. /* Open the command for reading. */
  12912. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  12913. if (fp == NULL) {
  12914. printf("Failed to run command\n" );
  12915. exit(1);
  12916. }
  12917. int ftppathlen = 0;
  12918. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  12919. int i = 0;
  12920. /* Read the output a line at a time - output it. */
  12921. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  12922. if(i==0)
  12923. {
  12924. ftppathlen = strlen(fnamePlusPath);
  12925. printf("%s\n", fnamePlusPath);
  12926. fnamePlusPath[ftppathlen]='\0';
  12927. break;
  12928. }
  12929. i= i+1;
  12930. }
  12931. /* close */
  12932. pclose(fp);
  12933. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  12934. {
  12935. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  12936. {
  12937. fnamePlusPath[k]='\0';
  12938. }
  12939. }
  12940. i=1;
  12941. //char fname[60]={0};
  12942. while(i < ftppathlen)
  12943. {
  12944. int len=ftppathlen-i;
  12945. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  12946. {
  12947. printf("compare '/' all right\n");
  12948. break;
  12949. }
  12950. i=i+1;
  12951. }
  12952. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  12953. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  12954. fnamePWithNoPath[i+1] = '\0';
  12955. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  12956. {
  12957. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  12958. {
  12959. fnamePWithNoPath[j]='\0';
  12960. }
  12961. }
  12962. FILE* fp1 = fopen(fnamePlusPath, "r");
  12963. if (fp1)
  12964. {
  12965. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  12966. // file exists
  12967. fclose(fp1);
  12968. }
  12969. else
  12970. {
  12971. // file doesn't exist
  12972. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  12973. }
  12974. }
  12975. void* GetLogProcess(void* data)
  12976. {
  12977. th_GetLog = pthread_self();
  12978. pthread_detach(pthread_self());
  12979. mtrace();
  12980. int requestId, retriesInt=0, retryIntervalInt=0;
  12981. char logType[32], remoteLocation[1024]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  12982. 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};
  12983. int port=0;
  12984. int isSuccess = FALSE;
  12985. char ftpbuf[1024]={0};
  12986. char cmdBuf[2048];
  12987. struct tm *tmNow;
  12988. time_t CurrentTime;
  12989. struct tm tmStart;
  12990. struct tm tmStop;
  12991. CurrentTime = time(NULL);
  12992. tmNow=localtime(&CurrentTime);
  12993. uint16_t targetYear, targetMonth;
  12994. json_object *GetLog;
  12995. DEBUG_INFO("GetGetProcess...\n");
  12996. GetLog = json_tokener_parse(data);
  12997. if(!is_error(GetLog))
  12998. {
  12999. // Required data
  13000. if(json_object_object_get(GetLog, "requestId") != NULL)
  13001. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  13002. if(json_object_object_get(GetLog, "logType") != NULL)
  13003. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  13004. if(json_object_object_get(GetLog, "log") != NULL)
  13005. {
  13006. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  13007. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  13008. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  13009. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  13010. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  13011. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  13012. }
  13013. // Optional data
  13014. if(json_object_object_get(GetLog, "retries") != NULL)
  13015. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  13016. else
  13017. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  13018. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  13019. retryIntervalInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  13020. else
  13021. retryIntervalInt = 30;
  13022. }
  13023. json_object_put(GetLog);
  13024. ShmOCPP20Data->GetLog.requestId = requestId;
  13025. if(strstr(logType, LogEnumTypeStr[LogEnumType_SecurityLog]))
  13026. {
  13027. /*
  13028. * TODO:
  13029. * 1. Pack security log
  13030. */
  13031. }
  13032. else
  13033. {
  13034. // Pack log to compress file
  13035. 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) &&
  13036. (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))
  13037. {
  13038. // Pack system log
  13039. memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
  13040. sprintf(cmdBuf, "exec zip -9 --password %04d%02d%s /mnt/system.zip", tmNow->tm_year+1900, tmNow->tm_mon+1, ShmSysConfigAndInfo->SysConfig.SerialNumber);
  13041. targetYear = tmStart.tm_year;
  13042. targetMonth = tmStart.tm_mon;
  13043. do
  13044. {
  13045. sprintf(cmdBuf, "%s /Storage/SystemLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  13046. sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*SystemLog*", cmdBuf, targetYear, targetMonth);
  13047. if(targetMonth+1>=13)
  13048. {
  13049. targetYear += 1;
  13050. targetMonth = 1;
  13051. }
  13052. else
  13053. {
  13054. targetMonth += 1;
  13055. }
  13056. }while((targetYear < (tmNow->tm_year+1900)) ||
  13057. ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
  13058. sprintf(cmdBuf, "%s /Storage/CCS*.zip", cmdBuf);
  13059. system(cmdBuf);
  13060. // Pack charging & event log
  13061. memset(cmdBuf, 0x00, ARRAY_SIZE(cmdBuf));
  13062. sprintf(cmdBuf, "exec zip -9 /mnt/charging_event.zip");
  13063. targetYear = tmStart.tm_year;
  13064. targetMonth = tmStart.tm_mon;
  13065. do
  13066. {
  13067. sprintf(cmdBuf, "%s /Storage/EventLog/*%04d*%02d*", cmdBuf, targetYear, targetMonth);
  13068. sprintf(cmdBuf, "%s /Storage/OCPP/*%04d*%02d*OcppMessageLog*", cmdBuf, targetYear, targetMonth);
  13069. if(targetMonth+1>=13)
  13070. {
  13071. targetYear += 1;
  13072. targetMonth = 1;
  13073. }
  13074. else
  13075. {
  13076. targetMonth += 1;
  13077. }
  13078. }while((targetYear < (tmNow->tm_year+1900)) ||
  13079. ((targetYear <= (tmNow->tm_year+1900)) && (targetMonth <= (tmNow->tm_mon+1))));
  13080. sprintf(cmdBuf, "%s /Storage/ChargeLog/*.db", cmdBuf);
  13081. sprintf(cmdBuf, "%s /Storage/EventLog/*.db", cmdBuf);
  13082. system(cmdBuf);
  13083. // Combine log file
  13084. system("exec zip -9 /mnt/log.zip /mnt/system.zip /mnt/charging_event.zip");
  13085. system("exec rm -f /mnt/system.zip /mnt/charging_event.zip");
  13086. }
  13087. else
  13088. {
  13089. system("exec /root/logPackTools 'log' 6");
  13090. }
  13091. }
  13092. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", ShmOCPP20Data->GetLog.Response_filename);
  13093. system(cmdBuf);
  13094. checkUploadLog();
  13095. //****************location*******************/
  13096. if(strcmp(remoteLocation,"")==0)
  13097. {
  13098. DEBUG_INFO("remoteLocation is <Empty>!\n");
  13099. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  13100. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13101. goto end;
  13102. }
  13103. memset(protocol, 0, ARRAY_SIZE(protocol));
  13104. memset(user, 0, ARRAY_SIZE(user) );
  13105. memset(password, 0, ARRAY_SIZE(password));
  13106. memset(host, 0, ARRAY_SIZE(host));
  13107. memset(path, 0, ARRAY_SIZE(path));
  13108. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  13109. memset(host1, 0, ARRAY_SIZE(host1));
  13110. memset(path1, 0, ARRAY_SIZE(path1));
  13111. /*location: ftp://user:password@host:port/path*/
  13112. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  13113. if((access(fnamePlusPath,F_OK))!=-1)
  13114. {
  13115. DEBUG_INFO("fnamePlusPath exist.\n");
  13116. }
  13117. else
  13118. {
  13119. DEBUG_INFO("fnamePlusPath not exist!\n");
  13120. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  13121. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13122. goto end;
  13123. }
  13124. if(strchr(remoteLocation,'@')==NULL)
  13125. {
  13126. sscanf(remoteLocation,
  13127. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  13128. protocol, host, &port, path);
  13129. strcpy(user,"anonymous");
  13130. strcpy(password,"");
  13131. }
  13132. else
  13133. {
  13134. //DEBUG_INFO("pch=%s\n", pch);
  13135. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  13136. protocol, user, password, host, &port, path);
  13137. }
  13138. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0)&&(strcmp(protocol,"https")!=0))
  13139. {
  13140. DEBUG_INFO("protocol is not ftp/http ! \n");
  13141. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  13142. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13143. goto end;
  13144. }
  13145. if(strncmp(remoteLocation,"http", 4) == 0)
  13146. {
  13147. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  13148. sprintf(ftppath,"/%s", path);
  13149. do
  13150. {
  13151. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  13152. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13153. sleep(3);
  13154. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  13155. if(!isSuccess)
  13156. {
  13157. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  13158. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  13159. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13160. sleep(retryIntervalInt);
  13161. }
  13162. else
  13163. {
  13164. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  13165. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  13166. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13167. }
  13168. retriesInt--;
  13169. }while((isSuccess == 0)&&(retriesInt >= 0));
  13170. }
  13171. else
  13172. {
  13173. sscanf(host,"%[^/]%s",host1, path1);
  13174. if(strlen(path) > 0)
  13175. sprintf(ftppath,"/%s", path);
  13176. else
  13177. sprintf(ftppath,"/%s", path1);
  13178. int ftppathlen=strlen(ftppath);
  13179. int i=1;
  13180. char filenametemp[50];
  13181. while(i < ftppathlen)
  13182. {
  13183. int len=ftppathlen-i;
  13184. if(ftppath[len]== 47) // '/' ascll code: 47
  13185. {
  13186. DEBUG_INFO("find '/' all right\n");
  13187. break;
  13188. }
  13189. i=i+1;
  13190. }
  13191. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  13192. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  13193. filenametemp[i+1] = 0;
  13194. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13195. if(port == 0)
  13196. port = 21;
  13197. do
  13198. {
  13199. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  13200. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13201. sleep(3);
  13202. isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  13203. if(!isSuccess)
  13204. {
  13205. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  13206. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  13207. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13208. sleep(retryIntervalInt);
  13209. }
  13210. else
  13211. {
  13212. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  13213. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  13214. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13215. }
  13216. retriesInt--;
  13217. }while((!isSuccess)&&(retriesInt >= 0));
  13218. }
  13219. end:
  13220. system("rm -f /mnt/*");
  13221. sleep(5);
  13222. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  13223. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13224. interLock.isGetLogGoing = OFF;
  13225. pthread_exit(NULL);
  13226. }
  13227. int handleGetLogRequest(char *uuid, char *payload)
  13228. {
  13229. mtrace();
  13230. int result = FAIL;
  13231. char fName[258];
  13232. time_t CurrentTime;
  13233. struct tm *tm;
  13234. pthread_t th_Status;
  13235. DEBUG_INFO("handleGetLogRequest...\n");
  13236. CurrentTime = time(NULL);
  13237. tm = localtime(&CurrentTime);
  13238. 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);
  13239. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  13240. if(interLock.isGetLogGoing)
  13241. {
  13242. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_AcceptedCanceled]);
  13243. isCancelUploadLog = TRUE;
  13244. pthread_cancel(th_GetLog);
  13245. interLock.isGetLogGoing = OFF;
  13246. sleep(1);
  13247. isCancelUploadLog = OFF;
  13248. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_AcceptedCanceled]);
  13249. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  13250. sleep(1);
  13251. }
  13252. else
  13253. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  13254. sendGetLogConfirmation(uuid);
  13255. if(!interLock.isGetLogGoing)
  13256. {
  13257. interLock.isGetLogGoing = ON;
  13258. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  13259. sleep(1);
  13260. }
  13261. else
  13262. {
  13263. DEBUG_WARN("Other GetDiagnostic request on going.\n");
  13264. }
  13265. return result;
  13266. }
  13267. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  13268. {
  13269. mtrace();
  13270. int result = FAIL;
  13271. json_object *GetMonitoringReport;
  13272. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  13273. GetMonitoringReport = json_tokener_parse(payload);
  13274. if(!is_error(GetMonitoringReport))
  13275. {
  13276. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  13277. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  13278. // Required data
  13279. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  13280. {
  13281. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  13282. }
  13283. // Optional data
  13284. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  13285. {
  13286. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  13287. }
  13288. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  13289. {
  13290. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  13291. {
  13292. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  13293. {
  13294. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  13295. {
  13296. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  13297. {
  13298. 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")));
  13299. }
  13300. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  13301. {
  13302. 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")));
  13303. }
  13304. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  13305. {
  13306. 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)
  13307. {
  13308. 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"));
  13309. }
  13310. 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)
  13311. {
  13312. 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"));
  13313. }
  13314. }
  13315. }
  13316. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  13317. {
  13318. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  13319. {
  13320. 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")));
  13321. }
  13322. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  13323. {
  13324. 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")));
  13325. }
  13326. }
  13327. }
  13328. }
  13329. }
  13330. }
  13331. json_object_put(GetMonitoringReport);
  13332. /*
  13333. * TODO:
  13334. * 1. Response result
  13335. */
  13336. strcpy((char*)ShmOCPP20Data->GetMonitoringReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  13337. sendGetMonitoringReportConfirmation(uuid);
  13338. return result;
  13339. }
  13340. int handleGetReportRequest(char *uuid, char *payload)
  13341. {
  13342. mtrace();
  13343. int result = FAIL;
  13344. json_object *GetReport;
  13345. DEBUG_INFO("handleGetReportRequest...\n");
  13346. GetReport = json_tokener_parse(payload);
  13347. if(!is_error(GetReport))
  13348. {
  13349. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  13350. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  13351. // Required data
  13352. if(json_object_object_get(GetReport, "requestId") != NULL)
  13353. {
  13354. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  13355. }
  13356. // Optional data
  13357. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  13358. {
  13359. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  13360. }
  13361. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  13362. {
  13363. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  13364. {
  13365. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  13366. {
  13367. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  13368. {
  13369. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  13370. {
  13371. 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")));
  13372. }
  13373. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  13374. {
  13375. 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")));
  13376. }
  13377. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  13378. {
  13379. 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)
  13380. {
  13381. 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"));
  13382. }
  13383. 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)
  13384. {
  13385. 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"));
  13386. }
  13387. }
  13388. }
  13389. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  13390. {
  13391. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  13392. {
  13393. 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")));
  13394. }
  13395. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  13396. {
  13397. 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")));
  13398. }
  13399. }
  13400. }
  13401. }
  13402. }
  13403. }
  13404. json_object_put(GetReport);
  13405. /*
  13406. * TODO:
  13407. * 1. Response result
  13408. */
  13409. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  13410. sendGetReportConfirmation(uuid);
  13411. return result;
  13412. }
  13413. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  13414. {
  13415. mtrace();
  13416. int result = FAIL;
  13417. int8_t gun_index = -1;
  13418. json_object *GetTransactionStatus;
  13419. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  13420. GetTransactionStatus = json_tokener_parse(payload);
  13421. if(!is_error(GetTransactionStatus))
  13422. {
  13423. /*
  13424. * TODO:
  13425. * 1. Check transaction locate which connector
  13426. */
  13427. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  13428. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  13429. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  13430. {
  13431. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  13432. }
  13433. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  13434. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  13435. }
  13436. json_object_put(GetTransactionStatus);
  13437. sendGetTransactionStatusConfirmation(uuid, gun_index);
  13438. return result;
  13439. }
  13440. int handleGetVariablesRequest(char *uuid, char *payload)
  13441. {
  13442. mtrace();
  13443. int result = FAIL;
  13444. int isUnknownComponent = TRUE;
  13445. json_object *GetVariables;
  13446. DEBUG_INFO("handleGetVariablesRequest...\n");
  13447. GetVariables = json_tokener_parse(payload);
  13448. if(!is_error(GetVariables))
  13449. {
  13450. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  13451. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  13452. // Required data
  13453. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  13454. {
  13455. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  13456. {
  13457. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  13458. {
  13459. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  13460. {
  13461. 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")));
  13462. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  13463. }
  13464. /*if(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType != NULL)
  13465. {
  13466. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, "Actual");
  13467. }*/
  13468. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  13469. {
  13470. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  13471. {
  13472. 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")));
  13473. }
  13474. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  13475. {
  13476. 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")));
  13477. }
  13478. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  13479. {
  13480. 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)
  13481. {
  13482. 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"));
  13483. }
  13484. 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)
  13485. {
  13486. 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"));
  13487. }
  13488. }
  13489. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  13490. }
  13491. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  13492. {
  13493. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  13494. {
  13495. 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")));
  13496. }
  13497. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  13498. {
  13499. 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")));
  13500. }
  13501. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  13502. }
  13503. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  13504. {
  13505. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) == 0) &&
  13506. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance) == 0) &&
  13507. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) == 0) &&
  13508. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance) == 0))
  13509. {
  13510. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  13511. isUnknownComponent = FALSE;
  13512. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type) != 0) &&
  13513. (json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL))
  13514. {
  13515. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_NotSupportedAttributeType]);
  13516. break;
  13517. }
  13518. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, "ChargingStation") == 0) &&
  13519. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, "SystemUptimeSec") == 0))
  13520. {
  13521. struct sysinfo s_info;
  13522. int error = sysinfo(&s_info);
  13523. if(error != 0)
  13524. {
  13525. DEBUG_WARN("System uptime get error: %d\n", error);
  13526. }
  13527. else
  13528. {
  13529. sprintf((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, "%ld", s_info.uptime);
  13530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, "%ld", s_info.uptime);
  13531. }
  13532. }
  13533. else if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, "ChargingStation") == 0) &&
  13534. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, "FreeVend") == 0))
  13535. {
  13536. sprintf((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, "%s", (ShmSysConfigAndInfo->SysConfig.AuthorisationMode?"true":"false"));
  13537. }
  13538. else
  13539. {
  13540. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  13541. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type);
  13542. }
  13543. break;
  13544. }
  13545. else
  13546. {
  13547. if(strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) != 0)
  13548. {
  13549. isUnknownComponent = FALSE;
  13550. }
  13551. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownVariable]);
  13552. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  13553. }
  13554. }
  13555. if(isUnknownComponent == TRUE)
  13556. {
  13557. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  13558. }
  13559. }
  13560. }
  13561. }
  13562. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  13563. }
  13564. json_object_put(GetVariables);
  13565. return result;
  13566. }
  13567. int handleInstallCertificateRequest(char *uuid, char *payload)
  13568. {
  13569. mtrace();
  13570. int result = FAIL;
  13571. json_object *InstallCertificate;
  13572. DEBUG_INFO("handleInstallCertificateRequest...\n");
  13573. InstallCertificate = json_tokener_parse(payload);
  13574. if(!is_error(InstallCertificate))
  13575. {
  13576. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  13577. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  13578. // Required data
  13579. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  13580. {
  13581. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  13582. }
  13583. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  13584. {
  13585. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  13586. }
  13587. }
  13588. json_object_put(InstallCertificate);
  13589. /*
  13590. * TODO:
  13591. * 1. Install certification preocess and response
  13592. */
  13593. if(strstr((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_V2GRootCertificate]))
  13594. {
  13595. }
  13596. else if(strstr((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_MORootCertificate]))
  13597. {
  13598. }
  13599. else if(strstr((char*)ShmOCPP20Data->InstallCertificate.certificateType, InstallCertificateUseEnumTypeStr[InstallCertificateUseEnumType_CSMSRootCertificate]))
  13600. {
  13601. }
  13602. else
  13603. {
  13604. }
  13605. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  13606. sendInstallCertificateConfirmation(uuid);
  13607. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  13608. return result;
  13609. }
  13610. int handlePublishFirmwareRequest(char *uuid, char *payload)
  13611. {
  13612. mtrace();
  13613. int result = FAIL;
  13614. json_object *PublishFirmware;
  13615. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  13616. PublishFirmware = json_tokener_parse(payload);
  13617. if(!is_error(PublishFirmware))
  13618. {
  13619. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  13620. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  13621. // Required data
  13622. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  13623. {
  13624. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  13625. }
  13626. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  13627. {
  13628. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  13629. }
  13630. // Optional data
  13631. if(json_object_object_get(PublishFirmware, "location") != NULL)
  13632. {
  13633. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  13634. }
  13635. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  13636. {
  13637. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  13638. }
  13639. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  13640. {
  13641. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  13642. }
  13643. }
  13644. json_object_put(PublishFirmware);
  13645. /*
  13646. * TODO:
  13647. * 1. Publish firmware preocess and response
  13648. */
  13649. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  13650. sendPublishFirmwareConfirmation(uuid);
  13651. return result;
  13652. }
  13653. int handleRequestStartTransactionRequest(char *uuid, char *payload)
  13654. {
  13655. mtrace();
  13656. int result = FAIL;
  13657. int8_t connectorIdx = -1;
  13658. uint8_t tempIndex;
  13659. uint8_t isOverConnectorMax = FALSE;
  13660. uint8_t isPeriodOverMax = FALSE;
  13661. uint8_t isTxProfile = TRUE;
  13662. uint8_t isAllowStart = TRUE;
  13663. uint8_t filename[128]={0};
  13664. char cmdBuf[128];
  13665. FILE *filePtr;
  13666. json_object *RemoteStartTransaction;
  13667. DEBUG_INFO("handleRequestStartTransactionRequest...\n");
  13668. RemoteStartTransaction = json_tokener_parse(payload);
  13669. if(!is_error(RemoteStartTransaction))
  13670. {
  13671. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  13672. {
  13673. if((0 < json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))) && (json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"))<=gunTotalNumber))
  13674. {
  13675. connectorIdx = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
  13676. }
  13677. else
  13678. {
  13679. isOverConnectorMax = TRUE;
  13680. DEBUG_WARN("Connector id shall not equal 0 and less than max connector id.\n");
  13681. }
  13682. }
  13683. else
  13684. {
  13685. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  13686. {
  13687. if(!cpinitateMsg.bits[idx].isOnCharging && (strstr((char*)ShmOCPP20Data->StatusNotification[idx].connectorStatus, ConnectorStatusEnumTypeStr[ConnectorStatusEnumType_Occupied]) != NULL))
  13688. {
  13689. connectorIdx = (idx+1);
  13690. DEBUG_INFO("Remote start without connectorId but detect connector-%02d connected ready to start.\n", connectorIdx);
  13691. break;
  13692. }
  13693. }
  13694. }
  13695. if(isOverConnectorMax == FALSE)
  13696. {
  13697. if(connectorIdx > 0)
  13698. {
  13699. DEBUG_INFO("Connector id: %d\n", connectorIdx);
  13700. memset(&ShmOCPP20Data->RequestStartTransaction[connectorIdx-1], 0, sizeof(struct RequestStartTransaction_20));
  13701. memcpy(&ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].guid));
  13702. // Required data
  13703. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  13704. {
  13705. ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  13706. }
  13707. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  13708. {
  13709. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  13710. {
  13711. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  13712. }
  13713. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  13714. {
  13715. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  13716. }
  13717. }
  13718. // Optional data
  13719. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  13720. {
  13721. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  13722. {
  13723. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  13724. }
  13725. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  13726. {
  13727. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  13728. }
  13729. }
  13730. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  13731. {
  13732. // Check periods is over max configuration
  13733. 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))
  13734. {
  13735. isPeriodOverMax = TRUE;
  13736. }
  13737. // Check profile purpose is TxProfile
  13738. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  13739. {
  13740. ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].chargingProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "id"));
  13741. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdx);
  13742. }
  13743. else
  13744. {
  13745. isTxProfile = FALSE;
  13746. }
  13747. }
  13748. //check Transaction active
  13749. if(gunType[connectorIdx-1] == GUN_TYPE_CHAdeMO)
  13750. {
  13751. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13752. {
  13753. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  13754. }
  13755. else
  13756. {
  13757. tempIndex = (connectorIdx-1);
  13758. }
  13759. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13760. {
  13761. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex )
  13762. {
  13763. 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))
  13764. {
  13765. //Reserved
  13766. DEBUG_INFO("CHAdeMO connector already reserved and idTag match.\n");
  13767. }
  13768. 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))
  13769. {
  13770. //Reserved
  13771. DEBUG_INFO("CHAdeMO connector already reserved and idTag does not match.\n");
  13772. isAllowStart = FALSE;
  13773. }
  13774. else
  13775. {
  13776. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13777. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARING ) //S_PRECHARGE
  13778. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV ) //S_PREPARING_FOR_EV
  13779. && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE )) // S_PREPARING_FOR_EVSE
  13780. {
  13781. DEBUG_WARN("CHAdeMO connector not allow start cause busy.\n.");
  13782. isAllowStart = FALSE;
  13783. }
  13784. }//END FOR ELSE
  13785. }
  13786. }// END FOR CHAdeMO_QUANTITY
  13787. }
  13788. else if(gunType[connectorIdx-1] == GUN_TYPE_CCS)
  13789. {
  13790. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13791. {
  13792. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  13793. }
  13794. else
  13795. {
  13796. tempIndex = (connectorIdx-1);
  13797. }
  13798. for (int index = 0; index < CCS_QUANTITY; index++)
  13799. {
  13800. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  13801. {
  13802. 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))
  13803. {
  13804. //Reserved
  13805. DEBUG_INFO("CCS connector already reserved and idTag match.\n");
  13806. }
  13807. 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))
  13808. {
  13809. //Reserved
  13810. DEBUG_INFO("CCS connector already reserved and idTag does not match.\n");
  13811. isAllowStart = FALSE;
  13812. }
  13813. else
  13814. {
  13815. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13816. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  13817. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  13818. && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  13819. {
  13820. DEBUG_WARN("CCS connector not allow start cause busy.\n.");
  13821. isAllowStart = FALSE;
  13822. }
  13823. }// END FOR ELSE
  13824. }
  13825. }// END FOR CCS_QUANTITY
  13826. }
  13827. else if(gunType[connectorIdx-1] == GUN_TYPE_GBT)
  13828. {
  13829. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  13830. {
  13831. tempIndex = ((connectorIdx-1) == 2) ? 1: 0;
  13832. }
  13833. else
  13834. {
  13835. tempIndex = (connectorIdx-1);
  13836. }
  13837. for (int index = 0; index < GB_QUANTITY; index++)
  13838. {
  13839. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex )
  13840. {
  13841. 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))
  13842. {
  13843. //Reserved
  13844. DEBUG_INFO("GBT connector already reserved and idTag match.\n");
  13845. }
  13846. 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))
  13847. {
  13848. //Reserved
  13849. DEBUG_INFO("GBT connector already reserved and idTag does not match.\n");
  13850. isAllowStart = FALSE;
  13851. }
  13852. else
  13853. {
  13854. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13855. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  13856. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  13857. && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  13858. {
  13859. DEBUG_WARN("GBT connector not allow start cause busy.\n");
  13860. isAllowStart = FALSE;
  13861. }
  13862. }// END FOR ELSE
  13863. }
  13864. } // END FOR GB_QUANTITY
  13865. }
  13866. else if(gunType[connectorIdx-1] == GUN_TYPE_DO)
  13867. {
  13868. tempIndex = (connectorIdx-1);
  13869. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13870. {
  13871. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex )
  13872. {
  13873. 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))
  13874. {
  13875. //Reserved
  13876. DEBUG_INFO("Dispenser connector already reserved and idTag match.\n");
  13877. }
  13878. 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))
  13879. {
  13880. //Reserved
  13881. DEBUG_INFO("Dispenser connector already reserved and idTag does not match.\n");
  13882. isAllowStart = FALSE;
  13883. }
  13884. else
  13885. {
  13886. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13887. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  13888. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  13889. && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  13890. {
  13891. DEBUG_WARN("Dispenser connector not allow start cause busy.\n");
  13892. isAllowStart = FALSE;
  13893. }
  13894. }// END FOR ELSE
  13895. }
  13896. } // END FOR GB_QUANTITY
  13897. }
  13898. else
  13899. {
  13900. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13901. {
  13902. tempIndex = 2;
  13903. }
  13904. else
  13905. {
  13906. tempIndex = (connectorIdx-1);
  13907. }
  13908. for (int index = 0; index < AC_QUANTITY; index++)
  13909. {
  13910. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex )
  13911. {
  13912. 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))
  13913. {
  13914. //Reserved
  13915. DEBUG_INFO("AC connector already reserved and idTag match.\n");
  13916. }
  13917. 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))
  13918. {
  13919. //Reserved
  13920. DEBUG_INFO("AC connector already reserved and idTag does not match.\n");
  13921. isAllowStart = FALSE;
  13922. }
  13923. else
  13924. {
  13925. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  13926. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARING) //S_PRECHARGE
  13927. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EV) //S_PREPARING_FOR_EV
  13928. && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_PREPARE_FOR_EVSE)) // S_PREPARING_FOR_EVSE
  13929. {
  13930. DEBUG_WARN("AC connector not allow start cause busy.\n");
  13931. isAllowStart = FALSE;
  13932. }
  13933. }//END FOR ELSE
  13934. }
  13935. }// END FOR AC_QUANTITY
  13936. }
  13937. }
  13938. else
  13939. {
  13940. DEBUG_INFO("Connector id does not specific.\n");
  13941. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  13942. {
  13943. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  13944. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  13945. // Required data
  13946. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  13947. {
  13948. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  13949. }
  13950. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  13951. {
  13952. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  13953. {
  13954. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  13955. }
  13956. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  13957. {
  13958. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  13959. }
  13960. }
  13961. // Optional data
  13962. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  13963. {
  13964. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  13965. {
  13966. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  13967. }
  13968. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  13969. {
  13970. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  13971. }
  13972. }
  13973. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  13974. {
  13975. // Check periods is over max configuration
  13976. 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))
  13977. {
  13978. isPeriodOverMax = TRUE;
  13979. }
  13980. // Check profile purpose is TxProfile
  13981. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  13982. {
  13983. ShmOCPP20Data->RequestStartTransaction[gun_index].chargingProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "id"));
  13984. sprintf((char*)filename, "/Storage/OCPP/TxProfile_Tmp_OCPP20.json");
  13985. }
  13986. else
  13987. {
  13988. isTxProfile = FALSE;
  13989. }
  13990. }
  13991. }
  13992. }
  13993. }
  13994. // Profile replace or add info
  13995. if((isOverConnectorMax == FALSE) && !isPeriodOverMax && isTxProfile && isAllowStart)
  13996. {
  13997. if(connectorIdx != -1)
  13998. {
  13999. if(strlen((char*)filename) > 0)
  14000. {
  14001. // Save profile to file
  14002. sprintf(cmdBuf, "rm -f /Storage/OCPP/TxProfile_%d_OCPP20.json", connectorIdx);
  14003. system(cmdBuf);
  14004. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json.json", connectorIdx);
  14005. filePtr = fopen((char*)filename, "w");
  14006. 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));
  14007. fclose(filePtr);
  14008. }
  14009. ShmOCPP20Data->CsMsg.bits[connectorIdx-1].RequestStartTransactionReq = ON;
  14010. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  14011. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[connectorIdx-1].Response_transactionId);
  14012. result = PASS;
  14013. }
  14014. else
  14015. {
  14016. uint8_t isHasIdleConnector = FALSE;
  14017. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  14018. {
  14019. if(!cpinitateMsg.bits[gun_index].isOnCharging)
  14020. {
  14021. isHasIdleConnector = TRUE;
  14022. break;
  14023. }
  14024. }
  14025. if(isHasIdleConnector == TRUE)
  14026. {
  14027. DEBUG_INFO("Start wait connector link to EV in %s seconds.\n", ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value);
  14028. if(strlen((char*)filename) > 0)
  14029. {
  14030. // Save profile to file
  14031. sprintf(cmdBuf, "rm -f /Storage/OCPP/TxProfile_Tmp_OCPP20.json");
  14032. system(cmdBuf);
  14033. sprintf((char*)filename, "/Storage/OCPP/TxProfile_Tmp_OCPP20.json.json");
  14034. filePtr = fopen((char*)filename, "w");
  14035. fprintf(filePtr, "{\"evseId\":0,\"chargingProfile\":%s}\n", json_object_to_json_string_ext(json_object_object_get(RemoteStartTransaction, "chargingProfile"), JSON_C_TO_STRING_PLAIN));
  14036. fclose(filePtr);
  14037. }
  14038. refreshStartTimer(&clientTime.RemoteStartWait);
  14039. ShmOCPP20Data->MsMsg.bits.isRemoteStartWaitReq = ON;
  14040. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  14041. {
  14042. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  14043. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId);
  14044. }
  14045. result = PASS;
  14046. }
  14047. else
  14048. {
  14049. DEBUG_INFO("There is not any connector is idle.\n");
  14050. for(uint8_t gun_index=0;gun_index<gunTotalNumber;gun_index++)
  14051. strcpy((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status, RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  14052. }
  14053. }
  14054. }
  14055. else
  14056. {
  14057. if(isOverConnectorMax != FALSE)
  14058. DEBUG_WARN("evseId id equal 0 or over maximun id.\n");
  14059. if(isPeriodOverMax)
  14060. DEBUG_WARN("Profile periods quantity is over spec.\n");
  14061. if(!isTxProfile)
  14062. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  14063. if(!isAllowStart)
  14064. DEBUG_WARN("Target connector does not allow start.\n");
  14065. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[((connectorIdx-1)<0?0:(connectorIdx-1))].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  14066. }
  14067. }
  14068. json_object_put(RemoteStartTransaction);
  14069. sendRemoteStartTransactionConfirmation(uuid, ((connectorIdx-1)<0?0:(connectorIdx-1)));
  14070. return result;
  14071. }
  14072. int handleRequestStopTransactionRequest(char *uuid, char *payload)
  14073. {
  14074. mtrace();
  14075. int result = FAIL;
  14076. int match = FALSE;
  14077. int GunNO = 0;
  14078. int tempIndex = 0;
  14079. char transactionIdStr[37];
  14080. int transactionIdIsNULL= TRUE;
  14081. json_object *RemoteStopTransaction;
  14082. DEBUG_INFO("handleRequestStopTransactionRequest...\n");
  14083. if(server_pending == TRUE)
  14084. {
  14085. return 0;
  14086. }
  14087. RemoteStopTransaction = json_tokener_parse(payload);
  14088. if(!is_error(RemoteStopTransaction))
  14089. {
  14090. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  14091. {
  14092. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  14093. transactionIdIsNULL = FALSE;
  14094. }
  14095. }
  14096. json_object_put(RemoteStopTransaction);
  14097. if(transactionIdIsNULL == FALSE)
  14098. {
  14099. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  14100. {
  14101. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  14102. {
  14103. //check Transaction active
  14104. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  14105. {
  14106. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14107. {
  14108. tempIndex = ((gun_index==2) ? 1: 0);
  14109. }
  14110. else
  14111. {
  14112. tempIndex = gun_index;
  14113. }
  14114. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  14115. {
  14116. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  14117. {
  14118. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  14119. {
  14120. match = TRUE;
  14121. GunNO = gun_index;
  14122. }
  14123. }
  14124. }// END FOR CHAdeMO_QUANTITY
  14125. }
  14126. else if(gunType[gun_index] == GUN_TYPE_CCS)
  14127. {
  14128. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14129. {
  14130. tempIndex = ((gun_index==2) ? 1: 0);
  14131. }
  14132. else
  14133. {
  14134. tempIndex = gun_index;
  14135. }
  14136. for (int index = 0; index < CCS_QUANTITY; index++)
  14137. {
  14138. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  14139. {
  14140. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  14141. {
  14142. match = TRUE;
  14143. GunNO = gun_index;
  14144. }
  14145. }
  14146. }// END FOR CCS_QUANTITY
  14147. }
  14148. else if(gunType[gun_index] == GUN_TYPE_GBT)
  14149. {
  14150. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14151. {
  14152. tempIndex = ((gun_index==2) ? 1: 0);
  14153. }
  14154. else
  14155. {
  14156. tempIndex = gun_index;
  14157. }
  14158. for (int index = 0; index < GB_QUANTITY; index++)
  14159. {
  14160. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  14161. {
  14162. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  14163. {
  14164. match = TRUE;
  14165. GunNO = gun_index;
  14166. }
  14167. }
  14168. }// END FOR GB_QUANTITY
  14169. }
  14170. else if(gunType[gun_index] == GUN_TYPE_DO)
  14171. {
  14172. tempIndex = gun_index;
  14173. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  14174. {
  14175. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  14176. {
  14177. 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
  14178. {
  14179. match = TRUE;
  14180. GunNO = gun_index;
  14181. }
  14182. }
  14183. }// END FOR GB_QUANTITY
  14184. }
  14185. else
  14186. {
  14187. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  14188. {
  14189. tempIndex = 2;
  14190. }
  14191. else
  14192. {
  14193. tempIndex = gun_index;
  14194. }
  14195. for (int index = 0; index < AC_QUANTITY; index++)
  14196. {
  14197. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  14198. {
  14199. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  14200. {
  14201. match = TRUE;
  14202. GunNO = gun_index;
  14203. }
  14204. }
  14205. }// END FOR CHAdeMO_QUANTITY
  14206. } // END FOR AC ELSE
  14207. }// CHECK IF ResponseTransactionId == transactionIdInt
  14208. }//END FOR
  14209. if( match == TRUE)
  14210. {
  14211. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  14212. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  14213. }
  14214. else
  14215. {
  14216. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  14217. }
  14218. }
  14219. else
  14220. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  14221. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  14222. return result;
  14223. }
  14224. int handleReserveNowRequest(char *uuid, char *payload)
  14225. {
  14226. mtrace();
  14227. int result = FAIL;
  14228. int connectorIdInt=0, reservationIdInt=0;
  14229. int tempIndex = 0;
  14230. json_object *ReserveNow;
  14231. DEBUG_INFO("handleReserveNowRequest ...\n");
  14232. ReserveNow = json_tokener_parse(payload);
  14233. if(!is_error(ReserveNow))
  14234. {
  14235. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  14236. {
  14237. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  14238. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  14239. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  14240. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  14241. }
  14242. // Required data
  14243. if(json_object_object_get(ReserveNow, "id") != NULL)
  14244. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "id"));
  14245. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  14246. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  14247. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  14248. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  14249. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  14250. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  14251. // Optional data
  14252. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  14253. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  14254. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  14255. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  14256. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  14257. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  14258. result = PASS;
  14259. }
  14260. json_object_put(ReserveNow);
  14261. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14262. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  14263. {
  14264. //check Transaction active
  14265. if(gunType[connectorIdInt -1] == GUN_TYPE_CHAdeMO)
  14266. {
  14267. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14268. {
  14269. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  14270. }
  14271. else
  14272. {
  14273. tempIndex = connectorIdInt -1;
  14274. }
  14275. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  14276. {
  14277. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  14278. {
  14279. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  14280. {
  14281. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  14282. {
  14283. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  14284. {
  14285. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == 1) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].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.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'))
  14296. {
  14297. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14298. }
  14299. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].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.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
  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 CHAdeMO_QUANTITY
  14321. }
  14322. else if(gunType[connectorIdInt -1] == GUN_TYPE_CCS)
  14323. {
  14324. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14325. {
  14326. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  14327. }
  14328. else
  14329. {
  14330. tempIndex = connectorIdInt -1;
  14331. }
  14332. for (int index = 0; index < CCS_QUANTITY; index++)
  14333. {
  14334. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  14335. {
  14336. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  14337. {
  14338. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  14339. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  14340. {
  14341. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  14342. {
  14343. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == 1) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].InProgress == 1))
  14344. {
  14345. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14346. }
  14347. else
  14348. {
  14349. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14350. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14351. }
  14352. }
  14353. 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'))
  14354. {
  14355. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14356. }
  14357. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  14358. {
  14359. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14360. }
  14361. else
  14362. {
  14363. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14364. }
  14365. }
  14366. 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
  14367. {
  14368. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14369. }
  14370. }
  14371. else
  14372. {
  14373. //replace reservation
  14374. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14375. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14376. }
  14377. }
  14378. } // END FOR CCS_QUANTITY
  14379. }
  14380. else if(gunType[connectorIdInt -1] == GUN_TYPE_GBT)
  14381. {
  14382. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  14383. {
  14384. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  14385. }
  14386. else
  14387. {
  14388. tempIndex = connectorIdInt -1;
  14389. }
  14390. for (int index = 0; index < GB_QUANTITY; index++)
  14391. {
  14392. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  14393. {
  14394. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  14395. {
  14396. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  14397. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  14398. {
  14399. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  14400. {
  14401. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == 1) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].InProgress == 1))
  14402. {
  14403. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14404. }
  14405. else
  14406. {
  14407. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14408. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14409. }
  14410. }
  14411. 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'))
  14412. {
  14413. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14414. }
  14415. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  14416. {
  14417. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14418. }
  14419. else
  14420. {
  14421. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14422. }
  14423. }
  14424. 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
  14425. {
  14426. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14427. }
  14428. }
  14429. else
  14430. {
  14431. //replace reservation
  14432. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14433. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14434. }
  14435. }
  14436. }// END FOR GB_QUANTITY
  14437. }
  14438. else if(gunType[connectorIdInt -1] == GUN_TYPE_DO)
  14439. {
  14440. tempIndex = connectorIdInt -1;
  14441. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  14442. {
  14443. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  14444. {
  14445. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ReservationId)
  14446. {
  14447. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  14448. 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
  14449. {
  14450. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  14451. {
  14452. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == 1) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.InProgress == 1))
  14453. {
  14454. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14455. }
  14456. else
  14457. {
  14458. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14459. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14460. }
  14461. }
  14462. 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'))
  14463. {
  14464. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14465. }
  14466. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  14467. {
  14468. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14469. }
  14470. else
  14471. {
  14472. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14473. }
  14474. }
  14475. 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
  14476. {
  14477. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14478. }
  14479. }
  14480. else
  14481. {
  14482. //replace reservation
  14483. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14484. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14485. }
  14486. }
  14487. }// END FOR DO_QUANTITY
  14488. }
  14489. else
  14490. {
  14491. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  14492. {
  14493. tempIndex = 2;
  14494. }
  14495. else
  14496. {
  14497. tempIndex = (connectorIdInt -1);
  14498. }
  14499. for (int index = 0; index < AC_QUANTITY; index++)
  14500. {
  14501. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  14502. {
  14503. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  14504. {
  14505. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  14506. {
  14507. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  14508. {
  14509. 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))
  14510. {
  14511. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14512. }
  14513. else
  14514. {
  14515. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14516. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14517. }
  14518. }
  14519. 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'))
  14520. {
  14521. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14522. }
  14523. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  14524. {
  14525. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14526. }
  14527. else
  14528. {
  14529. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14530. }
  14531. }
  14532. 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
  14533. {
  14534. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14535. }
  14536. }
  14537. else
  14538. {
  14539. //replace reservation
  14540. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  14541. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14542. }
  14543. }
  14544. } // END FOR AC_QUANTITY
  14545. }
  14546. }
  14547. else if(connectorIdInt == 0)
  14548. {
  14549. //check Transaction active
  14550. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  14551. {
  14552. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  14553. {
  14554. 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'))
  14555. {
  14556. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14557. goto end;
  14558. }
  14559. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  14560. {
  14561. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14562. goto end;
  14563. }
  14564. 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
  14565. {
  14566. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14567. goto end;
  14568. }
  14569. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  14570. {
  14571. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14572. goto end;
  14573. }
  14574. }
  14575. }// END FOR CHAdeMO_QUANTITY
  14576. for (int index = 0; index < CCS_QUANTITY; index++)
  14577. {
  14578. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  14579. {
  14580. 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'))
  14581. {
  14582. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14583. goto end;
  14584. }
  14585. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  14586. {
  14587. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14588. goto end;
  14589. }
  14590. 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
  14591. {
  14592. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14593. goto end;
  14594. }
  14595. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  14596. {
  14597. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14598. goto end;
  14599. }
  14600. }
  14601. } // END FOR CCS_QUANTITY
  14602. for (int index = 0; index < GB_QUANTITY; index++)
  14603. {
  14604. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  14605. {
  14606. 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'))
  14607. {
  14608. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14609. goto end;
  14610. }
  14611. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  14612. {
  14613. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14614. goto end;
  14615. }
  14616. 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
  14617. {
  14618. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14619. goto end;
  14620. }
  14621. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  14622. {
  14623. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14624. goto end;
  14625. }
  14626. }
  14627. } // END FOR GB_QUANTITY
  14628. for (int index = 0; index < AC_QUANTITY; index++)
  14629. {
  14630. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  14631. {
  14632. 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'))
  14633. {
  14634. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  14635. goto end;
  14636. }
  14637. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  14638. {
  14639. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14640. goto end;
  14641. }
  14642. 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
  14643. {
  14644. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  14645. goto end;
  14646. }
  14647. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  14648. {
  14649. 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))
  14650. {
  14651. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  14652. goto end;
  14653. }
  14654. }
  14655. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  14656. {
  14657. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14658. goto end;
  14659. }
  14660. }
  14661. }// END FOR AC_QUANTITY
  14662. //The connectorId is 0
  14663. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  14664. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  14665. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  14666. result = TRUE;
  14667. return result;
  14668. }
  14669. else
  14670. {
  14671. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  14672. }
  14673. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  14674. {
  14675. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  14676. result = TRUE;
  14677. return result;
  14678. }
  14679. end:
  14680. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  14681. return result;
  14682. }
  14683. int handleResetRequest(char *uuid, char *payload)
  14684. {
  14685. mtrace();
  14686. int result = FAIL;
  14687. json_object *Reset = json_object_new_object();
  14688. DEBUG_INFO("handleResetRequest...\n");
  14689. Reset = json_tokener_parse(payload);
  14690. ShmOCPP20Data->Reset.evseId = 0;
  14691. if(!is_error(Reset))
  14692. {
  14693. // Required data
  14694. if(json_object_object_get(Reset, "type") != NULL)
  14695. {
  14696. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  14697. }
  14698. if(json_object_object_get(Reset, "evseId") != NULL)
  14699. {
  14700. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  14701. }
  14702. }
  14703. json_object_put(Reset);
  14704. if((ShmOCPP20Data->Reset.evseId == 0) && ((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0)))
  14705. {
  14706. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  14707. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]);
  14708. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  14709. result = PASS;
  14710. }
  14711. else
  14712. {
  14713. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  14714. }
  14715. if(strlen((char*)ShmOCPP20Data->Reset.Response_status) > 0)
  14716. sendResetConfirmation(uuid);
  14717. return result;
  14718. }
  14719. int handleSendLocalListRequest(char *uuid, char *payload)
  14720. {
  14721. mtrace();
  14722. int result = FAIL;
  14723. int checkState_Faulted = FALSE;
  14724. json_object *SendLocalList;
  14725. DEBUG_INFO("handleSendLocalListRequest...\n");
  14726. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "false") == 0)
  14727. {
  14728. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  14729. goto end;
  14730. }
  14731. SendLocalList = json_tokener_parse(payload);
  14732. if(!is_error(SendLocalList))
  14733. {
  14734. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  14735. // Required data
  14736. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  14737. {
  14738. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  14739. }
  14740. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  14741. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  14742. // Optional data
  14743. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  14744. {
  14745. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  14746. {
  14747. // Required data
  14748. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  14749. {
  14750. 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")));
  14751. 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")));
  14752. }
  14753. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  14754. {
  14755. 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")));
  14756. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  14757. 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")));
  14758. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  14759. 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"));
  14760. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  14761. {
  14762. 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")));
  14763. 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")));
  14764. }
  14765. }
  14766. }
  14767. }
  14768. }
  14769. json_object_put(SendLocalList);
  14770. //check Charge Point state
  14771. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  14772. {
  14773. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  14774. {
  14775. checkState_Faulted = TRUE; //OCPP Status: Faulted
  14776. }
  14777. }
  14778. for (int index = 0; index < CCS_QUANTITY; index++)
  14779. {
  14780. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  14781. {
  14782. checkState_Faulted = TRUE; //OCPP Status
  14783. }
  14784. }
  14785. for (int index = 0; index < GB_QUANTITY; index++)
  14786. {
  14787. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  14788. {
  14789. checkState_Faulted = TRUE; //OCPP Status: Faulted
  14790. }
  14791. }
  14792. for (int index = 0; index < AC_QUANTITY; index++)
  14793. {
  14794. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  14795. {
  14796. checkState_Faulted = TRUE; //OCPP Status: Faulted
  14797. }
  14798. }
  14799. if(checkState_Faulted == TRUE)
  14800. {
  14801. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  14802. goto end;
  14803. }
  14804. // Check update type
  14805. if(strcmp((char*)ShmOCPP20Data->SendLocalList.updateType, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  14806. {
  14807. //Local list full update
  14808. DEBUG_INFO("Local list full update.\n");
  14809. DB_getListVerion();
  14810. /*if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  14811. {
  14812. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  14813. goto end;
  14814. }*/
  14815. DB_cleanLocalList();
  14816. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  14817. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  14818. }
  14819. else if(strcmp((char*)ShmOCPP20Data->SendLocalList.updateType, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  14820. {
  14821. //Local list different update
  14822. DEBUG_INFO("Local list different update.\n");
  14823. DB_getListVerion();
  14824. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  14825. {
  14826. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  14827. goto end;
  14828. }
  14829. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  14830. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  14831. }
  14832. else
  14833. {
  14834. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  14835. goto end;
  14836. }
  14837. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  14838. end:
  14839. sendSendLocalListConfirmation(uuid);
  14840. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  14841. return result;
  14842. }
  14843. int handleSetChargingProfileRequest(char *uuid, char *payload)
  14844. {
  14845. mtrace();
  14846. int result = FAIL;
  14847. struct SetChargingProfile_20 SetProfileReq = {0};
  14848. uint8_t isLostConnectorId = FALSE;
  14849. uint8_t isPeriodOverMax = FALSE;
  14850. uint8_t isStackOverMax = FALSE;
  14851. uint8_t isProfileOverMax = FALSE;
  14852. uint8_t isConnectorMismatch = FALSE;
  14853. uint8_t isTransactiodIdMismatch = FALSE;
  14854. uint8_t isInvalidLimit = FALSE;
  14855. uint8_t isWrongFormat = FALSE;
  14856. uint8_t replaceableProfileCnt = 0;
  14857. uint8_t existProfileQuantity = 0;
  14858. uint8_t filename[128]={0};
  14859. uint8_t dataLine[4096]={0};
  14860. FILE *filePtr;
  14861. json_object *SetChargingProfile;
  14862. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  14863. SetChargingProfile = json_tokener_parse(payload);
  14864. if(!is_error(SetChargingProfile))
  14865. {
  14866. // Required data
  14867. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  14868. SetProfileReq.evseId = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  14869. else
  14870. isLostConnectorId = TRUE;
  14871. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "id") != NULL)
  14872. SetProfileReq.chargingProfile.id = json_object_get_int((json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "id")));
  14873. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  14874. {
  14875. sprintf((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")));
  14876. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "stackLevel") != NULL)
  14877. {
  14878. SetProfileReq.chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "stackLevel"));
  14879. }
  14880. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose") != NULL)
  14881. {
  14882. strcpy((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")));
  14883. }
  14884. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfileKind") != NULL)
  14885. {
  14886. strcpy((char*)SetProfileReq.chargingProfile.chargingProfileKind, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfileKind")));
  14887. }
  14888. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "transactionId") != NULL)
  14889. {
  14890. strcpy((char*)SetProfileReq.chargingProfile.transactionId, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "transactionId")));
  14891. }
  14892. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "recurrencyKind") != NULL)
  14893. {
  14894. strcpy((char*)SetProfileReq.chargingProfile.recurrencyKind, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "recurrencyKind")));
  14895. }
  14896. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "validFrom") != NULL)
  14897. {
  14898. strcpy((char*)SetProfileReq.chargingProfile.validFrom, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "validFrom")));
  14899. }
  14900. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "validTo") != NULL)
  14901. {
  14902. strcpy((char*)SetProfileReq.chargingProfile.validTo, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "validTo")));
  14903. }
  14904. if(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule") != NULL)
  14905. {
  14906. int chargingScheduleCount = 0;
  14907. int chargingSchedulePeriodCount = 0;
  14908. if(json_object_is_type(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), 5))
  14909. {
  14910. chargingScheduleCount = json_object_array_length(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"));
  14911. for(int idxSchedule=0;idxSchedule<chargingScheduleCount;idxSchedule++)
  14912. {
  14913. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingRateUnit") != NULL)
  14914. {
  14915. 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")));
  14916. }
  14917. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "duration") != NULL)
  14918. {
  14919. 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"));
  14920. }
  14921. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "minChargingRate") != NULL)
  14922. {
  14923. 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"));
  14924. }
  14925. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "startSchedule") != NULL)
  14926. {
  14927. 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")));
  14928. }
  14929. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), idxSchedule), "chargingSchedulePeriod") != NULL)
  14930. {
  14931. 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"));
  14932. if(chargingSchedulePeriodCount <= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value))
  14933. {
  14934. for(int idxPeriod=0;idxPeriod<chargingSchedulePeriodCount;idxPeriod++)
  14935. {
  14936. 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)
  14937. {
  14938. 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"));
  14939. }
  14940. 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)
  14941. {
  14942. 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"));
  14943. }
  14944. 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)
  14945. {
  14946. 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"));
  14947. }
  14948. 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)
  14949. {
  14950. 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"));
  14951. }
  14952. // Check invalid limit
  14953. if((strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) == NULL) ||
  14954. ((strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL) && (ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharing != 1)))
  14955. {
  14956. if(ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'A')
  14957. {
  14958. 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)))) ||
  14959. (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit > (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit[0]=='W'?modelnameInfo.ratedPower:ShmSysConfigAndInfo->SysConfig.RatingCurrent)))
  14960. {
  14961. DEBUG_WARN("Profile chargingSchedule-%d period-%02d is invalid limit: %.2f %s with phase %d.\n", idxSchedule, idxPeriod,
  14962. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit,
  14963. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit,
  14964. (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases==0?3:SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  14965. DEBUG_WARN("Rated Power: %d, Rating Current: %d\n", modelnameInfo.ratedPower, ShmSysConfigAndInfo->SysConfig.RatingCurrent);
  14966. isInvalidLimit = TRUE;
  14967. }
  14968. }
  14969. else
  14970. {
  14971. 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) ||
  14972. (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)))
  14973. {
  14974. DEBUG_WARN("Profile period-%02d is invalid limit: %.2f %s with phase %d.\n", idxPeriod,
  14975. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit,
  14976. SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingRateUnit,
  14977. (SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases==0?3:SetProfileReq.chargingProfile.chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  14978. DEBUG_WARN("Rated Power: %d \n", modelnameInfo.ratedPower);
  14979. isInvalidLimit = TRUE;
  14980. }
  14981. }
  14982. }
  14983. }
  14984. }
  14985. else
  14986. {
  14987. isPeriodOverMax = TRUE;
  14988. }
  14989. }
  14990. }
  14991. }
  14992. else
  14993. {
  14994. isWrongFormat = TRUE;
  14995. }
  14996. }
  14997. // Check periods is over max configuration
  14998. if(strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  14999. {
  15000. if(SetProfileReq.evseId == 0)
  15001. {
  15002. sprintf((char*)filename, ChargingStationMaxProfile_JSON);
  15003. filePtr = fopen((char*)filename, "r");
  15004. if (!filePtr)
  15005. {
  15006. DEBUG_INFO("%s not exist, create it.\n", ChargingStationMaxProfile_JSON);
  15007. filePtr = fopen((char*)filename, "w+");
  15008. }
  15009. else
  15010. {
  15011. //Check Charging Profile Count
  15012. //while(fscanf(filePtr, "%s", dataLine) != EOF)
  15013. char *line = NULL;
  15014. size_t len = 0;
  15015. while(getline(&line, &len, filePtr) != -1)
  15016. {
  15017. json_object *obj = NULL;
  15018. obj = json_tokener_parse(line);
  15019. if(is_error(obj))
  15020. {
  15021. DEBUG_ERROR("Parse ChargingStationMaxProfile from file error.\n");
  15022. }
  15023. else
  15024. {
  15025. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != SetProfileReq.chargingProfile.id) &&
  15026. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) != SetProfileReq.chargingProfile.stackLevel))
  15027. {
  15028. existProfileQuantity += 1;
  15029. }
  15030. else
  15031. replaceableProfileCnt += 1;
  15032. }
  15033. //DEBUG_INFO("word=%s\n",word);
  15034. /*if(strstr((char*)dataLine, "id")!= NULL)
  15035. {
  15036. existProfileQuantity += 1;
  15037. }*/
  15038. }
  15039. DEBUG_INFO("existProfileQuantity: %d, Max stack limit: %d\n", existProfileQuantity, atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value));
  15040. if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value))
  15041. {
  15042. isStackOverMax = TRUE;
  15043. }
  15044. }
  15045. fclose(filePtr);
  15046. }
  15047. else
  15048. isConnectorMismatch = TRUE;
  15049. }
  15050. else if(strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  15051. {
  15052. if((0 < SetProfileReq.evseId) && (SetProfileReq.evseId > gunTotalNumber))
  15053. isConnectorMismatch = TRUE;
  15054. if(!isConnectorMismatch)
  15055. {
  15056. if(SetProfileReq.evseId == 0)
  15057. {
  15058. int tmpExistProfileQuantity;
  15059. for(int idxCon=1;idxCon<=gunTotalNumber;idxCon++)
  15060. {
  15061. tmpExistProfileQuantity = 0;
  15062. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
  15063. filePtr = fopen((char*)filename, "r");
  15064. if (!filePtr)
  15065. {
  15066. DEBUG_INFO("%s not exist, create it.\n", filename);
  15067. filePtr = fopen((char*)filename, "w+");
  15068. }
  15069. else
  15070. {
  15071. //Check Charging Profile Count
  15072. //while(fscanf(filePtr, "%s", dataLine) != EOF)
  15073. char *line = NULL;
  15074. size_t len = 0;
  15075. while(getline(&line, &len, filePtr) != -1)
  15076. {
  15077. json_object *obj = NULL;
  15078. obj = json_tokener_parse(line);
  15079. if(is_error(obj))
  15080. {
  15081. DEBUG_ERROR("Parse ChargingStationMaxProfile from file error.\n");
  15082. }
  15083. else
  15084. {
  15085. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != SetProfileReq.chargingProfile.id) &&
  15086. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) != SetProfileReq.chargingProfile.stackLevel))
  15087. {
  15088. tmpExistProfileQuantity += 1;
  15089. }
  15090. else
  15091. replaceableProfileCnt += 1;
  15092. }
  15093. //DEBUG_INFO("word=%s\n",word);
  15094. /*if(strstr((char*)dataLine, "id")!= NULL)
  15095. {
  15096. tmpExistProfileQuantity += 1;
  15097. }*/
  15098. }
  15099. }
  15100. fclose(filePtr);
  15101. DEBUG_INFO("existProfileQuantity: %d, Max stack limit: %d\n", tmpExistProfileQuantity, atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value));
  15102. if(tmpExistProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value))
  15103. {
  15104. isStackOverMax = TRUE;
  15105. }
  15106. //existProfileQuantity = (existProfileQuantity < tmpExistProfileQuantity) ? tmpExistProfileQuantity : existProfileQuantity;
  15107. }
  15108. }
  15109. else
  15110. {
  15111. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", SetProfileReq.evseId);
  15112. filePtr = fopen((char*)filename, "r");
  15113. if (!filePtr)
  15114. {
  15115. DEBUG_INFO("%s not exist, create it.\n", filename);
  15116. filePtr = fopen((char*)filename, "w+");
  15117. }
  15118. else
  15119. {
  15120. //Check Charging Profile Count
  15121. //while(fscanf(filePtr, "%s", dataLine) != EOF)
  15122. char *line = NULL;
  15123. size_t len = 0;
  15124. while(getline(&line, &len, filePtr) != -1)
  15125. {
  15126. json_object *obj = NULL;
  15127. obj = json_tokener_parse(line);
  15128. if(is_error(obj))
  15129. {
  15130. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  15131. }
  15132. else
  15133. {
  15134. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != SetProfileReq.chargingProfile.id) &&
  15135. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) != SetProfileReq.chargingProfile.stackLevel))
  15136. {
  15137. existProfileQuantity += 1;
  15138. }
  15139. else
  15140. replaceableProfileCnt += 1;
  15141. }
  15142. //DEBUG_INFO("word=%s\n",word);
  15143. /*if(strstr((char*)dataLine, "id")!= NULL)
  15144. {
  15145. existProfileQuantity += 1;
  15146. }*/
  15147. }
  15148. DEBUG_INFO("existProfileQuantity: %d, Max stack limit: %d\n", existProfileQuantity, atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value));
  15149. if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value))
  15150. {
  15151. isStackOverMax = TRUE;
  15152. }
  15153. }
  15154. fclose(filePtr);
  15155. }
  15156. }
  15157. }
  15158. else if(strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  15159. {
  15160. if((SetProfileReq.evseId > 0) && (SetProfileReq.evseId <= gunTotalNumber))
  15161. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", SetProfileReq.evseId);
  15162. else
  15163. isConnectorMismatch = TRUE;
  15164. if(!isConnectorMismatch)
  15165. {
  15166. filePtr = fopen((char*)filename, "r");
  15167. if (!filePtr)
  15168. {
  15169. DEBUG_INFO("%s not exist, create it.\n", filename);
  15170. filePtr = fopen((char*)filename, "w+");
  15171. }
  15172. else
  15173. {
  15174. //Check Charging Profile Count
  15175. //while(fscanf(filePtr, "%s", dataLine) != EOF)
  15176. char *line = NULL;
  15177. size_t len = 0;
  15178. while(getline(&line, &len, filePtr) != -1)
  15179. {
  15180. json_object *obj = NULL;
  15181. obj = json_tokener_parse(line);
  15182. if(is_error(obj))
  15183. {
  15184. DEBUG_ERROR("Parse TxProfile from file error.\n");
  15185. }
  15186. else
  15187. {
  15188. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "id")) != SetProfileReq.chargingProfile.id) &&
  15189. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "chargingProfile"), "stackLevel")) != SetProfileReq.chargingProfile.stackLevel))
  15190. {
  15191. existProfileQuantity += 1;
  15192. }
  15193. else
  15194. replaceableProfileCnt += 1;
  15195. }
  15196. //DEBUG_INFO("word=%s\n",word);
  15197. /*if(strstr((char*)dataLine, "id")!= NULL)
  15198. {
  15199. existProfileQuantity += 1;
  15200. }*/
  15201. }
  15202. DEBUG_INFO("existProfileQuantity: %d, Max stack limit: %d\n", existProfileQuantity, atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value));
  15203. if(existProfileQuantity >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value))
  15204. {
  15205. isStackOverMax = TRUE;
  15206. }
  15207. }
  15208. fclose(filePtr);
  15209. if(SetProfileReq.chargingProfile.transactionId != ShmOCPP20Data->TransactionEvent[SetProfileReq.evseId-1].transactionInfo.transactionId)
  15210. isTransactiodIdMismatch = TRUE;
  15211. }
  15212. }
  15213. else if(strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  15214. {
  15215. /*
  15216. * TODO:
  15217. *
  15218. */
  15219. }
  15220. else
  15221. {}
  15222. //------------------------------Start: Check ChargingProfileEntries Logic---------------------------------------//
  15223. {
  15224. FILE *fp;
  15225. char dataLine[4096]={0};
  15226. char fnametemp[128]={0};
  15227. int tmpProfileQuantity;
  15228. //Check ChargePointMaxProfile.json exit
  15229. existProfileQuantity = 0;
  15230. if((access(ChargingStationMaxProfile_JSON,F_OK))!=-1)
  15231. {
  15232. fp = fopen(ChargingStationMaxProfile_JSON, "r");
  15233. //Check Charging Profile Count
  15234. tmpProfileQuantity = 0;
  15235. while(fscanf(fp, "%s", dataLine) != EOF)
  15236. {
  15237. if(strstr(dataLine, "id")!= NULL)
  15238. {
  15239. existProfileQuantity += 1;
  15240. tmpProfileQuantity += 1;
  15241. }
  15242. memset(dataLine, 0, ARRAY_SIZE(dataLine));
  15243. }
  15244. fclose(fp);
  15245. DEBUG_INFO("ChargePointMaxProfile_OCPP20.json has %d charging Profile\n", tmpProfileQuantity);
  15246. }
  15247. //Check TxDefaultProfile_%d.json
  15248. for(int idxCon=1; idxCon <= gunTotalNumber; idxCon++)
  15249. {
  15250. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  15251. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
  15252. if((access(fnametemp,F_OK))!=-1)
  15253. {
  15254. fp = fopen(fnametemp, "r");
  15255. //Check Charging Profile Count
  15256. tmpProfileQuantity = 0;
  15257. while(fscanf(fp, "%s", dataLine) != EOF)
  15258. {
  15259. //DEBUG_INFO("word=%s\n",word);
  15260. if(strstr(dataLine, "id")!= NULL)
  15261. {
  15262. existProfileQuantity += 1;
  15263. tmpProfileQuantity += 1;
  15264. }
  15265. memset(dataLine, 0, ARRAY_SIZE(dataLine));
  15266. }
  15267. fclose(fp);
  15268. DEBUG_INFO("%s has %d charging Profile\n",fnametemp, tmpProfileQuantity);
  15269. }
  15270. }
  15271. //Check TxProfile_%d.json
  15272. for(int idxCon=1; idxCon <= gunTotalNumber; idxCon++)
  15273. {
  15274. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  15275. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d_OCPP20.json", idxCon);
  15276. if((access(fnametemp,F_OK))!=-1)
  15277. {
  15278. fp = fopen(fnametemp, "r");
  15279. //Check Charging Profile Count
  15280. tmpProfileQuantity = 0;
  15281. while(fscanf(fp, "%s", dataLine) != EOF)
  15282. {
  15283. if(strstr(dataLine, "id")!= NULL)
  15284. {
  15285. existProfileQuantity += 1;
  15286. tmpProfileQuantity += 1;
  15287. }
  15288. memset(dataLine, 0, ARRAY_SIZE(dataLine));
  15289. }
  15290. fclose(fp);
  15291. DEBUG_INFO("%s has %d charging Profile\n",fnametemp, tmpProfileQuantity);
  15292. }
  15293. }
  15294. DEBUG_INFO("All purpose profile quantity: %d\n", existProfileQuantity);
  15295. DEBUG_INFO("Replaceable profile quantity: %d\n", replaceableProfileCnt);
  15296. // To check total Profile quantity
  15297. if((SetProfileReq.evseId > 0) || (strstr((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL))
  15298. {
  15299. if((existProfileQuantity-replaceableProfileCnt) >= atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value))
  15300. isProfileOverMax = TRUE;
  15301. }
  15302. else
  15303. {
  15304. if((existProfileQuantity+gunTotalNumber-replaceableProfileCnt) > atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value))
  15305. isProfileOverMax = TRUE;
  15306. }
  15307. }
  15308. //------------------------------End: Check ChargingProfileEntries Logic---------------------------------------//
  15309. }
  15310. // Profile replace or add info
  15311. if(!isLostConnectorId && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTransactiodIdMismatch && !isInvalidLimit && !isWrongFormat && !isStackOverMax)
  15312. {
  15313. FILE *infile;
  15314. FILE *outfile;
  15315. char tmpProfileName[] = "/Storage/OCPP/SetChargingProfiletemp_OCPP20.json";
  15316. char rmFileCmd[128];
  15317. int tempchargingProfileIdInt;
  15318. int tempchargingProfileStackLevelInt;
  15319. int chkChar;
  15320. for(int idxCon=1; idxCon <= (SetProfileReq.evseId==0?gunTotalNumber:1); idxCon++)
  15321. {
  15322. if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) == 0)
  15323. {
  15324. sprintf((char*)filename, "%s", ChargingStationMaxProfile_JSON);
  15325. }
  15326. else if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0)
  15327. {
  15328. if(SetProfileReq.evseId==0)
  15329. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", idxCon);
  15330. else
  15331. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", SetProfileReq.evseId);
  15332. }
  15333. else if(strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) == 0)
  15334. {
  15335. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", SetProfileReq.evseId);
  15336. }
  15337. else
  15338. {
  15339. /*
  15340. * TODO:
  15341. *
  15342. */
  15343. }
  15344. infile = fopen ((char*)filename, "r");
  15345. outfile = fopen ((char*)tmpProfileName, "w");
  15346. chkChar = fgetc(infile);
  15347. rewind(infile);
  15348. if(chkChar == EOF)
  15349. {
  15350. // Profile is empty
  15351. if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
  15352. json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
  15353. fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  15354. fclose(infile);
  15355. fclose(outfile);
  15356. sprintf(rmFileCmd,"rm -f %s",filename);
  15357. system(rmFileCmd);
  15358. rename((char*)tmpProfileName, (char*)filename);
  15359. }
  15360. else
  15361. {
  15362. // Profile is not empty
  15363. int ChargingProfileAdded = FALSE;
  15364. while (fgets((char*)dataLine, ARRAY_SIZE(dataLine), infile) != NULL)
  15365. {
  15366. dataLine[strlen((char*)dataLine) - 1] = '\0'; // eat the newline fgets() stores
  15367. json_object *tmpChargingProfile;
  15368. tmpChargingProfile = json_tokener_parse((char*)dataLine);
  15369. if(!is_error(tmpChargingProfile))
  15370. {
  15371. if(json_object_object_get(tmpChargingProfile, "chargingProfile") != NULL)
  15372. {
  15373. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "id") != NULL)
  15374. {
  15375. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "id"));
  15376. DEBUG_INFO("tempchargingProfileIdInt: %d\n", tempchargingProfileIdInt);
  15377. DEBUG_INFO("SetProfileReq.chargingProfile.id: %d\n", SetProfileReq.chargingProfile.id);
  15378. }
  15379. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "stackLevel") != NULL)
  15380. {
  15381. tempchargingProfileStackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "chargingProfile"), "stackLevel"));
  15382. DEBUG_INFO("tempchargingProfileStackLevelInt: %d\n", tempchargingProfileStackLevelInt);
  15383. DEBUG_INFO("SetProfileReq.chargingProfile.stackLevel: %d\n", SetProfileReq.chargingProfile.stackLevel);
  15384. }
  15385. }
  15386. }
  15387. json_object_put(tmpChargingProfile);
  15388. if((tempchargingProfileIdInt == SetProfileReq.chargingProfile.id) || (tempchargingProfileStackLevelInt == SetProfileReq.chargingProfile.stackLevel))
  15389. {
  15390. if(ChargingProfileAdded == FALSE)
  15391. {
  15392. if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
  15393. json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
  15394. fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  15395. ChargingProfileAdded = TRUE;
  15396. }
  15397. }
  15398. else
  15399. {
  15400. fprintf(outfile,"%s\n",dataLine);
  15401. if(ChargingProfileAdded == FALSE)
  15402. {
  15403. if((strcmp((char*)SetProfileReq.chargingProfile.chargingProfilePurpose, ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) == 0) && (SetProfileReq.evseId==0))
  15404. json_object_object_add(SetChargingProfile, "evseId", json_object_new_int(idxCon));
  15405. fprintf(outfile,"%s\n",json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  15406. ChargingProfileAdded = TRUE;
  15407. }
  15408. }
  15409. } // end of while loop
  15410. fclose(infile);
  15411. fclose(outfile);
  15412. sprintf(rmFileCmd,"rm -f %s",filename);
  15413. system(rmFileCmd);
  15414. rename((char*)tmpProfileName, (char*)filename);
  15415. }
  15416. }
  15417. sleep(1);
  15418. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  15419. result = PASS;
  15420. }
  15421. else
  15422. {
  15423. if(isLostConnectorId)
  15424. DEBUG_WARN("Connector id is wrong.\n");
  15425. if(isConnectorMismatch)
  15426. DEBUG_WARN("Connector id is mismatch.\n");
  15427. if(isPeriodOverMax)
  15428. DEBUG_WARN("Profile periods quantity is over spec.\n");
  15429. if(isProfileOverMax)
  15430. DEBUG_WARN("Profile quantity is over spec.\n");
  15431. if(isTransactiodIdMismatch)
  15432. DEBUG_WARN("Transaction id is mismatch.\n");
  15433. if(isInvalidLimit)
  15434. DEBUG_WARN("Limit value is invalid.\n");
  15435. if(isStackOverMax)
  15436. DEBUG_WARN("Profile stack is over spec.\n");
  15437. if(isWrongFormat)
  15438. DEBUG_WARN("Profile format is wrong.\n");
  15439. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  15440. }
  15441. }
  15442. json_object_put(SetChargingProfile);
  15443. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  15444. {
  15445. if(SetProfileReq.evseId == 0)
  15446. {
  15447. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  15448. {
  15449. //ShmOCPP20Data->CSUMsg.bits[idx].ChargingProfileReq = ON;
  15450. checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
  15451. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx], 0, TRUE);
  15452. }
  15453. }
  15454. else
  15455. {
  15456. //ShmOCPP20Data->CSUMsg.bits[SetProfileReq.evseId-1].ChargingProfileReq = ON;
  15457. checkChargingStationMaxProfile(86400, &ShmOCPP20Data->MaxChargingProfile, 0, TRUE);
  15458. checkCompositeSchedule(SetProfileReq.evseId, 86400, &ShmOCPP20Data->SmartChargingProfile[SetProfileReq.evseId-1], 0, TRUE);
  15459. }
  15460. }
  15461. sendSetChargingProfileConfirmation(uuid, (SetProfileReq.evseId==0?SetProfileReq.evseId:SetProfileReq.evseId-1));
  15462. system("/bin/fsync -d /dev/mtdblock13;/bin/sync &");
  15463. return result;
  15464. }
  15465. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  15466. {
  15467. mtrace();
  15468. int result = FAIL;
  15469. json_object *SetDisplayMessage;
  15470. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  15471. SetDisplayMessage = json_tokener_parse(payload);
  15472. if(!is_error(SetDisplayMessage))
  15473. {
  15474. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  15475. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  15476. // Required data
  15477. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  15478. {
  15479. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  15480. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  15481. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  15482. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  15483. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  15484. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  15485. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  15486. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  15487. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  15488. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  15489. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  15490. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  15491. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  15492. {
  15493. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  15494. 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")));
  15495. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  15496. 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")));
  15497. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  15498. 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")));
  15499. }
  15500. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  15501. {
  15502. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  15503. 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")));
  15504. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  15505. 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")));
  15506. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  15507. {
  15508. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  15509. 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"));
  15510. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  15511. 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"));
  15512. }
  15513. }
  15514. }
  15515. }
  15516. json_object_put(SetDisplayMessage);
  15517. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  15518. sendSetDisplayMessagesConfirmation(uuid);
  15519. // Announce CSU there is display request come from server
  15520. ShmOCPP20Data->MsMsg.bits.SetDisplayMessageReq = ON;
  15521. return result;
  15522. }
  15523. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  15524. {
  15525. mtrace();
  15526. int result = FAIL;
  15527. json_object *SetMonitoringBase;
  15528. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  15529. SetMonitoringBase = json_tokener_parse(payload);
  15530. if(!is_error(SetMonitoringBase))
  15531. {
  15532. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  15533. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  15534. // Required data
  15535. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  15536. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  15537. }
  15538. json_object_put(SetMonitoringBase);
  15539. /*
  15540. * TODO:
  15541. * 1. Configure monitor base and response
  15542. */
  15543. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  15544. sendSetMonitoringBaseConfirmation(uuid);
  15545. return result;
  15546. }
  15547. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  15548. {
  15549. mtrace();
  15550. int result = FAIL;
  15551. json_object *SetMonitoringLevel;
  15552. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  15553. SetMonitoringLevel = json_tokener_parse(payload);
  15554. if(!is_error(SetMonitoringLevel))
  15555. {
  15556. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  15557. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  15558. // Required data
  15559. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  15560. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  15561. }
  15562. json_object_put(SetMonitoringLevel);
  15563. /*
  15564. * TODO:
  15565. * Configure monitor status and response
  15566. */
  15567. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  15568. sendSetMonitoringLevelConfirmation(uuid);
  15569. return result;
  15570. }
  15571. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  15572. {
  15573. mtrace();
  15574. int result = FAIL;
  15575. json_object *SetNetworkProfile;
  15576. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  15577. SetNetworkProfile = json_tokener_parse(payload);
  15578. if(!is_error(SetNetworkProfile))
  15579. {
  15580. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  15581. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  15582. // Required data
  15583. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  15584. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  15585. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  15586. {
  15587. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  15588. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  15589. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  15590. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  15591. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  15592. {
  15593. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  15594. memcpy((char*)ShmOCPP20Data->OcppServerURL, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl));
  15595. }
  15596. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  15597. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  15598. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  15599. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  15600. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  15601. {
  15602. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  15603. 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")));
  15604. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  15605. 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")));
  15606. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  15607. 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")));
  15608. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  15609. 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")));
  15610. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  15611. 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")));
  15612. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  15613. 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")));
  15614. }
  15615. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  15616. {
  15617. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  15618. {
  15619. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  15620. 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")));
  15621. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  15622. }
  15623. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  15624. {
  15625. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  15626. 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")));
  15627. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  15628. }
  15629. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  15630. {
  15631. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  15632. 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")));
  15633. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  15634. }
  15635. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  15636. 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"));
  15637. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  15638. 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")));
  15639. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  15640. 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"));
  15641. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  15642. 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")));
  15643. }
  15644. DB_addNetworkProfile(ShmOCPP20Data->SetNetworkProfile.configurationSlot, (char*)json_object_get_string(json_object_object_get(SetNetworkProfile, "connectionData")));
  15645. }
  15646. }
  15647. json_object_put(SetNetworkProfile);
  15648. /*
  15649. * TODO:
  15650. * 1. Process network configuration and response
  15651. */
  15652. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  15653. {
  15654. }
  15655. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  15656. {
  15657. }
  15658. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  15659. {
  15660. }
  15661. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  15662. {
  15663. }
  15664. else
  15665. {
  15666. }
  15667. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  15668. {
  15669. }
  15670. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  15671. {
  15672. }
  15673. else
  15674. {
  15675. }
  15676. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  15677. {
  15678. }
  15679. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  15680. {
  15681. }
  15682. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  15683. {
  15684. }
  15685. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  15686. {
  15687. }
  15688. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  15689. {
  15690. }
  15691. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  15692. {
  15693. }
  15694. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  15695. {
  15696. }
  15697. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  15698. {
  15699. }
  15700. else
  15701. {
  15702. }
  15703. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  15704. {
  15705. }
  15706. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  15707. {
  15708. }
  15709. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  15710. {
  15711. }
  15712. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  15713. {
  15714. }
  15715. else
  15716. {
  15717. }
  15718. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  15719. {
  15720. }
  15721. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  15722. {
  15723. }
  15724. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  15725. {
  15726. }
  15727. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  15728. {
  15729. }
  15730. else
  15731. {
  15732. }
  15733. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  15734. sendSetNetworkProfileConfirmation(uuid);
  15735. return result;
  15736. }
  15737. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  15738. {
  15739. mtrace();
  15740. int result = FAIL;
  15741. json_object *SetVariableMonitoring;
  15742. uint8_t variableQuantity = 0;
  15743. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  15744. SetVariableMonitoring = json_tokener_parse(payload);
  15745. if(!is_error(SetVariableMonitoring))
  15746. {
  15747. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  15748. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  15749. // Required data
  15750. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  15751. {
  15752. variableQuantity++;
  15753. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  15754. {
  15755. 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"));
  15756. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  15757. }
  15758. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  15759. {
  15760. 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"));
  15761. }
  15762. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  15763. {
  15764. 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")));
  15765. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  15766. }
  15767. else
  15768. {
  15769. sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type, "Actual");
  15770. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  15771. }
  15772. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  15773. {
  15774. 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"));
  15775. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  15776. }
  15777. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  15778. {
  15779. 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"));
  15780. }
  15781. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component") != NULL)
  15782. {
  15783. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "name") != NULL)
  15784. {
  15785. 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")));
  15786. }
  15787. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "instance") != NULL)
  15788. {
  15789. 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")));
  15790. }
  15791. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "component"), "evse") != NULL)
  15792. {
  15793. 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)
  15794. {
  15795. 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"));
  15796. }
  15797. 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)
  15798. {
  15799. 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"));
  15800. }
  15801. }
  15802. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  15803. }
  15804. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "variable") != NULL)
  15805. {
  15806. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "variable"), "name") != NULL)
  15807. {
  15808. 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")));
  15809. }
  15810. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "variable"), "instance") != NULL)
  15811. {
  15812. 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")));
  15813. }
  15814. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  15815. }
  15816. /*
  15817. * TODO
  15818. * Set Variables and save to DB
  15819. */
  15820. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, SetMonitoringStatusEnumTypeStr[SetMonitoringStatusEnumType_Accepted]);
  15821. }
  15822. }
  15823. json_object_put(SetVariableMonitoring);
  15824. sendSetVariableMonitoringConfirmation(uuid, variableQuantity);
  15825. return result;
  15826. }
  15827. int handleSetVariablesRequest(char *uuid, char *payload)
  15828. {
  15829. mtrace();
  15830. uint8_t result = FAIL;
  15831. uint8_t isUnknownComponent = TRUE;
  15832. uint8_t isNeedReconnect = FALSE;
  15833. json_object *SetVariables;
  15834. DEBUG_INFO("handleSetVariablesRequest...\n");
  15835. SetVariables = json_tokener_parse(payload);
  15836. if(!is_error(SetVariables))
  15837. {
  15838. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  15839. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  15840. // Required data
  15841. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  15842. {
  15843. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  15844. {
  15845. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  15846. {
  15847. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  15848. {
  15849. 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")));
  15850. }
  15851. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  15852. {
  15853. 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")));
  15854. }
  15855. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  15856. {
  15857. 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)
  15858. {
  15859. 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"));
  15860. }
  15861. 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)
  15862. {
  15863. 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"));
  15864. }
  15865. }
  15866. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  15867. }
  15868. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  15869. {
  15870. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  15871. {
  15872. 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")));
  15873. }
  15874. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  15875. {
  15876. 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")));
  15877. }
  15878. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  15879. }
  15880. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  15881. {
  15882. 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")));
  15883. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  15884. }
  15885. if(strlen((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType) == 0)
  15886. {
  15887. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, "Actual");
  15888. }
  15889. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  15890. {
  15891. 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")));
  15892. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  15893. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  15894. {
  15895. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL) &&
  15896. (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) &&
  15897. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name) != NULL) &&
  15898. (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))
  15899. {
  15900. isUnknownComponent = FALSE;
  15901. // To make sure all boolean value is in uppercase
  15902. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"true") != NULL) ||
  15903. (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"True") != NULL) ||
  15904. (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"TRUE") != NULL))
  15905. {
  15906. strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"true");
  15907. }
  15908. else if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"false") != NULL) ||
  15909. (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"False") != NULL) ||
  15910. (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"FALSE") != NULL))
  15911. {
  15912. strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,"false");
  15913. }
  15914. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType) == NULL) &&
  15915. (json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL))
  15916. {
  15917. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_NotSupportedAttributeType]);
  15918. break;
  15919. }
  15920. if(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].mutability, MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]) != NULL)
  15921. {
  15922. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
  15923. break;
  15924. }
  15925. if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "AuthCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "Enabled") != NULL))
  15926. {
  15927. char tmp[ARRAY_SIZE(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)];
  15928. for(int tmpidx=0;tmpidx<ARRAY_SIZE(tmp);tmpidx++)
  15929. tmp[idx] = tolower(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue[tmpidx]);
  15930. if((strstr((char*)tmp, "true") != NULL) || (strstr((char*)tmp, "false") != NULL))
  15931. {
  15932. strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,(strstr((char*)tmp, "true") != NULL)? "true" : "false");
  15933. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  15934. if(strstr((char*)tmp, "true") != NULL)
  15935. {
  15936. ShmSysConfigAndInfo->SysConfig.AuthorisationMode = AUTH_MODE_ENABLE;
  15937. }
  15938. else
  15939. {
  15940. ShmSysConfigAndInfo->SysConfig.AuthorisationMode = AUTH_MODE_DISABLE;
  15941. }
  15942. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  15943. }
  15944. else
  15945. {
  15946. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
  15947. break;
  15948. }
  15949. }
  15950. if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "NetworkConfigurationPriority") != NULL))
  15951. {
  15952. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]);
  15953. }
  15954. else
  15955. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  15956. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "WebSocketPingInterval") != NULL))
  15957. {
  15958. if((0 < atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)) && (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < 10) )
  15959. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  15960. else
  15961. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  15962. }
  15963. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "HeartbeatInterval") != NULL))
  15964. {
  15965. if((atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
  15966. {
  15967. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  15968. }
  15969. else
  15970. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  15971. }
  15972. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "StatusNotificationPeriodically") != NULL))
  15973. {
  15974. char tmp[ARRAY_SIZE(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)];
  15975. for(int tmpidx=0;tmpidx<ARRAY_SIZE(tmp);tmpidx++)
  15976. tmp[idx] = tolower(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue[tmpidx]);
  15977. if((strstr((char*)tmp, "true") != NULL) || (strstr((char*)tmp, "false") != NULL))
  15978. {
  15979. strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,(strstr((char*)tmp, "true") != NULL)? "true" : "false");
  15980. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  15981. }
  15982. else
  15983. {
  15984. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Rejected]);
  15985. break;
  15986. }
  15987. }
  15988. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "StatusNotificationInterval") != NULL))
  15989. {
  15990. if((atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
  15991. {
  15992. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  15993. }
  15994. else
  15995. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  15996. }
  15997. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "SecurityCtrlr") != NULL) &&
  15998. ((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "SecurityProfile") != NULL) || (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "BasicAuthPassword") != NULL)))
  15999. {
  16000. isNeedReconnect = TRUE;
  16001. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  16002. //SetOcppConnStatus(FALSE);
  16003. }
  16004. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "AlignedDataCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "Interval") != NULL))
  16005. {
  16006. if((0 < atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)) && (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
  16007. {
  16008. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  16009. }
  16010. else
  16011. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  16012. }
  16013. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "SampledDataCtrlr") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "TxUpdatedInterval") != NULL))
  16014. {
  16015. if((0 < atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)) && (atoi((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) < (int)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableCharacteristics.minLimit) )
  16016. {
  16017. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  16018. }
  16019. else
  16020. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  16021. }
  16022. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "ChargingStation") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "FreeVend") != NULL))
  16023. {
  16024. char tmp[ARRAY_SIZE(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue)];
  16025. for(int tmpidx=0;tmpidx<ARRAY_SIZE(tmp);tmpidx++)
  16026. tmp[idx] = tolower(ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue[tmpidx]);
  16027. if((strstr((char*)tmp, "true") != NULL) || (strstr((char*)tmp, "false") != NULL))
  16028. {
  16029. strcpy((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue,(strstr((char*)tmp, "true") != NULL)? "true" : "false");
  16030. ShmSysConfigAndInfo->SysConfig.AuthorisationMode =((strstr((char*)tmp, "true") != NULL)? 1 : 0);
  16031. StoreUsrConfigData(&ShmSysConfigAndInfo->SysConfig);
  16032. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  16033. }
  16034. }
  16035. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "ChargingStation") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "FreeVendIdtag") != NULL))
  16036. {
  16037. if(strlen((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) > 20)
  16038. {
  16039. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  16040. }
  16041. else
  16042. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  16043. }
  16044. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "ChargingStation") != NULL) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "OffLineMaxChargingPower") != NULL))
  16045. {
  16046. if(atoi((const char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue) > modelnameInfo.ratedPower)
  16047. {
  16048. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_OutOfRange]);
  16049. }
  16050. else
  16051. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  16052. }
  16053. if((strstr((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]) != NULL) ||
  16054. (strstr((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]) != NULL))
  16055. {
  16056. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  16057. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  16058. }
  16059. break;
  16060. }
  16061. else
  16062. {
  16063. if(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL)
  16064. {
  16065. isUnknownComponent = FALSE;
  16066. }
  16067. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownVariable]);
  16068. }
  16069. }
  16070. if(isUnknownComponent == TRUE)
  16071. {
  16072. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  16073. }
  16074. }
  16075. }
  16076. }
  16077. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  16078. if(isNeedReconnect)
  16079. {
  16080. SetOcppConnStatus(FALSE);
  16081. }
  16082. }
  16083. json_object_put(SetVariables);
  16084. return result;
  16085. }
  16086. int handleTriggerMessageRequest(char *uuid, char *payload)
  16087. {
  16088. mtrace();
  16089. int result = FAIL;
  16090. int connectorIdIsNULL = FALSE;
  16091. int connectorIdInt =0;
  16092. json_object *TriggerMessage;
  16093. DEBUG_INFO("handleTriggerMessageRequest\n");
  16094. TriggerMessage = json_tokener_parse(payload);
  16095. if(!is_error(TriggerMessage))
  16096. {
  16097. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  16098. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  16099. // Required data
  16100. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  16101. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  16102. // Optional data
  16103. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  16104. {
  16105. // Required data
  16106. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  16107. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  16108. // Optional data
  16109. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  16110. {
  16111. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  16112. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  16113. }
  16114. else
  16115. connectorIdIsNULL = TRUE;
  16116. }
  16117. else
  16118. connectorIdIsNULL = TRUE;
  16119. }
  16120. json_object_put(TriggerMessage);
  16121. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  16122. {
  16123. if((strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  16124. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  16125. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  16126. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  16127. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  16128. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  16129. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  16130. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  16131. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  16132. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  16133. (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  16134. {
  16135. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  16136. sendTriggerMessageConfirmation(uuid);
  16137. return TRUE;
  16138. }
  16139. else
  16140. {
  16141. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  16142. sendTriggerMessageConfirmation(uuid);
  16143. }
  16144. }
  16145. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  16146. {
  16147. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  16148. sendTriggerMessageConfirmation(uuid);
  16149. return TRUE;
  16150. }
  16151. //==========================
  16152. // Trigger message
  16153. //==========================
  16154. if( strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  16155. {
  16156. if((strlen((char*)ShmOCPP20Data->FirmwareStatusNotification.status) == 0) ||
  16157. ((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) && (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing)))
  16158. {
  16159. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  16160. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  16161. }
  16162. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16163. }
  16164. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  16165. {
  16166. if(strlen((char*)ShmOCPP20Data->LogStatusNotification.status) == 0)
  16167. sprintf((char*)ShmOCPP20Data->LogStatusNotification.status, "%s", UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Idle]);
  16168. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = ON;
  16169. }
  16170. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  16171. {
  16172. if(server_sign)
  16173. {
  16174. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  16175. sendTriggerMessageConfirmation(uuid);
  16176. return TRUE;
  16177. }
  16178. else
  16179. {
  16180. if(DB_updateBootType(BootReasonEnumType_Triggered))
  16181. server_sign = FALSE;
  16182. }
  16183. }
  16184. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  16185. {
  16186. refreshStartTimer(&clientTime.Heartbeat);
  16187. clientTime.Heartbeat.tv_sec -= ShmOCPP20Data->BootNotification.Response_interval;
  16188. }
  16189. else if (strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  16190. {
  16191. if(connectorIdIsNULL == FALSE)
  16192. {
  16193. if((connectorIdInt > 0) && ((connectorIdInt-1) < gunTotalNumber))
  16194. {
  16195. cpinitateMsg.bits[connectorIdInt-1].TriggerMeterValueReq = ON;
  16196. }
  16197. }
  16198. else
  16199. {
  16200. for(int idx=0;idx< gunTotalNumber;idx++)
  16201. {
  16202. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  16203. }
  16204. }
  16205. }
  16206. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  16207. {
  16208. if(connectorIdIsNULL == FALSE)
  16209. {
  16210. if((connectorIdInt > 0) && ((connectorIdInt-1) < gunTotalNumber))
  16211. {
  16212. cpinitateMsg.bits[connectorIdInt-1].TriggerStatusNotificationReq = ON;
  16213. //clientTime.StatusNotification[connectorIdInt-1] = time((time_t*)NULL);
  16214. }
  16215. }
  16216. else
  16217. {
  16218. for(int idx=0;idx< gunTotalNumber;idx++)
  16219. {
  16220. cpinitateMsg.bits[idx].TriggerStatusNotificationReq = ON;
  16221. //clientTime.StatusNotification[idx] = time((time_t*)NULL);
  16222. }
  16223. }
  16224. }
  16225. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) == 0 )
  16226. {
  16227. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  16228. if(access("/Storage/OCPP/certCP.csr",F_OK) == -1)
  16229. {
  16230. 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\" &");
  16231. }
  16232. }
  16233. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) == 0 )
  16234. {
  16235. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  16236. if(access("/Storage/OCPP/certV2G.csr",F_OK) == -1)
  16237. {
  16238. 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\" &");
  16239. }
  16240. }
  16241. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) == 0 )
  16242. {
  16243. if(connectorIdIsNULL == FALSE)
  16244. {
  16245. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  16246. {
  16247. //ShmOCPP20Data->CpMsg.bits[connectorIdInt -1].TransactionEventReq = ON;
  16248. cpinitateMsg.bits[connectorIdInt -1].TriggerTransactionEventReq = ON;
  16249. }
  16250. }
  16251. else
  16252. {
  16253. for(int idx=0;idx< gunTotalNumber;idx++)
  16254. {
  16255. //ShmOCPP20Data->CpMsg.bits[idx].TransactionEventReq = ON;
  16256. cpinitateMsg.bits[idx].TriggerTransactionEventReq = ON;
  16257. }
  16258. }
  16259. }
  16260. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) == 0 )
  16261. {
  16262. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = ON;
  16263. if(access("/Storage/OCPP/certCP.csr",F_OK) == -1)
  16264. {
  16265. 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\" &");
  16266. }
  16267. if(access("/Storage/OCPP/certV2G.csr",F_OK) == -1)
  16268. {
  16269. 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\" &");
  16270. }
  16271. }
  16272. else if(strcmp((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) == 0 )
  16273. {
  16274. ShmOCPP20Data->MsMsg.bits.PublishFirmwareReq = ON;
  16275. }
  16276. return result;
  16277. }
  16278. int handleUnlockConnectorRequest(char *uuid, char *payload)
  16279. {
  16280. mtrace();
  16281. int result = FAIL;
  16282. int connectorIdInt =0;
  16283. int tempIndex = 0;
  16284. json_object *UnlockConnector;
  16285. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  16286. UnlockConnector = json_tokener_parse(payload);
  16287. if(!is_error(UnlockConnector))
  16288. {
  16289. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  16290. {
  16291. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  16292. }
  16293. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  16294. {
  16295. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  16296. }
  16297. }
  16298. json_object_put(UnlockConnector);
  16299. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  16300. if(gunTotalNumber == 0)
  16301. {
  16302. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  16303. goto end;
  16304. }
  16305. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  16306. {
  16307. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  16308. goto end;
  16309. }
  16310. else
  16311. {
  16312. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  16313. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  16314. //check Transaction active
  16315. if(gunType[connectorIdInt-1] == GUN_TYPE_CHAdeMO)
  16316. {
  16317. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  16318. {
  16319. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  16320. }
  16321. else
  16322. {
  16323. tempIndex = connectorIdInt -1;
  16324. }
  16325. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  16326. {
  16327. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ))
  16328. {
  16329. //stop Transaction
  16330. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  16331. }
  16332. }
  16333. }
  16334. else if(gunType[connectorIdInt-1] == GUN_TYPE_CCS)
  16335. {
  16336. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  16337. {
  16338. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  16339. }
  16340. else
  16341. {
  16342. tempIndex = connectorIdInt -1;
  16343. }
  16344. for (int index = 0; index < CCS_QUANTITY; index++)
  16345. {
  16346. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ))
  16347. {
  16348. //stop Transaction
  16349. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  16350. }
  16351. }
  16352. }
  16353. else if(gunType[connectorIdInt-1] == GUN_TYPE_GBT)
  16354. {
  16355. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  16356. {
  16357. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  16358. }
  16359. else
  16360. {
  16361. tempIndex = connectorIdInt -1;
  16362. }
  16363. for (int index = 0; index < GB_QUANTITY; index++)
  16364. {
  16365. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ))
  16366. {
  16367. //stop Transaction
  16368. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  16369. }
  16370. }
  16371. }
  16372. else if(gunType[connectorIdInt-1] == GUN_TYPE_DO)
  16373. {
  16374. tempIndex = connectorIdInt -1;
  16375. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  16376. {
  16377. if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex ))
  16378. {
  16379. //stop Transaction
  16380. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  16381. }
  16382. }
  16383. }
  16384. else
  16385. {
  16386. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  16387. {
  16388. tempIndex = 2;
  16389. }
  16390. else
  16391. {
  16392. tempIndex = connectorIdInt-1;
  16393. }
  16394. for (int index = 0; index < AC_QUANTITY; index++)
  16395. {
  16396. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ))
  16397. {
  16398. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  16399. }
  16400. }
  16401. }
  16402. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  16403. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  16404. result = TRUE;
  16405. return result;
  16406. }
  16407. end:
  16408. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorConf = ON;
  16409. return result;
  16410. }
  16411. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  16412. {
  16413. mtrace();
  16414. int result = FAIL;
  16415. json_object *UnpublishFirmware;
  16416. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  16417. UnpublishFirmware = json_tokener_parse(payload);
  16418. if(!is_error(UnpublishFirmware))
  16419. {
  16420. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  16421. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  16422. // Required data
  16423. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  16424. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  16425. }
  16426. json_object_put(UnpublishFirmware);
  16427. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  16428. /*
  16429. * TODO:
  16430. * 1. Check unpublished status
  16431. */
  16432. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  16433. sendUnpublishFirmwareConfirmation(uuid);
  16434. return result;
  16435. }
  16436. static char UpdateFirmwarepayloadData[512]={0};
  16437. void *UpdateFirmwareProcess(void *data)
  16438. {
  16439. pthread_detach(pthread_self());
  16440. mtrace();
  16441. char protocol[10], user[64],password[64],host[128], path[512], ftppath[512],host1[128],path1[512];
  16442. int port=0;
  16443. int isSuccess = 0;
  16444. char ftpbuf[1024];
  16445. char temp[1024];
  16446. char * pch;
  16447. DEBUG_INFO("handleUpdateFirmwareRequest...\n");
  16448. json_object *UpdateFirmware;
  16449. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  16450. if(!is_error(UpdateFirmware))
  16451. {
  16452. // Required data
  16453. if(json_object_object_get(UpdateFirmware, "requestId"))
  16454. {
  16455. ShmOCPP20Data->UpdateFirmware.requestId = json_object_get_int(json_object_object_get(UpdateFirmware, "requestId"));
  16456. }
  16457. if(json_object_object_get(UpdateFirmware, "firmware"))
  16458. {
  16459. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "location") != NULL)
  16460. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "location")));
  16461. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "retrieveDate") != NULL)
  16462. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "retrieveDate")));
  16463. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "installDateTime") != NULL)
  16464. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "installDateTime")));
  16465. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signingCertificate") != NULL)
  16466. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signingCertificate")));
  16467. if(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signature") != NULL)
  16468. sprintf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location, "%s", json_object_get_string(json_object_object_get(json_object_object_get(UpdateFirmware, "firmware"), "signature")));
  16469. }
  16470. // Optional data
  16471. if(json_object_object_get(UpdateFirmware, "retries"))
  16472. {
  16473. ShmOCPP20Data->UpdateFirmware.retries = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  16474. }
  16475. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  16476. {
  16477. ShmOCPP20Data->UpdateFirmware.retryInterval = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  16478. }
  16479. }
  16480. json_object_put(UpdateFirmware);
  16481. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  16482. memset(path, 0, ARRAY_SIZE(path));
  16483. // Wait retrieveData
  16484. if(strlen((char*)ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime) > 10)
  16485. {
  16486. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16487. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled]);
  16488. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16489. do
  16490. {
  16491. sleep(1);
  16492. }while(!isOvertNow(ShmOCPP20Data->UpdateFirmware.firmware.retrieveDateTime));
  16493. }
  16494. system("rm -f /mnt/*");
  16495. if(strncmp((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"http", 4) == 0)
  16496. {
  16497. sscanf((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  16498. sprintf(ftppath,"/%s", path);
  16499. DEBUG_INFO("locationstr: %s\n", ShmOCPP20Data->UpdateFirmware.firmware.location);
  16500. DEBUG_INFO("protocol: %s\n",protocol);
  16501. DEBUG_INFO("host: %s\n",host);
  16502. DEBUG_INFO("path: %s\n",path);
  16503. DEBUG_INFO("ftppath: %s\n",ftppath);
  16504. int ftppathlen=strlen(ftppath);
  16505. int i=1;
  16506. char filenametemp[50];
  16507. while(i < ftppathlen)
  16508. {
  16509. int len=ftppathlen-i;
  16510. if(ftppath[len]== 47) // '/' ascll code: 47
  16511. {
  16512. DEBUG_INFO("compare '/' all right\n");
  16513. break;
  16514. }
  16515. i=i+1;
  16516. }
  16517. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  16518. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  16519. filenametemp[i+1] = 0;
  16520. do
  16521. {
  16522. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16523. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  16524. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16525. sleep(3);
  16526. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
  16527. if(!isSuccess)
  16528. {
  16529. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16530. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  16531. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16532. if(ShmOCPP20Data->UpdateFirmware.retries>0)sleep(ShmOCPP20Data->UpdateFirmware.retryInterval);else sleep(1);
  16533. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16534. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  16535. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16536. }
  16537. else
  16538. {
  16539. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16540. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  16541. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16542. }
  16543. ShmOCPP20Data->UpdateFirmware.retries--;
  16544. }while((isSuccess == 0)&&(ShmOCPP20Data->UpdateFirmware.retries >= 0));
  16545. }
  16546. else if(strncmp((char*)ShmOCPP20Data->UpdateFirmware.firmware.location,"ftp", 3) == 0)
  16547. {
  16548. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  16549. memset(temp, 0, ARRAY_SIZE(temp));
  16550. strcpy(ftpbuf, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
  16551. int ftppathlen=strlen(ftpbuf);
  16552. int i=1;
  16553. char filenametemp[50];
  16554. while(i < ftppathlen)
  16555. {
  16556. int len=ftppathlen-i;
  16557. if(ftpbuf[len]== 47) // '/' ascll code: 47
  16558. {
  16559. DEBUG_INFO(" compare '/' all right\n");
  16560. break;
  16561. }
  16562. i=i+1;
  16563. }
  16564. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  16565. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  16566. filenametemp[i+1] = 0;
  16567. strncpy(temp, ftpbuf, ftppathlen-i+1);
  16568. pch=strchr(temp,'@');
  16569. if(pch==NULL)
  16570. {
  16571. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  16572. protocol, host, &port, path);
  16573. strcpy(user,"anonymous");
  16574. strcpy(password,"");
  16575. }
  16576. else
  16577. {
  16578. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  16579. protocol, user, password, host, &port, path);
  16580. }
  16581. sscanf(host,"%[^/]%s",host1, path1);
  16582. sprintf(ftppath,"%s", path1);
  16583. if(port == 0)
  16584. {
  16585. port = 21;
  16586. }
  16587. do
  16588. {
  16589. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16590. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  16591. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16592. sleep(3);
  16593. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, (char*)ShmOCPP20Data->UpdateFirmware.firmware.location);
  16594. if(!isSuccess)
  16595. {
  16596. //BulldogUtil.sleepMs(interval*1000);
  16597. DEBUG_INFO("Update firmware request and download file fail.\n");
  16598. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16599. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  16600. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16601. if(ShmOCPP20Data->UpdateFirmware.retries>0)sleep(ShmOCPP20Data->UpdateFirmware.retryInterval);else sleep(1);
  16602. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16603. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  16604. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16605. }
  16606. else
  16607. {
  16608. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16609. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  16610. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16611. }
  16612. ShmOCPP20Data->UpdateFirmware.retries--;
  16613. }while((!isSuccess)&&(ShmOCPP20Data->UpdateFirmware.retries >= 0));
  16614. }
  16615. else
  16616. {
  16617. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16618. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  16619. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16620. sleep(1);
  16621. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  16622. sprintf((char*)ShmOCPP20Data->FirmwareStatusNotification.status, "%s",FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle]);
  16623. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
  16624. }
  16625. if(strstr((char*)ShmOCPP20Data->FirmwareStatusNotification.status, FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]) != NULL)ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  16626. interLock.isUpdateFirmwareGoing = OFF;
  16627. pthread_exit(NULL);
  16628. }
  16629. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  16630. {
  16631. mtrace();
  16632. int result = FAIL;
  16633. pthread_t t;
  16634. sendUpdateFirmwareConfirmation(uuid);
  16635. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  16636. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  16637. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  16638. if(!interLock.isUpdateFirmwareGoing)
  16639. {
  16640. interLock.isUpdateFirmwareGoing = ON;
  16641. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  16642. sleep(1);
  16643. }
  16644. else
  16645. DEBUG_WARN("Other UpdateFirmware request on going.\n");
  16646. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  16647. return result;
  16648. }
  16649. int handleUnknownRequest(char *uuid, char *payload)
  16650. {
  16651. mtrace();
  16652. int result = FAIL;
  16653. DEBUG_INFO("handleUnknownRequest...\n");
  16654. sendUnknownConfirmation(uuid);
  16655. result = PASS;
  16656. return result;
  16657. }
  16658. //==========================================
  16659. // Handle server response routine
  16660. //==========================================
  16661. void handleAuthorizeResponse(char *payload, int gun_index)
  16662. {
  16663. mtrace();
  16664. DEBUG_INFO("handleAuthorizeResponse...\n");
  16665. json_object *Authorize;
  16666. Authorize = json_tokener_parse(payload);
  16667. if(!is_error(Authorize))
  16668. {
  16669. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  16670. {
  16671. // Required data
  16672. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  16673. // Optional data
  16674. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  16675. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  16676. else
  16677. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  16678. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  16679. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  16680. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  16681. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  16682. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  16683. {
  16684. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  16685. {
  16686. 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));
  16687. }
  16688. }
  16689. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  16690. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  16691. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  16692. {
  16693. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  16694. 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")));
  16695. else
  16696. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  16697. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  16698. 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")));
  16699. }
  16700. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  16701. {
  16702. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  16703. 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")));
  16704. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  16705. 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")));
  16706. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  16707. 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")));
  16708. }
  16709. }
  16710. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  16711. {
  16712. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  16713. }
  16714. }
  16715. json_object_put(Authorize);
  16716. //Update idTag information to authorization cache if supported
  16717. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "true") == 0) &&
  16718. /*(strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  16719. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&*/
  16720. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  16721. {
  16722. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  16723. }
  16724. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  16725. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  16726. authorizeRetryTimes = 0;
  16727. }
  16728. void handleBootNotificationResponse(char *payload, int gun_index)
  16729. {
  16730. mtrace();
  16731. char statusStr[12]={0};
  16732. char currentTimeStr[30]={0};
  16733. int intervalInt = 0;
  16734. DEBUG_INFO("handleBootNotificationResponse...\n");
  16735. json_object *BootNotification;
  16736. BootNotification = json_tokener_parse(payload);
  16737. if(!is_error(BootNotification))
  16738. {
  16739. // Required data
  16740. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  16741. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  16742. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  16743. }
  16744. json_object_put(BootNotification);
  16745. DEBUG_INFO("statusStr: %s\n", statusStr);
  16746. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  16747. BootNotificationInterval = intervalInt;
  16748. //write back to ShmOCPP20Data->BootNotification
  16749. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  16750. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  16751. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  16752. {
  16753. if(intervalInt < (int)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.minLimit)
  16754. {
  16755. //Do nothing because the value is out of range.
  16756. }
  16757. else
  16758. {
  16759. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value,"%d", HeartBeatWaitTime);
  16760. HeartBeatWaitTime = intervalInt;
  16761. DEBUG_INFO("BootNotificationResponse setting interval to %d...\n",intervalInt);
  16762. }
  16763. server_sign = TRUE;
  16764. server_pending =FALSE;
  16765. DB_updateBootType(BootReasonEnumType_PowerUp);
  16766. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = ON;
  16767. }
  16768. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  16769. {
  16770. server_pending = TRUE;
  16771. }
  16772. syncDateTimeRTC(ShmOCPP20Data->BootNotification.Response_currentTime);
  16773. srand(time(NULL));
  16774. refreshStartTimer(&clientTime.Heartbeat);
  16775. clientTime.Heartbeat.tv_sec -= (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  16776. SetOcppConnStatus(TRUE);
  16777. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  16778. }
  16779. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  16780. {
  16781. mtrace();
  16782. json_object *ClearedChargingLimit;
  16783. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  16784. ClearedChargingLimit = json_tokener_parse(payload);
  16785. if(!is_error(ClearedChargingLimit))
  16786. {
  16787. // Required data
  16788. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  16789. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  16790. }
  16791. json_object_put(ClearedChargingLimit);
  16792. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  16793. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitConf = ON;
  16794. }
  16795. void handleDataTransferResponse(char *payload, int gun_index)
  16796. {
  16797. mtrace();
  16798. json_object *DataTrans;
  16799. DEBUG_INFO("handleDataTransferResponse...\n");
  16800. DataTrans = json_tokener_parse(payload);
  16801. if(!is_error(DataTrans))
  16802. {
  16803. // Required data
  16804. if(json_object_object_get(DataTrans,"status") != NULL)
  16805. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  16806. // Optional data
  16807. if(json_object_object_get(DataTrans,"data") != NULL)
  16808. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  16809. }
  16810. json_object_put(DataTrans);
  16811. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  16812. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  16813. }
  16814. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  16815. {
  16816. mtrace();
  16817. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  16818. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  16819. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  16820. }
  16821. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  16822. {
  16823. mtrace();
  16824. json_object *Get15118EVCertificate;
  16825. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  16826. Get15118EVCertificate = json_tokener_parse(payload);
  16827. if(!is_error(Get15118EVCertificate))
  16828. {
  16829. // Required data
  16830. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  16831. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  16832. // Optional data
  16833. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  16834. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  16835. }
  16836. json_object_put(Get15118EVCertificate);
  16837. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  16838. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  16839. }
  16840. void handleGetCertificateStatusResponse(char *payload, int gun_index)
  16841. {
  16842. mtrace();
  16843. json_object *GetCertificateStatus;
  16844. DEBUG_INFO("handleGetCertificateStatusResponse...\n");
  16845. GetCertificateStatus = json_tokener_parse(payload);
  16846. if(!is_error(GetCertificateStatus))
  16847. {
  16848. // Required data
  16849. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  16850. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  16851. // Optional data
  16852. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  16853. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  16854. if(json_object_object_get(GetCertificateStatus,"statusInfo") != NULL)
  16855. {
  16856. if(json_object_object_get(json_object_object_get(GetCertificateStatus,"statusInfo"), "reasonCode") != NULL)
  16857. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_statusInfo.reasonCode, json_object_get_string(json_object_object_get(json_object_object_get(GetCertificateStatus,"ocspResult"), "reasonCode")));
  16858. if(json_object_object_get(json_object_object_get(GetCertificateStatus,"statusInfo"), "additionalInfo") != NULL)
  16859. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_statusInfo.additionalInfo, json_object_get_string(json_object_object_get(json_object_object_get(GetCertificateStatus,"ocspResult"), "additionalInfo")));
  16860. }
  16861. }
  16862. json_object_put(GetCertificateStatus);
  16863. if(strstr((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, GetCertificateStatusEnumTypeStr[GetCertificateStatusEnumType_Accepted]) != NULL)
  16864. {
  16865. /*
  16866. * TODO:
  16867. * 1. If get certificate response accepted process something here
  16868. */
  16869. }
  16870. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  16871. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  16872. }
  16873. void handleHeartbeatResponse(char *payload, int gun_index)
  16874. {
  16875. mtrace();
  16876. DEBUG_INFO("handleHeartbeatResponse...\n");
  16877. json_object *Heartbeat;
  16878. Heartbeat = json_tokener_parse(payload);
  16879. if(!is_error(Heartbeat))
  16880. {
  16881. // Required data
  16882. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  16883. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  16884. }
  16885. json_object_put(Heartbeat);
  16886. if(FirstHeartBeat == OFF)
  16887. {
  16888. FirstHeartBeat = ON;
  16889. DEBUG_INFO("FirstHeartBeat \n");
  16890. }
  16891. HeartBeatWithNOResponse = 0;
  16892. refreshStartTimer(&clientTime.Heartbeat);
  16893. syncDateTimeRTC(ShmOCPP20Data->Heartbeat.Response_currentTime);
  16894. }
  16895. void handleLogStatusNotificationResponse(char *payload, int gun_index)
  16896. {
  16897. mtrace();
  16898. DEBUG_INFO("handleLogStatusNotificationResponse...\n");
  16899. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  16900. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  16901. }
  16902. void handleMeterValuesResponse(char *payload, int gun_index)
  16903. {
  16904. mtrace();
  16905. DEBUG_INFO("handleMeterValuesResponse...\n");
  16906. isQueueSendable = ON;
  16907. }
  16908. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  16909. {
  16910. mtrace();
  16911. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  16912. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  16913. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  16914. }
  16915. void handleNotifyCustomerInformationResponse(char *payload, int gun_index)
  16916. {
  16917. mtrace();
  16918. DEBUG_INFO("handleNotifyCustomerInformationResponse...\n");
  16919. }
  16920. void handleNotifyDisplayMessagesResponse(char *payload, int gun_index)
  16921. {
  16922. mtrace();
  16923. DEBUG_INFO("handleNotifyDisplayMessagesResponse...\n");
  16924. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  16925. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  16926. }
  16927. void handleNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  16928. {
  16929. mtrace();
  16930. json_object *NotifyEVChargingNeeds;
  16931. DEBUG_INFO("handleNotifyEVChargingNeedsResponse...\n");
  16932. NotifyEVChargingNeeds = json_tokener_parse(payload);
  16933. if(!is_error(NotifyEVChargingNeeds))
  16934. {
  16935. // Required data
  16936. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  16937. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  16938. }
  16939. json_object_put(NotifyEVChargingNeeds);
  16940. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  16941. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  16942. }
  16943. void handleNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  16944. {
  16945. mtrace();
  16946. json_object *NotifyEVChargingSchedule;
  16947. DEBUG_INFO("handleNotifyEVChargingScheduleResponse...\n");
  16948. NotifyEVChargingSchedule = json_tokener_parse(payload);
  16949. if(!is_error(NotifyEVChargingSchedule))
  16950. {
  16951. // Required data
  16952. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  16953. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  16954. }
  16955. json_object_put(NotifyEVChargingSchedule);
  16956. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  16957. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  16958. }
  16959. void handleNotifyEventResponse(char *payload, int gun_index)
  16960. {
  16961. mtrace();
  16962. DEBUG_INFO("handleNotifyEventResponse...\n");
  16963. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  16964. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  16965. }
  16966. void handleNotifyMonitoringReportResponse(char *payload, int gun_index)
  16967. {
  16968. mtrace();
  16969. DEBUG_INFO("handleNotifyMonitoringReportResponse...\n");
  16970. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  16971. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  16972. }
  16973. void handleNotifyReportResponse(char *payload, int gun_index)
  16974. {
  16975. mtrace();
  16976. DEBUG_INFO("handleNotifyReportResponse...\n");
  16977. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  16978. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  16979. }
  16980. void handlePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  16981. {
  16982. mtrace();
  16983. DEBUG_INFO("handlePublishFirmwareStatusNotificationResponse...\n");
  16984. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  16985. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  16986. }
  16987. void handleReportChargingProfilesResponse(char *payload, int gun_index)
  16988. {
  16989. mtrace();
  16990. DEBUG_INFO("handleReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  16991. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  16992. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  16993. }
  16994. void handleReservationStatusUpdateResponse(char *payload, int gun_index)
  16995. {
  16996. mtrace();
  16997. DEBUG_INFO("handleReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  16998. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  16999. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  17000. }
  17001. void handleSecurityEventNotificationResponse(char *payload, int gun_index)
  17002. {
  17003. mtrace();
  17004. DEBUG_INFO("handleSecurityEventNotificationResponse...\n");
  17005. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  17006. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  17007. DB_updateSecurityEventType(SecurityEventEnumType_ResetOrReboot);
  17008. }
  17009. void handleSignCertificateResponse(char *payload, int gun_index)
  17010. {
  17011. mtrace();
  17012. json_object *SignCertificate;
  17013. DEBUG_INFO("handleSignCertificateResponse...\n");
  17014. SignCertificate = json_tokener_parse(payload);
  17015. if(!is_error(SignCertificate))
  17016. {
  17017. // Required data
  17018. if(json_object_object_get(SignCertificate,"status") != NULL)
  17019. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  17020. // Optional data
  17021. if(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "reasonCode") != NULL)
  17022. {
  17023. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_statusInfo.reasonCode, json_object_get_string(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "reasonCode")));
  17024. if(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "additionalInfo") != NULL)
  17025. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_statusInfo.additionalInfo, json_object_get_string(json_object_object_get(json_object_object_get(SignCertificate,"statusInfo"), "additionalInfo")));
  17026. }
  17027. }
  17028. json_object_put(SignCertificate);
  17029. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  17030. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  17031. }
  17032. void handleStatusNotificationResponse(char *payload, int gun_index)
  17033. {
  17034. mtrace();
  17035. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  17036. //cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  17037. //cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  17038. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  17039. }
  17040. void handleTransactionEventResponse(char *payload, int gun_index)
  17041. {
  17042. mtrace();
  17043. json_object *TransactionEven;
  17044. DEBUG_INFO("handleTransactionEventResponse...\n");
  17045. TransactionEven = json_tokener_parse(payload);
  17046. if(!is_error(TransactionEven))
  17047. {
  17048. // Required data
  17049. // Optional data
  17050. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  17051. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  17052. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  17053. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  17054. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  17055. {
  17056. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  17057. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  17058. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  17059. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  17060. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  17061. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  17062. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  17063. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  17064. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  17065. {
  17066. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  17067. 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")));
  17068. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  17069. 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")));
  17070. }
  17071. }
  17072. if(json_object_object_get(TransactionEven,"updatedPersonalMessage") != NULL)
  17073. {
  17074. if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "format") != NULL)
  17075. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.format, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "format")));
  17076. if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "language") != NULL)
  17077. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.language, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "language")));
  17078. if(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "content") != NULL)
  17079. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_updatedPersonalMessage.content, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"updatedPersonalMessage"), "content")));
  17080. }
  17081. }
  17082. json_object_put(TransactionEven);
  17083. isQueueSendable = ON;
  17084. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  17085. }
  17086. //==========================================
  17087. // Handle Error routine
  17088. //==========================================
  17089. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  17090. {
  17091. mtrace();
  17092. #ifdef SystemLogMessage
  17093. DEBUG_INFO("errorCode: %s\n", errorCode);
  17094. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  17095. DEBUG_INFO("errorDetails: %s\n", payload);
  17096. #endif
  17097. }
  17098. //===============================================
  17099. // Common routine
  17100. //===============================================
  17101. int initialConfigurationTable(void)
  17102. {
  17103. DEBUG_INFO("initialConfigurationTable...\n");
  17104. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  17105. DB_variableIsCreate();
  17106. DB_variableLoadFromDb();
  17107. if(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_VariableVersion].variableAttribute[0].value) != variableVersion)
  17108. {
  17109. DEBUG_WARN("EVSE variable version in local db older than firmware.\n");
  17110. DB_variableClear();
  17111. DB_variableIsCreate();
  17112. DB_variableLoadFromDb();
  17113. }
  17114. DB_getNetworkProfileFromDb();
  17115. return 0;
  17116. }
  17117. int TransactionMessageAttemptsGet(void)
  17118. {
  17119. return TransactionMessageAttemptsValue;
  17120. }
  17121. int FirstHeartBeatResponse(void)
  17122. {
  17123. return FirstHeartBeat;
  17124. }
  17125. int TransactionMessageRetryIntervalGet(void)
  17126. {
  17127. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  17128. }
  17129. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  17130. {
  17131. int result = TRUE;
  17132. char rmFileCmd[100]={0};
  17133. char FilePath[100]={0};
  17134. char ftpbuf[200];
  17135. int systemresult;
  17136. sprintf(FilePath,"/mnt/%s",filename);
  17137. system("ping 8.8.8.8 &");
  17138. if((access(FilePath,F_OK))!=-1)
  17139. {
  17140. DEBUG_INFO("filename=%s exist.\n",FilePath);
  17141. sprintf(rmFileCmd,"rm -f %s",FilePath);
  17142. system(rmFileCmd);
  17143. }
  17144. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  17145. sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-check-certificate",filename, url);
  17146. DEBUG_INFO("Download command: %s\n",ftpbuf);
  17147. systemresult = system(ftpbuf);
  17148. if(systemresult != 0)
  17149. {
  17150. DEBUG_INFO("HTTP/HTTPS download fail!\n");
  17151. result = FALSE;
  17152. }
  17153. system("pkill ping");
  17154. return result;
  17155. }
  17156. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  17157. {
  17158. int result = TRUE;
  17159. char rmFileCmd[100]={0};
  17160. char FilePath[100]={0};
  17161. char ftpbuf[200];
  17162. int systemresult;
  17163. sprintf(FilePath,"/mnt/%s",filename);
  17164. system("ping 8.8.8.8 &");
  17165. if((access(FilePath,F_OK))!=-1)
  17166. {
  17167. DEBUG_INFO("filename=%s exist.\n",FilePath);
  17168. sprintf(rmFileCmd,"rm -f %s",FilePath);
  17169. system(rmFileCmd);
  17170. }
  17171. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  17172. sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120",filename, url);
  17173. DEBUG_INFO("Download command: %s\n",ftpbuf);
  17174. systemresult = system(ftpbuf);
  17175. if(systemresult != 0)
  17176. {
  17177. sprintf(ftpbuf, "wget --tries=1 -O /mnt/%s -c %s -T 120 --no-passive-ftp",filename, url);
  17178. DEBUG_INFO("Download command: %s\n",ftpbuf);
  17179. systemresult = system(ftpbuf);
  17180. if(systemresult != 0)
  17181. {
  17182. DEBUG_WARN("FTP download fail!\n");
  17183. result = FALSE;
  17184. }
  17185. }
  17186. system("pkill ping");
  17187. return result;
  17188. }
  17189. int httpUploadFile(char *location, char *path, char *filename,char *url)
  17190. {
  17191. char rmFileCmd[100]={0};
  17192. char FilePath[100]={0};
  17193. char buf[512];
  17194. int systemresult = 0;
  17195. //DEBUG_INFO("filename=%s\n",filename);
  17196. //DEBUG_INFO("url=%s\n",url);
  17197. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  17198. if((access(FilePath,F_OK))!=-1)
  17199. {
  17200. DEBUG_INFO("filename=%s exist.\n",FilePath);
  17201. sprintf(rmFileCmd,"rm -f %s",FilePath);
  17202. system(rmFileCmd);
  17203. }
  17204. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  17205. if(fp == NULL)
  17206. {
  17207. DEBUG_INFO("log is NULL\n");
  17208. return FALSE;
  17209. }
  17210. else
  17211. {
  17212. fprintf(fp, "%s\n", url);
  17213. fprintf(fp, "%s\n", filename);
  17214. fclose(fp);
  17215. }
  17216. FILE *phpFP = popen("/bin/php-cgi /var/www/ocpp_upload.php", "r");
  17217. if(phpFP == NULL)
  17218. {
  17219. DEBUG_INFO("PHP upload fail.\n");
  17220. return FALSE;
  17221. }
  17222. else
  17223. {
  17224. while(fgets(buf, sizeof(buf), phpFP) != NULL)
  17225. {
  17226. if(strstr(buf, "result") != NULL)
  17227. {
  17228. sscanf(buf, "result: %d", &systemresult);
  17229. DEBUG_INFO("PHP HTTP upload result: %d\n", systemresult);
  17230. }
  17231. }
  17232. pclose(phpFP);
  17233. }
  17234. if(systemresult != 1)
  17235. {
  17236. DEBUG_WARN("HTTP POST upload error, change to PUT method\n");
  17237. FILE *phpFP = popen("/bin/php-cgi /var/www/ocpp_upload_put.php", "r");
  17238. if(phpFP == NULL)
  17239. {
  17240. DEBUG_WARN("PHP PUT upload fail.\n");
  17241. return FALSE;
  17242. }
  17243. else
  17244. {
  17245. while(fgets(buf, sizeof(buf), phpFP) != NULL)
  17246. {
  17247. if(strstr(buf, "result") != NULL)
  17248. {
  17249. sscanf(buf, "result: %d", &systemresult);
  17250. DEBUG_INFO("PHP HTTP PUT upload result: %d\n", systemresult);
  17251. }
  17252. }
  17253. pclose(phpFP);
  17254. }
  17255. }
  17256. if(systemresult != 1)
  17257. {
  17258. DEBUG_WARN("PHP PUT upload fail.\n");
  17259. return FALSE;
  17260. }
  17261. return TRUE;
  17262. }
  17263. int ftpUploadFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  17264. {
  17265. int result = FALSE;
  17266. char ftpbuf[200];
  17267. int systemresult;
  17268. /*
  17269. // Domaind name transfer to IP address
  17270. struct hostent* server;
  17271. char *IPbuffer;
  17272. server = gethostbyname(location);
  17273. IPbuffer = inet_ntoa(*((struct in_addr*)server->h_addr_list[0]));*/
  17274. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  17275. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s", user, password, location, port/*21*/, path, filename, fnamePlusPath);
  17276. DEBUG_INFO("ftp command: %s\n",ftpbuf);
  17277. systemresult = system(ftpbuf);
  17278. if(systemresult != 0)
  17279. {
  17280. DEBUG_INFO("ftpput error!\n");
  17281. }
  17282. else
  17283. {
  17284. result = TRUE;
  17285. DEBUG_INFO("ftpput OK!\n");
  17286. }
  17287. return result;
  17288. }
  17289. //=========================================
  17290. // Routine
  17291. //=========================================
  17292. int GetOcppServerURL()
  17293. {
  17294. int result = FALSE;
  17295. struct yuarel url;
  17296. char urlStr[512];
  17297. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  17298. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  17299. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  17300. if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  17301. {
  17302. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  17303. if(yuarel_parse(&url, urlStr) != -1)
  17304. {
  17305. sprintf(OcppProtocol, "%s", url.scheme);
  17306. sprintf(OcppHost, "%s", url.host);
  17307. if(url.path == NULL)
  17308. OcppTempPath[0] = '\0';
  17309. else
  17310. sprintf(OcppTempPath, "%s", url.path);
  17311. if(url.port == 0)
  17312. {
  17313. if(strcmp(OcppProtocol, "wss") == 0)
  17314. OcppPort = 443;
  17315. else
  17316. OcppPort = 80;
  17317. }
  17318. else
  17319. OcppPort = url.port;
  17320. result = TRUE;
  17321. }
  17322. }
  17323. else
  17324. {
  17325. strcpy(OcppHost,"");
  17326. }
  17327. return result;
  17328. }
  17329. int GetOcppPath()
  17330. {
  17331. int result = FALSE;
  17332. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  17333. {
  17334. if(OcppTempPath == NULL)
  17335. {
  17336. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  17337. }
  17338. else
  17339. {
  17340. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  17341. }
  17342. result = TRUE;
  17343. }
  17344. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  17345. {
  17346. if(OcppTempPath == NULL)
  17347. {
  17348. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  17349. }
  17350. else
  17351. {
  17352. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  17353. }
  17354. result = TRUE;
  17355. }
  17356. else
  17357. {
  17358. strcpy(OcppPath,"");
  17359. }
  17360. return result;
  17361. }
  17362. int GetOcppPort()
  17363. {
  17364. return OcppPort;
  17365. }
  17366. int GetOcppConnStatus(void)
  17367. {
  17368. return ShmOCPP20Data->OcppConnStatus;
  17369. }
  17370. void SetOcppConnStatus(uint8_t status)
  17371. {
  17372. ShmOCPP20Data->OcppConnStatus = status;
  17373. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  17374. }
  17375. int GetHeartBeatWithNOResponse(void)
  17376. {
  17377. return HeartBeatWithNOResponse;
  17378. }
  17379. void SetHeartBeatWithNOResponse(void)
  17380. {
  17381. HeartBeatWithNOResponse = 0;
  17382. }
  17383. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  17384. void storeTempStopTransaction(int gun_index)
  17385. {
  17386. char TempStopTransaction[256];
  17387. char message[1024*20]={0};
  17388. char guid[37]={0};
  17389. json_object *TransactionEvent = json_object_new_object();
  17390. json_object *transactionInfo = json_object_new_object();
  17391. json_object *idToken = json_object_new_object();
  17392. json_object *evse = json_object_new_object();
  17393. json_object *meterValues = json_object_new_array();
  17394. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
  17395. DEBUG_INFO("storeTempStopTransaction...\n");
  17396. getNowDatetime(ShmOCPP20Data->TransactionEvent[gun_index].timestamp);
  17397. ShmOCPP20Data->TransactionEvent[gun_index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  17398. ShmOCPP20Data->TransactionEvent[gun_index].evse.id = (gun_index + 1);
  17399. ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId = (gun_index + 1);
  17400. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  17401. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  17402. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  17403. // Message
  17404. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  17405. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  17406. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  17407. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo+1));
  17408. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  17409. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  17410. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  17411. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  17412. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  17413. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  17414. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  17415. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  17416. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  17417. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  17418. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  17419. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  17420. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  17421. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  17422. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  17423. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  17424. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  17425. {
  17426. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  17427. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  17428. json_object_object_add(TransactionEvent, "idToken", idToken);
  17429. }
  17430. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  17431. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  17432. json_object_object_add(TransactionEvent, "evse", evse);
  17433. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  17434. {
  17435. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  17436. {
  17437. json_object *meterValue = json_object_new_object();
  17438. json_object *sampledValues = json_object_new_array();
  17439. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  17440. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  17441. {
  17442. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  17443. ((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)))
  17444. {
  17445. if(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, (char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) != NULL)
  17446. {
  17447. json_object *sampledValue = json_object_new_object();
  17448. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  17449. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  17450. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  17451. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  17452. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  17453. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  17454. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  17455. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  17456. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  17457. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  17458. {
  17459. json_object *unitOfMeasure = json_object_new_object();
  17460. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  17461. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  17462. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  17463. }
  17464. json_object_array_add(sampledValues, sampledValue);
  17465. }
  17466. }
  17467. }
  17468. json_object_object_add(meterValue, "sampledValue", sampledValues);
  17469. json_object_array_add(meterValues, meterValue);
  17470. }
  17471. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  17472. }
  17473. random_uuid(guid);
  17474. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL
  17475. , guid
  17476. , "TransactionEvent"
  17477. , json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  17478. json_object_put(TransactionEvent);
  17479. // open file for writing
  17480. FILE *outfile;
  17481. outfile = fopen (TempStopTransaction, "w+");
  17482. //DEBUG_INFO("data = %s\n", queuedata);
  17483. fputs(message, outfile);
  17484. fputs("\n", outfile);
  17485. fclose (outfile);
  17486. }
  17487. void checkTempStopTransaction(int gun_index)
  17488. {
  17489. FILE *fptr1;
  17490. char ch;
  17491. char str[QUEUE_MESSAGE_LENGTH]={0};
  17492. char guid[37]={0};
  17493. char tempdata[65]={0};
  17494. char TempStopTransaction[256];
  17495. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction20_%d", (gun_index+1));
  17496. fptr1 = fopen(TempStopTransaction, "r");
  17497. if (!fptr1)
  17498. {
  17499. //DEBUG_INFO("TempStopTransaction20_%d not found or unable to open the input file!\n", (gun_index+1));
  17500. return ;
  17501. }
  17502. ch=fgetc(fptr1);
  17503. rewind(fptr1);
  17504. if(ch!=EOF)
  17505. {
  17506. // copy all contents to the temporary file except the specific line
  17507. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  17508. {
  17509. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  17510. if(str[0]=='\0')
  17511. {
  17512. break;
  17513. }
  17514. strncpy(guid, str+4, 36); //copy guid
  17515. sprintf(tempdata, "TransactionEvent,%d", (gun_index));
  17516. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  17517. {
  17518. //DEBUG_INFO("StopTransaction mapitem pass\n");
  17519. }
  17520. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  17521. memset(str,0,ARRAY_SIZE(str));
  17522. }
  17523. }
  17524. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  17525. fclose(fptr1);
  17526. remove(TempStopTransaction); // remove the original file
  17527. }
  17528. int GetWebSocketPingInterval(void)
  17529. {
  17530. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  17531. }
  17532. int GetServerSign(void)
  17533. {
  17534. return server_sign;
  17535. }
  17536. uint8_t GetOcppSecurityProfile()
  17537. {
  17538. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  17539. }
  17540. void GetOcppChargerBoxId(uint8_t *data)
  17541. {
  17542. sprintf((char*)data, "%s", ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  17543. }
  17544. void GetOcppSecurityPassword(uint8_t *data)
  17545. {
  17546. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  17547. }
  17548. void SetServerSign(int value)
  17549. {
  17550. server_sign = value;
  17551. }
  17552. int GetBootNotificationInterval(void)
  17553. {
  17554. return BootNotificationInterval;
  17555. }
  17556. int GetInternetConn(void)
  17557. {
  17558. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  17559. }
  17560. int GetBackendConnectionTimeout(void)
  17561. {
  17562. return ShmSysConfigAndInfo->SysConfig.BackendConnTimeout>=0?ShmSysConfigAndInfo->SysConfig.BackendConnTimeout:300;
  17563. }
  17564. int isConnectorInitMode(int gun_index)
  17565. {
  17566. int tempIndex = 0;
  17567. int result = TRUE;
  17568. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  17569. if(gunType[gun_index] == GUN_TYPE_CHAdeMO)
  17570. {
  17571. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  17572. {
  17573. tempIndex = ((gun_index==2) ? 1: 0);
  17574. }
  17575. else
  17576. {
  17577. tempIndex = gun_index;
  17578. }
  17579. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  17580. {
  17581. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  17582. {
  17583. result = (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  17584. } //end of the same index
  17585. }//end of for CHAdeMO_QUANTITY
  17586. }
  17587. else if(gunType[gun_index] == GUN_TYPE_CCS)
  17588. {
  17589. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  17590. {
  17591. tempIndex = ((gun_index==2) ? 1: 0);
  17592. }
  17593. else
  17594. {
  17595. tempIndex = gun_index;
  17596. }
  17597. for (int index = 0; index < CCS_QUANTITY; index++)
  17598. {
  17599. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  17600. {
  17601. result = (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  17602. } //end of the same index
  17603. } // end of for CCS_QUANTITY
  17604. }
  17605. else if(gunType[gun_index] == GUN_TYPE_GBT)
  17606. {
  17607. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  17608. {
  17609. tempIndex = ((gun_index==2) ? 1: 0);
  17610. }
  17611. else
  17612. {
  17613. tempIndex = gun_index;
  17614. }
  17615. for (int index = 0; index < GB_QUANTITY; index++)
  17616. {
  17617. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  17618. {
  17619. result = (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  17620. } //end of the same index
  17621. } // end of for GB_QUANTITY
  17622. }
  17623. else if(gunType[gun_index] == GUN_TYPE_DO)
  17624. {
  17625. tempIndex = gun_index;
  17626. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  17627. {
  17628. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  17629. {
  17630. result = (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  17631. } //end of the same index
  17632. }
  17633. }
  17634. else
  17635. {
  17636. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  17637. {
  17638. tempIndex = 2;
  17639. }
  17640. else
  17641. {
  17642. tempIndex = gun_index;
  17643. }
  17644. for (int index = 0; index < AC_QUANTITY; index++)
  17645. {
  17646. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  17647. {
  17648. result = (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus==SYS_MODE_BOOTING)?TRUE:FALSE;
  17649. }//end of the same index
  17650. }//end of for AC_QUANTITY
  17651. }
  17652. return result;
  17653. }
  17654. void refreshProcDogTimer()
  17655. {
  17656. ShmOCPP20Data->procDogTime = time((time_t*)NULL);
  17657. }
  17658. void InitialSystemValue(void)
  17659. {
  17660. localversion=0;
  17661. BootNotificationInterval = 10;
  17662. authorizeRetryTimes = 0;
  17663. GunStatusInterval = 10;
  17664. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  17665. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  17666. //Hear Beat
  17667. HeartBeatWithNOResponse = 0;
  17668. HeartBeatCountPerHour = 0;
  17669. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  17670. FirstHeartBeat = 0;
  17671. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  17672. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  17673. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  17674. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  17675. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  17676. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  17677. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  17678. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  17679. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  17680. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  17681. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  17682. //Status && ConnectorPlugIn Setting
  17683. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  17684. {
  17685. ChademoPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  17686. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  17687. }
  17688. for (int index = 0; index < CCS_QUANTITY; index++)
  17689. {
  17690. CcsPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  17691. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  17692. }
  17693. for (int index = 0; index < GB_QUANTITY; index++)
  17694. {
  17695. GbPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  17696. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  17697. }
  17698. for (int index = 0; index < AC_QUANTITY; index++)
  17699. {
  17700. AcPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  17701. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  17702. }
  17703. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  17704. {
  17705. DoPreviousSystemStatus[index] = 99; //ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  17706. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  17707. }
  17708. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  17709. {
  17710. cpinitateMsg.bits[gun_index].TriggerStatusNotificationReq = OFF;
  17711. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  17712. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  17713. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  17714. refreshStartTimer(&clientTime.StatusNotification[gun_index]);
  17715. //memset(&ShmOCPP20Data->StatusNotification[gun_index], 0x00, sizeof(struct StatusNotification_20));
  17716. memset(&ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, 0x00, sizeof(ShmOCPP20Data->StatusNotification[gun_index].connectorStatus));
  17717. }
  17718. refreshStartTimer(&clientTime.Heartbeat);
  17719. sleep(1);
  17720. }
  17721. void LWS_Send(char *str)
  17722. {
  17723. //=====================================================
  17724. // Check InternetConn 0: disconnected, 1: connected
  17725. //====================================================
  17726. if(GetOcppConnStatus() == 0)
  17727. {
  17728. DEBUG_INFO("offline now !!!\n");
  17729. return;
  17730. }
  17731. // Only disable isWebsocketSendable operation initiated by charger
  17732. if((strstr((char*)str, "\"Authorize\"") != NULL)
  17733. || (strstr((char*)str, "\"BootNotification\"") != NULL)
  17734. || (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
  17735. || (strstr((char*)str, "\"DataTransfer\"") != NULL)
  17736. || (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
  17737. || (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
  17738. || (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
  17739. || (strstr((char*)str, "\"Heartbeat\"") != NULL)
  17740. || (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
  17741. || (strstr((char*)str, "\"MeterValues\"") != NULL)
  17742. || (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
  17743. || (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
  17744. || (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
  17745. || (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
  17746. || (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
  17747. || (strstr((char*)str, "\"NotifyEvent\"") != NULL)
  17748. || (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
  17749. || (strstr((char*)str, "\"NotifyReport\"") != NULL)
  17750. || (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
  17751. || (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
  17752. || (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
  17753. || (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
  17754. || (strstr((char*)str, "\"SignCertificate\"") != NULL)
  17755. || (strstr((char*)str, "\"StatusNotification\"") != NULL)
  17756. || (strstr((char*)str, "\"TransactionEvent\"") != NULL))
  17757. {
  17758. isWebsocketSendable = OFF;
  17759. }
  17760. pthread_mutex_lock(&lock_send);
  17761. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  17762. sprintf((char *)SendBuffer, "%s", str);
  17763. SendBufLen = strlen(str);
  17764. pthread_mutex_unlock(&lock_send);
  17765. lws_callback_on_writable(wsi_client);
  17766. //lws_service(context, 0);
  17767. //sleep(1);
  17768. }
  17769. void LWS_SendNow(char *str)
  17770. {
  17771. //=====================================================
  17772. // Check InternetConn 0: disconnected, 1: connected
  17773. //====================================================
  17774. if(GetOcppConnStatus() == 0)
  17775. {
  17776. DEBUG_INFO("offline now !!!\n");
  17777. return;
  17778. }
  17779. // Only disable isWebsocketSendable operation initiated by charger
  17780. if((strstr((char*)str, "\"Authorize\"") != NULL)
  17781. || (strstr((char*)str, "\"BootNotification\"") != NULL)
  17782. || (strstr((char*)str, "\"ClearedChargingLimit\"") != NULL)
  17783. || (strstr((char*)str, "\"DataTransfer\"") != NULL)
  17784. || (strstr((char*)str, "\"FirmwareStatusNotification\"") != NULL)
  17785. || (strstr((char*)str, "\"Get15118EVCertificate\"") != NULL)
  17786. || (strstr((char*)str, "\"GetCertificateStatus\"") != NULL)
  17787. || (strstr((char*)str, "\"Heartbeat\"") != NULL)
  17788. || (strstr((char*)str, "\"LogStatusNotification\"") != NULL)
  17789. || (strstr((char*)str, "\"MeterValues\"") != NULL)
  17790. || (strstr((char*)str, "\"NotifyChargingLimit\"") != NULL)
  17791. || (strstr((char*)str, "\"NotifyCustomerInformation\"") != NULL)
  17792. || (strstr((char*)str, "\"NotifyDisplayMessages\"") != NULL)
  17793. || (strstr((char*)str, "\"NotifyEVChargingNeeds\"") != NULL)
  17794. || (strstr((char*)str, "\"NotifyEVChargingSchedule\"") != NULL)
  17795. || (strstr((char*)str, "\"NotifyEvent\"") != NULL)
  17796. || (strstr((char*)str, "\"NotifyMonitoringReport\"") != NULL)
  17797. || (strstr((char*)str, "\"NotifyReport\"") != NULL)
  17798. || (strstr((char*)str, "\"PublishFirmwareStatusNotification\"") != NULL)
  17799. || (strstr((char*)str, "\"ReportChargingProfiles\"") != NULL)
  17800. || (strstr((char*)str, "\"ReservationStatusUpdate\"") != NULL)
  17801. || (strstr((char*)str, "\"SecurityEventNotification\"") != NULL)
  17802. || (strstr((char*)str, "\"SignCertificate\"") != NULL)
  17803. || (strstr((char*)str, "\"StatusNotification\"") != NULL)
  17804. || (strstr((char*)str, "\"TransactionEvent\"") != NULL))
  17805. {
  17806. isWebsocketSendable = OFF;
  17807. }
  17808. pthread_mutex_lock(&lock_send);
  17809. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  17810. sprintf((char *)SendBuffer, "%s", str);
  17811. SendBufLen = strlen(str);
  17812. pthread_mutex_unlock(&lock_send);
  17813. lws_callback_on_writable(wsi_client);
  17814. lws_service(context, 0);
  17815. //sleep(1);
  17816. }