MessageHandler.c 793 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917
  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. static char *AuthorizeCertificateStatusEnumTypeStr[] = {
  28. MACROSTR(Accepted),
  29. MACROSTR(SignatureError),
  30. MACROSTR(CertificateExpired),
  31. MACROSTR(CertificateRevoked),
  32. MACROSTR(NoCertificateAvailable),
  33. MACROSTR(CertChainError),
  34. MACROSTR(ContractCancelled)
  35. };
  36. static char *BootReasonEnumTypeStr[] = {
  37. MACROSTR(ApplicationReset),
  38. MACROSTR(FirmwareUpdate),
  39. MACROSTR(LocalReset),
  40. MACROSTR(PowerUp),
  41. MACROSTR(RemoteReset),
  42. MACROSTR(ScheduledReset),
  43. MACROSTR(Triggered),
  44. MACROSTR(Unknown),
  45. MACROSTR(Watchdog)
  46. };
  47. static char *CancelReservationStatusEnumTypeStr[] = {
  48. MACROSTR(Accepted),
  49. MACROSTR(Rejected)
  50. };
  51. static char *CertificateActionEnumTypeStr[] = {
  52. MACROSTR(Install),
  53. MACROSTR(Update)
  54. };
  55. static char *CertificateSignedStatusEnumTypeStr[] = {
  56. MACROSTR(Accepted),
  57. MACROSTR(Rejected)
  58. };
  59. static char *CertificateSigningUseEnumTypeStr[] = {
  60. MACROSTR(ChargingStationCertificate),
  61. MACROSTR(V2GCertificate)
  62. };
  63. static char *ChangeAvailabilityStatusEnumTypeStr[] = {
  64. MACROSTR(Accepted),
  65. MACROSTR(Rejected),
  66. MACROSTR(Scheduled)
  67. };
  68. static char *ChargingLimitSourceEnumTypeStr[] = {
  69. MACROSTR(EMS),
  70. MACROSTR(Other),
  71. MACROSTR(SO),
  72. MACROSTR(CSO)
  73. };
  74. static char *ChargingProfileKindEnumTypeStr[] = {
  75. MACROSTR(Absolute),
  76. MACROSTR(Recurring),
  77. MACROSTR(Relative)
  78. };
  79. static char *ChargingProfilePurposeEnumTypeStr[] = {
  80. MACROSTR(ChargingStationExternalConstraints),
  81. MACROSTR(ChargingStationMaxProfile),
  82. MACROSTR(TxDefaultProfile),
  83. MACROSTR(TxProfile)
  84. };
  85. static char *ChargingProfileStatusEnumTypeStr[] = {
  86. MACROSTR(Accepted),
  87. MACROSTR(Rejected)
  88. };
  89. static char *ChargingRateUnitEnumTypeStr[] = {
  90. MACROSTR(W),
  91. MACROSTR(A)
  92. };
  93. static char *ChargingStateEnumTypeStr[] = {
  94. MACROSTR(Charging),
  95. MACROSTR(EVConnected),
  96. MACROSTR(SuspendedEV),
  97. MACROSTR(SuspendedEVSE),
  98. MACROSTR(Idle)
  99. };
  100. static char *ClearCacheStatusEnumTypeStr[] = {
  101. MACROSTR(Accepted),
  102. MACROSTR(Rejected)
  103. };
  104. static char *ClearChargingProfileStatusEnumTypeStr[] = {
  105. MACROSTR(Accepted),
  106. MACROSTR(Unknown)
  107. };
  108. static char *ClearMessageStatusEnumTypeStr[] = {
  109. MACROSTR(Accepted),
  110. MACROSTR(Unknown)
  111. };
  112. static char *ClearMonitoringStatusEnumTypeStr[] = {
  113. MACROSTR(Accepted),
  114. MACROSTR(Rejected),
  115. MACROSTR(NotFound)
  116. };
  117. static char *ComponentCriterionEnumTypeStr[] = {
  118. MACROSTR(Active),
  119. MACROSTR(Available),
  120. MACROSTR(Enabled),
  121. MACROSTR(Problem)
  122. };
  123. static char *ConnectorEnumTypeStr[] = {
  124. MACROSTR(cCCS1),
  125. MACROSTR(cCCS2),
  126. MACROSTR(cG105),
  127. MACROSTR(cTesla),
  128. MACROSTR(cType1),
  129. MACROSTR(cType2),
  130. MACROSTR(s309-1P-16A),
  131. MACROSTR(s309-1P-32A),
  132. MACROSTR(s309-3P-16A),
  133. MACROSTR(s309-3P-32A),
  134. MACROSTR(sBS1361),
  135. MACROSTR(sCEE-7-7),
  136. MACROSTR(sType2),
  137. MACROSTR(sType3),
  138. MACROSTR(Other1PhMax16A),
  139. MACROSTR(Other1PhOver16A),
  140. MACROSTR(Other3Ph),
  141. MACROSTR(Pan),
  142. MACROSTR(wInductive),
  143. MACROSTR(wResonant),
  144. MACROSTR(Undetermined),
  145. MACROSTR(Unknown)
  146. };
  147. static char *ConnectorStatusEnumTypeStr[] = {
  148. MACROSTR(Available),
  149. MACROSTR(Occupied),
  150. MACROSTR(Reserved),
  151. MACROSTR(Unavailable),
  152. MACROSTR(Faulted)
  153. };
  154. static char *CostKindEnumTypeStr[] = {
  155. MACROSTR(CarbonDioxideEmission),
  156. MACROSTR(RelativePricePercentage),
  157. MACROSTR(RenewableGenerationPercentage)
  158. };
  159. static char *CustomerInformationStatusEnumTypeStr[] = {
  160. MACROSTR(Accepted),
  161. MACROSTR(Rejected),
  162. MACROSTR(Invalid)
  163. };
  164. static char *DataEnumTypeStr[] = {
  165. MACROSTR(string),
  166. MACROSTR(decimal),
  167. MACROSTR(integer),
  168. MACROSTR(dateTime),
  169. MACROSTR(boolean),
  170. MACROSTR(OptionList),
  171. MACROSTR(SequenceList),
  172. MACROSTR(MemberList)
  173. };
  174. static char *DataTransferStatusEnumTypeStr[] = {
  175. MACROSTR(Accepted),
  176. MACROSTR(Rejected),
  177. MACROSTR(UnknownMessageId),
  178. MACROSTR(UnknownVendorId)
  179. };
  180. static char *DeleteCertificateStatusEnumTypeStr[] = {
  181. MACROSTR(Accepted),
  182. MACROSTR(Failed),
  183. MACROSTR(NotFound)
  184. };
  185. static char *DisplayMessageStatusEnumTypeStr[] = {
  186. MACROSTR(Accepted),
  187. MACROSTR(NotSupportedMessageFormat),
  188. MACROSTR(Rejected),
  189. MACROSTR(NotSupportedPriority),
  190. MACROSTR(NotSupportedState),
  191. MACROSTR(UnknownTransaction)
  192. };
  193. static char *EnergyTransferModeEnumTypeStr[] = {
  194. MACROSTR(DC),
  195. MACROSTR(AC_single_phase),
  196. MACROSTR(AC_two_phase),
  197. MACROSTR(AC_three_phase)
  198. };
  199. static char *EventNotificationEnumTypeStr[] = {
  200. MACROSTR(HardWiredNotification),
  201. MACROSTR(HardWiredMonitor),
  202. MACROSTR(PreconfiguredMonitor),
  203. MACROSTR(CustomMonitor)
  204. };
  205. static char *EventTriggerEnumTypeStr[] = {
  206. MACROSTR(Alerting),
  207. MACROSTR(Delta),
  208. MACROSTR(Periodic)
  209. };
  210. static char *FirmwareStatusEnumTypeStr[] = {
  211. MACROSTR(Downloaded),
  212. MACROSTR(DownloadFailed),
  213. MACROSTR(Downloading),
  214. MACROSTR(DownloadScheduled),
  215. MACROSTR(DownloadPaused),
  216. MACROSTR(Idle),
  217. MACROSTR(InstallationFailed),
  218. MACROSTR(Installing),
  219. MACROSTR(Installed),
  220. MACROSTR(InstallRebooting),
  221. MACROSTR(InstallScheduled),
  222. MACROSTR(InstallVerificationFailed),
  223. MACROSTR(InvalidSignature),
  224. MACROSTR(SignatureVerified)
  225. };
  226. static char *GenericDeviceModelStatusEnumTypeStr[] = {
  227. MACROSTR(Accepted),
  228. MACROSTR(Rejected),
  229. MACROSTR(NotSupported),
  230. MACROSTR(EmptyResultSet)
  231. };
  232. static char *GenericStatusEnumTypeStr[] = {
  233. MACROSTR(Accepted),
  234. MACROSTR(Rejected)
  235. };
  236. static char *GetCertificateIdUseEnumTypeStr[] = {
  237. MACROSTR(V2GRootCertificate),
  238. MACROSTR(MORootCertificate),
  239. MACROSTR(CSMSRootCertificate),
  240. MACROSTR(V2GCertificateChain),
  241. MACROSTR(ManufacturerRootCertificate)
  242. };
  243. static char *GetCertificateStatusEnumTypeStr[] = {
  244. MACROSTR(Accepted),
  245. MACROSTR(Failed)
  246. };
  247. static char *GetChargingProfileStatusEnumTypeStr[] = {
  248. MACROSTR(Accepted),
  249. MACROSTR(NoProfiles)
  250. };
  251. static char *GetDisplayMessagesStatusEnumTypeStr[] = {
  252. MACROSTR(Accepted),
  253. MACROSTR(Unknown)
  254. };
  255. static char *GetInstalledCertificateStatusEnumTypeStr[] = {
  256. MACROSTR(Accepted),
  257. MACROSTR(NotFound)
  258. };
  259. static char *GetVariableStatusEnumTypeStr[] = {
  260. MACROSTR(Accepted),
  261. MACROSTR(Rejected),
  262. MACROSTR(UnknownComponent),
  263. MACROSTR(UnknownVariable),
  264. MACROSTR(NotSupportedAttributeType)
  265. };
  266. static char *HashAlgorithmEnumTypeStr[] = {
  267. MACROSTR(SHA256),
  268. MACROSTR(SHA384),
  269. MACROSTR(SHA512)
  270. };
  271. static char *IdTokenEnumTypeStr[] = {
  272. MACROSTR(Central),
  273. MACROSTR(eMAID),
  274. MACROSTR(ISO14443),
  275. MACROSTR(KeyCode),
  276. MACROSTR(Local),
  277. MACROSTR(NoAuthorization),
  278. MACROSTR(ISO15693)
  279. };
  280. static char *InstallCertificateUseEnumTypeStr[] = {
  281. MACROSTR(V2GRootCertificate),
  282. MACROSTR(MORootCertificate),
  283. MACROSTR(CSMSRootCertificate),
  284. MACROSTR(ManufacturerRootCertificate)
  285. };
  286. static char *InstallCertificateStatusEnumTypeStr[]={
  287. MACROSTR(Accepted),
  288. MACROSTR(Failed),
  289. MACROSTR(Rejected)
  290. };
  291. static char *Iso15118EVCertificateStatusEnumTypeStr[] = {
  292. MACROSTR(Accepted),
  293. MACROSTR(Failed)
  294. };
  295. static char *LocationEnumTypeStr[] = {
  296. MACROSTR(Body),
  297. MACROSTR(Cable),
  298. MACROSTR(EV),
  299. MACROSTR(Inlet),
  300. MACROSTR(Outlet)
  301. };
  302. static char *LogEnumTypeStr[] = {
  303. MACROSTR(DiagnosticsLog),
  304. MACROSTR(SecurityLog)
  305. };
  306. static char *LogStatusEnumTypeStr[] = {
  307. MACROSTR(Accepted),
  308. MACROSTR(Rejected),
  309. MACROSTR(AcceptedCanceled)
  310. };
  311. static char *MeasurandEnumTypeStr[] = {
  312. MACROSTR(Current.Export),
  313. MACROSTR(Current.Import),
  314. MACROSTR(Current.Offered),
  315. MACROSTR(Energy.Active.Export.Register),
  316. MACROSTR(Energy.Active.Import.Register),
  317. MACROSTR(Energy.Reactive.Export.Register),
  318. MACROSTR(Energy.Reactive.Import.Register),
  319. MACROSTR(Energy.Active.Export.Interval),
  320. MACROSTR(Energy.Active.Import.Interval),
  321. MACROSTR(Energy.Active.Net),
  322. MACROSTR(Energy.Reactive.Export.Interval),
  323. MACROSTR(Energy.Reactive.Import.Interval),
  324. MACROSTR(Energy.Reactive.Net),
  325. MACROSTR(Energy.Apparent.Net),
  326. MACROSTR(Energy.Apparent.Import),
  327. MACROSTR(Energy.Apparent.Export),
  328. MACROSTR(Frequency),
  329. MACROSTR(Power.Active.Export),
  330. MACROSTR(Power.Active.Import),
  331. MACROSTR(Power.Factor),
  332. MACROSTR(Power.Offered),
  333. MACROSTR(Power.Reactive.Export),
  334. MACROSTR(Power.Reactive.Import),
  335. MACROSTR(SoC),
  336. MACROSTR(Voltage)
  337. };
  338. static char *MessageFormatEnumTypeStr[] = {
  339. MACROSTR(ASCII),
  340. MACROSTR(HTML),
  341. MACROSTR(URI),
  342. MACROSTR(UTF8)
  343. };
  344. static char *MessagePriorityEnumTypeStr[] = {
  345. MACROSTR(AlwaysFront),
  346. MACROSTR(InFront),
  347. MACROSTR(NormalCycle)
  348. };
  349. static char *MessageStateEnumTypeStr[] = {
  350. MACROSTR(Charging),
  351. MACROSTR(Faulted),
  352. MACROSTR(Idle),
  353. MACROSTR(Unavailable)
  354. };
  355. static char *MessageTriggerEnumTypeStr[] = {
  356. MACROSTR(BootNotification),
  357. MACROSTR(LogStatusNotification),
  358. MACROSTR(FirmwareStatusNotification),
  359. MACROSTR(Heartbeat),
  360. MACROSTR(MeterValues),
  361. MACROSTR(SignChargingStationCertificate),
  362. MACROSTR(SignV2GCertificate),
  363. MACROSTR(StatusNotification),
  364. MACROSTR(TransactionEvent),
  365. MACROSTR(SignCombinedCertificate),
  366. MACROSTR(PublishFirmwareStatusNotification)
  367. };
  368. static char *MonitorEnumTypeStr[] = {
  369. MACROSTR(UpperThreshold),
  370. MACROSTR(LowerThreshold),
  371. MACROSTR(Delta),
  372. MACROSTR(Periodic),
  373. MACROSTR(PeriodicClockAligned)
  374. };
  375. static char *MonitoringBaseEnumTypeStr[] = {
  376. MACROSTR(All),
  377. MACROSTR(FactoryDefault),
  378. MACROSTR(HardWiredOnly)
  379. };
  380. static char *MonitoringCriterionEnumTypeStr[] = {
  381. MACROSTR(ThresholdMonitoring),
  382. MACROSTR(DeltaMonitoring),
  383. MACROSTR(PeriodicMonitoring)
  384. };
  385. static char *MutabilityEnumTypeStr[] = {
  386. MACROSTR(ReadOnly),
  387. MACROSTR(WriteOnly),
  388. MACROSTR(ReadWrite)
  389. };
  390. static char *NotifyEVChargingNeedsStatusEnumTypeStr[] = {
  391. MACROSTR(Accepted),
  392. MACROSTR(Rejected),
  393. MACROSTR(Processing)
  394. };
  395. static char *OCPPInterfaceEnumTypeStr[] = {
  396. MACROSTR(Wired0),
  397. MACROSTR(Wired1),
  398. MACROSTR(Wired2),
  399. MACROSTR(Wired3),
  400. MACROSTR(Wireless0),
  401. MACROSTR(Wireless1),
  402. MACROSTR(Wireless2),
  403. MACROSTR(Wireless3)
  404. };
  405. static char *OCPPTransportEnumTypeStr[] = {
  406. MACROSTR(JSON),
  407. MACROSTR(SOAP)
  408. };
  409. static char *OCPPVersionEnumTypeStr[] = {
  410. MACROSTR(OCPP12),
  411. MACROSTR(OCPP15),
  412. MACROSTR(OCPP16),
  413. MACROSTR(OCPP20)
  414. };
  415. static char *OperationalStatusEnumTypeStr[] = {
  416. MACROSTR(Inoperative),
  417. MACROSTR(Operative)
  418. };
  419. static char *PhaseEnumTypeStr[] = {
  420. MACROSTR(L1),
  421. MACROSTR(L2),
  422. MACROSTR(L3),
  423. MACROSTR(N),
  424. MACROSTR(L1-N),
  425. MACROSTR(L2-N),
  426. MACROSTR(L3-N),
  427. MACROSTR(L1-L2),
  428. MACROSTR(L2-L3),
  429. MACROSTR(L3-L1)
  430. };
  431. static char *PublishFirmwareStatusEnumTypeStr[] = {
  432. MACROSTR(Downloaded),
  433. MACROSTR(DownloadFailed),
  434. MACROSTR(Downloading),
  435. MACROSTR(DownloadScheduled),
  436. MACROSTR(DownloadPaused),
  437. MACROSTR(PublishFailed),
  438. MACROSTR(Published),
  439. MACROSTR(InvalidChecksum),
  440. MACROSTR(ChecksumVerified)
  441. };
  442. static char *ReadingContextEnumTypeStr[] = {
  443. MACROSTR(Interruption.Begin),
  444. MACROSTR(Interruption.End),
  445. MACROSTR(Other),
  446. MACROSTR(Sample.Clock),
  447. MACROSTR(Sample.Periodic),
  448. MACROSTR(Transaction.Begin),
  449. MACROSTR(Transaction.End),
  450. MACROSTR(Trigger)
  451. };
  452. static char *ReasonEnumTypeStr[] = {
  453. MACROSTR(DeAuthorized),
  454. MACROSTR(EmergencyStop),
  455. MACROSTR(EnergyLimitReached),
  456. MACROSTR(EVDisconnected),
  457. MACROSTR(GroundFault),
  458. MACROSTR(ImmediateReset),
  459. MACROSTR(Local),
  460. MACROSTR(LocalOutOfCredit),
  461. MACROSTR(MasterPass),
  462. MACROSTR(Other),
  463. MACROSTR(OvercurrentFault),
  464. MACROSTR(PowerLoss),
  465. MACROSTR(PowerQuality),
  466. MACROSTR(Reboot),
  467. MACROSTR(Remote),
  468. MACROSTR(SOCLimitReached),
  469. MACROSTR(StoppedByEV),
  470. MACROSTR(TimeLimitReached),
  471. MACROSTR(TimeLimitReached)
  472. };
  473. static char *RecurrencyKindEnumTypeStr[] = {
  474. MACROSTR(Daily),
  475. MACROSTR(Weekly)
  476. };
  477. static char *RegistrationStatusEnumTypeStr[] = {
  478. MACROSTR(Accepted),
  479. MACROSTR(Pending),
  480. MACROSTR(Rejected)
  481. };
  482. static char *ReportBaseEnumTypeStr[] = {
  483. MACROSTR(ConfigurationInventory),
  484. MACROSTR(FullInventory),
  485. MACROSTR(SummaryInventory)
  486. };
  487. static char *RequestStartStopStatusEnumTypeStr[] = {
  488. MACROSTR(Accepted),
  489. MACROSTR(Rejected)
  490. };
  491. static char *ReservationUpdateStatusEnumTypeStr[] = {
  492. MACROSTR(Expired),
  493. MACROSTR(Removed)
  494. };
  495. static char *ReserveNowStatusEnumTypeStr[] = {
  496. MACROSTR(Accepted),
  497. MACROSTR(Faulted),
  498. MACROSTR(Occupied),
  499. MACROSTR(Rejected),
  500. MACROSTR(Unavailable)
  501. };
  502. static char *ResetEnumTypeStr[] = {
  503. MACROSTR(Immediate),
  504. MACROSTR(OnIdle)
  505. };
  506. static char *ResetStatusEnumTypeStr[] = {
  507. MACROSTR(Accepted),
  508. MACROSTR(Rejected),
  509. MACROSTR(Scheduled)
  510. };
  511. static char *SetMonitoringStatusEnumTypeStr[] = {
  512. MACROSTR(Accepted),
  513. MACROSTR(UnknownComponent),
  514. MACROSTR(UnknownVariable),
  515. MACROSTR(UnsupportedMonitorType),
  516. MACROSTR(Rejected),
  517. MACROSTR(OutOfRange),
  518. MACROSTR(Duplicate)
  519. };
  520. static char *SetNetworkProfileStatusEnumTypeStr[] = {
  521. MACROSTR(Accepted),
  522. MACROSTR(Rejected),
  523. MACROSTR(Failed)
  524. };
  525. static char *SetVariableStatusEnumTypeStr[] = {
  526. MACROSTR(Accepted),
  527. MACROSTR(Rejected),
  528. MACROSTR(InvalidValue),
  529. MACROSTR(UnknownComponent),
  530. MACROSTR(UnknownVariable),
  531. MACROSTR(NotSupportedAttributeType),
  532. MACROSTR(OutOfRange),
  533. MACROSTR(RebootRequired)
  534. };
  535. static char *TransactionEventEnumTypeStr[] = {
  536. MACROSTR(Ended),
  537. MACROSTR(Started),
  538. MACROSTR(Updated)
  539. };
  540. static char *TriggerMessageStatusEnumTypeStr[] = {
  541. MACROSTR(Accepted),
  542. MACROSTR(Rejected),
  543. MACROSTR(NotImplemented)
  544. };
  545. static char *TriggerReasonEnumTypeStr[] = {
  546. MACROSTR(Authorized),
  547. MACROSTR(CablePluggedIn),
  548. MACROSTR(ChargingRateChanged),
  549. MACROSTR(ChargingStateChanged),
  550. MACROSTR(Deauthorized),
  551. MACROSTR(EnergyLimitReached),
  552. MACROSTR(EVCommunicationLost),
  553. MACROSTR(EVConnectTimeout),
  554. MACROSTR(MeterValueClock),
  555. MACROSTR(MeterValuePeriodic),
  556. MACROSTR(TimeLimitReached),
  557. MACROSTR(Trigger),
  558. MACROSTR(UnlockCommand),
  559. MACROSTR(StopAuthorized),
  560. MACROSTR(EVDeparted),
  561. MACROSTR(EVDetected),
  562. MACROSTR(RemoteStop),
  563. MACROSTR(RemoteStart),
  564. MACROSTR(AbnormalCondition),
  565. MACROSTR(SignedDataReceived),
  566. MACROSTR(ResetCommand)
  567. };
  568. static char *UnlockStatusEnumTypeStr[] = {
  569. MACROSTR(Unlocked),
  570. MACROSTR(UnlockFailed),
  571. MACROSTR(OngoingAuthorizedTransaction),
  572. MACROSTR(UnknownConnector)
  573. };
  574. static char *UnpublishFirmwareStatusEnumTypeStr[] = {
  575. MACROSTR(DownloadOngoing),
  576. MACROSTR(NoFirmware),
  577. MACROSTR(Unpublished)
  578. };
  579. static char *UpdateEnumTypeStr[] = {
  580. MACROSTR(Differential),
  581. MACROSTR(Full)
  582. };
  583. static char *UpdateFirmwareStatusEnumTypeStr[] = {
  584. MACROSTR(Accepted),
  585. MACROSTR(Rejected),
  586. MACROSTR(AcceptedCanceled),
  587. MACROSTR(InvalidCertificate),
  588. MACROSTR(RevokedCertificate)
  589. };
  590. static char *UpdateStatusEnumTypeStr[] = {
  591. MACROSTR(Accepted),
  592. MACROSTR(Failed),
  593. MACROSTR(VersionMismatch)
  594. };
  595. static char *UploadLogStatusEnumTypeStr[] = {
  596. MACROSTR(BadMessage),
  597. MACROSTR(Idle),
  598. MACROSTR(NotSupportedOperation),
  599. MACROSTR(PermissionDenied),
  600. MACROSTR(Uploaded),
  601. MACROSTR(UploadFailure),
  602. MACROSTR(Uploading)
  603. };
  604. static char *VPNEnumTypeStr[] = {
  605. MACROSTR(IKEv2),
  606. MACROSTR(IPSec),
  607. MACROSTR(L2TP),
  608. MACROSTR(PPTP)
  609. };
  610. #if 0
  611. static char *ChargePointErrorCodeEnumTypeStr[] = {
  612. MACROSTR(ConnectorLockFailure),
  613. MACROSTR(EVCommunicationError),
  614. MACROSTR(GroundFailure),
  615. MACROSTR(HighTemperature),
  616. MACROSTR(InternalError),
  617. MACROSTR(LocalListConflict),
  618. MACROSTR(NoError),
  619. MACROSTR(OtherError),
  620. MACROSTR(OverCurrentFailure),
  621. MACROSTR(OverVoltage),
  622. MACROSTR(PowerMeterFailure),
  623. MACROSTR(PowerSwitchFailure),
  624. MACROSTR(ReaderFailure),
  625. MACROSTR(ResetFailure),
  626. MACROSTR(UnderVoltage),
  627. MACROSTR(WeakSignal)
  628. };
  629. #endif
  630. static char *GetCompositeScheduleStatusEnumTypeStr[] = {
  631. MACROSTR(Accepted),
  632. MACROSTR(Rejected)
  633. };
  634. static char *RemoteStartStopStatusEnumTypeStr[] = {
  635. MACROSTR(Accepted),
  636. MACROSTR(Rejected)
  637. };
  638. static char *ReservationStatusEnumTypeStr[] = {
  639. MACROSTR(Accepted),
  640. MACROSTR(Faulted),
  641. MACROSTR(Occupied),
  642. MACROSTR(Rejected),
  643. MACROSTR(Unavailable)
  644. };
  645. #if 0
  646. static char * StopTransactionReasonEnumTypeStr[] = {
  647. MACROSTR(EmergencyStop),
  648. MACROSTR(EVDisconnected),
  649. MACROSTR(HardReset),
  650. MACROSTR(Local),
  651. MACROSTR(Other),
  652. MACROSTR(PowerLoss),
  653. MACROSTR(Reboot),
  654. MACROSTR(Remote),
  655. MACROSTR(SoftReset),
  656. MACROSTR(UnlockCommand),
  657. MACROSTR(DeAuthorized)
  658. };
  659. #endif
  660. //ChargePointMaxProfile
  661. #define ChargePointMaxProfile_JSON "/Storage/OCPP/ChargePointMaxProfile_OCPP20.json"
  662. //TxDefaultProfile
  663. #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0_OCPP20.json"
  664. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  665. struct StatusCodeData *ShmStatusCodeData;
  666. struct PsuData *ShmPsuData ;
  667. struct OCPP20Data *ShmOCPP20Data;
  668. pthread_mutex_t lock_send = PTHREAD_MUTEX_INITIALIZER;
  669. char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
  670. //===============================
  671. // Gun Total Numbers
  672. //===============================
  673. static int gunTotalNumber = 0;
  674. static uint8_t gunType[4] = {0};
  675. //===============================
  676. // Local List Version
  677. //===============================
  678. static int localversion=0;
  679. //===============================
  680. // OCPP sign variable
  681. //===============================
  682. static int server_sign = FALSE;
  683. int server_pending = FALSE;
  684. static int BootNotificationInterval = 10;
  685. static int SystemInitial = 0;//= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; // System Boot UP
  686. //===============================
  687. // OCPP auth variable
  688. //===============================
  689. static int authorizeRetryTimes = 0; //number of Retry times
  690. //===============================
  691. // OCPP other variables
  692. //===============================
  693. static int HeartBeatWaitTime = 10;
  694. static int FirstHeartBeat = 0;
  695. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  696. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  697. static char CurrentChargingProfileScheduleStr[30] = {0};
  698. //========================================
  699. // OCPP status/previous related variables
  700. //========================================
  701. static int GunStatusInterval = 10;
  702. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  703. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  704. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  705. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  706. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  707. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  708. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  709. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  710. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  711. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  712. static int TransactionMessageAttemptsValue = 0;
  713. static int TransactionMessageRetryIntervalValue = 0;
  714. static int TempMeterValueInterval = 0;
  715. static struct AuthorizationData idTagQuery;
  716. //=============================================
  717. // OCPP HeartBeat Response Not Receive Counts
  718. //============================================
  719. static int HeartBeatWithNOResponse = 0;
  720. static int HeartBeatCountPerHour = 0;
  721. sqlite3 *db;
  722. int TransactionMessageAttemptsGet(void);
  723. int TransactionMessageRetryIntervalGet(void);
  724. int GetOcppConnStatus(void);
  725. void SetOcppConnStatus(uint8_t status);
  726. int setKeyValue(char *key, char *value);
  727. void OCPP_get_TableAuthlocalAllData(void);
  728. void processUnkownKey(void);
  729. struct StructOCPPMeterValue
  730. {
  731. unsigned char TimeStamp[28];
  732. struct StructSampledValue SampledValue[10];
  733. };
  734. struct ClientTime
  735. {
  736. unsigned int Heartbeat;
  737. unsigned int StatusNotification[CONNECTOR_QUANTITY];
  738. unsigned int StartTransaction;
  739. unsigned int StopTransaction;
  740. unsigned int MeterValues[CONNECTOR_QUANTITY];
  741. }clientTime;
  742. typedef union
  743. {
  744. //Operations Initiated by Central System
  745. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  746. struct
  747. {
  748. //CsMsgValue[0]
  749. unsigned char StatusNotificationReq:1; //bit 0,
  750. unsigned char StatusNotificationConf:1; //bit 1,
  751. unsigned char TriggerMeterValueReq:1; //bit 2,
  752. unsigned char TransactionEventReq:1; //bit 3,
  753. unsigned char SampleMeterReq:1; //bit 4,
  754. unsigned char ClockAlignMeterReq:1; //bit 5,
  755. unsigned char :2;
  756. }bits[CONNECTOR_QUANTITY];
  757. }CpinitiateMsg;
  758. CpinitiateMsg cpinitateMsg;
  759. //=========================================
  760. // Date time related function
  761. //=========================================
  762. void getNowDatetime(uint8_t *data)
  763. {
  764. time_t t = time(NULL);
  765. struct tm tm = *localtime(&t);
  766. 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);
  767. }
  768. //=========================================
  769. // Sqlite3 related function
  770. //=========================================
  771. int DB_Initial()
  772. {
  773. int result = PASS;
  774. char* errMsg = NULL;
  775. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  776. "idToken text UNIQUE,"
  777. "type text,"
  778. "status text,"
  779. "cacheExpiryDateTime text,"
  780. "chargingPriority integer,"
  781. "language1 text,"
  782. "evseId text,"
  783. "language2 text,"
  784. "groupIdToken_idToken text,"
  785. "groupIdToken_type text,"
  786. "personalMessage text);";
  787. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  788. "idToken text UNIQUE,"
  789. "type text,"
  790. "status text,"
  791. "cacheExpiryDateTime text,"
  792. "chargingPriority integer,"
  793. "language1 text,"
  794. "evseId text,"
  795. "language2 text,"
  796. "groupIdToken_idToken text,"
  797. "groupIdToken_type text,"
  798. "personalMessage text,"
  799. "version text);";
  800. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  801. "componentName text NOT NULL ,"
  802. "componentInstance text, "
  803. "variableName text NOT NULL, "
  804. "variableInstance text, "
  805. "variableCharacteristicsDataType integer, "
  806. "variableCharacteristicsUnit text, "
  807. "variableCharacteristicsMaxLimit real,"
  808. "variableAttributesType text, "
  809. "variableAttributesTypeMutability text, "
  810. "variableAttributesTypeValue text, "
  811. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  812. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  813. "type text);";
  814. char *sqlNetworkProfile = "create table if not exists ocpp20_networkprofile (idx integer primary key,"
  815. "slot integer UNIQUE, connectionData text);";
  816. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  817. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  818. {
  819. result = FAIL;
  820. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  821. sqlite3_close(db);
  822. }
  823. else
  824. {
  825. DEBUG_INFO( "OCPP local database open successfully.\n");
  826. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  827. {
  828. result = FAIL;
  829. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  830. }
  831. else
  832. {
  833. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  834. }
  835. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  836. {
  837. result = FAIL;
  838. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  839. }
  840. else
  841. {
  842. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  843. }
  844. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  845. {
  846. result = FAIL;
  847. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  848. }
  849. else
  850. {
  851. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  852. }
  853. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  854. {
  855. result = FAIL;
  856. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  857. }
  858. else
  859. {
  860. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  861. }
  862. if (sqlite3_exec(db, sqlNetworkProfile, 0, 0, &errMsg) != SQLITE_OK)
  863. {
  864. result = FAIL;
  865. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_networkprofile table error message: %s\n", errMsg);
  866. }
  867. else
  868. {
  869. DEBUG_INFO( "Create OCPP 2.0 ocpp20_networkprofile table successfully\n");
  870. }
  871. //sqlite3_close(db);
  872. }
  873. return result;
  874. }
  875. int DB_cbGetVersion(void *para, int columnCount, char **columnValue, char **columnName)
  876. {
  877. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  878. return 0;
  879. }
  880. void DB_getListVerion()
  881. {
  882. char sql[256];
  883. char* errMsg = NULL;
  884. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  885. /* Execute SQL statement */
  886. if( sqlite3_exec(db, sql, DB_cbGetVersion, 0, &errMsg) != SQLITE_OK )
  887. {
  888. DEBUG_INFO("SQL error: %s", errMsg);
  889. }
  890. }
  891. int DB_cbGetIdTag(void *para, int columnCount, char **columnValue, char **columnName)
  892. {
  893. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  894. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  895. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  896. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  897. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  898. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  899. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  900. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  901. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  902. return 0;
  903. }
  904. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  905. {
  906. char sql[256];
  907. char* errMsg = NULL;
  908. memset(&idTagQuery, 0, sizeof(idTagQuery));
  909. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  910. if(isQueryFromCache)
  911. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  912. else
  913. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  914. /* Execute SQL statement */
  915. if(sqlite3_exec(db, sql, DB_cbGetIdTag, 0, &errMsg) != SQLITE_OK )
  916. {
  917. DEBUG_INFO("SQL error: %s", errMsg);
  918. }
  919. }
  920. int DB_cbTableAuthlocalAllData(void *para, int columnCount, char **columnValue, char **columnName)
  921. {
  922. for (int i = 0; i < columnCount; i++)
  923. {
  924. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  925. }
  926. return 0;
  927. }
  928. void DB_get_TableAuthlocalAllData(void)
  929. {
  930. char sql[256];
  931. char* errMsg = NULL;
  932. sprintf(sql,"select * from ocpp20_auth_local;");
  933. /* Execute SQL statement */
  934. if(sqlite3_exec(db, sql, DB_cbTableAuthlocalAllData, 0,&errMsg) != SQLITE_OK)
  935. {
  936. DEBUG_INFO("SQL error: %s", errMsg);
  937. }
  938. }
  939. int DB_cbAddLocalListCache(void *para, int columnCount, char **columnValue, char **columnName)
  940. {
  941. for(int i = 0; i<columnCount; i++)
  942. {
  943. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  944. }
  945. return 0;
  946. }
  947. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  948. {
  949. int result = PASS;
  950. char sql[512];
  951. char* errMsg = NULL;
  952. 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;",
  953. data->idToken.idToken,
  954. data->idToken.type,
  955. data->idTokenInfo.status,
  956. data->idTokenInfo.cacheExpiryDateTime,
  957. data->idTokenInfo.chargingPriority,
  958. data->idTokenInfo.language1,
  959. data->idTokenInfo.language2,
  960. data->idTokenInfo.groupIdToken.idToken,
  961. data->idTokenInfo.groupIdToken.type,
  962. listVersion);
  963. //* Execute SQL statement */
  964. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  965. {
  966. DEBUG_INFO("SQL error: %s\n", errMsg);
  967. result = FAIL;
  968. }
  969. else
  970. {
  971. memset(sql, 0, ARRAY_SIZE(sql));
  972. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  973. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  974. {
  975. DEBUG_INFO("SQL error: %s\n", errMsg);
  976. result = FAIL;
  977. }
  978. }
  979. return result;
  980. }
  981. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  982. {
  983. int result = PASS;
  984. char sql[512];
  985. char* errMsg = NULL;
  986. 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;",
  987. idToken->idToken,
  988. idToken->type,
  989. idTokenInfo->status,
  990. idTokenInfo->cacheExpiryDateTime,
  991. idTokenInfo->chargingPriority,
  992. idTokenInfo->language1,
  993. idTokenInfo->language2,
  994. idTokenInfo->groupIdToken.idToken,
  995. idTokenInfo->groupIdToken.type);
  996. //* Execute SQL statement */
  997. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  998. {
  999. DEBUG_INFO("SQL error: %s\n", errMsg);
  1000. result = FAIL;
  1001. }
  1002. return result;
  1003. }
  1004. int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  1005. {
  1006. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  1007. // printf("localversion=%d\n", localversion);
  1008. return 0;
  1009. }
  1010. void DB_deleteIdTag(char idTag[])
  1011. {
  1012. char sql[512];
  1013. char* errMsg = NULL;
  1014. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1015. //* Execute SQL statement */
  1016. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1017. {
  1018. DEBUG_INFO("SQL error: %s", errMsg);
  1019. }
  1020. }
  1021. int DB_cleanLocalList()
  1022. {
  1023. int result = PASS;
  1024. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1025. char *errMsg = 0;
  1026. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1027. {
  1028. DEBUG_INFO("%s\n", errMsg);
  1029. result = FAIL;
  1030. }
  1031. return result;
  1032. }
  1033. int DB_cleanLocalCache()
  1034. {
  1035. int result = PASS;
  1036. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1037. char *errMsg = 0;
  1038. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1039. {
  1040. DEBUG_INFO("%s\n", errMsg);
  1041. result = FAIL;
  1042. }
  1043. return result;
  1044. }
  1045. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1046. {
  1047. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1048. return 0;
  1049. }
  1050. void DB_getBooType()
  1051. {
  1052. char sql[256];
  1053. char* errMsg = NULL;
  1054. sprintf(sql,"select * from ocpp20_boot_type;");
  1055. /* Execute SQL statement */
  1056. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1057. {
  1058. DEBUG_INFO("SQL error: %s\n", errMsg);
  1059. }
  1060. }
  1061. int DB_cbUpdateBootType(void *para, int columnCount, char **columnValue, char **columnName)
  1062. {
  1063. for(int i = 0; i<columnCount; i++)
  1064. {
  1065. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1066. }
  1067. return 0;
  1068. }
  1069. int DB_updateBootType(BootReasonEnumType reason)
  1070. {
  1071. int result = PASS;
  1072. char sql[512];
  1073. char* errMsg = NULL;
  1074. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1075. //* Execute SQL statement */
  1076. if(sqlite3_exec(db, sql, DB_cbUpdateBootType, 0, &errMsg) != SQLITE_OK)
  1077. {
  1078. DEBUG_INFO("SQL error: %s\n", errMsg);
  1079. result = FAIL;
  1080. }
  1081. return result;
  1082. }
  1083. int DB_cbVariableSaveToDb(void *para, int columnCount, char **columnValue, char **columnName)
  1084. {
  1085. for(int i = 0; i<columnCount; i++)
  1086. {
  1087. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1088. }
  1089. return 0;
  1090. }
  1091. int DB_variableSaveToDb(struct ReportDataType *variable)
  1092. {
  1093. int result = FAIL;
  1094. char sql[4096];
  1095. char* errMsg = NULL;
  1096. sprintf(sql,"insert or replace into ocpp20_variable (componentName, componentInstance, variableName, variableInstance, variableCharacteristicsDataType, variableCharacteristicsUnit, variableCharacteristicsMaxLimit, variableAttributesType, variableAttributesTypeMutability, variableAttributesTypeValue) VALUES('%s', '%s', '%s', '%s', '%s', '%s', %f, '%s', '%s', '%s'); SELECT * from ocpp20_variable;",
  1097. variable->component.name,
  1098. variable->component.instance,
  1099. variable->variable.name,
  1100. variable->variable.instance,
  1101. variable->variableCharacteristics.dataType,
  1102. variable->variableCharacteristics.unit,
  1103. variable->variableCharacteristics.maxLimit,
  1104. variable->variableAttribute[0].type,
  1105. variable->variableAttribute[0].mutability,
  1106. variable->variableAttribute[0].value);
  1107. //* Execute SQL statement */
  1108. if(sqlite3_exec(db, sql, DB_cbVariableSaveToDb, 0, &errMsg) != SQLITE_OK)
  1109. {
  1110. DEBUG_INFO("SQL error: %s\n", errMsg);
  1111. result = FAIL;
  1112. }
  1113. return result;
  1114. }
  1115. int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1116. {
  1117. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1118. if(atoi(columnValue[0]) == 0)
  1119. {
  1120. DB_updateBootType(BootReasonEnumType_PowerUp);
  1121. // Create variable table content
  1122. /* AlignedDataCtrlr Required item */
  1123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1129. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1136. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1142. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1144. else
  1145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1146. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1154. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1161. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1168. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1174. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1176. else
  1177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1178. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1186. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1187. /* AuthCtrlrVariable Required item */
  1188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1194. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1201. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1208. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1215. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1222. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1229. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1233. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1237. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1238. /* AuthCacheCtrlr Variable Required item*/
  1239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1245. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1252. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1260. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1264. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*100);
  1265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1268. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1275. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1276. /* ClockCtrlr Variable Required item */
  1277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1282. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1283. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1290. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1298. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1305. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1312. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1320. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1327. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1334. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1335. /* ChargingStation Required item */
  1336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1340. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1342. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1349. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1356. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1357. /* Connector Required item */
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1364. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1371. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1377. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1378. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1379. /* CustomizationCtrlr Required item */
  1380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1384. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1385. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1386. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1387. /* DeviceDataCtrlr Required item */
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1393. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1395. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1403. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1411. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1416. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1419. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1422. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1425. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1427. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1430. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1435. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1440. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1443. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1451. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1452. /* DisplayMessageCtrlr Required item */
  1453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1459. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1466. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "0");
  1473. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1480. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1487. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1488. /* EVSE Required item */
  1489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1495. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1498. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1502. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1509. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1516. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1517. /* LocalAuthListCtrlr Required item */
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1522. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1524. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1531. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1535. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1536. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1538. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1543. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "50");
  1546. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1551. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "2048");
  1554. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1558. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = 1024*1024;
  1559. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "5000");
  1562. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1563. /* MonitoringCtrlr Required item */
  1564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1567. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1570. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1575. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1577. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1580. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1583. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1585. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1590. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1591. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1593. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1598. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1601. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1606. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1607. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1609. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1613. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1614. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1615. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1616. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1617. /* OCPPCommCtrlr Required item */
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1621. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1622. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1624. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1633. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1635. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1640. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1643. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1645. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1646. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1648. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1651. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1653. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1654. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "[0]");
  1655. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1657. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1658. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1659. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1660. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1661. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1662. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1666. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1667. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1668. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1670. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1673. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1674. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1675. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1676. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1677. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1682. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1683. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1684. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1686. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1688. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1690. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1691. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1692. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1693. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "3");
  1695. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1696. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1697. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1698. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1699. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1700. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1702. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1704. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1705. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1706. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1707. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1708. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1710. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1712. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1713. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1714. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1715. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1716. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1717. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1719. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1720. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1721. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1722. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1723. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1724. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1725. /* ReservationCtrlr Required item */
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1727. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1728. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1729. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1730. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1732. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1734. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1735. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1737. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1739. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1741. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1742. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1743. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1744. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1745. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1746. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1747. /* SampledDataCtrlr Required item */
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  1749. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  1750. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1751. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1752. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1753. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1754. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  1757. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1758. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1759. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1761. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  1764. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1765. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1766. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1767. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1768. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1772. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1773. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1774. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, " ");
  1775. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  1776. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1779. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1780. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1781. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1782. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1783. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  1784. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1787. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1788. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1789. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  1790. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  1791. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  1792. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  1793. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1795. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1796. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, " ");
  1797. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  1800. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  1801. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1802. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1803. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1804. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "0");
  1805. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  1806. /* SecurityCtrlr Required item */
  1807. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  1808. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  1809. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1810. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  1811. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1812. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1813. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, " ");
  1814. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  1815. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  1816. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  1817. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1818. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  1819. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1820. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1821. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "Phihong Technology");
  1822. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  1823. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  1824. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  1825. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1828. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "Phihong");
  1829. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  1831. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1833. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1835. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  1836. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  1839. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1842. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "0");
  1843. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  1844. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  1845. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1847. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1848. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1849. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  1850. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  1851. /* SmartChargingCtrlr Required item */
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  1854. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1855. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1857. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1858. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  1859. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1862. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1864. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  1865. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  1866. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1869. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1870. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1871. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  1872. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  1873. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  1874. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1876. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1877. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1878. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "0");
  1879. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  1880. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  1882. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1884. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1885. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  1886. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  1887. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  1888. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1891. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1892. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  1893. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  1894. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  1895. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1897. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1898. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1899. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  1900. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  1901. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  1902. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  1903. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1904. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1906. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  1907. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  1908. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  1909. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1911. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1912. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1913. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  1914. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  1916. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1918. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1919. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1920. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "3");
  1921. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  1922. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  1923. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1925. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1926. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1927. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  1928. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  1929. /* TariffCostCtrlr Required item */
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  1933. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1934. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1935. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1936. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  1937. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  1940. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  1941. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1942. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1943. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1944. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  1945. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  1946. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  1947. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  1948. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1949. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  1950. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1951. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1952. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  1953. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  1954. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  1955. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  1956. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  1957. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1958. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1959. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1960. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  1961. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  1962. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  1963. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  1964. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  1965. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1966. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1967. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1968. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  1969. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  1970. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  1971. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  1972. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1973. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  1974. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1975. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1976. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  1977. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  1978. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  1979. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  1980. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1981. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  1982. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1983. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1984. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  1985. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  1986. /* TxCtrlr Required item */
  1987. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  1988. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1990. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1991. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1992. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  1993. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  1994. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  1995. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  1996. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  1997. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1998. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1999. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2000. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  2001. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  2002. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2003. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2005. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2007. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  2008. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  2009. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2010. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2012. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2014. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2015. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  2016. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2017. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2018. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2019. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2020. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2021. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "EVConnected,Authorized,PowerPathClosed");
  2022. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  2023. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2024. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2026. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2027. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2028. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "EVConnected,Authorized,PowerPathClosed");
  2029. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2030. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2031. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2032. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2034. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2035. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2036. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "60000");
  2037. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2038. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2039. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2040. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2041. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2042. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2043. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2044. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2045. }
  2046. else
  2047. {
  2048. // Variable name init
  2049. /* AlignedDataCtrlr Required item */
  2050. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2051. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2052. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2053. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2054. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2055. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2056. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2059. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2062. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2063. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2064. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2065. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2066. /* AuthCtrlrVariable Required item */
  2067. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2068. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2069. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2070. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2071. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2073. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2074. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2076. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2077. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2078. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2080. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2081. /* AuthCacheCtrlr Variable Required item */
  2082. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2083. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2085. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2086. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2087. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2088. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2089. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2090. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2091. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2092. /* ClockCtrlr Variable Required item */
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2095. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2110. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2111. /* ChargingStation Required item */
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2117. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2118. /* Connector Required item */
  2119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2125. /* DeviceDataCtrlr Required item */
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2148. /* DisplayMessageCtrlr Required item */
  2149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2159. /* EVSE Required item */
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2168. /* LocalAuthListCtrlr Required item */
  2169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2183. /* MonitoringCtrlr Required item */
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2202. /* OCPPCommCtrlr Required item */
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2234. /* ReservationCtrlr Required item */
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2241. /* SampledDataCtrlr Required item */
  2242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2258. /* SecurityCtrlr Required item */
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2271. /* SmartChargingCtrlr Required item */
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2294. /* TariffCostCtrlr Required item */
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2313. /* TxCtrlr Required item */
  2314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2330. }
  2331. return 0;
  2332. }
  2333. void DB_variableIsCreate()
  2334. {
  2335. char sql[512];
  2336. char* errMsg = NULL;
  2337. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2338. /* Execute SQL statement */
  2339. if(sqlite3_exec(db, sql, DB_cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2340. {
  2341. DEBUG_INFO("SQL error: %s\n", errMsg);
  2342. }
  2343. }
  2344. int DB_cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2345. {
  2346. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2347. {
  2348. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) != NULL) &&
  2349. (strlen(columnValue[2])>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) != NULL):TRUE) &&
  2350. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) != NULL) &&
  2351. (strlen(columnValue[4])>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) != NULL):TRUE))
  2352. {
  2353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2355. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2359. }
  2360. }
  2361. return 0;
  2362. }
  2363. void DB_variableLoadFromDb()
  2364. {
  2365. char sql[512];
  2366. char* errMsg = NULL;
  2367. sprintf(sql,"select * from ocpp20_variable;");
  2368. /* Execute SQL statement */
  2369. if(sqlite3_exec(db, sql, DB_cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2370. {
  2371. DEBUG_INFO("SQL error: %s\n", errMsg);
  2372. }
  2373. }
  2374. int DB_cbGetNetworkProfileFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2375. {
  2376. memset(&ShmOCPP20Data->NetworkConnectionProfile[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile));
  2377. if(columnCount > 0)
  2378. {
  2379. for(int idx=0;idx<columnCount;idx++)
  2380. {
  2381. json_object *SetNetworkProfile;
  2382. SetNetworkProfile = json_tokener_parse(columnValue[2]);
  2383. if(!is_error(SetNetworkProfile))
  2384. {
  2385. // Required data
  2386. if(json_object_object_get(SetNetworkProfile, "ocppVersion") != NULL)
  2387. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppVersion")));
  2388. if(json_object_object_get(SetNetworkProfile, "ocppTransport") != NULL)
  2389. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppTransport")));
  2390. if(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl") != NULL)
  2391. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl")));
  2392. if(json_object_object_get(SetNetworkProfile, "messageTimeout") != NULL)
  2393. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.messageTimeout = json_object_get_int(json_object_object_get(SetNetworkProfile, "messageTimeout"));
  2394. if(json_object_object_get(SetNetworkProfile, "ocppInterface") != NULL)
  2395. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppInterface")));
  2396. if(json_object_object_get(SetNetworkProfile, "vpn") != NULL)
  2397. {
  2398. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server") != NULL)
  2399. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server")));
  2400. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user") != NULL)
  2401. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user")));
  2402. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group") != NULL)
  2403. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group")));
  2404. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password") != NULL)
  2405. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password")));
  2406. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key") != NULL)
  2407. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key")));
  2408. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type") != NULL)
  2409. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type")));
  2410. }
  2411. if(json_object_object_get(SetNetworkProfile, "apn") != NULL)
  2412. {
  2413. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn") != NULL)
  2414. {
  2415. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn));
  2416. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn")));
  2417. }
  2418. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName") != NULL)
  2419. {
  2420. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName));
  2421. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName")));
  2422. }
  2423. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword") != NULL)
  2424. {
  2425. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword));
  2426. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword")));
  2427. }
  2428. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin") != NULL)
  2429. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin"));
  2430. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork") != NULL)
  2431. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork")));
  2432. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork") != NULL)
  2433. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork"));
  2434. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication") != NULL)
  2435. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication")));
  2436. }
  2437. }
  2438. json_object_put(SetNetworkProfile);
  2439. ShmOCPP20Data->NetworkConnectionProfile[idx].slot = atoi(columnValue[1]);
  2440. }
  2441. }
  2442. return 0;
  2443. }
  2444. void DB_getNetworkProfileFromDb()
  2445. {
  2446. char sql[512];
  2447. char* errMsg = NULL;
  2448. sprintf(sql,"select * from ocpp20_networkprofile order by slot;");
  2449. /* Execute SQL statement */
  2450. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2451. {
  2452. DEBUG_INFO("SQL error: %s\n", errMsg);
  2453. }
  2454. }
  2455. int DB_addNetworkProfile(int slot, char *data)
  2456. {
  2457. int result = PASS;
  2458. char sql[512];
  2459. char* errMsg = NULL;
  2460. sprintf(sql,"insert or replace into ocpp20_networkprofile (slot, connectionData) VALUES('%d', '%s'); SELECT * from ocpp20_networkprofile order by slot;",
  2461. slot,
  2462. data);
  2463. //* Execute SQL statement */
  2464. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK)
  2465. {
  2466. DEBUG_INFO("SQL error: %s\n", errMsg);
  2467. result = FAIL;
  2468. }
  2469. return result;
  2470. }
  2471. int DB_deleteNetworkProfile(int slot)
  2472. {
  2473. int result = PASS;
  2474. char sql[512];
  2475. char* errMsg = NULL;
  2476. sprintf(sql,"DELETE from ocpp20_networkprofile where slot=%d; SELECT * from ocpp20_networkprofile order by slot;", slot);
  2477. //* Execute SQL statement */
  2478. if( sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2479. {
  2480. DEBUG_INFO("SQL error: %s", errMsg);
  2481. result = FAIL;
  2482. }
  2483. return result;
  2484. }
  2485. //==========================================
  2486. // Check time passed since today
  2487. //==========================================
  2488. long long DiffTimebWithNow(struct timeb ST)
  2489. {
  2490. //return milli-second
  2491. struct timeb ET;
  2492. long long StartTime,StopTime;
  2493. ftime(&ET);
  2494. StartTime=(long long)ST.time;
  2495. StopTime=(long long)ET.time;
  2496. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2497. }
  2498. int getTimePassSinceToday()
  2499. {
  2500. int result = -1;
  2501. time_t t;
  2502. struct tm *tmStartToday;
  2503. struct timeb tbStartToday;
  2504. t=time(NULL);
  2505. tmStartToday=localtime(&t);
  2506. tmStartToday->tm_hour = 0;
  2507. tmStartToday->tm_min = 0;
  2508. tmStartToday->tm_sec = 0;
  2509. tbStartToday.time = mktime(tmStartToday);
  2510. tbStartToday.millitm = 0;
  2511. result = DiffTimebWithNow(tbStartToday)/1000;
  2512. return result;
  2513. }
  2514. //==========================================
  2515. // GetCompositeSchedule logic related function
  2516. //==========================================
  2517. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2518. {
  2519. //return milli-second
  2520. unsigned int StartTime,StopTime;
  2521. StartTime=(unsigned int)ST.time;
  2522. StopTime=(unsigned int)ET.time;
  2523. return (StopTime-StartTime);
  2524. }
  2525. int DiffTimebWithNowSec(struct timeb ST)
  2526. {
  2527. //return milli-second
  2528. struct timeb ET;
  2529. unsigned int StartTime,StopTime;
  2530. ftime(&ET);
  2531. StartTime=(unsigned int)ST.time;
  2532. StopTime=(unsigned int)ET.time;
  2533. return (StopTime-StartTime);
  2534. }
  2535. int getStartStop(uint8_t *start, uint8_t *stop)
  2536. {
  2537. int result = -1;
  2538. struct tm tmStart;
  2539. struct timeb tbStart;
  2540. struct tm tmStop;
  2541. struct timeb tbStop;
  2542. if((sscanf((char*)start, "%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) &&
  2543. (sscanf((char*)stop, "%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))
  2544. {
  2545. //DEBUG_INFO("Start: %d-%d-%d %d:%d:%d\n", tmStart.tm_year, tmStart.tm_mon, tmStart.tm_mday, tmStart.tm_hour, tmStart.tm_min, tmStart.tm_sec);
  2546. //DEBUG_INFO("Stop: %d-%d-%d %d:%d:%d\n", tmStop.tm_year, tmStop.tm_mon, tmStop.tm_mday, tmStop.tm_hour, tmStop.tm_min, tmStop.tm_sec);
  2547. tmStart.tm_year -= 1900;
  2548. tmStart.tm_mon -= 1;
  2549. tbStart.time = mktime(&tmStart);
  2550. tbStart.millitm = 0;
  2551. tmStop.tm_year -= 1900;
  2552. tmStop.tm_mon -= 1;
  2553. tbStop.time = mktime(&tmStop);
  2554. tbStop.millitm = 0;
  2555. result = DiffTimebSec(tbStart, tbStop);
  2556. //DEBUG_INFO("getStartStop(): %d\n", result);
  2557. }
  2558. else
  2559. {
  2560. DEBUG_WARN("Start or stop date parsing error.\r\n");
  2561. }
  2562. return result;
  2563. }
  2564. int isOvertNow(uint8_t *start)
  2565. {
  2566. int result = YES;
  2567. struct tm tmStart;
  2568. struct timeb tbStart;
  2569. if((sscanf((char*)start, "%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))
  2570. {
  2571. //DEBUG_INFO("Start: %d-%d-%d %d:%d:%d\n", tmStart.tm_year, tmStart.tm_mon, tmStart.tm_mday, tmStart.tm_hour, tmStart.tm_min, tmStart.tm_sec);
  2572. tmStart.tm_year -= 1900;
  2573. tmStart.tm_mon -= 1;
  2574. tbStart.time = mktime(&tmStart);
  2575. tbStart.millitm = 0;
  2576. if(DiffTimebWithNowSec(tbStart) <= 0)
  2577. result = NO;
  2578. }
  2579. else
  2580. {
  2581. DEBUG_WARN("Start date parsing error.\r\n");
  2582. }
  2583. return result;
  2584. }
  2585. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  2586. {
  2587. int result = -1;
  2588. struct tm tmStart;
  2589. struct timeb tbStart;
  2590. struct tm tmStop;
  2591. struct timeb tbStop;
  2592. if((sscanf((char*)start, "%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) &&
  2593. (sscanf((char*)stop, "%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))
  2594. {
  2595. tmStart.tm_year -= 1900;
  2596. tmStart.tm_mon -= 1;
  2597. tbStart.time = mktime(&tmStart);
  2598. tbStart.millitm = 0;
  2599. tmStop.tm_year -= 1900;
  2600. tmStop.tm_mon -= 1;
  2601. tbStop.time = mktime(&tmStop);
  2602. tbStop.millitm = 0;
  2603. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  2604. }
  2605. return result;
  2606. }
  2607. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *compositeProfile)
  2608. {
  2609. FILE *fp;
  2610. char profileFileName[128];
  2611. char *line = NULL;
  2612. size_t len = 0;
  2613. time_t CurrentTime;
  2614. struct tm *tmComposite;
  2615. struct ChargingProfileType maxProfile;
  2616. struct ChargingProfileType defaultTxProfile;
  2617. struct ChargingProfileType txProfile;
  2618. struct ChargingSchedulePeriodType tmpPeriod;
  2619. uint8_t limitMax=0;
  2620. uint8_t limitDef=0;
  2621. uint8_t limitTx=0;
  2622. int compositePeriodIdx = 0;
  2623. CurrentTime = time(NULL);
  2624. tmComposite=localtime(&CurrentTime);
  2625. sprintf((char*)compositeProfile->chargingSchedule[0].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);
  2626. sprintf((char*)compositeProfile->chargingSchedule[0].chargingRateUnit, "A");
  2627. compositeProfile->chargingSchedule[0].duration = durationReq;
  2628. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2629. {
  2630. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2631. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2632. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2633. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  2634. }
  2635. compositeProfile->id = 0;
  2636. compositeProfile->stackLevel = 99 ;
  2637. sprintf((char*)compositeProfile->chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  2638. maxProfile.id = -1;
  2639. defaultTxProfile.id = -1;
  2640. txProfile.id = -1;
  2641. maxProfile.chargingSchedule[0].duration = -1;
  2642. defaultTxProfile.chargingSchedule[0].duration = -1;
  2643. txProfile.chargingSchedule[0].duration = -1;
  2644. system("yes|rm /tmp/*.json");
  2645. system("cp /Storage/OCPP/*.json /tmp");
  2646. /*
  2647. * Search valid charging profile
  2648. */
  2649. //DEBUG_INFO("====================================\n");
  2650. // Search tx profile
  2651. sprintf(profileFileName, "/tmp/TxProfile_%d.json", connectorId);
  2652. if((access(profileFileName, F_OK))!=-1)
  2653. {
  2654. fp = fopen(profileFileName, "r");
  2655. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2656. {
  2657. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2658. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2659. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2660. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2661. }
  2662. txProfile.id = -1;
  2663. txProfile.stackLevel = -1;
  2664. while(getline(&line, &len, fp) != -1)
  2665. {
  2666. json_object *obj = NULL;
  2667. obj = json_tokener_parse(line);
  2668. if(is_error(obj))
  2669. {
  2670. DEBUG_ERROR("Parse txProfile from file error.\n");
  2671. }
  2672. else
  2673. {
  2674. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != txProfile.id) &&
  2675. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= txProfile.stackLevel)
  2676. )
  2677. {
  2678. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2679. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2680. )
  2681. {
  2682. struct tm tmFrom, tmTo;
  2683. struct timeb tbFrom, tbTo;
  2684. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "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) &&
  2685. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "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))
  2686. {
  2687. tmFrom.tm_year -= 1900;
  2688. tmFrom.tm_mon -= 1;
  2689. tbFrom.time = mktime(&tmFrom);
  2690. tmTo.tm_year -= 1900;
  2691. tmTo.tm_mon -= 1;
  2692. tbTo.time = mktime(&tmTo);
  2693. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2694. {
  2695. if(txProfile.id == -1)
  2696. DEBUG_INFO("TxProfile found.\n");
  2697. else
  2698. DEBUG_INFO("TxProfile updated.\n");
  2699. // Required item
  2700. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2701. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2702. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2703. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2704. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  2705. {
  2706. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  2707. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/220:json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  2708. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  2709. 3:
  2710. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  2711. }
  2712. // Optional item
  2713. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2714. {
  2715. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2716. }
  2717. else
  2718. {
  2719. sprintf((char*)txProfile.validFrom, " ");
  2720. }
  2721. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2722. {
  2723. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2724. }
  2725. else
  2726. {
  2727. sprintf((char*)txProfile.validTo, " ");
  2728. }
  2729. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2730. {
  2731. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2732. }
  2733. else
  2734. {
  2735. sprintf((char*)txProfile.recurrencyKind, " ");
  2736. }
  2737. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2738. {
  2739. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2740. }
  2741. else
  2742. {
  2743. sprintf((char*)txProfile.transactionId, " ");
  2744. }
  2745. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2746. {
  2747. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2748. }
  2749. else
  2750. {
  2751. txProfile.chargingSchedule[0].duration = 86400;
  2752. }
  2753. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2754. {
  2755. sprintf((char*)txProfile.chargingSchedule[0].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  2756. }
  2757. else
  2758. {
  2759. sprintf((char*)txProfile.chargingSchedule[0].startSchedule, "%s", ((strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL) ? compositeProfile->chargingSchedule[0].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  2760. }
  2761. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2762. {
  2763. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2764. }
  2765. else
  2766. {
  2767. txProfile.chargingSchedule[0].minChargingRate = -1;
  2768. }
  2769. }
  2770. }
  2771. }
  2772. else
  2773. {
  2774. if(txProfile.id == -1)
  2775. DEBUG_INFO("TxProfile found.\n");
  2776. else
  2777. DEBUG_INFO("TxProfile updated.\n");
  2778. // Required item
  2779. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2780. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2781. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2782. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2783. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  2784. {
  2785. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  2786. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/220:json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  2787. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  2788. 3:
  2789. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  2790. }
  2791. // Optional item
  2792. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2793. {
  2794. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2795. }
  2796. else
  2797. {
  2798. sprintf((char*)txProfile.validFrom, " ");
  2799. }
  2800. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2801. {
  2802. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2803. }
  2804. else
  2805. {
  2806. sprintf((char*)txProfile.validTo, " ");
  2807. }
  2808. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2809. {
  2810. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2811. }
  2812. else
  2813. {
  2814. sprintf((char*)txProfile.recurrencyKind, " ");
  2815. }
  2816. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2817. {
  2818. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2819. }
  2820. else
  2821. {
  2822. sprintf((char*)txProfile.transactionId, " ");
  2823. }
  2824. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2825. {
  2826. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2827. }
  2828. else
  2829. {
  2830. txProfile.chargingSchedule[0].duration = 86400;
  2831. }
  2832. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2833. {
  2834. sprintf((char*)txProfile.chargingSchedule[0].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  2835. }
  2836. else
  2837. {
  2838. sprintf((char*)txProfile.chargingSchedule[0].startSchedule, "%s", ((strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL) ? compositeProfile->chargingSchedule[0].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  2839. }
  2840. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2841. {
  2842. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2843. }
  2844. else
  2845. {
  2846. txProfile.chargingSchedule[0].minChargingRate = -1;
  2847. }
  2848. }
  2849. }
  2850. }
  2851. json_object_put(obj);
  2852. }
  2853. fclose(fp);
  2854. /*
  2855. if(txProfile.ChargingProfileId != -1)
  2856. {
  2857. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  2858. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  2859. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  2860. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  2861. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  2862. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  2863. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  2864. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[0].StartSchedule);
  2865. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  2866. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  2867. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  2868. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  2869. {
  2870. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  2871. {
  2872. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  2873. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  2874. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  2875. }
  2876. }
  2877. }
  2878. else
  2879. DEBUG_INFO("TxProfile not found.\n");*/
  2880. }
  2881. // Search default tx profile
  2882. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d.json", connectorId);
  2883. if((access(profileFileName, F_OK))==-1)
  2884. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  2885. if((access(profileFileName, F_OK))!=-1)
  2886. {
  2887. fp = fopen(profileFileName, "r");
  2888. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2889. {
  2890. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2891. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2892. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2893. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2894. }
  2895. defaultTxProfile.id = -1;
  2896. defaultTxProfile.stackLevel = -1;
  2897. while(getline(&line, &len, fp) != -1)
  2898. {
  2899. json_object *obj = NULL;
  2900. obj = json_tokener_parse(line);
  2901. if(is_error(obj))
  2902. {
  2903. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  2904. }
  2905. else
  2906. {
  2907. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != defaultTxProfile.id) &&
  2908. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= defaultTxProfile.stackLevel)
  2909. )
  2910. {
  2911. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2912. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2913. )
  2914. {
  2915. struct tm tmFrom, tmTo;
  2916. struct timeb tbFrom, tbTo;
  2917. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "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) &&
  2918. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "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))
  2919. {
  2920. tmFrom.tm_year -= 1900;
  2921. tmFrom.tm_mon -= 1;
  2922. tbFrom.time = mktime(&tmFrom);
  2923. tmTo.tm_year -= 1900;
  2924. tmTo.tm_mon -= 1;
  2925. tbTo.time = mktime(&tmTo);
  2926. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2927. {
  2928. if(defaultTxProfile.id == -1)
  2929. DEBUG_INFO("TxDefaultProfile found.\n");
  2930. else
  2931. DEBUG_INFO("TxDefaultProfile updated.\n");
  2932. // Required item
  2933. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2934. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2935. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2936. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  2937. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  2938. {
  2939. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  2940. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/220:json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  2941. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  2942. 3:
  2943. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  2944. }
  2945. // Optional item
  2946. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2947. {
  2948. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2949. }
  2950. else
  2951. {
  2952. sprintf((char*)defaultTxProfile.validFrom, " ");
  2953. }
  2954. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2955. {
  2956. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2957. }
  2958. else
  2959. {
  2960. sprintf((char*)defaultTxProfile.validTo, " ");
  2961. }
  2962. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2963. {
  2964. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2965. }
  2966. else
  2967. {
  2968. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  2969. }
  2970. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2971. {
  2972. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2973. }
  2974. else
  2975. {
  2976. sprintf((char*)defaultTxProfile.transactionId, " ");
  2977. }
  2978. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2979. {
  2980. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2981. }
  2982. else
  2983. {
  2984. defaultTxProfile.chargingSchedule[0].duration = 86400;
  2985. }
  2986. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2987. {
  2988. sprintf((char*)defaultTxProfile.chargingSchedule[0].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  2989. }
  2990. else
  2991. {
  2992. sprintf((char*)defaultTxProfile.chargingSchedule[0].startSchedule, "%s", ((strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL) ? compositeProfile->chargingSchedule[0].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  2993. }
  2994. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2995. {
  2996. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2997. }
  2998. else
  2999. {
  3000. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  3001. }
  3002. }
  3003. }
  3004. }
  3005. else
  3006. {
  3007. if(defaultTxProfile.id == -1)
  3008. DEBUG_INFO("TxDefaultProfile found.\n");
  3009. else
  3010. DEBUG_INFO("TxDefaultProfile updated.\n");
  3011. // Required item
  3012. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3013. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3014. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3015. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3016. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3017. {
  3018. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3019. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/220:json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3020. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3021. 3:
  3022. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3023. }
  3024. // Optional item
  3025. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3026. {
  3027. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3028. }
  3029. else
  3030. {
  3031. sprintf((char*)defaultTxProfile.validFrom, " ");
  3032. }
  3033. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3034. {
  3035. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3036. }
  3037. else
  3038. {
  3039. sprintf((char*)defaultTxProfile.validTo, " ");
  3040. }
  3041. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3042. {
  3043. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3044. }
  3045. else
  3046. {
  3047. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  3048. }
  3049. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3050. {
  3051. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3052. }
  3053. else
  3054. {
  3055. sprintf((char*)defaultTxProfile.transactionId, " ");
  3056. }
  3057. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3058. {
  3059. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3060. }
  3061. else
  3062. {
  3063. defaultTxProfile.chargingSchedule[0].duration = 86400;
  3064. }
  3065. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3066. {
  3067. sprintf((char*)defaultTxProfile.chargingSchedule[0].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3068. }
  3069. else
  3070. {
  3071. sprintf((char*)defaultTxProfile.chargingSchedule[0].startSchedule, "%s", ((strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL) ? compositeProfile->chargingSchedule[0].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  3072. }
  3073. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3074. {
  3075. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3076. }
  3077. else
  3078. {
  3079. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  3080. }
  3081. }
  3082. }
  3083. }
  3084. json_object_put(obj);
  3085. }
  3086. fclose(fp);
  3087. /*
  3088. if(defaultTxProfile.ChargingProfileId != -1)
  3089. {
  3090. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3091. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3092. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3093. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3094. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3095. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3096. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3097. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[0].StartSchedule);
  3098. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3099. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3100. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3101. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3102. {
  3103. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3104. {
  3105. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3106. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3107. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3108. }
  3109. }
  3110. }
  3111. else
  3112. DEBUG_INFO("TxDefaultProfile not found.\n");
  3113. DEBUG_INFO("------------------------------------\n");*/
  3114. }
  3115. // Search max profile
  3116. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  3117. if((access(profileFileName, F_OK))!=-1)
  3118. {
  3119. fp = fopen(profileFileName, "r");
  3120. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3121. {
  3122. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3123. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  3124. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3125. }
  3126. maxProfile.id = -1;
  3127. maxProfile.stackLevel = -1;
  3128. while(getline(&line, &len, fp) != -1)
  3129. {
  3130. json_object *obj = NULL;
  3131. obj = json_tokener_parse(line);
  3132. if(is_error(obj))
  3133. {
  3134. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  3135. }
  3136. else
  3137. {
  3138. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != maxProfile.id) &&
  3139. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= maxProfile.stackLevel)
  3140. )
  3141. {
  3142. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3143. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3144. )
  3145. {
  3146. struct tm tmFrom, tmTo;
  3147. struct timeb tbFrom, tbTo;
  3148. if((sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "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) &&
  3149. (sscanf((char*)json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "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))
  3150. {
  3151. tmFrom.tm_year -= 1900;
  3152. tmFrom.tm_mon -= 1;
  3153. tbFrom.time = mktime(&tmFrom);
  3154. tmTo.tm_year -= 1900;
  3155. tmTo.tm_mon -= 1;
  3156. tbTo.time = mktime(&tmTo);
  3157. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3158. {
  3159. if(maxProfile.id == -1)
  3160. DEBUG_INFO("MaxProfile found.\n");
  3161. else
  3162. DEBUG_INFO("MaxProfile updated.\n");
  3163. // Required item
  3164. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3165. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3166. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3167. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3168. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3169. {
  3170. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3171. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = (strstr(json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/220:json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3172. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3173. 3:
  3174. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3175. }
  3176. // Optional item
  3177. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3178. {
  3179. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3180. }
  3181. else
  3182. {
  3183. sprintf((char*)maxProfile.validFrom, " ");
  3184. }
  3185. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3186. {
  3187. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3188. }
  3189. else
  3190. {
  3191. sprintf((char*)maxProfile.validTo, " ");
  3192. }
  3193. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3194. {
  3195. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3196. }
  3197. else
  3198. {
  3199. sprintf((char*)maxProfile.recurrencyKind, " ");
  3200. }
  3201. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3202. {
  3203. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3204. }
  3205. else
  3206. {
  3207. sprintf((char*)maxProfile.transactionId, " ");
  3208. }
  3209. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3210. {
  3211. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3212. }
  3213. else
  3214. {
  3215. maxProfile.chargingSchedule[0].duration = 86400;
  3216. }
  3217. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3218. {
  3219. sprintf((char*)maxProfile.chargingSchedule[0].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3220. }
  3221. else
  3222. {
  3223. sprintf((char*)maxProfile.chargingSchedule[0].startSchedule, "%s", ((strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL) ? compositeProfile->chargingSchedule[0].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  3224. }
  3225. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3226. {
  3227. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3228. }
  3229. else
  3230. {
  3231. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3232. }
  3233. }
  3234. }
  3235. }
  3236. else
  3237. {
  3238. if(maxProfile.id == -1)
  3239. DEBUG_INFO("MaxProfile found.\n");
  3240. else
  3241. DEBUG_INFO("MaxProfile updated.\n");
  3242. // Required item
  3243. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3244. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3245. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3246. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3247. for(int idxPeriod=0;idxPeriod<json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"));idxPeriod++)
  3248. {
  3249. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "startPeriod"));
  3250. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = (strstr((char*)json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingRateUnit")),ChargingRateUnitEnumTypeStr[ChargingRateUnitEnumType_W])!=NULL?json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit"))/220:json_object_get_double(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "limit")));
  3251. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = (json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")==NULL?
  3252. 3:
  3253. json_object_get_int(json_object_object_get(json_object_array_get_idx(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "chargingSchedulePeriod"), idxPeriod), "numberPhases")));
  3254. }
  3255. // Optional item
  3256. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3257. {
  3258. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3259. }
  3260. else
  3261. {
  3262. sprintf((char*)maxProfile.validFrom, " ");
  3263. }
  3264. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3265. {
  3266. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3267. }
  3268. else
  3269. {
  3270. sprintf((char*)maxProfile.validTo, " ");
  3271. }
  3272. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3273. {
  3274. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3275. }
  3276. else
  3277. {
  3278. sprintf((char*)maxProfile.recurrencyKind, " ");
  3279. }
  3280. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3281. {
  3282. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3283. }
  3284. else
  3285. {
  3286. sprintf((char*)maxProfile.transactionId, " ");
  3287. }
  3288. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3289. {
  3290. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3291. }
  3292. else
  3293. {
  3294. maxProfile.chargingSchedule[0].duration = 86400;
  3295. }
  3296. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3297. {
  3298. sprintf((char*)maxProfile.chargingSchedule[0].startSchedule, "%s", json_object_get_string(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule")));
  3299. }
  3300. else
  3301. {
  3302. sprintf((char*)maxProfile.chargingSchedule[0].startSchedule, "%s", ((strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL) ? compositeProfile->chargingSchedule[0].startSchedule : ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp));
  3303. }
  3304. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3305. {
  3306. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3307. }
  3308. else
  3309. {
  3310. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3311. }
  3312. }
  3313. }
  3314. }
  3315. json_object_put(obj);
  3316. }
  3317. fclose(fp);
  3318. /*
  3319. if(maxProfile.ChargingProfileId !=-1)
  3320. {
  3321. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3322. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3323. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3324. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3325. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3326. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3327. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3328. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[0].StartSchedule);
  3329. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3330. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3331. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3332. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3333. {
  3334. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3335. {
  3336. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3337. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3338. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3339. }
  3340. }
  3341. }
  3342. else
  3343. DEBUG_INFO("MaxProfile not found.\n");
  3344. DEBUG_INFO("------------------------------------\n");*/
  3345. }
  3346. /*
  3347. * Align found profile start schedule & periods
  3348. */
  3349. //DEBUG_INFO("====================================\n");
  3350. /*
  3351. // For local test usage, force modify found profile start schedule info
  3352. sprintf((char*)maxProfile.chargingSchedule[0].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);
  3353. sprintf((char*)defaultTxProfile.chargingSchedule[0].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);
  3354. sprintf((char*)txProfile.chargingSchedule[0].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);
  3355. */
  3356. if(txProfile.id != -1)
  3357. {
  3358. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3359. {
  3360. if(txProfile.chargingSchedule[0].duration != -1)
  3361. {
  3362. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3363. 0:
  3364. (txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3365. }
  3366. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3367. {
  3368. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3369. {
  3370. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3371. 0:
  3372. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3373. if(idxPeriod > 0)
  3374. {
  3375. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3376. {
  3377. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3378. }
  3379. }
  3380. }
  3381. }
  3382. }
  3383. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3384. {
  3385. if(txProfile.chargingSchedule[0].duration != -1)
  3386. {
  3387. txProfile.chargingSchedule[0].duration = (strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL)?txProfile.chargingSchedule[0].duration:((txProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3388. 0:
  3389. (txProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3390. }
  3391. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3392. {
  3393. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3394. {
  3395. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = (strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL)?txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod:((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3396. 0:
  3397. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3398. if(idxPeriod > 0)
  3399. {
  3400. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3401. {
  3402. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3403. }
  3404. }
  3405. }
  3406. }
  3407. }
  3408. else
  3409. {
  3410. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3411. {
  3412. if(txProfile.chargingSchedule[0].duration != -1)
  3413. {
  3414. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3415. 0:
  3416. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3417. }
  3418. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3419. {
  3420. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3421. {
  3422. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3423. 0:
  3424. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3425. if(idxPeriod > 0)
  3426. {
  3427. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3428. {
  3429. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3430. }
  3431. }
  3432. }
  3433. }
  3434. }
  3435. else
  3436. {
  3437. if(txProfile.chargingSchedule[0].duration != -1)
  3438. {
  3439. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3440. 0:
  3441. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3442. }
  3443. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3444. {
  3445. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3446. {
  3447. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3448. 0:
  3449. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3450. if(idxPeriod > 0)
  3451. {
  3452. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3453. {
  3454. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3455. }
  3456. }
  3457. }
  3458. }
  3459. }
  3460. }
  3461. /*
  3462. DEBUG_INFO("txProfile after align.\n");
  3463. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  3464. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3465. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3466. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3467. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3468. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3469. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  3470. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3471. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  3472. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  3473. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  3474. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3475. {
  3476. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3477. {
  3478. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3479. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3480. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3481. }
  3482. }*/
  3483. }
  3484. if(defaultTxProfile.id != -1)
  3485. {
  3486. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3487. {
  3488. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3489. {
  3490. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3491. 0:
  3492. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3493. }
  3494. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3495. {
  3496. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3497. {
  3498. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3499. 0:
  3500. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3501. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3502. {
  3503. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3504. }
  3505. if(idxPeriod > 0)
  3506. {
  3507. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3508. {
  3509. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3510. }
  3511. }
  3512. }
  3513. }
  3514. }
  3515. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3516. {
  3517. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3518. {
  3519. defaultTxProfile.chargingSchedule[0].duration = (strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL)?defaultTxProfile.chargingSchedule[0].duration:((defaultTxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3520. 0:
  3521. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3522. }
  3523. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3524. {
  3525. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3526. {
  3527. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = (strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL)?defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod:((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3528. 0:
  3529. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3530. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3531. {
  3532. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3533. }
  3534. if(idxPeriod > 0)
  3535. {
  3536. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3537. {
  3538. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3539. }
  3540. }
  3541. }
  3542. }
  3543. }
  3544. else
  3545. {
  3546. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3547. {
  3548. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3549. {
  3550. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3551. 0:
  3552. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3553. }
  3554. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3555. {
  3556. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3557. {
  3558. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3559. 0:
  3560. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3561. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3562. {
  3563. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3564. }
  3565. if(idxPeriod > 0)
  3566. {
  3567. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3568. {
  3569. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3570. }
  3571. }
  3572. }
  3573. }
  3574. }
  3575. else
  3576. {
  3577. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3578. {
  3579. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3580. 0:
  3581. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3582. }
  3583. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3584. {
  3585. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3586. {
  3587. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3588. 0:
  3589. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3590. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3591. {
  3592. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3593. }
  3594. if(idxPeriod > 0)
  3595. {
  3596. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3597. {
  3598. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3599. }
  3600. }
  3601. }
  3602. }
  3603. }
  3604. }
  3605. /*
  3606. DEBUG_INFO("defaultTxProfile after align.\n");
  3607. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3608. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3609. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3610. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3611. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3612. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3613. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3614. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3615. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3616. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3617. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3618. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3619. {
  3620. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3621. {
  3622. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3623. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3624. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3625. }
  3626. }
  3627. DEBUG_INFO("------------------------------------\n");*/
  3628. }
  3629. if(maxProfile.id != -1)
  3630. {
  3631. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3632. {
  3633. if(maxProfile.chargingSchedule[0].duration != -1)
  3634. {
  3635. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3636. 0:
  3637. (maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3638. }
  3639. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3640. {
  3641. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3642. {
  3643. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3644. 0:
  3645. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3646. if(idxPeriod > 0)
  3647. {
  3648. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3649. {
  3650. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3651. }
  3652. }
  3653. }
  3654. }
  3655. }
  3656. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3657. {
  3658. if(maxProfile.chargingSchedule[0].duration != -1)
  3659. {
  3660. maxProfile.chargingSchedule[0].duration = (strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL)?maxProfile.chargingSchedule[0].duration:((maxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3661. 0:
  3662. (maxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[9].startSchedule)));
  3663. }
  3664. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3665. {
  3666. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3667. {
  3668. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = (strstr((char*)ShmOCPP20Data->StatusNotification[(connectorId==0?0:connectorId-1)].connectorStatus, "Charging")==NULL)?maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod:((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3669. 0:
  3670. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3671. if(idxPeriod > 0)
  3672. {
  3673. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3674. {
  3675. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3676. }
  3677. }
  3678. }
  3679. }
  3680. }
  3681. else
  3682. {
  3683. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3684. {
  3685. if(maxProfile.chargingSchedule[0].duration != -1)
  3686. {
  3687. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3688. 0:
  3689. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3690. }
  3691. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3692. {
  3693. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3694. {
  3695. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3696. 0:
  3697. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3698. if(idxPeriod > 0)
  3699. {
  3700. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3701. {
  3702. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3703. }
  3704. }
  3705. }
  3706. }
  3707. }
  3708. else
  3709. {
  3710. if(maxProfile.chargingSchedule[0].duration != -1)
  3711. {
  3712. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3713. 0:
  3714. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3715. }
  3716. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3717. {
  3718. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3719. {
  3720. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3721. 0:
  3722. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3723. if(idxPeriod > 0)
  3724. {
  3725. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3726. {
  3727. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3728. }
  3729. }
  3730. }
  3731. }
  3732. }
  3733. }
  3734. /*
  3735. DEBUG_INFO("MaxProfile after align.\n");
  3736. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3737. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3738. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3739. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3740. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3741. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3742. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3743. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3744. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3745. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3746. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3747. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3748. {
  3749. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3750. {
  3751. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3752. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3753. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3754. }
  3755. }
  3756. DEBUG_INFO("------------------------------------\n");*/
  3757. }
  3758. /*
  3759. * Merge to conposite schedule
  3760. */
  3761. //DEBUG_INFO("====================================\n");
  3762. // Find each profile period quantity
  3763. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3764. {
  3765. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3766. limitMax = idx+1;
  3767. }
  3768. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3769. {
  3770. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3771. limitDef = idx+1;
  3772. }
  3773. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3774. {
  3775. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3776. limitTx = idx+1;
  3777. }
  3778. // TxProfile found, composite schedule based on it
  3779. if(txProfile.id != -1)
  3780. {
  3781. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  3782. {
  3783. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  3784. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  3785. (txProfile.chargingSchedule[0].duration > 0))
  3786. {
  3787. if(maxProfile.id != -1)
  3788. {
  3789. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3790. {
  3791. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  3792. {
  3793. if((maxProfile.chargingSchedule[0].duration > 0))
  3794. {
  3795. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3796. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3797. tmpPeriod.limit = (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit>maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit?maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit:txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit);
  3798. }
  3799. else
  3800. {
  3801. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3802. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3803. tmpPeriod.limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit;
  3804. }
  3805. }
  3806. if(idxMaxPeriod == (limitMax-1))
  3807. {
  3808. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3809. {
  3810. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3811. {
  3812. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3813. compositePeriodIdx++;
  3814. }
  3815. else
  3816. {
  3817. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3818. }
  3819. }
  3820. }
  3821. }
  3822. }
  3823. else
  3824. {
  3825. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3826. {
  3827. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3828. compositePeriodIdx++;
  3829. }
  3830. else
  3831. {
  3832. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3833. }
  3834. }
  3835. }
  3836. if(idxTxPeriod == (limitTx-1))
  3837. {
  3838. if(defaultTxProfile.id != -1)
  3839. {
  3840. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3841. {
  3842. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  3843. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3844. (defaultTxProfile.chargingSchedule[0].duration>0))
  3845. {
  3846. if(maxProfile.id != -1)
  3847. {
  3848. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3849. {
  3850. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3851. {
  3852. if((maxProfile.chargingSchedule[0].duration > 0))
  3853. {
  3854. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3855. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3856. tmpPeriod.limit = (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit>maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit?maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit:defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit);
  3857. }
  3858. else
  3859. {
  3860. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3861. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3862. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3863. }
  3864. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3865. {
  3866. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3867. {
  3868. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3869. compositePeriodIdx++;
  3870. }
  3871. else
  3872. {
  3873. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3874. }
  3875. }
  3876. break;
  3877. }
  3878. }
  3879. }
  3880. else
  3881. {
  3882. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3883. {
  3884. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3885. compositePeriodIdx++;
  3886. }
  3887. else
  3888. {
  3889. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3890. }
  3891. }
  3892. }
  3893. }
  3894. }
  3895. }
  3896. }
  3897. }
  3898. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  3899. else if(defaultTxProfile.id != -1)
  3900. {
  3901. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3902. {
  3903. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  3904. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3905. (defaultTxProfile.chargingSchedule[0].duration > 0))
  3906. {
  3907. if(maxProfile.id != -1)
  3908. {
  3909. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3910. {
  3911. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3912. {
  3913. if((maxProfile.chargingSchedule[0].duration > 0))
  3914. {
  3915. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3916. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3917. tmpPeriod.limit = (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit>maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit?maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit:defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit);
  3918. }
  3919. else
  3920. {
  3921. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3922. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3923. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3924. }
  3925. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3926. {
  3927. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3928. {
  3929. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3930. compositePeriodIdx++;
  3931. }
  3932. else
  3933. {
  3934. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3935. }
  3936. }
  3937. break;
  3938. }
  3939. }
  3940. }
  3941. else
  3942. {
  3943. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3944. {
  3945. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3946. compositePeriodIdx++;
  3947. }
  3948. else
  3949. {
  3950. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3951. }
  3952. }
  3953. }
  3954. }
  3955. }
  3956. // Fill other period by MaxProfile
  3957. if(maxProfile.id != -1)
  3958. {
  3959. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3960. {
  3961. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3962. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3963. (maxProfile.chargingSchedule[0].duration > 0))
  3964. {
  3965. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod >= compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod) &&
  3966. (maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3967. {
  3968. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod;
  3969. tmpPeriod.numberPhases = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].numberPhases;
  3970. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3971. }
  3972. if((maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3973. {
  3974. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].duration;
  3975. tmpPeriod.numberPhases = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  3976. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3977. }
  3978. if(tmpPeriod.limit != -1)
  3979. {
  3980. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3981. {
  3982. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3983. {
  3984. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3985. compositePeriodIdx++;
  3986. }
  3987. else
  3988. {
  3989. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3990. }
  3991. }
  3992. }
  3993. }
  3994. }
  3995. }
  3996. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  3997. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[0].startSchedule);
  3998. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[0].duration);
  3999. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[0].chargingRateUnit);
  4000. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  4001. {
  4002. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  4003. {
  4004. compositeProfile->id = 1;
  4005. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  4006. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit);
  4007. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases);
  4008. }
  4009. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit == -1)
  4010. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit =0;
  4011. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  4012. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  4013. }
  4014. if(line)
  4015. free(line);
  4016. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  4017. }
  4018. //==========================================
  4019. // Init all share memory
  4020. //==========================================
  4021. int InitShareMemory()
  4022. {
  4023. int result = PASS;
  4024. int MeterSMId;
  4025. //creat ShmSysConfigAndInfo
  4026. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  4027. {
  4028. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  4029. result = FAIL;
  4030. }
  4031. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4032. {
  4033. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  4034. result = FAIL;
  4035. }
  4036. else
  4037. {}
  4038. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  4039. {
  4040. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  4041. result = FAIL;
  4042. }
  4043. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4044. {
  4045. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  4046. result = FAIL;
  4047. }
  4048. else
  4049. {}
  4050. //creat ShmPsuData
  4051. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  4052. {
  4053. DEBUG_ERROR("shmget ShmPsuData NG\n");
  4054. result = FAIL;
  4055. }
  4056. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4057. {
  4058. DEBUG_ERROR("shmat ShmPsuData NG\n");
  4059. result = FAIL;
  4060. }
  4061. else
  4062. {}
  4063. //creat ShmOCPP20Data
  4064. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  4065. {
  4066. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  4067. result = FAIL;
  4068. }
  4069. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4070. {
  4071. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  4072. result = FAIL;
  4073. }
  4074. else
  4075. {}
  4076. /****************************** For Initial Settings************************************************/
  4077. //offline MeterValue Interval
  4078. TempMeterValueInterval = 0;
  4079. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  4080. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  4081. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  4082. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  4083. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  4084. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  4085. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  4086. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  4087. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  4088. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  4089. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  4090. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  4091. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  4092. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  4093. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  4094. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  4095. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  4096. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  4097. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  4098. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  4099. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  4100. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  4101. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  4102. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  4103. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  4104. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  4105. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  4106. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  4107. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  4108. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  4109. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  4110. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  4111. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  4112. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  4113. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  4114. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  4115. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  4116. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  4117. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  4118. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  4119. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  4120. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  4121. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  4122. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  4123. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  4124. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  4125. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  4126. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  4127. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  4128. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  4129. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  4130. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  4131. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  4132. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  4133. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  4134. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  4135. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  4136. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  4137. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  4138. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  4139. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  4140. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  4141. return result;
  4142. }
  4143. int ProcessShareMemory()
  4144. {
  4145. if(InitShareMemory() == FAIL)
  4146. {
  4147. DEBUG_ERROR("InitShareMemory NG\n");
  4148. if(ShmStatusCodeData!=NULL)
  4149. {
  4150. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  4151. }
  4152. sleep(5);
  4153. return FAIL;
  4154. }
  4155. return PASS;
  4156. }
  4157. //---------------------common routine---------------------------//
  4158. void checkNetworkProfile(void)
  4159. {
  4160. uint8_t isGetProfile = FALSE;
  4161. json_object *priority;
  4162. priority = json_tokener_parse((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value);
  4163. if(!is_error(priority))
  4164. {
  4165. for(uint8_t idxPriority=0;idxPriority<json_object_array_length(priority);idxPriority++)
  4166. {
  4167. for(uint8_t idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile);idx++)
  4168. {
  4169. if((ShmOCPP20Data->NetworkConnectionProfile[idx].slot == json_object_get_int(json_object_array_get_idx(priority, idxPriority))) &&
  4170. (strlen((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl) > 0) &&
  4171. (ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount < 3))
  4172. {
  4173. memcpy(ShmOCPP20Data->OcppServerURL, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  4174. memcpy(ShmSysConfigAndInfo->SysConfig.OcppServerURL, ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl));
  4175. isGetProfile = TRUE;
  4176. ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount++;
  4177. break;
  4178. }
  4179. }
  4180. }
  4181. }
  4182. json_object_put(priority);
  4183. if(!isGetProfile && (strlen((char*)ShmOCPP20Data->OcppServerURL) > 0))
  4184. {
  4185. memcpy(ShmSysConfigAndInfo->SysConfig.OcppServerURL, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  4186. }
  4187. DEBUG_INFO("Get network profile URL: %s\n", ShmSysConfigAndInfo->SysConfig.OcppServerURL);
  4188. }
  4189. void CheckSystemValue(void)
  4190. {
  4191. char filenmae[100]={0};
  4192. char str[100]={0};
  4193. int tempIndex = 0;
  4194. //===============================
  4195. // EVSE operation check
  4196. //===============================
  4197. //===============================
  4198. // Heartbeat check
  4199. //===============================
  4200. if((difftime(time((time_t*)NULL), clientTime.Heartbeat) < 0) || (HeartBeatWaitTime <= 0))
  4201. {
  4202. clientTime.Heartbeat = time((time_t*)NULL);
  4203. if(server_sign == TRUE)
  4204. {
  4205. HeartBeatWaitTime = ShmOCPP20Data->BootNotification.Response_interval;
  4206. }
  4207. else
  4208. {
  4209. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);
  4210. }
  4211. }
  4212. if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  4213. {
  4214. //parameter for test
  4215. sendHeartbeatRequest(0);
  4216. //==============================================
  4217. // Reset Waiting Time
  4218. //==============================================
  4219. HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
  4220. }
  4221. //===============================
  4222. // CSU Trigger Reset Conf
  4223. //===============================
  4224. if(isWebsocketSendable && (ShmOCPP20Data->MsMsg.bits.ResetConf == ON))
  4225. {
  4226. sendResetConfirmation((char *)ShmOCPP20Data->Reset.guid);
  4227. }
  4228. //===============================
  4229. // CSU Trigger Authorize Request
  4230. //===============================
  4231. if(isWebsocketSendable &&
  4232. (server_sign == TRUE) &&
  4233. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4234. (authorizeRetryTimes < 3))
  4235. {
  4236. sendAuthorizeRequest(0);
  4237. authorizeRetryTimes = authorizeRetryTimes + 1;
  4238. if(authorizeRetryTimes < 3)
  4239. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4240. }
  4241. else if((server_sign == TRUE) &&
  4242. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4243. (authorizeRetryTimes >= 3))
  4244. {
  4245. authorizeRetryTimes = 0;
  4246. SetOcppConnStatus(FALSE);
  4247. server_sign = FALSE;
  4248. }
  4249. else if((server_sign == FALSE) &&
  4250. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  4251. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  4252. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  4253. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  4254. {
  4255. sendAuthorizeRequest(0);
  4256. }
  4257. //===============================
  4258. // Each connector operation check
  4259. //===============================
  4260. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  4261. {
  4262. //==========================================
  4263. // csu trigger DataTransferReq
  4264. //==========================================
  4265. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  4266. {
  4267. sendDataTransferRequest(gun_index);
  4268. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  4269. }
  4270. //===============================
  4271. // CSU Trigger Smart Charging Profilw
  4272. //===============================
  4273. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  4274. {
  4275. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index]);
  4276. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  4277. }
  4278. //==============================================
  4279. // Charger start transaction
  4280. //==============================================
  4281. /*
  4282. if((ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq == ON))
  4283. {
  4284. ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq = OFF;
  4285. sendStartTransactionRequest(gun_index);
  4286. clientTime.StartTransaction = time((time_t*)NULL);
  4287. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4288. }*/
  4289. //==============================================
  4290. // Charger stop transaction
  4291. //==============================================
  4292. /*
  4293. if(((ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq == ON)))
  4294. {
  4295. ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq =OFF;
  4296. sendStopTransactionRequest(gun_index);
  4297. clientTime.StopTransaction = time((time_t*)NULL);
  4298. }*/
  4299. //==============================================
  4300. // Charger status notification & Transaction event report
  4301. //==============================================
  4302. //--- Check Mode Change ---//
  4303. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  4304. if(gunType[gun_index] == 'J')
  4305. {
  4306. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4307. {
  4308. tempIndex = ((gun_index==2) ? 1: 0);
  4309. }
  4310. else
  4311. {
  4312. tempIndex = gun_index;
  4313. }
  4314. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4315. {
  4316. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4317. {
  4318. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  4319. {
  4320. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  4321. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  4322. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4323. if(SystemInitial == 0)
  4324. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4325. }
  4326. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4327. {
  4328. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4329. if((access(filenmae,F_OK))!=-1)
  4330. {
  4331. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4332. sprintf(str,"rm -f %s",filenmae);
  4333. system(str);
  4334. }
  4335. }
  4336. #if 1 // for TempStopTransaction
  4337. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4338. {
  4339. checkTempStopTransaction(gun_index);
  4340. }
  4341. #endif
  4342. }
  4343. }
  4344. }
  4345. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4346. {
  4347. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4348. {
  4349. tempIndex = ((gun_index==2) ? 1: 0);
  4350. }
  4351. else
  4352. {
  4353. tempIndex = gun_index;
  4354. }
  4355. for (int index = 0; index < CCS_QUANTITY; index++)
  4356. {
  4357. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4358. {
  4359. if((SystemInitial > 0) || (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]*/ )
  4360. {
  4361. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  4362. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  4363. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4364. if(SystemInitial == 0)
  4365. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4366. }
  4367. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4368. {
  4369. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4370. if((access(filenmae,F_OK))!=-1)
  4371. {
  4372. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4373. sprintf(str,"rm -f %s",filenmae);
  4374. system(str);
  4375. }
  4376. }
  4377. #if 1 // for TempStopTransaction
  4378. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4379. {
  4380. checkTempStopTransaction(gun_index);
  4381. }
  4382. #endif
  4383. }
  4384. }
  4385. }
  4386. else if(gunType[gun_index] == 'G')
  4387. {
  4388. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4389. {
  4390. tempIndex = ((gun_index==2) ? 1: 0);
  4391. }
  4392. else
  4393. {
  4394. tempIndex = gun_index;
  4395. }
  4396. for (int index = 0; index < GB_QUANTITY; index++)
  4397. {
  4398. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4399. {
  4400. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  4401. {
  4402. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  4403. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  4404. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4405. if(SystemInitial == 0)
  4406. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4407. }
  4408. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4409. {
  4410. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4411. if((access(filenmae,F_OK))!=-1)
  4412. {
  4413. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4414. sprintf(str,"rm -f %s",filenmae);
  4415. system(str);
  4416. }
  4417. }
  4418. #if 1 // for TempStopTransaction
  4419. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4420. {
  4421. checkTempStopTransaction(gun_index);
  4422. }
  4423. #endif
  4424. }
  4425. }
  4426. }
  4427. else if(gunType[gun_index] == 'O')
  4428. {
  4429. tempIndex = gun_index;
  4430. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4431. {
  4432. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4433. {
  4434. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  4435. {
  4436. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  4437. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  4438. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4439. if(SystemInitial == 0)
  4440. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4441. }
  4442. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // complete
  4443. {
  4444. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4445. if((access(filenmae,F_OK))!=-1)
  4446. {
  4447. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4448. sprintf(str,"rm -f %s",filenmae);
  4449. system(str);
  4450. }
  4451. }
  4452. #if 1 // for TempStopTransaction
  4453. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4454. {
  4455. checkTempStopTransaction(gun_index);
  4456. }
  4457. #endif
  4458. }
  4459. }
  4460. }
  4461. else
  4462. {
  4463. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4464. {
  4465. tempIndex = 2;
  4466. }
  4467. else
  4468. {
  4469. tempIndex = gun_index;
  4470. }
  4471. for (int index = 0; index < AC_QUANTITY; index++)
  4472. {
  4473. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4474. {
  4475. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  4476. {
  4477. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  4478. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  4479. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4480. if(SystemInitial == 0)
  4481. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4482. }
  4483. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4484. {
  4485. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4486. if((access(filenmae,F_OK))!=-1)
  4487. {
  4488. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4489. sprintf(str,"rm -f %s",filenmae);
  4490. system(str);
  4491. }
  4492. }
  4493. #if 1 // for TempStopTransaction
  4494. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4495. {
  4496. checkTempStopTransaction(gun_index);
  4497. }
  4498. #endif
  4499. }
  4500. }// END
  4501. }
  4502. if(isWebsocketSendable &&
  4503. (cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) &&
  4504. ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 10) )
  4505. {
  4506. if(SystemInitial > 0)
  4507. SystemInitial -= 1;
  4508. sendStatusNotificationRequest(gun_index);
  4509. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  4510. }
  4511. if(isWebsocketSendable && (server_sign == TRUE) && (cpinitateMsg.bits[gun_index].TransactionEventReq == ON))
  4512. {
  4513. sendTransactionEventRequest(gun_index);
  4514. cpinitateMsg.bits[gun_index].TransactionEventReq = OFF;
  4515. }
  4516. //==============================================
  4517. // Meter report
  4518. //==============================================
  4519. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  4520. {
  4521. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  4522. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  4523. }
  4524. // ClockAlign MeterValue
  4525. if(isWebsocketSendable && (server_sign == TRUE) && ((atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value) > 0)?((getTimePassSinceToday()%(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value)))==0):FALSE))
  4526. {
  4527. //check Transaction active
  4528. if(gunType[gun_index] == 'J')
  4529. {
  4530. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4531. {
  4532. tempIndex = ((gun_index==2) ? 1: 0);
  4533. }
  4534. else
  4535. {
  4536. tempIndex = gun_index;
  4537. }
  4538. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4539. {
  4540. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4541. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4542. {
  4543. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4544. {
  4545. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4546. }
  4547. }
  4548. }// End for CHAdeMO
  4549. }
  4550. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4551. {
  4552. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4553. {
  4554. tempIndex = ((gun_index==2) ? 1: 0);
  4555. }
  4556. else
  4557. {
  4558. tempIndex = gun_index;
  4559. }
  4560. for (int index = 0; index < CCS_QUANTITY; index++)
  4561. {
  4562. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4563. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4564. {
  4565. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4566. {
  4567. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4568. }
  4569. }
  4570. } // End for CCS
  4571. }
  4572. else if(gunType[gun_index] == 'G')
  4573. {
  4574. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4575. {
  4576. tempIndex = ((gun_index==2) ? 1: 0);
  4577. }
  4578. else
  4579. {
  4580. tempIndex = gun_index;
  4581. }
  4582. for (int index = 0; index < GB_QUANTITY; index++)
  4583. {
  4584. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4585. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4586. {
  4587. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4588. {
  4589. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4590. }
  4591. }
  4592. }// End for GB
  4593. }
  4594. else if(gunType[gun_index] == 'O')
  4595. {
  4596. tempIndex = gun_index;
  4597. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4598. {
  4599. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4600. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4601. {
  4602. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_CHARGING)
  4603. {
  4604. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4605. }
  4606. }
  4607. }
  4608. }
  4609. else
  4610. {
  4611. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4612. {
  4613. tempIndex = 2;
  4614. }
  4615. else
  4616. {
  4617. tempIndex = gun_index;
  4618. }
  4619. for (int index = 0; index < AC_QUANTITY; index++)
  4620. {
  4621. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4622. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4623. {
  4624. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4625. {
  4626. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4627. }
  4628. }
  4629. }//End for AC
  4630. }
  4631. if(cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON)
  4632. {
  4633. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  4634. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  4635. }
  4636. }
  4637. // Sample period MeterValue
  4638. if(((time((time_t*)NULL) - clientTime.MeterValues[gun_index]) > (atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1)))
  4639. {
  4640. //check Transaction active
  4641. if(gunType[gun_index] == 'J')
  4642. {
  4643. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4644. {
  4645. tempIndex = ((gun_index==2) ? 1: 0);
  4646. }
  4647. else
  4648. {
  4649. tempIndex = gun_index;
  4650. }
  4651. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4652. {
  4653. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4654. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4655. {
  4656. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4657. {
  4658. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4659. }
  4660. }
  4661. }// End for CHAdeMO
  4662. }
  4663. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4664. {
  4665. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4666. {
  4667. tempIndex = ((gun_index==2) ? 1: 0);
  4668. }
  4669. else
  4670. {
  4671. tempIndex = gun_index;
  4672. }
  4673. for (int index = 0; index < CCS_QUANTITY; index++)
  4674. {
  4675. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4676. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4677. {
  4678. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4679. {
  4680. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4681. }
  4682. }
  4683. } // End for CCS
  4684. }
  4685. else if(gunType[gun_index] == 'G')
  4686. {
  4687. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4688. {
  4689. tempIndex = ((gun_index==2) ? 1: 0);
  4690. }
  4691. else
  4692. {
  4693. tempIndex = gun_index;
  4694. }
  4695. for (int index = 0; index < GB_QUANTITY; index++)
  4696. {
  4697. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4698. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4699. {
  4700. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4701. {
  4702. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4703. }
  4704. }
  4705. }// End for GB
  4706. }
  4707. else if(gunType[gun_index] == 'O')
  4708. {
  4709. tempIndex = gun_index;
  4710. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4711. {
  4712. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4713. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4714. {
  4715. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  4716. {
  4717. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4718. }
  4719. }
  4720. }
  4721. }
  4722. else
  4723. {
  4724. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4725. {
  4726. tempIndex = 2;
  4727. }
  4728. else
  4729. {
  4730. tempIndex = gun_index;
  4731. }
  4732. for (int index = 0; index < AC_QUANTITY; index++)
  4733. {
  4734. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4735. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4736. {
  4737. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4738. {
  4739. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4740. }
  4741. }
  4742. }//End for AC
  4743. }
  4744. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  4745. {
  4746. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  4747. storeTempStopTransaction(gun_index);
  4748. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  4749. }
  4750. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4751. }
  4752. //==============================================
  4753. // Check Connector reserved
  4754. //==============================================
  4755. //===============================
  4756. // Check if Reserve is expired
  4757. //===============================
  4758. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0) )
  4759. {
  4760. double diff_t;
  4761. struct tm tp;
  4762. // current time
  4763. time_t t = time(NULL);
  4764. strptime((char *)ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime, "%Y-%m-%dT%H:%M:%S", &tp);
  4765. tp.tm_isdst = -1;
  4766. time_t utc = mktime(&tp);
  4767. diff_t = difftime(utc, t);
  4768. if(diff_t <= 0)
  4769. {
  4770. DEBUG_INFO("reserve expired.\n");
  4771. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  4772. }
  4773. }//END OF Check if Reserve is expired
  4774. //==========================================
  4775. // csu trigger FirmwareStatusNotificationReq
  4776. //==========================================
  4777. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  4778. {
  4779. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  4780. }
  4781. //==========================================
  4782. // csu trigger CancelReservationConf
  4783. //==========================================
  4784. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  4785. {
  4786. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  4787. }
  4788. //==========================================
  4789. // csu trigger ChangeAvailabilityConf
  4790. //==========================================
  4791. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  4792. {
  4793. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  4794. }
  4795. //==========================================
  4796. // csu trigger UnlockConnectorConf
  4797. //==========================================
  4798. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  4799. {
  4800. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  4801. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  4802. }
  4803. //==========================================
  4804. // csu trigger ReserveNowConf
  4805. //==========================================
  4806. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  4807. {
  4808. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  4809. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  4810. }
  4811. }
  4812. }
  4813. //==========================================
  4814. // send request routine
  4815. //==========================================
  4816. int sendAuthorizeRequest(int gun_index)
  4817. {
  4818. mtrace();
  4819. int result = FAIL;
  4820. char message[4096]={0};
  4821. char guid[37];
  4822. char tempdata[128]={0};
  4823. json_object *Authorize = json_object_new_object();
  4824. json_object *idToken = json_object_new_object();
  4825. DEBUG_INFO("sendAuthorizeRequest...\n");
  4826. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  4827. //Local Authorize
  4828. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) &&(ShmOCPP20Data->OcppConnStatus == 0))
  4829. {
  4830. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  4831. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4832. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  4833. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  4834. result = PASS;
  4835. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4836. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4837. authorizeRetryTimes = 0;
  4838. return result;
  4839. }
  4840. 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))||
  4841. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  4842. {
  4843. // Query idtag from cache
  4844. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  4845. // Query idtag from list
  4846. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4847. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  4848. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4849. {
  4850. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  4851. {
  4852. DEBUG_INFO("offline Local Authorization Fail !!!!, Card %s is blank!!!!\n", idTagQuery.idToken.idToken);
  4853. }
  4854. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  4855. {
  4856. DEBUG_INFO("offline Local Authorization Fail !!!!, Card %s is not Accepted!!!!\n", idTagQuery.idToken.idToken);
  4857. }
  4858. DEBUG_INFO("offline Local Authorization Fail !!!!\n");
  4859. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4860. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4861. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  4862. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4863. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4864. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4865. authorizeRetryTimes = 0;
  4866. return result;
  4867. }
  4868. else
  4869. {
  4870. DEBUG_INFO("offline Local Authorization get result !!!!\n");
  4871. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  4872. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4873. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  4874. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  4875. else
  4876. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  4877. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4878. result = PASS;
  4879. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4880. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4881. authorizeRetryTimes = 0;
  4882. return result;
  4883. }
  4884. }
  4885. //initialize struct Authorize
  4886. memset(&(ShmOCPP20Data->Authorize), 0 , sizeof(struct StructAuthorize));
  4887. //get data from shared memory
  4888. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4889. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  4890. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  4891. json_object_object_add(Authorize, "idToken", idToken);
  4892. random_uuid(guid);
  4893. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  4894. json_object_put(Authorize);
  4895. LWS_Send(message);
  4896. sprintf(tempdata, "Authorize,%d", gun_index);
  4897. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4898. {
  4899. result = PASS;
  4900. }
  4901. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4902. return result;
  4903. }
  4904. int sendBootNotificationRequest()
  4905. {
  4906. mtrace();
  4907. int result = FAIL;
  4908. char message[4096]={0};
  4909. char guid[37]={0};
  4910. char tempdata[128]={0};
  4911. json_object *BootNotification = json_object_new_object();
  4912. json_object *chargingStation = json_object_new_object();
  4913. json_object *modem = json_object_new_object();
  4914. // Fill BootNotification fields
  4915. DB_getBooType();
  4916. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  4917. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  4918. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  4919. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  4920. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  4921. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  4922. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  4923. {
  4924. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  4925. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  4926. json_object_object_add(chargingStation, "modem", modem);
  4927. }
  4928. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  4929. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  4930. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  4931. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  4932. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  4933. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  4934. random_uuid(guid);
  4935. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  4936. json_object_put(BootNotification);
  4937. LWS_Send(message);
  4938. sprintf(tempdata, "BootNotification,0");
  4939. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4940. {
  4941. result = PASS;
  4942. }
  4943. return result;
  4944. }
  4945. int sendClearedChargingLimitRequest(int gun_index)
  4946. {
  4947. mtrace();
  4948. int result = FAIL;
  4949. char message[4096]={0};
  4950. char guid[37]={0};
  4951. char tempdata[128]={0};
  4952. json_object *ClearedChargingLimit = json_object_new_object();
  4953. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  4954. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  4955. random_uuid(guid);
  4956. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  4957. json_object_put(ClearedChargingLimit);
  4958. LWS_Send(message);
  4959. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  4960. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4961. {
  4962. result = PASS;
  4963. }
  4964. return result;
  4965. }
  4966. int sendDataTransferRequest(int gun_index)
  4967. {
  4968. mtrace();
  4969. char message[1000]={0};
  4970. char guid[37]={0};
  4971. char tempdata[65]={0};
  4972. int result = FAIL;
  4973. random_uuid(guid);
  4974. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  4975. MESSAGE_TYPE_CALL,
  4976. guid,
  4977. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  4978. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  4979. ShmOCPP20Data->DataTransfer[gun_index].data);
  4980. LWS_Send(message);
  4981. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  4982. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4983. {
  4984. result = PASS;
  4985. }
  4986. return result;
  4987. }
  4988. int sendFirmwareStatusNotificationRequest(char *status)
  4989. {
  4990. mtrace();
  4991. int result = FAIL;
  4992. char message[110]={0};
  4993. char guid[37]={0};
  4994. char tempdata[65]={0};
  4995. json_object *FirmwareStatusNotification = json_object_new_object();
  4996. DEBUG_INFO("sendFirmwareStatusNotificationRequest \n");
  4997. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  4998. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  4999. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  5000. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  5001. random_uuid(guid);
  5002. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  5003. json_object_put(FirmwareStatusNotification);
  5004. LWS_SendNow(message);
  5005. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  5006. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5007. {
  5008. result = PASS;
  5009. }
  5010. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  5011. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  5012. //record status
  5013. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  5014. {
  5015. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  5016. }
  5017. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  5018. {
  5019. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  5020. }
  5021. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  5022. {
  5023. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  5024. }
  5025. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  5026. {
  5027. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  5028. }
  5029. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  5030. {
  5031. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  5032. }
  5033. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  5034. {
  5035. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  5036. }
  5037. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  5038. {
  5039. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  5040. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5041. }
  5042. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  5043. {
  5044. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  5045. }
  5046. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  5047. {
  5048. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  5049. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5050. }
  5051. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  5052. {
  5053. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  5054. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5055. }
  5056. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  5057. {
  5058. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  5059. }
  5060. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  5061. {
  5062. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  5063. }
  5064. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  5065. {
  5066. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  5067. }
  5068. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  5069. {
  5070. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  5071. }
  5072. return result;
  5073. }
  5074. int sendGet15118EVCertificateRequest()
  5075. {
  5076. mtrace();
  5077. int result = FAIL;
  5078. char message[4096]={0};
  5079. char guid[37]={0};
  5080. char tempdata[128]={0};
  5081. json_object *Get15118EVCertificate = json_object_new_object();
  5082. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  5083. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  5084. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  5085. random_uuid(guid);
  5086. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  5087. json_object_put(Get15118EVCertificate);
  5088. LWS_Send(message);
  5089. sprintf(tempdata, "Get15118EVCertificate,0");
  5090. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5091. {
  5092. result = PASS;
  5093. }
  5094. return result;
  5095. }
  5096. int sendGetCertificateStatusRequest()
  5097. {
  5098. mtrace();
  5099. int result = FAIL;
  5100. char message[4096]={0};
  5101. char guid[37]={0};
  5102. char tempdata[128]={0};
  5103. json_object *GetCertificateStatus = json_object_new_object();
  5104. json_object *ocspRequestData = json_object_new_object();
  5105. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  5106. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  5107. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  5108. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  5109. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  5110. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  5111. random_uuid(guid);
  5112. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  5113. json_object_put(GetCertificateStatus);
  5114. LWS_Send(message);
  5115. sprintf(tempdata, "GetCertificateStatus,0");
  5116. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5117. {
  5118. result = PASS;
  5119. }
  5120. return result;
  5121. }
  5122. int sendHeartbeatRequest()
  5123. {
  5124. mtrace();
  5125. int result = FAIL;
  5126. char message[40096]={0};
  5127. char guid[37]={0};
  5128. char tempdata[128]={0};
  5129. random_uuid(guid);
  5130. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  5131. , MESSAGE_TYPE_CALL
  5132. , guid );
  5133. LWS_Send(message);
  5134. sprintf(tempdata, "Heartbeat,%d", 0);
  5135. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5136. {
  5137. result = PASS;
  5138. }
  5139. return result;
  5140. }
  5141. int sendLogStatusNotificationRequest(char *status)
  5142. {
  5143. mtrace();
  5144. int result = FAIL;
  5145. char message[4096]={0};
  5146. char guid[37]={0};
  5147. char tempdata[128]={0};
  5148. json_object *LogStatusNotification = json_object_new_object();
  5149. DEBUG_INFO("sendLogStatusNotificationRequest \n");
  5150. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  5151. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  5152. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  5153. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  5154. random_uuid(guid);
  5155. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  5156. json_object_put(LogStatusNotification);
  5157. LWS_SendNow(message);
  5158. sprintf(tempdata, "LogStatusNotification,%d", 0);
  5159. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5160. {
  5161. result = PASS;
  5162. }
  5163. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  5164. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  5165. //record status
  5166. if(strcmp(status,"BadMessage")==0)
  5167. {
  5168. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  5169. }
  5170. else if(strcmp(status,"Idle")==0)
  5171. {
  5172. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  5173. }
  5174. else if(strcmp(status,"NotSupportedOperation")==0)
  5175. {
  5176. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  5177. }
  5178. else if(strcmp(status,"PermissionDenied")==0)
  5179. {
  5180. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  5181. }
  5182. else if(strcmp(status,"Uploaded")==0)
  5183. {
  5184. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  5185. }
  5186. else if(strcmp(status,"UploadFailure")==0)
  5187. {
  5188. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  5189. }
  5190. else if(strcmp(status,"Uploading")==0)
  5191. {
  5192. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  5193. }
  5194. return result;
  5195. }
  5196. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  5197. {
  5198. mtrace();
  5199. int result = FAIL;
  5200. char guid[37]={0};
  5201. char tempdata[65]={0};
  5202. int tempIndex = 0;
  5203. json_object *MeterValueReq = json_object_new_object();
  5204. json_object *meterValues = json_object_new_array();
  5205. json_object *meterValue = json_object_new_object();
  5206. json_object *sampledValues = json_object_new_array();
  5207. json_object *sampledValue = json_object_new_object();
  5208. json_object *unitOfMeasure = json_object_new_object();
  5209. DEBUG_INFO("sendMeterValuesRequest ...\n");
  5210. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  5211. //set value
  5212. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  5213. //UTC Date time
  5214. struct timeval tmnow;
  5215. struct tm *tm;
  5216. char buf[28];//, usec_buf[6];
  5217. gettimeofday(&tmnow, NULL);
  5218. time_t t;
  5219. t = time(NULL);
  5220. /*UTC time and date*/
  5221. tm = gmtime(&t);
  5222. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  5223. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  5224. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  5225. //idx_sample=0;
  5226. //********************************(1)Current.Import L1************************************************/
  5227. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5228. if(gunType[gun_index] == 'J')
  5229. {
  5230. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5231. {
  5232. tempIndex = ((gun_index==2) ? 1: 0);
  5233. }
  5234. else
  5235. {
  5236. tempIndex = gun_index;
  5237. }
  5238. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5239. {
  5240. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5241. {
  5242. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent;
  5243. }
  5244. }
  5245. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5246. }
  5247. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5248. {
  5249. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5250. {
  5251. tempIndex = ((gun_index==2) ? 1: 0);
  5252. }
  5253. else
  5254. {
  5255. tempIndex = gun_index;
  5256. }
  5257. for (int index = 0; index < CCS_QUANTITY; index++)
  5258. {
  5259. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5260. {
  5261. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent;
  5262. }
  5263. }
  5264. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5265. }
  5266. else if(gunType[gun_index] == 'G')
  5267. {
  5268. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5269. {
  5270. tempIndex = ((gun_index==2) ? 1: 0);
  5271. }
  5272. else
  5273. {
  5274. tempIndex = gun_index;
  5275. }
  5276. for (int index = 0; index < GB_QUANTITY; index++)
  5277. {
  5278. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5279. {
  5280. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent;
  5281. }
  5282. }
  5283. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5284. }
  5285. else if(gunType[gun_index] == 'O')
  5286. {
  5287. tempIndex = gun_index;
  5288. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5289. {
  5290. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5291. {
  5292. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent;
  5293. }
  5294. }
  5295. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5296. }
  5297. else
  5298. {
  5299. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5300. {
  5301. tempIndex = 2;
  5302. }
  5303. else
  5304. {
  5305. tempIndex = gun_index;
  5306. }
  5307. for (int index = 0; index < AC_QUANTITY; index++)
  5308. {
  5309. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5310. {
  5311. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent;
  5312. }
  5313. }
  5314. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5315. }
  5316. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  5317. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5318. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5319. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  5320. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  5321. //idx_sample=1;
  5322. //********************************(2)Energy.Active.Import.Register ************************************************/
  5323. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5324. if(gunType[gun_index] == 'J')
  5325. {
  5326. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5327. {
  5328. tempIndex = ((gun_index==2) ? 1: 0);
  5329. }
  5330. else
  5331. {
  5332. tempIndex = gun_index;
  5333. }
  5334. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5335. {
  5336. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5337. {
  5338. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  5339. }
  5340. }
  5341. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5342. }
  5343. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5344. {
  5345. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5346. {
  5347. tempIndex = ((gun_index==2) ? 1: 0);
  5348. }
  5349. else
  5350. {
  5351. tempIndex = gun_index;
  5352. }
  5353. for (int index = 0; index < CCS_QUANTITY; index++)
  5354. {
  5355. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5356. {
  5357. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  5358. }
  5359. }
  5360. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5361. }
  5362. else if(gunType[gun_index] == 'G')
  5363. {
  5364. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5365. {
  5366. tempIndex = ((gun_index==2) ? 1: 0);
  5367. }
  5368. else
  5369. {
  5370. tempIndex = gun_index;
  5371. }
  5372. for (int index = 0; index < GB_QUANTITY; index++)
  5373. {
  5374. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5375. {
  5376. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  5377. }
  5378. }
  5379. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5380. }
  5381. else if(gunType[gun_index] == 'O')
  5382. {
  5383. tempIndex = gun_index;
  5384. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5385. {
  5386. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5387. {
  5388. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  5389. }
  5390. }
  5391. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5392. }
  5393. else
  5394. {
  5395. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5396. {
  5397. tempIndex = 2;
  5398. }
  5399. else
  5400. {
  5401. tempIndex = gun_index;
  5402. }
  5403. for (int index = 0; index < AC_QUANTITY; index++)
  5404. {
  5405. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5406. {
  5407. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  5408. }
  5409. }
  5410. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5411. }
  5412. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  5413. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  5414. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5415. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  5416. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5417. //idx_sample=2;
  5418. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  5419. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5420. if(gunType[gun_index] == 'J')
  5421. {
  5422. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5423. {
  5424. tempIndex = ((gun_index==2) ? 1: 0);
  5425. }
  5426. else
  5427. {
  5428. tempIndex = gun_index;
  5429. }
  5430. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5431. {
  5432. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5433. {
  5434. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
  5435. }
  5436. } // END OF FOR CHAdeMO_QUANTITY
  5437. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5438. }
  5439. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5440. {
  5441. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5442. {
  5443. tempIndex = ((gun_index==2) ? 1: 0);
  5444. }
  5445. else
  5446. {
  5447. tempIndex = gun_index;
  5448. }
  5449. for (int index = 0; index < CCS_QUANTITY; index++)
  5450. {
  5451. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5452. {
  5453. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
  5454. }
  5455. } // END OF CCS_QUANTITY
  5456. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5457. }
  5458. else if(gunType[gun_index] == 'G')
  5459. {
  5460. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5461. {
  5462. tempIndex = ((gun_index==2) ? 1: 0);
  5463. }
  5464. else
  5465. {
  5466. tempIndex = gun_index;
  5467. }
  5468. for (int index = 0; index < GB_QUANTITY; index++)
  5469. {
  5470. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5471. {
  5472. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
  5473. }
  5474. } // END OF GB_QUANTITY
  5475. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5476. }
  5477. else if(gunType[gun_index] == 'O')
  5478. {
  5479. tempIndex = gun_index;
  5480. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5481. {
  5482. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5483. {
  5484. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy;
  5485. }
  5486. }
  5487. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5488. }
  5489. else
  5490. {
  5491. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5492. {
  5493. tempIndex = 2;
  5494. }
  5495. else
  5496. {
  5497. tempIndex = gun_index;
  5498. }
  5499. for (int index = 0; index < AC_QUANTITY; index++)
  5500. {
  5501. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5502. {
  5503. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
  5504. }
  5505. }
  5506. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5507. }
  5508. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  5509. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  5510. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5511. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  5512. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5513. //idx_sample=3;
  5514. //********************************(4)Power.Active.Import************************************************/
  5515. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5516. if(gunType[gun_index] == 'J')
  5517. {
  5518. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5519. {
  5520. tempIndex = ((gun_index==2) ? 1: 0);
  5521. }
  5522. else
  5523. {
  5524. tempIndex = gun_index;
  5525. }
  5526. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5527. {
  5528. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5529. {
  5530. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower;
  5531. }
  5532. } // END OF FOR
  5533. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5534. }
  5535. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5536. {
  5537. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5538. {
  5539. tempIndex = ((gun_index==2) ? 1: 0);
  5540. }
  5541. else
  5542. {
  5543. tempIndex = gun_index;
  5544. }
  5545. for (int index = 0; index < CCS_QUANTITY; index++)
  5546. {
  5547. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5548. {
  5549. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower;
  5550. }
  5551. }
  5552. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5553. }
  5554. else if(gunType[gun_index] == 'G')
  5555. {
  5556. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5557. {
  5558. tempIndex = ((gun_index==2) ? 1: 0);
  5559. }
  5560. else
  5561. {
  5562. tempIndex = gun_index;
  5563. }
  5564. for (int index = 0; index < GB_QUANTITY; index++)
  5565. {
  5566. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5567. {
  5568. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5569. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower;
  5570. }
  5571. }
  5572. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5573. }
  5574. else if(gunType[gun_index] == 'O')
  5575. {
  5576. tempIndex = gun_index;
  5577. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5578. {
  5579. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5580. {
  5581. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5582. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower;
  5583. }
  5584. }
  5585. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5586. }
  5587. else
  5588. {
  5589. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5590. {
  5591. tempIndex = 2;
  5592. }
  5593. else
  5594. {
  5595. tempIndex = gun_index;
  5596. }
  5597. for (int index = 0; index < AC_QUANTITY; index++)
  5598. {
  5599. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5600. {
  5601. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower;
  5602. }
  5603. }
  5604. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5605. }
  5606. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  5607. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  5608. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5609. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  5610. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  5611. //idx_sample=4;
  5612. //***********************************************(5)VOLTAGE L1******************************************************/
  5613. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5614. if(gunType[gun_index] == 'J')
  5615. {
  5616. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5617. {
  5618. tempIndex = ((gun_index==2) ? 1: 0);
  5619. }
  5620. else
  5621. {
  5622. tempIndex = gun_index;
  5623. }
  5624. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5625. {
  5626. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5627. {
  5628. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage;
  5629. }
  5630. }
  5631. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5632. }
  5633. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5634. {
  5635. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5636. {
  5637. tempIndex = ((gun_index==2) ? 1: 0);
  5638. }
  5639. else
  5640. {
  5641. tempIndex = gun_index;
  5642. }
  5643. for (int index = 0; index < CCS_QUANTITY; index++)
  5644. {
  5645. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5646. {
  5647. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage;
  5648. }
  5649. }
  5650. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5651. }
  5652. else if(gunType[gun_index] == 'G')
  5653. {
  5654. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5655. {
  5656. tempIndex = ((gun_index==2) ? 1: 0);
  5657. }
  5658. else
  5659. {
  5660. tempIndex = gun_index;
  5661. }
  5662. for (int index = 0; index < GB_QUANTITY; index++)
  5663. {
  5664. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5665. {
  5666. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage;
  5667. }
  5668. }
  5669. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5670. }
  5671. else if(gunType[gun_index] == 'O')
  5672. {
  5673. tempIndex = gun_index;
  5674. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5675. {
  5676. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5677. {
  5678. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage;
  5679. }
  5680. }
  5681. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5682. }
  5683. else
  5684. {
  5685. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5686. {
  5687. tempIndex = 2;
  5688. }
  5689. else
  5690. {
  5691. tempIndex = gun_index;
  5692. }
  5693. for (int index = 0; index < AC_QUANTITY; index++)
  5694. {
  5695. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5696. {
  5697. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage;
  5698. }
  5699. }
  5700. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5701. }
  5702. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  5703. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5704. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5705. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  5706. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  5707. //***********************************************(6)SOC******************************************************/
  5708. if((gunType[gun_index] == 'J')||(gunType[gun_index] == 'U')||(gunType[gun_index] == 'E')||(gunType[gun_index] == 'G'))
  5709. {
  5710. //idx_sample=5;
  5711. //sampledValue = NULL;
  5712. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5713. {
  5714. tempIndex = ((gun_index==2) ? 1: 0);
  5715. }
  5716. else
  5717. {
  5718. tempIndex = gun_index;
  5719. }
  5720. if(gunType[gun_index] == 'J')
  5721. {
  5722. //tempIndex = ((gun_index==2) ? 1: 0);
  5723. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5724. {
  5725. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5726. {
  5727. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  5728. }
  5729. }
  5730. }
  5731. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5732. {
  5733. //tempIndex = ((gun_index==2) ? 1: 0);
  5734. for (int index = 0; index < CCS_QUANTITY; index++)
  5735. {
  5736. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5737. {
  5738. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  5739. }
  5740. }
  5741. }
  5742. else if(gunType[gun_index] == 'G')
  5743. {
  5744. //tempIndex = ((gun_index==2) ? 1: 0);
  5745. for (int index = 0; index < GB_QUANTITY; index++)
  5746. {
  5747. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5748. {
  5749. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  5750. }
  5751. }
  5752. }
  5753. else if(gunType[gun_index] == 'O')
  5754. {
  5755. //tempIndex = ((gun_index==2) ? 1: 0);
  5756. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5757. {
  5758. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5759. {
  5760. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  5761. }
  5762. }
  5763. }
  5764. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  5765. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  5766. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5767. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  5768. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  5769. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  5770. }
  5771. //********************************(7)Current.Import L2************************************************/
  5772. // Only for AC 3 phase
  5773. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5774. {
  5775. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5776. {
  5777. tempIndex = 2;
  5778. }
  5779. else
  5780. {
  5781. tempIndex = gun_index;
  5782. }
  5783. for (int index = 0; index < AC_QUANTITY; index++)
  5784. {
  5785. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5786. {
  5787. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2;
  5788. }
  5789. }
  5790. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5791. }
  5792. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  5793. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5794. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5795. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  5796. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  5797. //********************************(8)Current.Import L3************************************************/
  5798. // Only for AC 3 phase
  5799. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5800. {
  5801. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5802. {
  5803. tempIndex = 2;
  5804. }
  5805. else
  5806. {
  5807. tempIndex = gun_index;
  5808. }
  5809. for (int index = 0; index < AC_QUANTITY; index++)
  5810. {
  5811. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5812. {
  5813. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3;
  5814. }
  5815. }
  5816. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5817. }
  5818. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  5819. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5820. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5821. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  5822. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  5823. //***********************************************(9)VOLTAGE L2******************************************************/
  5824. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5825. {
  5826. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5827. {
  5828. tempIndex = 2;
  5829. }
  5830. else
  5831. {
  5832. tempIndex = gun_index;
  5833. }
  5834. for (int index = 0; index < AC_QUANTITY; index++)
  5835. {
  5836. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5837. {
  5838. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2;
  5839. }
  5840. }
  5841. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5842. }
  5843. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  5844. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5845. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5846. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  5847. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  5848. //***********************************************(10)VOLTAGE L3******************************************************/
  5849. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5850. {
  5851. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5852. {
  5853. tempIndex = 2;
  5854. }
  5855. else
  5856. {
  5857. tempIndex = gun_index;
  5858. }
  5859. for (int index = 0; index < AC_QUANTITY; index++)
  5860. {
  5861. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5862. {
  5863. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3;
  5864. }
  5865. }
  5866. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5867. }
  5868. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  5869. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5870. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5871. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  5872. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  5873. // Message create ====================================================================================================
  5874. random_uuid(guid);
  5875. uint8_t idxMeter = 0;
  5876. while(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp) > 0)
  5877. {
  5878. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  5879. {
  5880. if(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value > 0)
  5881. {
  5882. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  5883. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  5884. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  5885. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  5886. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  5887. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  5888. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  5889. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  5890. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  5891. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  5892. {
  5893. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  5894. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  5895. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  5896. }
  5897. json_object_array_add(sampledValues, sampledValue);
  5898. }
  5899. }
  5900. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  5901. json_object_object_add(meterValue, "sampledValue", sampledValues);
  5902. json_object_array_add(meterValues, meterValue);
  5903. idxMeter++;
  5904. }
  5905. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  5906. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  5907. sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",%s]"
  5908. ,gun_index + 1
  5909. ,MESSAGE_TYPE_CALL
  5910. ,guid
  5911. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  5912. json_object_put(MeterValueReq);
  5913. // Put request guid to hash map
  5914. sprintf(tempdata, "MeterValues,%d", (gun_index));
  5915. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5916. {
  5917. result = PASS;
  5918. }
  5919. if((dataType != ReadingContextEnumType_Trigger) &&
  5920. (dataType != ReadingContextEnumType_Sample_Clock))
  5921. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  5922. else
  5923. {
  5924. if(FirstHeartBeat)
  5925. LWS_Send(queuedata +2);
  5926. }
  5927. return result;
  5928. }
  5929. int sendNotifyChargingLimitRequest(int gun_index)
  5930. {
  5931. mtrace();
  5932. int result = FAIL;
  5933. char message[4096]={0};
  5934. char guid[37]={0};
  5935. char tempdata[128]={0};
  5936. json_object *NotifyChargingLimit = json_object_new_object();
  5937. json_object *chargingLimit = json_object_new_object();
  5938. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  5939. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  5940. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  5941. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  5942. random_uuid(guid);
  5943. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  5944. json_object_put(NotifyChargingLimit);
  5945. LWS_Send(message);
  5946. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  5947. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5948. {
  5949. result = PASS;
  5950. }
  5951. return result;
  5952. }
  5953. int sendNotifyCustomerInformationRequest()
  5954. {
  5955. mtrace();
  5956. int result = FAIL;
  5957. char message[4096]={0};
  5958. char guid[37]={0};
  5959. char tempdata[128]={0};
  5960. json_object *NotifyCustomerInformation = json_object_new_object();
  5961. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  5962. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  5963. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  5964. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  5965. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  5966. random_uuid(guid);
  5967. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  5968. json_object_put(NotifyCustomerInformation);
  5969. LWS_Send(message);
  5970. sprintf(tempdata, "NotifyCustomerInformation,0");
  5971. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5972. {
  5973. result = PASS;
  5974. }
  5975. return result;
  5976. }
  5977. int sendNotifyDisplayMessagesRequest()
  5978. {
  5979. mtrace();
  5980. int result = FAIL;
  5981. char message[4096]={0};
  5982. char guid[37]={0};
  5983. char tempdata[128]={0};
  5984. json_object *NotifyDisplayMessages = json_object_new_object();
  5985. json_object *messageInfos = json_object_new_array();
  5986. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  5987. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  5988. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  5989. {
  5990. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  5991. {
  5992. json_object *messageInfo = json_object_new_object();
  5993. json_object *message = json_object_new_object();
  5994. json_object *display = json_object_new_object();
  5995. json_object *evse = json_object_new_object();
  5996. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  5997. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  5998. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  5999. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  6000. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  6001. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  6002. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  6003. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  6004. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  6005. json_object_object_add(messageInfo, "message", message);
  6006. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  6007. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  6008. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  6009. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  6010. json_object_object_add(display, "evse",evse);
  6011. json_object_object_add(messageInfo, "evse", display);
  6012. json_object_array_add(messageInfos, messageInfo);
  6013. }
  6014. }
  6015. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  6016. random_uuid(guid);
  6017. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  6018. json_object_put(NotifyDisplayMessages);
  6019. LWS_Send(message);
  6020. sprintf(tempdata, "NotifyDisplayMessages,0");
  6021. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6022. {
  6023. result = PASS;
  6024. }
  6025. return result;
  6026. }
  6027. int sendNotifyEVChargingNeedsRequest(int gun_index)
  6028. {
  6029. mtrace();
  6030. int result = FAIL;
  6031. char message[4096]={0};
  6032. char guid[37]={0};
  6033. char tempdata[128]={0};
  6034. json_object *NotifyEVChargingNeeds = json_object_new_object();
  6035. json_object *chargingNeeds = json_object_new_object();
  6036. json_object *acChargingParameters = json_object_new_object();
  6037. json_object *dcChargingParameters = json_object_new_object();
  6038. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  6039. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  6040. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  6041. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  6042. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  6043. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  6044. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  6045. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  6046. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  6047. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  6048. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  6049. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  6050. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  6051. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  6052. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  6053. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  6054. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  6055. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  6056. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  6057. random_uuid(guid);
  6058. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  6059. json_object_put(NotifyEVChargingNeeds);
  6060. LWS_Send(message);
  6061. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  6062. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6063. {
  6064. result = PASS;
  6065. }
  6066. return result;
  6067. }
  6068. int sendNotifyEVChargingScheduleRequest(int gun_index)
  6069. {
  6070. mtrace();
  6071. int result = FAIL;
  6072. char message[4096]={0};
  6073. char guid[37]={0};
  6074. char tempdata[128]={0};
  6075. json_object *NotifyEVChargingSchedule = json_object_new_object();
  6076. json_object *chargingSchedule = json_object_new_object();
  6077. json_object *periods = json_object_new_array();
  6078. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  6079. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  6080. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  6081. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  6082. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  6083. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  6084. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  6085. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  6086. {
  6087. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  6088. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  6089. {
  6090. json_object *Period = json_object_new_object();
  6091. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  6092. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  6093. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  6094. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  6095. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  6096. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  6097. json_object_array_add(periods, Period);
  6098. }
  6099. }
  6100. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  6101. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  6102. random_uuid(guid);
  6103. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  6104. json_object_put(NotifyEVChargingSchedule);
  6105. LWS_Send(message);
  6106. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  6107. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6108. {
  6109. result = PASS;
  6110. }
  6111. return result;
  6112. }
  6113. int sendNotifyEventRequest()
  6114. {
  6115. mtrace();
  6116. int result = FAIL;
  6117. char message[4096]={0};
  6118. char guid[37]={0};
  6119. char tempdata[128]={0};
  6120. json_object *NotifyEvent = json_object_new_object();
  6121. json_object *eventDatas = json_object_new_array();
  6122. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  6123. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  6124. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  6125. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  6126. {
  6127. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  6128. {
  6129. json_object *eventData = json_object_new_object();
  6130. json_object *component = json_object_new_object();
  6131. json_object *evse = json_object_new_object();
  6132. json_object *variable = json_object_new_object();
  6133. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  6134. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  6135. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  6136. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  6137. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  6138. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  6139. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  6140. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  6141. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  6142. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  6143. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  6144. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  6145. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  6146. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  6147. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  6148. json_object_object_add(component, "evse",evse);
  6149. json_object_object_add(eventData, "component", component);
  6150. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  6151. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  6152. json_object_object_add(eventData, "variable", variable);
  6153. json_object_array_add(eventDatas, eventData);
  6154. }
  6155. }
  6156. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  6157. random_uuid(guid);
  6158. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  6159. json_object_put(NotifyEvent);
  6160. LWS_Send(message);
  6161. sprintf(tempdata, "NotifyEvent,0");
  6162. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6163. {
  6164. result = PASS;
  6165. }
  6166. return result;
  6167. }
  6168. int sendNotifyMonitoringReportRequest()
  6169. {
  6170. mtrace();
  6171. int result = FAIL;
  6172. char message[4096]={0};
  6173. char guid[37]={0};
  6174. char tempdata[128]={0};
  6175. json_object *NotifyMonitoringReport = json_object_new_object();
  6176. json_object *monitors = json_object_new_array();
  6177. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  6178. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  6179. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  6180. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  6181. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  6182. {
  6183. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  6184. {
  6185. json_object *monitor = json_object_new_object();
  6186. json_object *component = json_object_new_object();
  6187. json_object *evse = json_object_new_object();
  6188. json_object *variable = json_object_new_object();
  6189. json_object *variableMonitorings = json_object_new_array();
  6190. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  6191. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  6192. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  6193. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  6194. json_object_object_add(component, "evse",evse);
  6195. json_object_object_add(monitor, "component", component);
  6196. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  6197. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  6198. json_object_object_add(monitor, "variable", variable);
  6199. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  6200. {
  6201. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  6202. {
  6203. json_object *variableMonitoring = json_object_new_object();
  6204. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  6205. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  6206. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  6207. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  6208. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  6209. json_object_array_add(variableMonitorings, variableMonitoring);
  6210. }
  6211. }
  6212. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  6213. json_object_array_add(monitors, monitor);
  6214. }
  6215. }
  6216. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  6217. random_uuid(guid);
  6218. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  6219. json_object_put(NotifyMonitoringReport);
  6220. LWS_Send(message);
  6221. sprintf(tempdata, "NotifyMonitoringReport,0");
  6222. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6223. {
  6224. result = PASS;
  6225. }
  6226. return result;
  6227. }
  6228. int sendNotifyReportRequest()
  6229. {
  6230. mtrace();
  6231. int result = FAIL;
  6232. char message[4096]={0};
  6233. char guid[37]={0};
  6234. char tempdata[128]={0};
  6235. json_object *NotifyReport = json_object_new_object();
  6236. json_object *reportDatas = json_object_new_array();
  6237. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  6238. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  6239. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  6240. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  6241. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  6242. {
  6243. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  6244. {
  6245. json_object *reportData = json_object_new_object();
  6246. json_object *component = json_object_new_object();
  6247. json_object *evse = json_object_new_object();
  6248. json_object *variable = json_object_new_object();
  6249. json_object *variableAttributes = json_object_new_array();
  6250. json_object *variableCharacteristics = json_object_new_object();
  6251. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  6252. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  6253. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  6254. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  6255. json_object_object_add(component, "evse",evse);
  6256. json_object_object_add(reportData, "component", component);
  6257. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  6258. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  6259. json_object_object_add(reportData, "variable",variable);
  6260. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  6261. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  6262. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  6263. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  6264. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  6265. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  6266. {
  6267. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  6268. {
  6269. json_object *variableAttribute = json_object_new_object();
  6270. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  6271. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  6272. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  6273. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  6274. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  6275. json_object_array_add(variableAttributes, variableAttribute);
  6276. }
  6277. }
  6278. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  6279. json_object_array_add(reportDatas, reportData);
  6280. }
  6281. }
  6282. json_object_object_add(NotifyReport, "reportData", reportDatas);
  6283. random_uuid(guid);
  6284. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  6285. json_object_put(NotifyReport);
  6286. LWS_Send(message);
  6287. sprintf(tempdata, "NotifyReport,0");
  6288. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6289. {
  6290. result = PASS;
  6291. }
  6292. return result;
  6293. }
  6294. int sendPublishFirmwareStatusNotificationRequest()
  6295. {
  6296. mtrace();
  6297. int result = FAIL;
  6298. char message[4096]={0};
  6299. char guid[37]={0};
  6300. char tempdata[128]={0};
  6301. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  6302. json_object *locations = json_object_new_array();
  6303. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  6304. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  6305. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  6306. {
  6307. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  6308. }
  6309. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  6310. random_uuid(guid);
  6311. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  6312. json_object_put(PublishFirmwareStatusNotification);
  6313. LWS_Send(message);
  6314. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  6315. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6316. {
  6317. result = PASS;
  6318. }
  6319. return result;
  6320. }
  6321. int sendReportChargingProfilesRequest(int gun_index)
  6322. {
  6323. mtrace();
  6324. int result = FAIL;
  6325. char message[4096]={0};
  6326. char guid[37]={0};
  6327. char tempdata[128]={0};
  6328. json_object *ReportChargingProfiles = json_object_new_object();
  6329. json_object *chargingProfiles = json_object_new_array();
  6330. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  6331. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  6332. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  6333. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  6334. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  6335. {
  6336. json_object *chargingProfile = json_object_new_object();
  6337. json_object *chargingSchedules = json_object_new_array();
  6338. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  6339. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  6340. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  6341. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  6342. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  6343. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  6344. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  6345. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  6346. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  6347. {
  6348. json_object *chargingSchedule = json_object_new_object();
  6349. json_object *chargingSchedulePeriods = json_object_new_array();
  6350. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  6351. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  6352. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  6353. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  6354. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  6355. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  6356. {
  6357. json_object *chargingSchedulePeriod = json_object_new_object();
  6358. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  6359. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  6360. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  6361. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  6362. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  6363. }
  6364. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  6365. json_object_array_add(chargingSchedules, chargingSchedule);
  6366. }
  6367. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  6368. json_object_array_add(chargingProfiles, chargingProfile);
  6369. }
  6370. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  6371. random_uuid(guid);
  6372. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  6373. json_object_put(ReportChargingProfiles);
  6374. LWS_Send(message);
  6375. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  6376. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6377. {
  6378. result = PASS;
  6379. }
  6380. return result;
  6381. }
  6382. int sendReservationStatusUpdateRequest(int gun_index)
  6383. {
  6384. mtrace();
  6385. int result = FAIL;
  6386. char message[4096]={0};
  6387. char guid[37]={0};
  6388. char tempdata[128]={0};
  6389. json_object *ReservationStatusUpdate = json_object_new_object();
  6390. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  6391. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  6392. random_uuid(guid);
  6393. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  6394. json_object_put(ReservationStatusUpdate);
  6395. LWS_Send(message);
  6396. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  6397. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6398. {
  6399. result = PASS;
  6400. }
  6401. return result;
  6402. }
  6403. int sendSecurityEventNotificationRequest()
  6404. {
  6405. mtrace();
  6406. int result = FAIL;
  6407. char message[4096]={0};
  6408. char guid[37]={0};
  6409. char tempdata[128]={0};
  6410. json_object *SecurityEventNotification = json_object_new_object();
  6411. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  6412. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  6413. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techinfo));
  6414. random_uuid(guid);
  6415. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  6416. json_object_put(SecurityEventNotification);
  6417. LWS_Send(message);
  6418. sprintf(tempdata, "SecurityEventNotification,0");
  6419. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6420. {
  6421. result = PASS;
  6422. }
  6423. return result;
  6424. }
  6425. int sendSignCertificateRequest()
  6426. {
  6427. mtrace();
  6428. int result = FAIL;
  6429. char message[4096]={0};
  6430. char guid[37]={0};
  6431. char tempdata[128]={0};
  6432. json_object *SignCertificate = json_object_new_object();
  6433. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  6434. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  6435. random_uuid(guid);
  6436. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  6437. json_object_put(SignCertificate);
  6438. LWS_Send(message);
  6439. sprintf(tempdata, "SignCertificate,0");
  6440. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6441. {
  6442. result = PASS;
  6443. }
  6444. return result;
  6445. }
  6446. int sendStatusNotificationRequest(int gun_index)
  6447. {
  6448. mtrace();
  6449. int result = FAIL;
  6450. char message[600]={0};
  6451. char guid[37];
  6452. int currentStatus = 0;
  6453. struct timeval tmnow;
  6454. struct tm *tm;
  6455. char buf[28];//, usec_buf[6];
  6456. char tempdata[65]={0};
  6457. int tempIndex = 0;
  6458. gettimeofday(&tmnow, NULL);
  6459. time_t t;
  6460. t = time(NULL);
  6461. /*UTC time and date*/
  6462. tm = gmtime(&t);
  6463. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  6464. #if 0 // remove temporally
  6465. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  6466. strcat(buf,".");
  6467. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  6468. strcat(buf,usec_buf);
  6469. #endif
  6470. printf("%s",buf);
  6471. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  6472. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  6473. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  6474. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  6475. /*
  6476. enum _SYSTEM_STATUS
  6477. {
  6478. S_BOOTING = 0,
  6479. S_IDLE, = 1
  6480. S_AUTHORIZING, =2
  6481. S_REASSIGN_CHECK, =3
  6482. S_REASSIGN, =4
  6483. S_PRECHARGE, =5
  6484. S_PREPARING_FOR_EV, =6
  6485. S_PREPARING_FOR_EVSE, =7
  6486. S_CHARGING, =8
  6487. S_TERMINATING, =9
  6488. S_COMPLETE, =10
  6489. S_ALARM, =11
  6490. S_FAULT =12
  6491. }
  6492. */
  6493. //check Transaction active
  6494. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  6495. if(gunType[gun_index] == 'J')
  6496. {
  6497. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6498. {
  6499. tempIndex = ((gun_index==2) ? 1: 0);
  6500. }
  6501. else
  6502. {
  6503. tempIndex = gun_index;
  6504. }
  6505. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6506. {
  6507. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6508. {
  6509. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6510. {
  6511. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6512. {
  6513. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6514. }
  6515. else
  6516. {
  6517. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6518. }
  6519. }
  6520. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6521. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6522. ) //S_PRECHARGE
  6523. {
  6524. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6525. }
  6526. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6527. {
  6528. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6529. }
  6530. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6531. {
  6532. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6533. }
  6534. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6535. {
  6536. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6537. }
  6538. 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
  6539. {
  6540. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6541. }
  6542. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6543. {
  6544. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6545. }
  6546. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6547. {
  6548. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6549. }
  6550. } //end of the same index
  6551. }//end of for CHAdeMO_QUANTITY
  6552. }
  6553. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  6554. {
  6555. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6556. {
  6557. tempIndex = ((gun_index==2) ? 1: 0);
  6558. }
  6559. else
  6560. {
  6561. tempIndex = gun_index;
  6562. }
  6563. for (int index = 0; index < CCS_QUANTITY; index++)
  6564. {
  6565. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6566. {
  6567. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6568. {
  6569. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  6570. {
  6571. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6572. }
  6573. else
  6574. {
  6575. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6576. }
  6577. }
  6578. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6579. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6580. ) //S_PRECHARGE
  6581. {
  6582. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6583. }
  6584. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6585. {
  6586. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6587. }
  6588. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6589. {
  6590. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6591. }
  6592. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  6593. {
  6594. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6595. }
  6596. 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
  6597. {
  6598. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  6599. }
  6600. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6601. {
  6602. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6603. }
  6604. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6605. {
  6606. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6607. }
  6608. } //end of the same index
  6609. } // end of for CCS_QUANTITY
  6610. }
  6611. else if(gunType[gun_index] == 'G')
  6612. {
  6613. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6614. {
  6615. tempIndex = ((gun_index==2) ? 1: 0);
  6616. }
  6617. else
  6618. {
  6619. tempIndex = gun_index;
  6620. }
  6621. for (int index = 0; index < GB_QUANTITY; index++)
  6622. {
  6623. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6624. {
  6625. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6626. {
  6627. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6628. {
  6629. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6630. }
  6631. else
  6632. {
  6633. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6634. }
  6635. }
  6636. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6637. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6638. ) //S_PRECHARGE
  6639. {
  6640. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6641. }
  6642. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6643. {
  6644. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6645. }
  6646. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6647. {
  6648. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6649. }
  6650. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6651. {
  6652. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6653. }
  6654. 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
  6655. {
  6656. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6657. }
  6658. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6659. {
  6660. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6661. }
  6662. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6663. {
  6664. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6665. }
  6666. } //end of the same index
  6667. } // end of for GB_QUANTITY
  6668. }
  6669. else if(gunType[gun_index] == 'O')
  6670. {
  6671. tempIndex = gun_index;
  6672. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6673. {
  6674. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6675. {
  6676. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6677. {
  6678. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6679. {
  6680. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6681. }
  6682. else
  6683. {
  6684. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6685. }
  6686. }
  6687. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6688. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6689. ) //S_PRECHARGE
  6690. {
  6691. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6692. }
  6693. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6694. {
  6695. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6696. }
  6697. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6698. {
  6699. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6700. }
  6701. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6702. {
  6703. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6704. }
  6705. 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
  6706. {
  6707. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6708. }
  6709. 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
  6710. {
  6711. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6712. }
  6713. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6714. {
  6715. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6716. }
  6717. } //end of the same index
  6718. }
  6719. }
  6720. else
  6721. {
  6722. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6723. {
  6724. tempIndex = 2;
  6725. }
  6726. else
  6727. {
  6728. tempIndex = gun_index;
  6729. }
  6730. for (int index = 0; index < AC_QUANTITY; index++)
  6731. {
  6732. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6733. {
  6734. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  6735. {
  6736. 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))
  6737. {
  6738. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6739. }
  6740. else
  6741. {
  6742. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6743. }
  6744. }
  6745. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  6746. {
  6747. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6748. }
  6749. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  6750. {
  6751. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6752. }
  6753. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  6754. {
  6755. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6756. }
  6757. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6758. {
  6759. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6760. }
  6761. 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
  6762. {
  6763. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6764. }
  6765. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6766. {
  6767. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6768. }
  6769. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6770. {
  6771. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6772. }
  6773. }//end of the same index
  6774. }//end of for AC_QUANTITY
  6775. }
  6776. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  6777. random_uuid(guid);
  6778. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  6779. , MESSAGE_TYPE_CALL
  6780. , guid
  6781. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  6782. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  6783. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  6784. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  6785. if((server_sign == TRUE))
  6786. {
  6787. LWS_Send(message);
  6788. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  6789. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6790. {
  6791. result = PASS;
  6792. }
  6793. }
  6794. else
  6795. {
  6796. result = PASS;
  6797. }
  6798. return result;
  6799. }
  6800. int sendTransactionEventRequest(int gun_index)
  6801. {
  6802. mtrace();
  6803. int result = FAIL;
  6804. char message[1024*20]={0};
  6805. char guid[37]={0};
  6806. char tempdata[128]={0};
  6807. uint8_t tempIndex;
  6808. json_object *TransactionEvent = json_object_new_object();
  6809. json_object *transactionInfo = json_object_new_object();
  6810. json_object *idToken = json_object_new_object();
  6811. json_object *evse = json_object_new_object();
  6812. json_object *meterValues = json_object_new_array();
  6813. if(gunType[gun_index] == 'J')
  6814. {
  6815. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6816. {
  6817. tempIndex = ((gun_index==2) ? 1: 0);
  6818. }
  6819. else
  6820. {
  6821. tempIndex = gun_index;
  6822. }
  6823. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6824. {
  6825. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6826. {
  6827. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  6828. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  6829. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  6830. else
  6831. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  6832. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  6833. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  6834. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  6835. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6836. {
  6837. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6838. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6839. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6840. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6841. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6842. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6843. {
  6844. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  6845. }
  6846. else
  6847. {
  6848. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  6849. }
  6850. }
  6851. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  6852. {
  6853. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6854. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6855. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  6856. }
  6857. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6858. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6859. ) //S_PRECHARGE
  6860. {
  6861. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6862. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  6863. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6864. }
  6865. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6866. {
  6867. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  6868. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  6869. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  6870. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6871. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6872. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6873. }
  6874. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6875. {
  6876. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  6877. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6878. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6879. }
  6880. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6881. {
  6882. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6883. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  6884. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6885. }
  6886. 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
  6887. {
  6888. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6889. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6890. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6891. }
  6892. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6893. {
  6894. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6895. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6896. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6897. }
  6898. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6899. {
  6900. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6901. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6902. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6903. }
  6904. } //end of the same index
  6905. }//end of for CHAdeMO_QUANTITY
  6906. }
  6907. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  6908. {
  6909. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6910. {
  6911. tempIndex = ((gun_index==2) ? 1: 0);
  6912. }
  6913. else
  6914. {
  6915. tempIndex = gun_index;
  6916. }
  6917. for (int index = 0; index < CCS_QUANTITY; index++)
  6918. {
  6919. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6920. {
  6921. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  6922. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  6923. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  6924. else
  6925. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  6926. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  6927. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  6928. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  6929. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6930. {
  6931. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6932. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6933. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6934. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6935. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6936. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  6937. {
  6938. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  6939. }
  6940. else
  6941. {
  6942. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  6943. }
  6944. }
  6945. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  6946. {
  6947. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6948. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6949. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  6950. }
  6951. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6952. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6953. ) //S_PRECHARGE
  6954. {
  6955. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6956. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  6957. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6958. }
  6959. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6960. {
  6961. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  6962. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  6963. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  6964. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6965. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6966. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6967. }
  6968. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6969. {
  6970. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  6971. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6972. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6973. }
  6974. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6975. {
  6976. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6977. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  6978. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6979. }
  6980. 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
  6981. {
  6982. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6983. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6984. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6985. }
  6986. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6987. {
  6988. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6989. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6990. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6991. }
  6992. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6993. {
  6994. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6995. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6996. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6997. }
  6998. } //end of the same index
  6999. } // end of for CCS_QUANTITY
  7000. }
  7001. else if(gunType[gun_index] == 'G')
  7002. {
  7003. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7004. {
  7005. tempIndex = ((gun_index==2) ? 1: 0);
  7006. }
  7007. else
  7008. {
  7009. tempIndex = gun_index;
  7010. }
  7011. for (int index = 0; index < GB_QUANTITY; index++)
  7012. {
  7013. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7014. {
  7015. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7016. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7017. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7018. else
  7019. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7020. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7021. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  7022. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7023. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7024. {
  7025. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7026. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7027. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7028. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7029. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7030. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7031. {
  7032. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7033. }
  7034. else
  7035. {
  7036. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7037. }
  7038. }
  7039. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7040. {
  7041. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7042. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7043. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7044. }
  7045. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7046. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7047. ) //S_PRECHARGE
  7048. {
  7049. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7050. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7051. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7052. }
  7053. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7054. {
  7055. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7056. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7057. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  7058. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7059. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7060. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7061. }
  7062. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7063. {
  7064. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7065. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7066. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7067. }
  7068. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7069. {
  7070. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7071. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7072. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7073. }
  7074. 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
  7075. {
  7076. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7077. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7078. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7079. }
  7080. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7081. {
  7082. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7083. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7084. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7085. }
  7086. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7087. {
  7088. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7089. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7090. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7091. }
  7092. } //end of the same index
  7093. } // end of for GB_QUANTITY
  7094. }
  7095. else if(gunType[gun_index] == 'O')
  7096. {
  7097. tempIndex = gun_index;
  7098. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7099. {
  7100. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7101. {
  7102. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7103. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7104. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7105. else
  7106. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7107. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7108. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  7109. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7110. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7111. {
  7112. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7113. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7114. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7115. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7116. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7117. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7118. {
  7119. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7120. }
  7121. else
  7122. {
  7123. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7124. }
  7125. }
  7126. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7127. {
  7128. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7129. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7130. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7131. }
  7132. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7133. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7134. ) //S_PRECHARGE
  7135. {
  7136. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7137. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7138. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7139. }
  7140. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7141. {
  7142. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7143. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7144. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  7145. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7146. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7147. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7148. }
  7149. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7150. {
  7151. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7152. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7153. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7154. }
  7155. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7156. {
  7157. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7158. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7159. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7160. }
  7161. 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
  7162. {
  7163. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7164. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7165. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7166. }
  7167. 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
  7168. {
  7169. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7170. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7171. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7172. }
  7173. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7174. {
  7175. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7176. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7177. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7178. }
  7179. } //end of the same index
  7180. }
  7181. }
  7182. else
  7183. {
  7184. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7185. {
  7186. tempIndex = 2;
  7187. }
  7188. else
  7189. {
  7190. tempIndex = gun_index;
  7191. }
  7192. for (int index = 0; index < AC_QUANTITY; index++)
  7193. {
  7194. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7195. {
  7196. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7197. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7198. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7199. else
  7200. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7201. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7202. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  7203. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7204. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  7205. {
  7206. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7207. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7208. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7209. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7210. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7211. 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))
  7212. {
  7213. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7214. }
  7215. else
  7216. {
  7217. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7218. }
  7219. }
  7220. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7221. {
  7222. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7223. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7224. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7225. }
  7226. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7227. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7228. ) //S_PRECHARGE
  7229. {
  7230. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7231. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7232. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7233. }
  7234. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7235. {
  7236. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7237. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7238. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  7239. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7240. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7241. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7242. }
  7243. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7244. {
  7245. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7246. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7247. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7248. }
  7249. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7250. {
  7251. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7252. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7253. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7254. }
  7255. 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
  7256. {
  7257. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7258. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7259. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7260. }
  7261. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7262. {
  7263. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7264. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7265. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7266. }
  7267. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7268. {
  7269. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7270. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7271. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7272. }
  7273. }//end of the same index
  7274. }//end of for AC_QUANTITY
  7275. }
  7276. // Message
  7277. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7278. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  7279. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  7280. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  7281. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  7282. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  7283. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  7284. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  7285. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  7286. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  7287. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  7288. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  7289. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  7290. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  7291. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  7292. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  7293. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  7294. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  7295. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  7296. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  7297. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  7298. {
  7299. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  7300. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  7301. json_object_object_add(TransactionEvent, "idToken", idToken);
  7302. }
  7303. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  7304. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  7305. json_object_object_add(TransactionEvent, "evse", evse);
  7306. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  7307. {
  7308. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  7309. {
  7310. json_object *meterValue = json_object_new_object();
  7311. json_object *sampledValues = json_object_new_array();
  7312. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  7313. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  7314. {
  7315. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7316. {
  7317. json_object *sampledValue = json_object_new_object();
  7318. json_object *unitOfMeasure = json_object_new_object();
  7319. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  7320. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  7321. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  7322. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  7323. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  7324. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  7325. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  7326. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  7327. json_object_array_add(sampledValues, sampledValue);
  7328. }
  7329. }
  7330. json_object_object_add(meterValue, "sampledValue", sampledValues);
  7331. json_object_array_add(meterValues, meterValue);
  7332. }
  7333. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  7334. }
  7335. random_uuid(guid);
  7336. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  7337. json_object_put(TransactionEvent);
  7338. LWS_Send(message);
  7339. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  7340. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7341. {
  7342. result = PASS;
  7343. }
  7344. return result;
  7345. }
  7346. //==========================================
  7347. // send confirm routine
  7348. //==========================================
  7349. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  7350. {
  7351. mtrace();
  7352. int result = FAIL;
  7353. char message[4096]={0};
  7354. json_object *CancelReservation = json_object_new_object();
  7355. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  7356. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  7357. sprintf(message,"[%d,\"%s\",%s]"
  7358. ,MESSAGE_TYPE_CALLRESULT
  7359. ,uuid
  7360. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  7361. json_object_put(CancelReservation);
  7362. ShmOCPP20Data->CsMsg.bits[0].CancelReservationConf = OFF;
  7363. LWS_Send(message);
  7364. result = TRUE;
  7365. return result;
  7366. }
  7367. int sendCertificateSignedConfirmation(char *uuid)
  7368. {
  7369. mtrace();
  7370. int result = FAIL;
  7371. char message[4096]={0};
  7372. json_object *CertificateSigned = json_object_new_object();
  7373. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  7374. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  7375. sprintf(message,"[%d,\"%s\",%s]"
  7376. ,MESSAGE_TYPE_CALLRESULT
  7377. ,uuid
  7378. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  7379. json_object_put(CertificateSigned);
  7380. LWS_Send(message);
  7381. result = TRUE;
  7382. return result;
  7383. }
  7384. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  7385. {
  7386. mtrace();
  7387. int result = FAIL;
  7388. char message[4096]={0};
  7389. json_object *ChangeAvailability = json_object_new_object();
  7390. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  7391. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  7392. sprintf(message,"[%d,\"%s\",%s]"
  7393. ,MESSAGE_TYPE_CALLRESULT
  7394. ,uuid
  7395. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  7396. json_object_put(ChangeAvailability);
  7397. LWS_Send(message);
  7398. result = TRUE;
  7399. return result;
  7400. }
  7401. int sendClearCacheConfirmation(char *uuid)
  7402. {
  7403. mtrace();
  7404. int result = FAIL;
  7405. char message[4096]={0};
  7406. json_object *ClearCache = json_object_new_object();
  7407. DEBUG_INFO("sendClearCacheConfirmation...\n");
  7408. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  7409. sprintf(message,"[%d,\"%s\",%s]"
  7410. ,MESSAGE_TYPE_CALLRESULT
  7411. ,uuid
  7412. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  7413. json_object_put(ClearCache);
  7414. LWS_Send(message);
  7415. result = TRUE;
  7416. return result;
  7417. }
  7418. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  7419. {
  7420. mtrace();
  7421. int result = FAIL;
  7422. char message[500]={0};
  7423. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  7424. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  7425. LWS_Send(message);
  7426. return result;
  7427. }
  7428. int sendClearDisplayMessageConfirmation(char *uuid)
  7429. {
  7430. mtrace();
  7431. int result = FAIL;
  7432. char message[4096]={0};
  7433. json_object *ClearDisplayMessage = json_object_new_object();
  7434. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  7435. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  7436. sprintf(message,"[%d,\"%s\",%s]"
  7437. ,MESSAGE_TYPE_CALLRESULT
  7438. ,uuid
  7439. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  7440. json_object_put(ClearDisplayMessage);
  7441. LWS_Send(message);
  7442. result = TRUE;
  7443. return result;
  7444. }
  7445. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  7446. {
  7447. mtrace();
  7448. int result = FAIL;
  7449. char message[4096]={0};
  7450. json_object *ClearVariableMonitoring = json_object_new_object();
  7451. json_object *clearMonitoringResults = json_object_new_array();
  7452. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  7453. for(int idx=0;idx<variableQuantity;idx++)
  7454. {
  7455. json_object *clearMonitoringResult = json_object_new_object();
  7456. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  7457. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  7458. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  7459. }
  7460. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  7461. sprintf(message,"[%d,\"%s\",%s]"
  7462. ,MESSAGE_TYPE_CALLRESULT
  7463. ,uuid
  7464. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  7465. json_object_put(ClearVariableMonitoring);
  7466. LWS_Send(message);
  7467. result = TRUE;
  7468. return result;
  7469. }
  7470. int sendCostUpdatedConfirmation(char *uuid)
  7471. {
  7472. mtrace();
  7473. int result = FAIL;
  7474. char message[4096]={0};
  7475. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  7476. sprintf(message,"[%d,\"%s\",{}]"
  7477. ,MESSAGE_TYPE_CALLRESULT
  7478. ,uuid);
  7479. LWS_Send(message);
  7480. result = TRUE;
  7481. return result;
  7482. }
  7483. int sendCustomerInformationConfirmation(char *uuid)
  7484. {
  7485. mtrace();
  7486. int result = FAIL;
  7487. char message[4096]={0};
  7488. json_object *CustomerInformation = json_object_new_object();
  7489. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  7490. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  7491. sprintf(message,"[%d,\"%s\",%s]"
  7492. ,MESSAGE_TYPE_CALLRESULT
  7493. ,uuid
  7494. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  7495. json_object_put(CustomerInformation);
  7496. LWS_Send(message);
  7497. result = TRUE;
  7498. return result;
  7499. }
  7500. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  7501. {
  7502. mtrace();
  7503. int result = FAIL;
  7504. char message[4096]={0};
  7505. json_object *DataTransfer = json_object_new_object();
  7506. DEBUG_INFO("sendDataTransferConfirmation...\n");
  7507. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  7508. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  7509. sprintf(message,"[%d,\"%s\",%s]"
  7510. ,MESSAGE_TYPE_CALLRESULT
  7511. ,uuid
  7512. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  7513. json_object_put(DataTransfer);
  7514. LWS_Send(message);
  7515. result = TRUE;
  7516. return result;
  7517. }
  7518. int sendDeleteCertificateConfirmation(char *uuid)
  7519. {
  7520. mtrace();
  7521. int result = FAIL;
  7522. char message[4096]={0};
  7523. json_object *DeleteCertificate = json_object_new_object();
  7524. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  7525. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  7526. sprintf(message,"[%d,\"%s\",%s]"
  7527. ,MESSAGE_TYPE_CALLRESULT
  7528. ,uuid
  7529. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  7530. json_object_put(DeleteCertificate);
  7531. LWS_Send(message);
  7532. result = TRUE;
  7533. return result;
  7534. }
  7535. int sendGetBaseReportConfirmation(char *uuid)
  7536. {
  7537. mtrace();
  7538. int result = FAIL;
  7539. char message[4096]={0};
  7540. json_object *GetBaseReport = json_object_new_object();
  7541. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  7542. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  7543. sprintf(message,"[%d,\"%s\",%s]"
  7544. ,MESSAGE_TYPE_CALLRESULT
  7545. ,uuid
  7546. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  7547. json_object_put(GetBaseReport);
  7548. LWS_Send(message);
  7549. result = TRUE;
  7550. return result;
  7551. }
  7552. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  7553. {
  7554. mtrace();
  7555. int result = FAIL;
  7556. char message[4096]={0};
  7557. json_object *GetChargingProfiles = json_object_new_object();
  7558. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  7559. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  7560. sprintf(message,"[%d,\"%s\",%s]"
  7561. ,MESSAGE_TYPE_CALLRESULT
  7562. ,uuid
  7563. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  7564. json_object_put(GetChargingProfiles);
  7565. LWS_Send(message);
  7566. result = TRUE;
  7567. return result;
  7568. }
  7569. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  7570. {
  7571. mtrace();
  7572. int result = FAIL;
  7573. char message[4096]={0};
  7574. int CompositeScheduleIndex = 0;
  7575. json_object *GetCompositeSchedule = json_object_new_object();
  7576. json_object *schedule = json_object_new_object();
  7577. json_object *chargingSchedule = json_object_new_object();
  7578. json_object *chargingSchedulePeriod = json_object_new_array();
  7579. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  7580. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  7581. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  7582. if(nPeriod == 0)
  7583. {
  7584. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  7585. {
  7586. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7587. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7588. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7589. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7590. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7591. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7592. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7593. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7594. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7595. {
  7596. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7597. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7598. {
  7599. json_object *Period = json_object_new_object();
  7600. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7601. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7602. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7603. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7604. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7605. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7606. json_object_array_add(chargingSchedulePeriod, Period);
  7607. }
  7608. }
  7609. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7610. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7611. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7612. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7613. }
  7614. }
  7615. else
  7616. {
  7617. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7618. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7619. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7620. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7621. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7622. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7623. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7624. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7625. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7626. {
  7627. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7628. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7629. {
  7630. json_object *Period = json_object_new_object();
  7631. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7632. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7633. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7634. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7635. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7636. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7637. json_object_array_add(chargingSchedulePeriod, Period);
  7638. }
  7639. }
  7640. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7641. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7642. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7643. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7644. }
  7645. sprintf(message,"[%d,\"%s\",%s]"
  7646. ,MESSAGE_TYPE_CALLRESULT
  7647. ,uuid
  7648. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  7649. json_object_put(GetCompositeSchedule);
  7650. LWS_Send(message);
  7651. result = TRUE;
  7652. return result;
  7653. }
  7654. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  7655. {
  7656. mtrace();
  7657. int result = FAIL;
  7658. char message[4096]={0};
  7659. json_object *GetGetDisplayMessages = json_object_new_object();
  7660. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  7661. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  7662. sprintf(message,"[%d,\"%s\",%s]"
  7663. ,MESSAGE_TYPE_CALLRESULT
  7664. ,uuid
  7665. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  7666. json_object_put(GetGetDisplayMessages);
  7667. LWS_Send(message);
  7668. result = TRUE;
  7669. return result;
  7670. }
  7671. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  7672. {
  7673. mtrace();
  7674. int result = FAIL;
  7675. char message[4096]={0};
  7676. json_object *GetInstalledCertificateIds = json_object_new_object();
  7677. json_object *certificateHashDataChains = json_object_new_array();
  7678. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  7679. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  7680. for(int idx=0;idx<certQuantity;idx++)
  7681. {
  7682. json_object *cert = json_object_new_object();
  7683. json_object *certificateHashData = json_object_new_object();
  7684. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  7685. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  7686. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  7687. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  7688. json_object_object_add(cert, "certificateHashData", certificateHashData);
  7689. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  7690. json_object_array_add(certificateHashDataChains, cert);
  7691. }
  7692. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  7693. sprintf(message,"[%d,\"%s\",%s]"
  7694. ,MESSAGE_TYPE_CALLRESULT
  7695. ,uuid
  7696. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  7697. json_object_put(GetInstalledCertificateIds);
  7698. LWS_Send(message);
  7699. result = TRUE;
  7700. return result;
  7701. }
  7702. int sendGetLocalListVersionConfirmation(char *uuid)
  7703. {
  7704. mtrace();
  7705. int result = FAIL;
  7706. char message[4096]={0};
  7707. json_object *GetLocalListVersion = json_object_new_object();
  7708. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  7709. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  7710. sprintf(message,"[%d,\"%s\",%s]"
  7711. ,MESSAGE_TYPE_CALLRESULT
  7712. ,uuid
  7713. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  7714. json_object_put(GetLocalListVersion);
  7715. LWS_Send(message);
  7716. result = TRUE;
  7717. return result;
  7718. }
  7719. int sendGetLogConfirmation(char *uuid)
  7720. {
  7721. mtrace();
  7722. int result = FAIL;
  7723. char message[4096]={0};
  7724. json_object *GetLog = json_object_new_object();
  7725. DEBUG_INFO("sendGetLogConfirmation...\n");
  7726. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  7727. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  7728. sprintf(message,"[%d,\"%s\",%s]"
  7729. ,MESSAGE_TYPE_CALLRESULT
  7730. ,uuid
  7731. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  7732. json_object_put(GetLog);
  7733. LWS_Send(message);
  7734. result = TRUE;
  7735. return result;
  7736. }
  7737. int sendGetMonitoringReportConfirmation(char *uuid)
  7738. {
  7739. mtrace();
  7740. int result = FAIL;
  7741. char message[4096]={0};
  7742. json_object *GetMonitoringReport = json_object_new_object();
  7743. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  7744. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  7745. sprintf(message,"[%d,\"%s\",%s]"
  7746. ,MESSAGE_TYPE_CALLRESULT
  7747. ,uuid
  7748. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  7749. json_object_put(GetMonitoringReport);
  7750. LWS_Send(message);
  7751. result = TRUE;
  7752. return result;
  7753. }
  7754. int sendGetReportConfirmation(char *uuid)
  7755. {
  7756. mtrace();
  7757. int result = FAIL;
  7758. char message[4096]={0};
  7759. json_object *GetReport = json_object_new_object();
  7760. DEBUG_INFO("sendGetReportConfirmation...\n");
  7761. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  7762. sprintf(message,"[%d,\"%s\",%s]"
  7763. ,MESSAGE_TYPE_CALLRESULT
  7764. ,uuid
  7765. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  7766. json_object_put(GetReport);
  7767. LWS_Send(message);
  7768. result = TRUE;
  7769. return result;
  7770. }
  7771. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  7772. {
  7773. mtrace();
  7774. int result = FAIL;
  7775. char message[4096]={0};
  7776. json_object *GetTransactionStatus = json_object_new_object();
  7777. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  7778. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  7779. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  7780. sprintf(message,"[%d,\"%s\",%s]"
  7781. ,MESSAGE_TYPE_CALLRESULT
  7782. ,uuid
  7783. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  7784. json_object_put(GetTransactionStatus);
  7785. LWS_Send(message);
  7786. result = TRUE;
  7787. return result;
  7788. }
  7789. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  7790. {
  7791. mtrace();
  7792. int result = FAIL;
  7793. char message[4096]={0};
  7794. json_object *GetVariables = json_object_new_object();
  7795. json_object *getVariableResults = json_object_new_array();
  7796. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  7797. for(int idx=0;idx<variableQuantity;idx++)
  7798. {
  7799. json_object *variableResult = json_object_new_object();
  7800. json_object *component = json_object_new_object();
  7801. json_object *variable = json_object_new_object();
  7802. json_object *evse = json_object_new_object();
  7803. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  7804. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  7805. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  7806. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  7807. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  7808. json_object_object_add(component, "component", evse);
  7809. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  7810. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  7811. json_object_object_add(variableResult, "component", component);
  7812. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  7813. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  7814. json_object_object_add(variableResult, "variable", variable);
  7815. json_object_array_add(getVariableResults, variableResult);
  7816. }
  7817. json_object_object_add(GetVariables , "setVariableResult", getVariableResults);
  7818. sprintf(message,"[%d,\"%s\",%s]"
  7819. ,MESSAGE_TYPE_CALLRESULT
  7820. ,uuid
  7821. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  7822. json_object_put(GetVariables);
  7823. LWS_Send(message);
  7824. result = TRUE;
  7825. return result;
  7826. }
  7827. int sendInstallCertificateConfirmation(char *uuid)
  7828. {
  7829. mtrace();
  7830. int result = FAIL;
  7831. char message[4096]={0};
  7832. json_object *InstallCertificate = json_object_new_object();
  7833. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  7834. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  7835. sprintf(message,"[%d,\"%s\",%s]"
  7836. ,MESSAGE_TYPE_CALLRESULT
  7837. ,uuid
  7838. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  7839. json_object_put(InstallCertificate);
  7840. LWS_Send(message);
  7841. result = TRUE;
  7842. return result;
  7843. }
  7844. int sendPublishFirmwareConfirmation(char *uuid)
  7845. {
  7846. mtrace();
  7847. int result = FAIL;
  7848. char message[4096]={0};
  7849. json_object *PublishFirmware = json_object_new_object();
  7850. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  7851. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  7852. sprintf(message,"[%d,\"%s\",%s]"
  7853. ,MESSAGE_TYPE_CALLRESULT
  7854. ,uuid
  7855. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  7856. json_object_put(PublishFirmware);
  7857. LWS_Send(message);
  7858. result = TRUE;
  7859. return result;
  7860. }
  7861. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  7862. {
  7863. mtrace();
  7864. int result = FAIL;
  7865. char message[4096]={0};
  7866. json_object *RemoteStartTransaction = json_object_new_object();
  7867. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  7868. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  7869. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  7870. sprintf(message,"[%d,\"%s\",%s]"
  7871. ,MESSAGE_TYPE_CALLRESULT
  7872. ,uuid
  7873. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  7874. json_object_put(RemoteStartTransaction);
  7875. LWS_Send(message);
  7876. result = TRUE;
  7877. return result;
  7878. }
  7879. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  7880. {
  7881. mtrace();
  7882. int result = FAIL;
  7883. char message[4096]={0};
  7884. json_object *RemoteStopTransaction = json_object_new_object();
  7885. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  7886. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  7887. sprintf(message,"[%d,\"%s\",%s]"
  7888. ,MESSAGE_TYPE_CALLRESULT
  7889. ,uuid
  7890. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  7891. json_object_put(RemoteStopTransaction);
  7892. LWS_Send(message);
  7893. result = TRUE;
  7894. return result;
  7895. }
  7896. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  7897. {
  7898. mtrace();
  7899. int result = FAIL;
  7900. char message[4096]={0};
  7901. json_object *ReserveNow = json_object_new_object();
  7902. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  7903. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  7904. sprintf(message,"[%d,\"%s\",%s]"
  7905. ,MESSAGE_TYPE_CALLRESULT
  7906. ,uuid
  7907. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  7908. json_object_put(ReserveNow);
  7909. LWS_Send(message);
  7910. result = TRUE;
  7911. return result;
  7912. }
  7913. int sendResetConfirmation(char *uuid)
  7914. {
  7915. mtrace();
  7916. int result = FAIL;
  7917. char message[4096]={0};
  7918. json_object *Reset = json_object_new_object();
  7919. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  7920. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  7921. sprintf(message,"[%d,\"%s\",%s]"
  7922. ,MESSAGE_TYPE_CALLRESULT
  7923. ,uuid
  7924. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  7925. json_object_put(Reset);
  7926. LWS_Send(message);
  7927. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  7928. {
  7929. DB_updateBootType(BootReasonEnumType_RemoteReset);
  7930. }
  7931. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  7932. {
  7933. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  7934. }
  7935. result = TRUE;
  7936. return result;
  7937. }
  7938. int sendSendLocalListConfirmation(char *uuid)
  7939. {
  7940. mtrace();
  7941. int result = FAIL;
  7942. char message[4096]={0};
  7943. json_object *SendLocalList = json_object_new_object();
  7944. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  7945. sprintf(message,"[%d,\"%s\",%s]"
  7946. ,MESSAGE_TYPE_CALLRESULT
  7947. ,uuid
  7948. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  7949. json_object_put(SendLocalList);
  7950. LWS_Send(message);
  7951. result = TRUE;
  7952. return result;
  7953. }
  7954. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  7955. {
  7956. mtrace();
  7957. int result = FAIL;
  7958. char message[4096]={0};
  7959. json_object *SetChargingProfile = json_object_new_object();
  7960. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  7961. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  7962. sprintf(message,"[%d,\"%s\",%s]"
  7963. ,MESSAGE_TYPE_CALLRESULT
  7964. ,uuid
  7965. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  7966. json_object_put(SetChargingProfile);
  7967. LWS_Send(message);
  7968. result = TRUE;
  7969. return result;
  7970. }
  7971. int sendSetDisplayMessageConfirmation(char *uuid)
  7972. {
  7973. mtrace();
  7974. int result = FAIL;
  7975. char message[4096]={0};
  7976. json_object *SetDisplayMessage = json_object_new_object();
  7977. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  7978. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  7979. sprintf(message,"[%d,\"%s\",%s]"
  7980. ,MESSAGE_TYPE_CALLRESULT
  7981. ,uuid
  7982. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  7983. json_object_put(SetDisplayMessage);
  7984. LWS_Send(message);
  7985. result = TRUE;
  7986. return result;
  7987. }
  7988. int sendSetMonitoringBaseConfirmation(char *uuid)
  7989. {
  7990. mtrace();
  7991. int result = FAIL;
  7992. char message[4096]={0};
  7993. json_object *SetMonitoringBase = json_object_new_object();
  7994. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  7995. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  7996. sprintf(message,"[%d,\"%s\",%s]"
  7997. ,MESSAGE_TYPE_CALLRESULT
  7998. ,uuid
  7999. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  8000. json_object_put(SetMonitoringBase);
  8001. LWS_Send(message);
  8002. result = TRUE;
  8003. return result;
  8004. }
  8005. int sendSetMonitoringLevelConfirmation(char *uuid)
  8006. {
  8007. mtrace();
  8008. int result = FAIL;
  8009. char message[4096]={0};
  8010. json_object *SetMonitoringLevel = json_object_new_object();
  8011. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  8012. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  8013. sprintf(message,"[%d,\"%s\",%s]"
  8014. ,MESSAGE_TYPE_CALLRESULT
  8015. ,uuid
  8016. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  8017. json_object_put(SetMonitoringLevel);
  8018. LWS_Send(message);
  8019. result = TRUE;
  8020. return result;
  8021. }
  8022. int sendSetNetworkProfileConfirmation(char *uuid)
  8023. {
  8024. mtrace();
  8025. int result = FAIL;
  8026. char message[4096]={0};
  8027. json_object *SetNetworkProfile = json_object_new_object();
  8028. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  8029. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  8030. sprintf(message,"[%d,\"%s\",%s]"
  8031. ,MESSAGE_TYPE_CALLRESULT
  8032. ,uuid
  8033. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  8034. json_object_put(SetNetworkProfile);
  8035. LWS_Send(message);
  8036. result = TRUE;
  8037. return result;
  8038. }
  8039. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  8040. {
  8041. mtrace();
  8042. int result = FAIL;
  8043. char message[4096]={0};
  8044. json_object *SetVariableMonitoring = json_object_new_object();
  8045. json_object *setMonitoringResults = json_object_new_array();
  8046. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  8047. for(int idx=0;idx<variableQuantity;idx++)
  8048. {
  8049. json_object *variableMonitorResult = json_object_new_object();
  8050. json_object *component = json_object_new_object();
  8051. json_object *variable = json_object_new_object();
  8052. json_object *evse = json_object_new_object();
  8053. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  8054. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  8055. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  8056. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  8057. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  8058. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  8059. json_object_object_add(component, "component", evse);
  8060. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  8061. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  8062. json_object_object_add(variableMonitorResult, "component", component);
  8063. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  8064. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  8065. json_object_object_add(variableMonitorResult, "variable", variable);
  8066. json_object_array_add(setMonitoringResults, variableMonitorResult);
  8067. }
  8068. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  8069. sprintf(message,"[%d,\"%s\",%s]"
  8070. ,MESSAGE_TYPE_CALLRESULT
  8071. ,uuid
  8072. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  8073. json_object_put(SetVariableMonitoring);
  8074. LWS_Send(message);
  8075. result = TRUE;
  8076. return result;
  8077. }
  8078. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  8079. {
  8080. mtrace();
  8081. int result = FAIL;
  8082. char message[4096]={0};
  8083. json_object *SetVariable = json_object_new_object();
  8084. json_object *setVariableResults = json_object_new_array();
  8085. DEBUG_INFO("sendSetVariableConfirmation...\n");
  8086. for(int idx=0;idx<variableQuantity;idx++)
  8087. {
  8088. json_object *variableResult = json_object_new_object();
  8089. json_object *component = json_object_new_object();
  8090. json_object *variable = json_object_new_object();
  8091. json_object *evse = json_object_new_object();
  8092. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  8093. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  8094. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  8095. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  8096. json_object_object_add(component, "component", evse);
  8097. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  8098. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  8099. json_object_object_add(variableResult, "component", component);
  8100. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  8101. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  8102. json_object_object_add(variableResult, "variable", variable);
  8103. json_object_array_add(setVariableResults, variableResult);
  8104. }
  8105. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  8106. sprintf(message,"[%d,\"%s\",%s]"
  8107. ,MESSAGE_TYPE_CALLRESULT
  8108. ,uuid
  8109. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  8110. json_object_put(SetVariable);
  8111. LWS_Send(message);
  8112. result = TRUE;
  8113. return result;
  8114. }
  8115. int sendTriggerMessageConfirmation(char *uuid)
  8116. {
  8117. mtrace();
  8118. int result = FAIL;
  8119. char message[4096]={0};
  8120. json_object *TriggerMessage = json_object_new_object();
  8121. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  8122. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  8123. sprintf(message,"[%d,\"%s\",%s]",
  8124. MESSAGE_TYPE_CALLRESULT,
  8125. uuid,
  8126. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  8127. json_object_put(TriggerMessage);
  8128. LWS_Send(message);
  8129. result = TRUE;
  8130. return result;
  8131. }
  8132. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  8133. {
  8134. mtrace();
  8135. int result = FAIL;
  8136. char message[4096]={0};
  8137. json_object *UnlockConnector = json_object_new_object();
  8138. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  8139. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  8140. sprintf(message,"[%d,\"%s\",%s]",
  8141. MESSAGE_TYPE_CALLRESULT,
  8142. uuid,
  8143. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  8144. json_object_put(UnlockConnector);
  8145. LWS_Send(message);
  8146. result = TRUE;
  8147. return result;
  8148. }
  8149. int sendUnpublishFirmwareConfirmation(char *uuid)
  8150. {
  8151. mtrace();
  8152. int result = FAIL;
  8153. char message[4096]={0};
  8154. json_object *UnpublishFirmware = json_object_new_object();
  8155. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  8156. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  8157. sprintf(message,"[%d,\"%s\",%s]"
  8158. ,MESSAGE_TYPE_CALLRESULT
  8159. ,uuid
  8160. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  8161. json_object_put(UnpublishFirmware);
  8162. LWS_Send(message);
  8163. result = TRUE;
  8164. return result;
  8165. }
  8166. int sendUpdateFirmwareConfirmation(char *uuid)
  8167. {
  8168. mtrace();
  8169. int result = FAIL;
  8170. char message[4096]={0};
  8171. json_object *UpdateFirmware = json_object_new_object();
  8172. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  8173. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  8174. sprintf(message,"[%d,\"%s\",%s]"
  8175. ,MESSAGE_TYPE_CALLRESULT
  8176. ,uuid
  8177. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  8178. json_object_put(UpdateFirmware);
  8179. LWS_Send(message);
  8180. result = TRUE;
  8181. return result;
  8182. }
  8183. //==========================================
  8184. // send CallError routine
  8185. //==========================================
  8186. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  8187. {
  8188. mtrace();
  8189. char message[220]={0};
  8190. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  8191. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  8192. LWS_Send(message);
  8193. }
  8194. //==========================================
  8195. // Handle server request routine Start
  8196. //==========================================
  8197. int handleCancelReservationRequest(char *uuid, char *payload)
  8198. {
  8199. mtrace();
  8200. int result = FAIL;
  8201. int gunNO = 0;
  8202. int reservationIdInt = -1;
  8203. DEBUG_INFO("handleCancelReservationRequest...\n");
  8204. json_object *CancelReservation;
  8205. CancelReservation = json_tokener_parse(payload);
  8206. if(!is_error(CancelReservation))
  8207. {
  8208. // Required data
  8209. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  8210. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  8211. }
  8212. json_object_put(CancelReservation);
  8213. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  8214. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  8215. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  8216. if(reservationIdInt != -1)
  8217. {
  8218. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  8219. //check Transaction active
  8220. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  8221. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8222. {
  8223. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  8224. {
  8225. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8226. if(gunType[2] == 'J')
  8227. {
  8228. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  8229. }
  8230. else
  8231. {
  8232. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  8233. }
  8234. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8235. goto end;
  8236. }
  8237. }
  8238. for (int index = 0; index < CCS_QUANTITY; index++)
  8239. {
  8240. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  8241. {
  8242. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8243. if((gunType[2] == 'U') || (gunType[2] == 'E'))
  8244. {
  8245. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  8246. }
  8247. else
  8248. {
  8249. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  8250. }
  8251. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8252. goto end;
  8253. }
  8254. }
  8255. for (int index = 0; index < GB_QUANTITY; index++)
  8256. {
  8257. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  8258. {
  8259. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8260. if(gunType[2] == 'G')
  8261. {
  8262. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  8263. }
  8264. else
  8265. {
  8266. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  8267. }
  8268. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8269. goto end;
  8270. }
  8271. }
  8272. for (int index = 0; index < AC_QUANTITY; index++)
  8273. {
  8274. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  8275. {
  8276. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8277. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8278. {
  8279. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  8280. }
  8281. else
  8282. {
  8283. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  8284. }
  8285. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8286. goto end;
  8287. }
  8288. }
  8289. }
  8290. //The reservationId does NOT match the reservationId
  8291. sendCancelReservationConfirmation(uuid, gunNO);
  8292. end:
  8293. // Fill in ocpp packet uuid
  8294. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  8295. return result;
  8296. }
  8297. int handleCertificateSignedRequest(char *uuid, char *payload)
  8298. {
  8299. mtrace();
  8300. int result = FAIL;
  8301. json_object *CertificateSigned;
  8302. DEBUG_INFO("handleCertificateSignedRequest...\n");
  8303. CertificateSigned = json_tokener_parse(payload);
  8304. if(!is_error(CertificateSigned))
  8305. {
  8306. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  8307. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  8308. // Required data
  8309. if(json_object_array_length(json_object_object_get(CertificateSigned, "certificate")) <= ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.certificate))
  8310. {
  8311. for(int idx=0;idx<json_object_array_length(json_object_object_get(CertificateSigned, "certificate"));idx++)
  8312. {
  8313. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificate[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(CertificateSigned, "certificateType"), idx)));
  8314. /*
  8315. * TODO:
  8316. * 1. Certificate install response
  8317. */
  8318. }
  8319. }
  8320. // Optional data
  8321. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  8322. {
  8323. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  8324. }
  8325. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  8326. }
  8327. else
  8328. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  8329. json_object_put(CertificateSigned);
  8330. sendCertificateSignedConfirmation(uuid);
  8331. return result;
  8332. }
  8333. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  8334. {
  8335. mtrace();
  8336. int result = FAIL;
  8337. int evseId = 0, gunIndex = 0;
  8338. char operationalStatus[16]={0};
  8339. char comfirmstr[20];
  8340. int specificId = FALSE;
  8341. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  8342. json_object *ChangeAvailability;
  8343. ChangeAvailability = json_tokener_parse(payload);
  8344. if(!is_error(ChangeAvailability))
  8345. {
  8346. // Required data
  8347. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  8348. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  8349. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  8350. {
  8351. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  8352. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  8353. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  8354. }
  8355. }
  8356. json_object_put(ChangeAvailability);
  8357. if((evseId != 0) && (evseId <= gunTotalNumber))
  8358. {
  8359. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  8360. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  8361. }
  8362. else if(evseId == 0)
  8363. {
  8364. for(int i=0; i < gunTotalNumber; i++)
  8365. {
  8366. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  8367. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8368. }
  8369. }
  8370. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8371. {
  8372. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  8373. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  8374. }
  8375. else if(gunIndex == 0)
  8376. {
  8377. for(int i=0; i < gunTotalNumber; i++)
  8378. {
  8379. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  8380. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8381. }
  8382. }
  8383. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  8384. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8385. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  8386. {
  8387. specificId = TRUE;
  8388. }
  8389. if(specificId == FALSE)
  8390. goto end;
  8391. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  8392. {
  8393. //----------------------gunIndex is 0 ------------------------------------------------//
  8394. if(gunIndex == 0)
  8395. {
  8396. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8397. {
  8398. for(int i=0; i < gunTotalNumber; i++)
  8399. {
  8400. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8401. {
  8402. if ((gunType[i] == 'J')&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  8403. {
  8404. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8405. {
  8406. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8407. goto end;
  8408. }
  8409. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8410. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8411. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8412. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8413. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8414. {
  8415. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8416. goto end;
  8417. }
  8418. }
  8419. }//END FOR CHAdeMO_QUANTITY
  8420. for (int index = 0; index < CCS_QUANTITY; index++)
  8421. {
  8422. if (((gunType[i] == 'U')||(gunType[i] == 'E'))&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  8423. {
  8424. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  8425. {
  8426. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8427. goto end;
  8428. }
  8429. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8430. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8431. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8432. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8433. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8434. {
  8435. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8436. goto end;
  8437. }
  8438. }
  8439. }//END FOR CCS_QUANTITY
  8440. for (int index = 0; index < GB_QUANTITY; index++)
  8441. {
  8442. if ((gunType[i] == 'G')&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  8443. {
  8444. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8445. {
  8446. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8447. goto end;
  8448. }
  8449. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8450. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8451. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8452. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8453. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8454. {
  8455. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8456. goto end;
  8457. }
  8458. }
  8459. }// END FOR GB_QUANTITY
  8460. for (int index = 0; index < AC_QUANTITY; index++)
  8461. {
  8462. if (((gunType[i] > '0')&&(gunType[i] <= '9'))&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  8463. {
  8464. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8465. {
  8466. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8467. goto end;
  8468. }
  8469. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8470. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8471. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8472. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8473. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8474. {
  8475. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8476. goto end;
  8477. }
  8478. }
  8479. }//END FOR AC_QUANTITY
  8480. }// END FOR gunTotalNumber
  8481. }
  8482. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8483. {
  8484. for(int i=0; i < gunTotalNumber; i++)
  8485. {
  8486. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8487. {
  8488. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8489. goto end;
  8490. }
  8491. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8492. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  8493. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  8494. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  8495. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8496. {
  8497. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8498. goto end;
  8499. }
  8500. }
  8501. }
  8502. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8503. goto end;
  8504. }
  8505. //----------------------gunIndex is not 0 ------------------------------------------------//
  8506. //check Transaction active
  8507. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8508. {
  8509. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J'))
  8510. {
  8511. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  8512. {
  8513. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8514. goto end;
  8515. }
  8516. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8517. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8518. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8519. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8520. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8521. {
  8522. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8523. goto end;
  8524. }
  8525. else
  8526. {
  8527. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  8528. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8529. goto end;
  8530. }
  8531. }
  8532. }//END FOR CHAdeMO_QUANTITY
  8533. for (int index = 0; index < CCS_QUANTITY; index++)
  8534. {
  8535. if ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E')))
  8536. {
  8537. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  8538. {
  8539. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8540. goto end;
  8541. }
  8542. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8543. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8544. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8545. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8546. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8547. {
  8548. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8549. goto end;
  8550. }
  8551. else
  8552. {
  8553. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  8554. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8555. goto end;
  8556. }
  8557. }
  8558. }//END FOR CCS_QUANTITY
  8559. for (int index = 0; index < GB_QUANTITY; index++)
  8560. {
  8561. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))
  8562. {
  8563. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8564. {
  8565. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8566. goto end;
  8567. }
  8568. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8569. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8570. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8571. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8572. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8573. {
  8574. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8575. goto end;
  8576. }
  8577. else
  8578. {
  8579. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  8580. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8581. goto end;
  8582. }
  8583. }
  8584. }// END FOR GB_QUANTITY
  8585. for (int index = 0; index < AC_QUANTITY; index++)
  8586. {
  8587. if ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))
  8588. {
  8589. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8590. {
  8591. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8592. goto end;
  8593. }
  8594. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8595. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8596. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8597. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8598. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8599. {
  8600. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8601. goto end;
  8602. }
  8603. else
  8604. {
  8605. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  8606. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8607. goto end;
  8608. }
  8609. }
  8610. }//END FOR AC_QUANTITY
  8611. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  8612. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  8613. {
  8614. //----------------------gunIndex is 0 ------------------------------------------------//
  8615. if(gunIndex == 0)
  8616. {
  8617. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8618. {
  8619. for(int i=0; i < gunTotalNumber; i++)
  8620. {
  8621. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8622. {
  8623. if ((gunType[i] == 'J' )&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT //(((gunIndex == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J')) ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8624. {
  8625. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8626. goto end;
  8627. }
  8628. }//END FOR CHAdeMO_QUANTITY
  8629. for (int index = 0; index < CCS_QUANTITY; index++)
  8630. {
  8631. if (((gunType[i] == 'U')||(gunType[i] == 'E'))&&(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
  8632. {
  8633. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8634. goto end;
  8635. }
  8636. }//END FOR CCS_QUANTITY
  8637. for (int index = 0; index < GB_QUANTITY; index++)
  8638. {
  8639. if ((gunType[i] == 'G')&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)) //S_FAULT //(((gunIndex == 0)|| ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G')))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8640. {
  8641. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8642. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8643. goto end;
  8644. }
  8645. }// END FOR GB_QUANTITY
  8646. for (int index = 0; index < AC_QUANTITY; index++)
  8647. {
  8648. if (((gunType[i] > '0')&&(gunType[i] <= '9')) &&(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
  8649. {
  8650. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8651. goto end;
  8652. }
  8653. }//END FOR CHAdeMO_QUANTITY
  8654. }// END FOR gunTotalNumber
  8655. }
  8656. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8657. {
  8658. for(int i=0; i < gunTotalNumber; i++)
  8659. {
  8660. for (int index = 0; index < AC_QUANTITY; index++)
  8661. {
  8662. if (((gunType[i] > '0')&&(gunType[i] <= '9')) &&(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
  8663. {
  8664. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8665. goto end;
  8666. }
  8667. }//END FOR CHAdeMO_QUANTITY
  8668. } // END FOR gunTotalNumber
  8669. }
  8670. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8671. goto end;
  8672. }
  8673. //----------------------gunIndex is not 0 ------------------------------------------------//
  8674. //check Transaction active
  8675. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8676. {
  8677. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'J') ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8678. {
  8679. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8680. goto end;
  8681. }
  8682. }//END FOR CHAdeMO_QUANTITY
  8683. for (int index = 0; index < CCS_QUANTITY; index++)
  8684. {
  8685. if ((((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8686. {
  8687. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8688. goto end;
  8689. }
  8690. }//END FOR CCS_QUANTITY
  8691. for (int index = 0; index < GB_QUANTITY; index++)
  8692. {
  8693. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8694. {
  8695. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8696. goto end;
  8697. }
  8698. }// END FOR GB_QUANTITY
  8699. for (int index = 0; index < AC_QUANTITY; index++)
  8700. {
  8701. if (((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9'))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8702. {
  8703. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8704. goto end;
  8705. }
  8706. }//END FOR AC_QUANTITY
  8707. }//END FOR AvailabilityEnumTypeStr[Operative]
  8708. end:
  8709. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8710. {
  8711. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  8712. }
  8713. else
  8714. {
  8715. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  8716. }
  8717. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8718. {
  8719. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  8720. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8721. }
  8722. else if(gunIndex == 0)
  8723. {
  8724. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  8725. {
  8726. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  8727. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  8728. }
  8729. }
  8730. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  8731. return result;
  8732. }
  8733. int handleClearCacheRequest(char *uuid, char *payload)
  8734. {
  8735. mtrace();
  8736. int result = FAIL;
  8737. char rmFileCmd[100]={0};
  8738. struct stat stats;
  8739. DEBUG_INFO("handleClearCacheRequest...\n");
  8740. stat("/Storage/OCPP", &stats);
  8741. // Check for directory existence
  8742. if (S_ISDIR(stats.st_mode) == 1)
  8743. {}
  8744. else
  8745. {
  8746. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  8747. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  8748. system(rmFileCmd);
  8749. }
  8750. /*
  8751. * TODO:
  8752. * 1. Clear cache from sqlite db
  8753. */
  8754. if(1)
  8755. {
  8756. DEBUG_INFO("open AuthorizationCache file failed\n");
  8757. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  8758. }
  8759. else
  8760. {
  8761. DEBUG_INFO("open AuthorizationCache file successful\n");
  8762. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  8763. }
  8764. sendClearCacheConfirmation(uuid);
  8765. return result;
  8766. }
  8767. int handleClearChargingProfileRequest(char *uuid, char *payload)
  8768. {
  8769. mtrace();
  8770. int result = FAIL;
  8771. int resultRename;
  8772. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  8773. char chargingProfilePurposeStr[26]={0};
  8774. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  8775. char tempchargingProfilePurposeStr[26]={0};
  8776. char sstr[160]={0};
  8777. char str[100]={0};
  8778. int c = 0;
  8779. char *loc;
  8780. char fname[200]={0};
  8781. char comfirmstr[20]={0};
  8782. char word[1600]={0};
  8783. int clearflag = FALSE;
  8784. int chargingProfileIdIsNULL = FALSE;
  8785. int connectorIsNULL = FALSE;
  8786. int chargingProfilePurposeIsNULL = FALSE;
  8787. int stackLevelIsNULL = FALSE;
  8788. //int GotoEnd = FALSE;
  8789. FILE *fptr1, *fptr2;
  8790. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  8791. int n_chargingProfile=0;
  8792. int isEmptyFile = FALSE;
  8793. char sLineWord[1600]={0};
  8794. char chargingProfiles[10][100]={0};
  8795. int ChargeProfileCount = 0;
  8796. int ch;
  8797. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  8798. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  8799. json_object *ClearChargingProfile;
  8800. ClearChargingProfile = json_tokener_parse(payload);
  8801. if(!is_error(ClearChargingProfile))
  8802. {
  8803. // Optional data
  8804. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  8805. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  8806. else
  8807. chargingProfileIdIsNULL = TRUE;
  8808. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  8809. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  8810. else
  8811. connectorIsNULL = TRUE;
  8812. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  8813. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  8814. else
  8815. chargingProfilePurposeIsNULL = TRUE;
  8816. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  8817. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  8818. else
  8819. stackLevelIsNULL = TRUE;
  8820. }
  8821. json_object_put(ClearChargingProfile);
  8822. if(connectorIsNULL == FALSE)
  8823. {
  8824. switch(connectorIdInt)
  8825. {
  8826. case 0:
  8827. if(chargingProfilePurposeIsNULL == TRUE)
  8828. {
  8829. int l = 0;
  8830. strcpy(fname, ChargePointMaxProfile_JSON);
  8831. if((access(fname,F_OK))!=-1)
  8832. {
  8833. strcpy(chargingProfiles[l], fname);
  8834. l = l + 1;
  8835. }
  8836. strcpy(fname, TxDefaultProfile_0_JSON);
  8837. if((access(fname,F_OK))!=-1)
  8838. {
  8839. strcpy(chargingProfiles[l], fname);
  8840. l = l + 1;
  8841. }
  8842. ChargeProfileCount = l;
  8843. }
  8844. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  8845. {
  8846. strcpy(fname, ChargePointMaxProfile_JSON);
  8847. if((access(fname,F_OK))!=-1)
  8848. {
  8849. strcpy(chargingProfiles[0], fname);
  8850. ChargeProfileCount = 1;
  8851. }
  8852. }
  8853. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  8854. {
  8855. strcpy(fname, TxDefaultProfile_0_JSON);
  8856. if((access(fname,F_OK))!=-1)
  8857. {
  8858. strcpy(chargingProfiles[0], fname);
  8859. ChargeProfileCount = 1;
  8860. }
  8861. }
  8862. break;
  8863. default:
  8864. if(chargingProfilePurposeIsNULL == TRUE)
  8865. {
  8866. int m = 0;
  8867. memset(fname, 0, ARRAY_SIZE(fname));
  8868. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  8869. if((access(fname,F_OK))!=-1)
  8870. {
  8871. strcpy(chargingProfiles[m], fname);
  8872. m = m + 1;
  8873. }
  8874. memset(fname, 0, ARRAY_SIZE(fname));
  8875. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  8876. if((access(fname,F_OK))!=-1)
  8877. {
  8878. strcpy(chargingProfiles[m], fname);
  8879. m = m + 1;
  8880. }
  8881. ChargeProfileCount = m;
  8882. }
  8883. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  8884. {
  8885. //strcpy(fname, TxDefaultProfile_1_JSON);
  8886. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  8887. if((access(fname,F_OK))!=-1)
  8888. {
  8889. strcpy(chargingProfiles[0], fname);
  8890. ChargeProfileCount = 1;
  8891. }
  8892. }
  8893. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  8894. {
  8895. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  8896. if((access(fname,F_OK))!=-1)
  8897. {
  8898. strcpy(chargingProfiles[0], fname);
  8899. ChargeProfileCount = 1;
  8900. }
  8901. }
  8902. //strcpy(fname, ChargePointMaxProfile_JSON );
  8903. break;
  8904. }
  8905. }
  8906. else // Check all Charging Profiles
  8907. {
  8908. int i = 0;
  8909. char fnametemp[200]={0};
  8910. ChargeProfileCount = 0;
  8911. //Check ChargePointMaxProfile.json exit
  8912. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  8913. {
  8914. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  8915. i = i + 1;
  8916. }
  8917. //Check TxDefaultProfile_0.json exit
  8918. if((access("/Storage/OCPP/TxDefaultProfile_0.json",F_OK))!=-1)
  8919. {
  8920. strcpy(chargingProfiles[i], "/Storage/OCPP/TxDefaultProfile_0.json");
  8921. i = i + 1;
  8922. }
  8923. //Check TxDefaultProfile_%d.json
  8924. for(int j=1; j <= gunTotalNumber; j++)
  8925. {
  8926. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  8927. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d.json", j);
  8928. if((access(fnametemp,F_OK))!=-1)
  8929. {
  8930. strcpy(chargingProfiles[i], fnametemp);
  8931. i = i + 1;
  8932. }
  8933. }
  8934. //Check TxProfile_%d.json
  8935. for(int j=1; j <= gunTotalNumber; j++)
  8936. {
  8937. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  8938. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d.json", j);
  8939. if((access(fnametemp,F_OK))!=-1)
  8940. {
  8941. strcpy(chargingProfiles[i], fnametemp);
  8942. i = i + 1;
  8943. }
  8944. }
  8945. ChargeProfileCount = i;
  8946. }// End connectorIsNULL is TRUE
  8947. if(ChargeProfileCount == 0)
  8948. {
  8949. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  8950. goto end;
  8951. }
  8952. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  8953. {
  8954. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  8955. goto end;
  8956. }
  8957. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  8958. {
  8959. memset(str, 0, ARRAY_SIZE(str));
  8960. // clear temp file
  8961. sprintf(str,"rm -f %s",temp);
  8962. system(str);
  8963. for(int k=0; k < ChargeProfileCount; k++)
  8964. {
  8965. memset(str, 0, ARRAY_SIZE(str));
  8966. //clear file in C
  8967. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8968. system(str);
  8969. }
  8970. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8971. goto end;
  8972. }
  8973. else if(connectorIsNULL == TRUE)
  8974. {
  8975. for(int k=0; k < ChargeProfileCount; k++)
  8976. {
  8977. fptr1 = fopen(chargingProfiles[k], "r");
  8978. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  8979. //Check Charging Profile Count
  8980. while(fscanf(fptr1, "%s", word) != EOF)
  8981. {
  8982. //DEBUG_INFO("word=%s\n",word);
  8983. if(strstr(word, "chargingProfileId")!= NULL)
  8984. {
  8985. //DEBUG_INFO("test chargingProfileId \n");
  8986. n_chargingProfile = n_chargingProfile + 1;
  8987. //DEBUG_INFO("chargingProfileId Found\n");
  8988. }
  8989. }
  8990. rewind(fptr1);
  8991. //search Charging Profile Element
  8992. //int i= 0;
  8993. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  8994. {
  8995. //------------------------tempconnectorIdInt------------------------//
  8996. loc = strstr(sLineWord, "connectorId");
  8997. c = 0;
  8998. memset(sstr ,0, sizeof(sstr) );
  8999. while (loc[strlen("connectorId")+2+c] != ',')
  9000. {
  9001. sstr[c] = loc[strlen("connectorId")+2+c];
  9002. c++;
  9003. }
  9004. sstr[c] = '\0';
  9005. tempconnectorIdInt = atoi(sstr);
  9006. printf("file's gun number is %d\n", tempconnectorIdInt);
  9007. //--------------------------chargingProfileId--------------------//
  9008. c = 0;
  9009. loc = strstr(sLineWord, "chargingProfileId");
  9010. memset(sstr ,0, ARRAY_SIZE(sstr));
  9011. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9012. {
  9013. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9014. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9015. c++;
  9016. }
  9017. sstr[c] = '\0';
  9018. tempchargingProfileIdInt = atoi(sstr);
  9019. //stackLevel
  9020. c = 0;
  9021. loc = strstr(sLineWord, "stackLevel");
  9022. memset(sstr ,0, ARRAY_SIZE(sstr));
  9023. while (loc[strlen("stackLevel")+2+c] != ',')
  9024. {
  9025. sstr[c] = loc[strlen("stackLevel")+2+c];
  9026. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9027. c++;
  9028. }
  9029. sstr[c] = '\0';
  9030. tempstackLevelInt = atoi(sstr);
  9031. c = 0;
  9032. loc = strstr(sLineWord, "chargingProfilePurpose");
  9033. memset(sstr ,0, ARRAY_SIZE(sstr));
  9034. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9035. {
  9036. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9037. c++;
  9038. }
  9039. sstr[c] = '\0';
  9040. strcpy(tempchargingProfilePurposeStr, sstr);
  9041. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9042. {
  9043. //------- not write to fptr2-------//
  9044. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9045. //clearflag = TRUE;
  9046. }
  9047. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  9048. {
  9049. //------- not write to fptr2-------//
  9050. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9051. }
  9052. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9053. {
  9054. //------- not write to fptr2-------//
  9055. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9056. }
  9057. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  9058. {
  9059. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9060. }
  9061. else
  9062. {
  9063. fprintf(fptr2, sLineWord);//writing data into file
  9064. }
  9065. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9066. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9067. if(clearflag == TRUE)
  9068. {
  9069. fclose(fptr1);
  9070. fclose(fptr2);
  9071. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9072. system(str);
  9073. // clear temp file
  9074. sprintf(str,"rm -f %s",temp);
  9075. system(str);
  9076. }
  9077. else
  9078. {
  9079. fclose(fptr1);
  9080. fclose(fptr2);
  9081. memset(str, 0, ARRAY_SIZE(str));
  9082. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9083. system(str);
  9084. resultRename = rename(temp, chargingProfiles[k]);
  9085. if(resultRename == 0)
  9086. {
  9087. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  9088. }
  9089. else
  9090. {
  9091. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  9092. }
  9093. if(comfirmstr[0]== 0)
  9094. {
  9095. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9096. }
  9097. //Check chargingProfile is empty file
  9098. /*------ Read the file ----------------*/
  9099. fptr1=fopen(chargingProfiles[k],"r");
  9100. ch=fgetc(fptr1);
  9101. rewind(fptr1);
  9102. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9103. if(ch!=EOF)
  9104. {
  9105. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9106. {
  9107. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9108. if(sLineWord[0]=='\0')
  9109. {
  9110. isEmptyFile = TRUE;
  9111. break;
  9112. }
  9113. else
  9114. {
  9115. isEmptyFile = FALSE;
  9116. break;
  9117. }
  9118. }
  9119. }
  9120. else
  9121. isEmptyFile = TRUE;
  9122. fclose(fptr1);
  9123. if(isEmptyFile == TRUE)
  9124. {
  9125. memset(str, 0, ARRAY_SIZE(str));
  9126. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9127. system(str);
  9128. }
  9129. }
  9130. }// End of while(int k=0; k < ChargePointCount; k++)
  9131. }
  9132. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  9133. {
  9134. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  9135. for(int k=0; k < ChargeProfileCount; k++)
  9136. {
  9137. fptr1 = fopen(chargingProfiles[k], "r");
  9138. fptr2 = fopen(temp, "w+");
  9139. //Check Charging Profile Count
  9140. while(fscanf(fptr1, "%s", word) != EOF)
  9141. {
  9142. //DEBUG_INFO("word=%s\n",word);
  9143. if(strstr(word, "chargingProfileId")!= NULL)
  9144. {
  9145. n_chargingProfile = n_chargingProfile + 1;
  9146. }
  9147. }
  9148. rewind(fptr1);
  9149. //search Charging Profile Element
  9150. //int i= 0;
  9151. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9152. {
  9153. //*************************tempconnectorIdInt*********************************/
  9154. loc = strstr(sLineWord, "connectorId");
  9155. c = 0;
  9156. memset(sstr ,0, ARRAY_SIZE(sstr));
  9157. while (loc[strlen("connectorId")+2+c] != ',')
  9158. {
  9159. sstr[c] = loc[strlen("connectorId")+2+c];
  9160. c++;
  9161. }
  9162. sstr[c] = '\0';
  9163. tempconnectorIdInt = atoi(sstr);
  9164. //chargingProfileId
  9165. c = 0;
  9166. loc = strstr(sLineWord, "chargingProfileId");
  9167. memset(sstr ,0, ARRAY_SIZE(sstr));
  9168. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9169. {
  9170. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9171. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9172. c++;
  9173. }
  9174. sstr[c] = '\0';
  9175. tempchargingProfileIdInt = atoi(sstr);
  9176. //stackLevel
  9177. c = 0;
  9178. loc = strstr(sLineWord, "stackLevel");
  9179. memset(sstr ,0, ARRAY_SIZE(sstr));
  9180. while (loc[strlen("stackLevel")+2+c] != ',')
  9181. {
  9182. sstr[c] = loc[strlen("stackLevel")+2+c];
  9183. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9184. c++;
  9185. }
  9186. sstr[c] = '\0';
  9187. tempstackLevelInt = atoi(sstr);
  9188. c = 0;
  9189. loc = strstr(sLineWord, "chargingProfilePurpose");
  9190. memset(sstr ,0, ARRAY_SIZE(sstr));
  9191. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9192. {
  9193. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9194. c++;
  9195. }
  9196. sstr[c] = '\0';
  9197. strcpy(tempchargingProfilePurposeStr, sstr);
  9198. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9199. {
  9200. //------- not write to fptr2-------//
  9201. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9202. //clearflag = TRUE;
  9203. }
  9204. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9205. {
  9206. //------- not write to fptr2-------//
  9207. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9208. }
  9209. else if(stackLevelIsNULL == TRUE)
  9210. {
  9211. //Clear Whole File
  9212. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9213. clearflag = TRUE;
  9214. break;
  9215. }
  9216. else
  9217. {
  9218. fprintf(fptr2, sLineWord);//writing data into file
  9219. }
  9220. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9221. }
  9222. if(clearflag == TRUE)
  9223. {
  9224. fclose(fptr1);
  9225. fclose(fptr2);
  9226. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9227. system(str);
  9228. // clear temp file
  9229. sprintf(str,"rm -f %s",temp);
  9230. system(str);
  9231. }
  9232. else
  9233. {
  9234. fclose(fptr1);
  9235. fclose(fptr2);
  9236. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9237. system(str);
  9238. resultRename = rename(temp, chargingProfiles[k]);
  9239. if(resultRename == 0)
  9240. {
  9241. DEBUG_INFO("File ChargingProfile renamed successfully");
  9242. }
  9243. else
  9244. {
  9245. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  9246. }
  9247. if(comfirmstr[0]== 0)
  9248. {
  9249. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9250. }
  9251. //Check chargingProfile is empty file
  9252. /*------ Read the file ----------------*/
  9253. fptr1=fopen(chargingProfiles[k],"r");
  9254. ch=fgetc(fptr1);
  9255. rewind(fptr1);
  9256. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9257. if(ch!=EOF)
  9258. {
  9259. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9260. {
  9261. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9262. if(sLineWord[0]=='\0')
  9263. {
  9264. isEmptyFile = TRUE;
  9265. break;
  9266. }
  9267. else
  9268. {
  9269. isEmptyFile = FALSE;
  9270. break;
  9271. }
  9272. }
  9273. }
  9274. else
  9275. isEmptyFile = TRUE;
  9276. fclose(fptr1);
  9277. if(isEmptyFile == TRUE)
  9278. {
  9279. memset(str, 0, ARRAY_SIZE(str));
  9280. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9281. system(str);
  9282. }
  9283. /*------- End of reading ---------------*/
  9284. }
  9285. } // while(int k=0; k < ChargeProfileCount; k++)
  9286. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  9287. end:
  9288. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  9289. {
  9290. if(connectorIdInt == 0)
  9291. {
  9292. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  9293. {
  9294. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  9295. }
  9296. }
  9297. else
  9298. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1]);
  9299. }
  9300. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  9301. return result;
  9302. }
  9303. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  9304. {
  9305. mtrace();
  9306. int result = FAIL;
  9307. json_object *ClearDisplayMessage;
  9308. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  9309. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  9310. ClearDisplayMessage = json_tokener_parse(payload);
  9311. if(!is_error(ClearDisplayMessage))
  9312. {
  9313. // Required data
  9314. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  9315. {
  9316. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  9317. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  9318. }
  9319. }
  9320. json_object_put(ClearDisplayMessage);
  9321. sendCostUpdatedConfirmation(uuid);
  9322. return result;
  9323. }
  9324. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  9325. {
  9326. mtrace();
  9327. int result = FAIL;
  9328. json_object *ClearVariableMonitorin;
  9329. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  9330. ClearVariableMonitorin = json_tokener_parse(payload);
  9331. if(!is_error(ClearVariableMonitorin))
  9332. {
  9333. // Required data
  9334. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  9335. {
  9336. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  9337. {
  9338. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  9339. /*
  9340. * TODO:
  9341. * 1. Check response
  9342. */
  9343. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  9344. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  9345. }
  9346. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  9347. }
  9348. }
  9349. json_object_put(ClearVariableMonitorin);
  9350. return result;
  9351. }
  9352. int handleCostUpdatedRequest(char *uuid, char *payload)
  9353. {
  9354. mtrace();
  9355. int result = FAIL;
  9356. json_object *CostUpdate;
  9357. DEBUG_INFO("handleCostUpdatedRequest...\n");
  9358. CostUpdate = json_tokener_parse(payload);
  9359. if(!is_error(CostUpdate))
  9360. {
  9361. // Required data
  9362. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  9363. {
  9364. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  9365. }
  9366. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  9367. {
  9368. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  9369. }
  9370. }
  9371. json_object_put(CostUpdate);
  9372. sendCostUpdatedConfirmation(uuid);
  9373. return result;
  9374. }
  9375. int handleCustomerInformationRequest(char *uuid, char *payload)
  9376. {
  9377. mtrace();
  9378. int result = FAIL;
  9379. json_object *CustomerInformation;
  9380. DEBUG_INFO("handleCustomerInformationRequest...\n");
  9381. CustomerInformation = json_tokener_parse(payload);
  9382. if(!is_error(CustomerInformation))
  9383. {
  9384. // Required data
  9385. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  9386. {
  9387. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  9388. }
  9389. if(json_object_object_get(CustomerInformation, "report") != NULL)
  9390. {
  9391. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  9392. }
  9393. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  9394. {
  9395. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  9396. }
  9397. // Optional data
  9398. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  9399. {
  9400. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  9401. {
  9402. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  9403. }
  9404. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  9405. {
  9406. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  9407. }
  9408. }
  9409. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  9410. {
  9411. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  9412. {
  9413. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  9414. }
  9415. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  9416. {
  9417. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  9418. }
  9419. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  9420. {
  9421. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  9422. }
  9423. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  9424. {
  9425. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  9426. }
  9427. }
  9428. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  9429. }
  9430. else
  9431. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  9432. json_object_put(CustomerInformation);
  9433. sendCustomerInformationConfirmation(uuid);
  9434. return result;
  9435. }
  9436. void createFirmwareVersionByDataTransfer(void)
  9437. {
  9438. json_object *FirmwareDataTransfer = json_object_new_object();
  9439. // AC & DC model
  9440. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  9441. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  9442. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  9443. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  9444. // DC model
  9445. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  9446. {
  9447. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  9448. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  9449. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  9450. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  9451. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  9452. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  9453. }
  9454. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
  9455. ((gunType[1] != '0') || (gunType[2] != '0') || (gunType[3] != '0')))
  9456. {
  9457. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  9458. }
  9459. // 4G model
  9460. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  9461. {
  9462. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  9463. }
  9464. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "Phihong Technology");
  9465. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion");
  9466. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, json_object_to_json_string(FirmwareDataTransfer));
  9467. }
  9468. int handleDataTransferRequest(char *uuid, char *payload)
  9469. {
  9470. mtrace();
  9471. int result = PASS;
  9472. DEBUG_INFO("handleDataTransferRequest...\n");
  9473. if((uuid != NULL) && (payload != NULL))
  9474. {
  9475. json_object *DataTransfer;
  9476. DataTransfer = json_tokener_parse(payload);
  9477. if(!is_error(DataTransfer))
  9478. {
  9479. // Required data
  9480. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  9481. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  9482. // Optional data
  9483. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  9484. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  9485. if(json_object_object_get(DataTransfer, "data") != NULL)
  9486. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  9487. result = PASS;
  9488. }
  9489. json_object_put(DataTransfer);
  9490. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  9491. {
  9492. // Send all moudle firmware version on EVSE
  9493. system("/usr/bin/run_tmate_restart.sh");
  9494. createFirmwareVersionByDataTransfer();
  9495. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9496. }
  9497. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  9498. {
  9499. json_object *data;
  9500. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  9501. if(!is_error(data))
  9502. {
  9503. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  9504. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  9505. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  9506. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  9507. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  9508. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  9509. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  9510. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  9511. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  9512. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  9513. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9514. }
  9515. else
  9516. {
  9517. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  9518. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  9519. }
  9520. json_object_put(data);
  9521. }
  9522. else
  9523. {
  9524. // Can not find valid message id
  9525. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9526. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  9527. ,ShmOCPP20Data->DataTransfer[0].vendorId
  9528. ,ShmOCPP20Data->DataTransfer[0].messageId
  9529. ,ShmOCPP20Data->DataTransfer[0].data);
  9530. }
  9531. }
  9532. else
  9533. {
  9534. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9535. result = FAIL;
  9536. }
  9537. sendDataTransferConfirmation(uuid, 0);
  9538. return result;
  9539. }
  9540. int handleDeleteCertificateRequest(char *uuid, char *payload)
  9541. {
  9542. mtrace();
  9543. int result = FAIL;
  9544. json_object *DeleteCertificate;
  9545. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  9546. DeleteCertificate = json_tokener_parse(payload);
  9547. if(!is_error(DeleteCertificate))
  9548. {
  9549. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  9550. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  9551. // Required data
  9552. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  9553. {
  9554. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  9555. {
  9556. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  9557. }
  9558. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  9559. {
  9560. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  9561. }
  9562. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  9563. {
  9564. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  9565. }
  9566. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  9567. {
  9568. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  9569. }
  9570. /*
  9571. * TODO:
  9572. * 1. Delete certification and response
  9573. */
  9574. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  9575. }
  9576. }
  9577. else
  9578. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  9579. json_object_put(DeleteCertificate);
  9580. sendDeleteCertificateConfirmation(uuid);
  9581. return result;
  9582. }
  9583. int handleGetBaseReportRequest(char *uuid, char *payload)
  9584. {
  9585. mtrace();
  9586. int result = FAIL;
  9587. json_object *GetBaseRepor;
  9588. DEBUG_INFO("handleGetBaseReportRequest...\n");
  9589. GetBaseRepor = json_tokener_parse(payload);
  9590. if(!is_error(GetBaseRepor))
  9591. {
  9592. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  9593. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  9594. // Required data
  9595. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  9596. {
  9597. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  9598. }
  9599. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  9600. {
  9601. sprintf((char*)ShmOCPP20Data->GetBaseReport.requestId, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  9602. }
  9603. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  9604. }
  9605. else
  9606. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  9607. json_object_put(GetBaseRepor);
  9608. sendGetBaseReportConfirmation(uuid);
  9609. /*
  9610. * TODO:
  9611. * 1. Delete certification and response
  9612. */
  9613. return result;
  9614. }
  9615. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  9616. {
  9617. mtrace();
  9618. int result = FAIL;
  9619. int gun_index = -1;
  9620. json_object *GetChargingProfiles;
  9621. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  9622. GetChargingProfiles = json_tokener_parse(payload);
  9623. if(!is_error(GetChargingProfiles))
  9624. {
  9625. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  9626. {
  9627. 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;
  9628. }
  9629. if(gun_index >-1)
  9630. {
  9631. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  9632. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  9633. // Required data
  9634. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  9635. {
  9636. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  9637. }
  9638. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  9639. {
  9640. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  9641. {
  9642. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  9643. }
  9644. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  9645. {
  9646. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  9647. }
  9648. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  9649. {
  9650. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  9651. {
  9652. 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)));
  9653. }
  9654. }
  9655. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  9656. {
  9657. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  9658. {
  9659. 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));
  9660. }
  9661. }
  9662. }
  9663. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  9664. }
  9665. else
  9666. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  9667. }
  9668. json_object_put(GetChargingProfiles);
  9669. sendGetChargingProfilesConfirmation(uuid, gun_index);
  9670. return result;
  9671. }
  9672. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  9673. {
  9674. mtrace();
  9675. int result = FAIL;
  9676. int connectorIdInt, durationInt;
  9677. char chargingRateUnitStr[4]={0};
  9678. char comfirmstr[20];
  9679. int confirmPeriods = 0;
  9680. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  9681. json_object *GetCompositeSchedule;
  9682. GetCompositeSchedule = json_tokener_parse(payload);
  9683. if(!is_error(GetCompositeSchedule))
  9684. {
  9685. // Required data
  9686. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  9687. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  9688. else
  9689. connectorIdInt = -1;
  9690. if(json_object_object_get(GetCompositeSchedule, "duration"))
  9691. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  9692. else
  9693. durationInt = 86400;
  9694. // Optional data
  9695. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  9696. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  9697. }
  9698. json_object_put(GetCompositeSchedule);
  9699. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  9700. if((connectorIdInt == 0) ||
  9701. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  9702. {
  9703. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  9704. struct ChargingProfileType tmpProfile[1];
  9705. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  9706. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  9707. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0]);
  9708. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  9709. {
  9710. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  9711. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  9712. }
  9713. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  9714. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  9715. {
  9716. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  9717. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  9718. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  9719. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0))
  9720. {
  9721. confirmPeriods = idx;
  9722. break;
  9723. }
  9724. }
  9725. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  9726. }
  9727. else
  9728. {
  9729. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  9730. }
  9731. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  9732. return result;
  9733. }
  9734. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  9735. {
  9736. mtrace();
  9737. int result = FAIL;
  9738. json_object *GetDisplayMessages;
  9739. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  9740. GetDisplayMessages = json_tokener_parse(payload);
  9741. if(!is_error(GetDisplayMessages))
  9742. {
  9743. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  9744. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  9745. // Required data
  9746. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  9747. {
  9748. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  9749. }
  9750. // Optional data
  9751. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  9752. {
  9753. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  9754. }
  9755. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  9756. {
  9757. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  9758. }
  9759. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  9760. {
  9761. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  9762. {
  9763. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  9764. }
  9765. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  9766. }
  9767. else
  9768. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  9769. }
  9770. json_object_put(GetDisplayMessages);
  9771. return result;
  9772. }
  9773. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  9774. {
  9775. mtrace();
  9776. int result = FAIL;
  9777. json_object *GetInstalledCertificateIds;
  9778. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  9779. GetInstalledCertificateIds = json_tokener_parse(payload);
  9780. if(!is_error(GetInstalledCertificateIds))
  9781. {
  9782. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  9783. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  9784. // Optional data
  9785. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  9786. {
  9787. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  9788. {
  9789. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  9790. /*
  9791. * TODO:
  9792. * 1. Get installed certificate info for response
  9793. */
  9794. }
  9795. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  9796. }
  9797. else
  9798. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  9799. }
  9800. json_object_put(GetInstalledCertificateIds);
  9801. sendInstallCertificateConfirmation(uuid);
  9802. return result;
  9803. }
  9804. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  9805. {
  9806. mtrace();
  9807. int result = FAIL;
  9808. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  9809. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  9810. {
  9811. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  9812. localversion = -1;
  9813. }
  9814. else
  9815. {
  9816. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  9817. DB_getListVerion();
  9818. }
  9819. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  9820. sendGetLocalListVersionConfirmation(uuid);
  9821. return result;
  9822. }
  9823. static char fnamePlusPath[100]={0};
  9824. static char fnamePWithNoPath[60]={0};
  9825. void checkUploadLog(void)
  9826. {
  9827. FILE *fp;
  9828. /* Open the command for reading. */
  9829. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  9830. if (fp == NULL) {
  9831. printf("Failed to run command\n" );
  9832. exit(1);
  9833. }
  9834. int ftppathlen = 0;
  9835. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  9836. int i = 0;
  9837. /* Read the output a line at a time - output it. */
  9838. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  9839. if(i==0)
  9840. {
  9841. ftppathlen = strlen(fnamePlusPath);
  9842. printf("%s\n", fnamePlusPath);
  9843. fnamePlusPath[ftppathlen]='\0';
  9844. break;
  9845. }
  9846. i= i+1;
  9847. }
  9848. /* close */
  9849. pclose(fp);
  9850. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  9851. {
  9852. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  9853. {
  9854. fnamePlusPath[k]='\0';
  9855. }
  9856. }
  9857. i=1;
  9858. //char fname[60]={0};
  9859. while(i < ftppathlen)
  9860. {
  9861. int len=ftppathlen-i;
  9862. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  9863. {
  9864. printf("compare '/' all right\n");
  9865. break;
  9866. }
  9867. i=i+1;
  9868. }
  9869. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  9870. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  9871. fnamePWithNoPath[i+1] = '\0';
  9872. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  9873. {
  9874. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  9875. {
  9876. fnamePWithNoPath[j]='\0';
  9877. }
  9878. }
  9879. FILE* fp1 = fopen(fnamePlusPath, "r");
  9880. if (fp1)
  9881. {
  9882. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  9883. // file exists
  9884. fclose(fp1);
  9885. }
  9886. else
  9887. {
  9888. // file doesn't exist
  9889. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  9890. }
  9891. }
  9892. void* GetLogProcess(void* data)
  9893. {
  9894. pthread_detach(pthread_self());
  9895. mtrace();
  9896. int requestId, retriesInt=0, retryIntervalInt=0;
  9897. char logType[32], remoteLocation[512]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  9898. char protocol[10]={0}, user[50]={0},password[50]={0},host[50]={0}, path[50]={0}, ftppath[60]={0},host1[50]={0},path1[50]={0};
  9899. int port=0;
  9900. int isSuccess = FALSE;
  9901. char ftpbuf[200]={0};
  9902. json_object *GetLog;
  9903. DEBUG_INFO("GetGetProcess...\n");
  9904. GetLog = json_tokener_parse(data);
  9905. if(!is_error(GetLog))
  9906. {
  9907. // Required data
  9908. if(json_object_object_get(GetLog, "requestId") != NULL)
  9909. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  9910. if(json_object_object_get(GetLog, "logType") != NULL)
  9911. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  9912. if(json_object_object_get(GetLog, "log") != NULL)
  9913. {
  9914. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  9915. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  9916. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  9917. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  9918. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  9919. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  9920. }
  9921. // Optional data
  9922. if(json_object_object_get(GetLog, "retries") != NULL)
  9923. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  9924. else
  9925. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  9926. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  9927. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  9928. else
  9929. retryIntervalInt = 30;
  9930. }
  9931. json_object_put(GetLog);
  9932. ShmOCPP20Data->GetLog.requestId = requestId;
  9933. //****************location*******************/
  9934. if(strcmp(remoteLocation,"")==0)
  9935. {
  9936. DEBUG_INFO("remoteLocation is <Empty>!\n");
  9937. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9938. goto end;
  9939. }
  9940. memset(protocol, 0, ARRAY_SIZE(protocol));
  9941. memset(user, 0, ARRAY_SIZE(user) );
  9942. memset(password, 0, ARRAY_SIZE(password));
  9943. memset(host, 0, ARRAY_SIZE(host));
  9944. memset(path, 0, ARRAY_SIZE(path));
  9945. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  9946. memset(host1, 0, ARRAY_SIZE(host1));
  9947. memset(path1, 0, ARRAY_SIZE(path1));
  9948. /*location: ftp://user:password@host:port/path*/
  9949. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  9950. if((access(fnamePlusPath,F_OK))!=-1)
  9951. {
  9952. DEBUG_INFO("fnamePlusPath exist.\n");
  9953. }
  9954. else
  9955. {
  9956. DEBUG_INFO("fnamePlusPath not exist!\n");
  9957. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9958. goto end;
  9959. }
  9960. if(strchr(remoteLocation,'@')==NULL)
  9961. {
  9962. sscanf(remoteLocation,
  9963. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  9964. protocol, host, &port, path);
  9965. strcpy(user,"anonymous");
  9966. strcpy(password,"");
  9967. }
  9968. else
  9969. {
  9970. //DEBUG_INFO("pch=%s\n", pch);
  9971. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  9972. protocol, user, password, host, &port, path);
  9973. }
  9974. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
  9975. {
  9976. DEBUG_INFO("protocol is not ftp/http ! \n");
  9977. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9978. goto end;
  9979. }
  9980. if(strncmp(remoteLocation,"http", 4) == 0)
  9981. {
  9982. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  9983. sprintf(ftppath,"/%s", path);
  9984. do
  9985. {
  9986. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  9987. sleep(3);
  9988. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  9989. if(!isSuccess)
  9990. {
  9991. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  9992. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9993. sleep(retryIntervalInt);
  9994. }
  9995. else
  9996. {
  9997. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  9998. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  9999. }
  10000. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt--));
  10001. }
  10002. else
  10003. {
  10004. sscanf(host,"%[^/]%s",host1, path1);
  10005. sprintf(ftppath,"%s", path1);
  10006. int ftppathlen=strlen(ftppath);
  10007. int i=1;
  10008. char filenametemp[50];
  10009. while(i < ftppathlen)
  10010. {
  10011. int len=ftppathlen-i;
  10012. if(ftppath[len]== 47) // '/' ascll code: 47
  10013. {
  10014. DEBUG_INFO("find '/' all right\n");
  10015. break;
  10016. }
  10017. i=i+1;
  10018. }
  10019. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  10020. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  10021. filenametemp[i+1] = 0;
  10022. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  10023. if(port == 0)
  10024. port = 21;
  10025. do
  10026. {
  10027. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  10028. sleep(3);
  10029. isSuccess = ftpFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  10030. if(!isSuccess)
  10031. {
  10032. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  10033. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10034. sleep(retryIntervalInt);
  10035. }
  10036. else
  10037. {
  10038. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  10039. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  10040. }
  10041. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  10042. }
  10043. end:
  10044. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  10045. pthread_exit(NULL);
  10046. }
  10047. int handleGetLogRequest(char *uuid, char *payload)
  10048. {
  10049. mtrace();
  10050. int result = FAIL;
  10051. char cmdBuf[512];
  10052. char fName[258];
  10053. time_t CurrentTime;
  10054. struct tm *tm;
  10055. pthread_t th_Status;
  10056. system("/usr/bin/run_tmate_restart.sh");
  10057. CurrentTime = time(NULL);
  10058. tm = localtime(&CurrentTime);
  10059. 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);
  10060. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  10061. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  10062. sendGetLogConfirmation(uuid);
  10063. system("exec /root/logPackTools 'log' 6");
  10064. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", fName);
  10065. system(cmdBuf);
  10066. checkUploadLog();
  10067. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  10068. return result;
  10069. }
  10070. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  10071. {
  10072. mtrace();
  10073. int result = FAIL;
  10074. json_object *GetMonitoringReport;
  10075. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  10076. GetMonitoringReport = json_tokener_parse(payload);
  10077. if(!is_error(GetMonitoringReport))
  10078. {
  10079. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  10080. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  10081. // Required data
  10082. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  10083. {
  10084. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  10085. }
  10086. // Optional data
  10087. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  10088. {
  10089. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  10090. }
  10091. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  10092. {
  10093. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  10094. {
  10095. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  10096. {
  10097. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  10098. {
  10099. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  10100. {
  10101. 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")));
  10102. }
  10103. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10104. {
  10105. 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")));
  10106. }
  10107. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10108. {
  10109. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "getVariableData"), idx), "component"), "evse"), "id") != NULL)
  10110. {
  10111. 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"));
  10112. }
  10113. 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)
  10114. {
  10115. 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"));
  10116. }
  10117. }
  10118. }
  10119. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  10120. {
  10121. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10122. {
  10123. 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")));
  10124. }
  10125. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10126. {
  10127. 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")));
  10128. }
  10129. }
  10130. }
  10131. }
  10132. }
  10133. }
  10134. json_object_put(GetMonitoringReport);
  10135. /*
  10136. * TODO:
  10137. * 1. Response result
  10138. */
  10139. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10140. sendGetMonitoringReportConfirmation(uuid);
  10141. return result;
  10142. }
  10143. int handleGetReportRequest(char *uuid, char *payload)
  10144. {
  10145. mtrace();
  10146. int result = FAIL;
  10147. json_object *GetReport;
  10148. DEBUG_INFO("handleGetReportRequest...\n");
  10149. GetReport = json_tokener_parse(payload);
  10150. if(!is_error(GetReport))
  10151. {
  10152. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  10153. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  10154. // Required data
  10155. if(json_object_object_get(GetReport, "requestId") != NULL)
  10156. {
  10157. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  10158. }
  10159. // Optional data
  10160. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  10161. {
  10162. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  10163. }
  10164. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  10165. {
  10166. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  10167. {
  10168. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  10169. {
  10170. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  10171. {
  10172. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  10173. {
  10174. 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")));
  10175. }
  10176. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10177. {
  10178. 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")));
  10179. }
  10180. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10181. {
  10182. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "getVariableData"), idx), "component"), "evse"), "id") != NULL)
  10183. {
  10184. 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"), "instance"), "id"));
  10185. }
  10186. 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)
  10187. {
  10188. 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"), "instance"), "connectorId"));
  10189. }
  10190. }
  10191. }
  10192. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  10193. {
  10194. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10195. {
  10196. 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")));
  10197. }
  10198. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10199. {
  10200. 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")));
  10201. }
  10202. }
  10203. }
  10204. }
  10205. }
  10206. }
  10207. json_object_put(GetReport);
  10208. /*
  10209. * TODO:
  10210. * 1. Response result
  10211. */
  10212. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10213. sendGetReportConfirmation(uuid);
  10214. return result;
  10215. }
  10216. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  10217. {
  10218. mtrace();
  10219. int result = FAIL;
  10220. int8_t gun_index = -1;
  10221. json_object *GetTransactionStatus;
  10222. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  10223. GetTransactionStatus = json_tokener_parse(payload);
  10224. if(!is_error(GetTransactionStatus))
  10225. {
  10226. /*
  10227. * TODO:
  10228. * 1. Check transaction locate which connector
  10229. */
  10230. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  10231. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  10232. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  10233. {
  10234. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  10235. }
  10236. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  10237. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  10238. }
  10239. json_object_put(GetTransactionStatus);
  10240. sendGetTransactionStatusConfirmation(uuid, gun_index);
  10241. return result;
  10242. }
  10243. int handleGetVariablesRequest(char *uuid, char *payload)
  10244. {
  10245. mtrace();
  10246. int result = FAIL;
  10247. json_object *GetVariables;
  10248. DEBUG_INFO("handleGetVariablesRequest...\n");
  10249. GetVariables = json_tokener_parse(payload);
  10250. if(!is_error(GetVariables))
  10251. {
  10252. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  10253. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  10254. // Required data
  10255. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  10256. {
  10257. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  10258. {
  10259. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  10260. {
  10261. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  10262. {
  10263. 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")));
  10264. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  10265. }
  10266. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  10267. {
  10268. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  10269. {
  10270. 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")));
  10271. }
  10272. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  10273. {
  10274. 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")));
  10275. }
  10276. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  10277. {
  10278. 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)
  10279. {
  10280. 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"));
  10281. }
  10282. 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)
  10283. {
  10284. 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"));
  10285. }
  10286. }
  10287. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  10288. }
  10289. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  10290. {
  10291. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  10292. {
  10293. 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")));
  10294. }
  10295. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  10296. {
  10297. 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")));
  10298. }
  10299. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  10300. }
  10301. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  10302. {
  10303. if((strstr((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) != NULL) &&
  10304. (strlen((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance)>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance) != NULL):TRUE) &&
  10305. (strstr((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) != NULL) &&
  10306. (strlen((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance)>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance) != NULL):TRUE))
  10307. {
  10308. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  10309. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type);
  10310. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  10311. }
  10312. else
  10313. {
  10314. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  10315. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  10316. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  10317. }
  10318. }
  10319. }
  10320. }
  10321. }
  10322. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  10323. }
  10324. json_object_put(GetVariables);
  10325. return result;
  10326. }
  10327. int handleInstallCertificateRequest(char *uuid, char *payload)
  10328. {
  10329. mtrace();
  10330. int result = FAIL;
  10331. json_object *InstallCertificate;
  10332. DEBUG_INFO("handleInstallCertificateRequest...\n");
  10333. InstallCertificate = json_tokener_parse(payload);
  10334. if(!is_error(InstallCertificate))
  10335. {
  10336. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  10337. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  10338. // Required data
  10339. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  10340. {
  10341. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  10342. }
  10343. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  10344. {
  10345. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  10346. }
  10347. }
  10348. json_object_put(InstallCertificate);
  10349. /*
  10350. * TODO:
  10351. * 1. Install certification preocess and response
  10352. */
  10353. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10354. sendInstallCertificateConfirmation(uuid);
  10355. return result;
  10356. }
  10357. int handlePublishFirmwareRequest(char *uuid, char *payload)
  10358. {
  10359. mtrace();
  10360. int result = FAIL;
  10361. json_object *PublishFirmware;
  10362. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  10363. PublishFirmware = json_tokener_parse(payload);
  10364. if(!is_error(PublishFirmware))
  10365. {
  10366. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  10367. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  10368. // Required data
  10369. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  10370. {
  10371. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  10372. }
  10373. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  10374. {
  10375. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  10376. }
  10377. // Optional data
  10378. if(json_object_object_get(PublishFirmware, "location") != NULL)
  10379. {
  10380. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  10381. }
  10382. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  10383. {
  10384. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  10385. }
  10386. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  10387. {
  10388. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  10389. }
  10390. }
  10391. json_object_put(PublishFirmware);
  10392. /*
  10393. * TODO:
  10394. * 1. Publish firmware preocess and response
  10395. */
  10396. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10397. sendPublishFirmwareConfirmation(uuid);
  10398. return result;
  10399. }
  10400. int handleRemoteStartTransactionRequest(char *uuid, char *payload)
  10401. {
  10402. mtrace();
  10403. int result = FAIL;
  10404. int8_t gun_index = -1;
  10405. uint8_t isPeriodOverMax = FALSE;
  10406. uint8_t isProfileOverMax = FALSE;
  10407. uint8_t isConnectorMismatch = FALSE;
  10408. uint8_t isTxProfile = FALSE;
  10409. uint8_t existProfileQuantity = 0;
  10410. uint8_t filename[128]={0};
  10411. uint8_t word[2048]={0};
  10412. FILE *filePtr;
  10413. json_object *RemoteStartTransaction;
  10414. DEBUG_INFO("handleRemoteStartTransactionRequest...\n");
  10415. RemoteStartTransaction = json_tokener_parse(payload);
  10416. if(!is_error(RemoteStartTransaction))
  10417. {
  10418. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  10419. {
  10420. gun_index = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
  10421. }
  10422. else
  10423. {
  10424. /*
  10425. * TODO:
  10426. * 1. Selected connector process
  10427. */
  10428. gun_index = 0;
  10429. }
  10430. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  10431. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  10432. // Required data
  10433. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  10434. {
  10435. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  10436. }
  10437. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  10438. {
  10439. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  10440. {
  10441. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  10442. }
  10443. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  10444. {
  10445. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  10446. }
  10447. }
  10448. // Optional data
  10449. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  10450. {
  10451. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  10452. {
  10453. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  10454. }
  10455. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  10456. {
  10457. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  10458. }
  10459. }
  10460. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  10461. {
  10462. // Check periods is over max configuration
  10463. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  10464. {
  10465. isPeriodOverMax = TRUE;
  10466. }
  10467. // Check periods is over max configuration
  10468. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  10469. {
  10470. if(gun_index > 0)
  10471. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  10472. else
  10473. isConnectorMismatch = TRUE;
  10474. if(!isConnectorMismatch)
  10475. {
  10476. filePtr = fopen((char*)filename, "r");
  10477. if (!filePtr)
  10478. {
  10479. DEBUG_INFO("%s not exist, create it.\n", filename);
  10480. filePtr = fopen((char*)filename, "w+");
  10481. }
  10482. else
  10483. {
  10484. //Check Charging Profile Count
  10485. while(fscanf(filePtr, "%s", word) != EOF)
  10486. {
  10487. //DEBUG_INFO("word=%s\n",word);
  10488. if(strstr((char*)word, "chargingProfileId")!= NULL)
  10489. {
  10490. existProfileQuantity += 1;
  10491. }
  10492. }
  10493. }
  10494. fclose(filePtr);
  10495. }
  10496. }
  10497. else
  10498. {
  10499. }
  10500. if(existProfileQuantity > 3)
  10501. isProfileOverMax = TRUE;
  10502. }
  10503. // Profile replace or add info
  10504. if((gun_index > 0) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTxProfile)
  10505. {
  10506. FILE *infile;
  10507. FILE *outfile;
  10508. char tmpProfileName[32];
  10509. char rmFileCmd[128];
  10510. char tempchargingProfilePurposeStr[30]={0};
  10511. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  10512. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfileRemote");
  10513. infile = fopen ((char*)filename, "r");
  10514. outfile = fopen ((char*)tmpProfileName, "w");
  10515. int d = fgetc(infile);
  10516. rewind(infile);
  10517. if(d == EOF)
  10518. {
  10519. // Profile is empty
  10520. fprintf(outfile,"%s\n", payload);
  10521. fclose(infile);
  10522. fclose(outfile);
  10523. sprintf(rmFileCmd,"rm -f %s",filename);
  10524. system(rmFileCmd);
  10525. rename((char*)tmpProfileName, (char*)filename);
  10526. }
  10527. else
  10528. {
  10529. // Profile is not empty
  10530. char buf[2048]={0};
  10531. int ChargingProfileAdded = FALSE;
  10532. while (fgets(buf, sizeof(buf), infile) != NULL)
  10533. {
  10534. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  10535. json_object *tmpChargingProfile;
  10536. tmpChargingProfile = json_tokener_parse(buf);
  10537. if(!is_error(tmpChargingProfile))
  10538. {
  10539. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  10540. {
  10541. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  10542. }
  10543. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  10544. {
  10545. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  10546. {
  10547. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  10548. }
  10549. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  10550. {
  10551. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  10552. }
  10553. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  10554. {
  10555. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  10556. }
  10557. }
  10558. }
  10559. json_object_put(tmpChargingProfile);
  10560. if((tempconnectorIdInt == gun_index) &&
  10561. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId"))))
  10562. {
  10563. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel"))) &&
  10564. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  10565. {
  10566. if(ChargingProfileAdded == FALSE)
  10567. {
  10568. fprintf(outfile,"%s\n",payload);
  10569. ChargingProfileAdded = TRUE;
  10570. }
  10571. }
  10572. else
  10573. {
  10574. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10575. {
  10576. if(ChargingProfileAdded == FALSE)
  10577. {
  10578. fprintf(outfile,"%s\n",buf);
  10579. fprintf(outfile,"%s\n",payload);
  10580. ChargingProfileAdded = TRUE;
  10581. }
  10582. else
  10583. {
  10584. fprintf(outfile,"%s\n",buf);
  10585. }
  10586. }
  10587. else
  10588. {
  10589. if(ChargingProfileAdded == FALSE)
  10590. {
  10591. fprintf(outfile,"%s\n",buf);
  10592. fprintf(outfile,"%s\n",payload);
  10593. ChargingProfileAdded = TRUE;
  10594. }
  10595. else
  10596. {
  10597. fprintf(outfile,"%s\n",buf);
  10598. }
  10599. }
  10600. }
  10601. }
  10602. else
  10603. {
  10604. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId")))
  10605. {
  10606. if(ChargingProfileAdded == FALSE)
  10607. {
  10608. fprintf(outfile,"%s\n",buf);
  10609. fprintf(outfile,"%s\n",payload);
  10610. ChargingProfileAdded = TRUE;
  10611. }
  10612. else
  10613. {
  10614. fprintf(outfile,"%s\n",buf);
  10615. }
  10616. }
  10617. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10618. {
  10619. if(ChargingProfileAdded == FALSE)
  10620. {
  10621. fprintf(outfile,"%s\n",buf);
  10622. fprintf(outfile,"%s\n",payload);
  10623. ChargingProfileAdded = TRUE;
  10624. }
  10625. else
  10626. {
  10627. fprintf(outfile,"%s\n",buf);
  10628. }
  10629. }
  10630. else
  10631. {
  10632. if(ChargingProfileAdded == FALSE)
  10633. {
  10634. fprintf(outfile,"%s\n",buf);
  10635. fprintf(outfile,"%s\n",payload);
  10636. ChargingProfileAdded = TRUE;
  10637. }
  10638. else
  10639. {
  10640. fprintf(outfile,"%s\n",buf);
  10641. }
  10642. }
  10643. }
  10644. } // end of while loop
  10645. fclose(infile);
  10646. fclose(outfile);
  10647. sprintf(rmFileCmd,"rm -f %s",filename);
  10648. system(rmFileCmd);
  10649. rename((char*)tmpProfileName, (char*)filename);
  10650. }
  10651. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted] );
  10652. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_transactionId);
  10653. result = PASS;
  10654. }
  10655. else
  10656. {
  10657. if(gun_index <= 0)
  10658. DEBUG_WARN("Connector id is wrong.\n");
  10659. if(isConnectorMismatch)
  10660. DEBUG_WARN("Connector id is mismatch.\n");
  10661. if(isPeriodOverMax)
  10662. DEBUG_WARN("Profile periods quantity is over spec.\n");
  10663. if(isProfileOverMax)
  10664. DEBUG_WARN("Profile quantity is over spec.\n");
  10665. if(!isTxProfile)
  10666. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  10667. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  10668. }
  10669. }
  10670. json_object_put(RemoteStartTransaction);
  10671. sendRemoteStartTransactionConfirmation(uuid, gun_index);
  10672. return result;
  10673. }
  10674. int handleRemoteStopTransactionRequest(char *uuid, char *payload)
  10675. {
  10676. mtrace();
  10677. int result = FAIL;
  10678. int match = FALSE;
  10679. int GunNO = 0;
  10680. int tempIndex = 0;
  10681. char transactionIdStr[37];
  10682. int transactionIdIsNULL= TRUE;
  10683. json_object *RemoteStopTransaction;
  10684. DEBUG_INFO("handleRemoteStopTransactionRequest...\n");
  10685. if(server_pending == TRUE)
  10686. {
  10687. return 0;
  10688. }
  10689. RemoteStopTransaction = json_tokener_parse(payload);
  10690. if(!is_error(RemoteStopTransaction))
  10691. {
  10692. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  10693. {
  10694. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  10695. transactionIdIsNULL = FALSE;
  10696. }
  10697. }
  10698. json_object_put(RemoteStopTransaction);
  10699. if(transactionIdIsNULL == FALSE)
  10700. {
  10701. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  10702. {
  10703. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  10704. {
  10705. //check Transaction active
  10706. if(gunType[gun_index] == 'J')
  10707. {
  10708. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10709. {
  10710. tempIndex = ((gun_index==2) ? 1: 0);
  10711. }
  10712. else
  10713. {
  10714. tempIndex = gun_index;
  10715. }
  10716. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10717. {
  10718. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  10719. {
  10720. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10721. {
  10722. match = TRUE;
  10723. GunNO = gun_index;
  10724. }
  10725. }
  10726. }// END FOR CHAdeMO_QUANTITY
  10727. }
  10728. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  10729. {
  10730. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10731. {
  10732. tempIndex = ((gun_index==2) ? 1: 0);
  10733. }
  10734. else
  10735. {
  10736. tempIndex = gun_index;
  10737. }
  10738. for (int index = 0; index < CCS_QUANTITY; index++)
  10739. {
  10740. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  10741. {
  10742. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10743. {
  10744. match = TRUE;
  10745. GunNO = gun_index;
  10746. }
  10747. }
  10748. }// END FOR CCS_QUANTITY
  10749. }
  10750. else if(gunType[gun_index] == 'G')
  10751. {
  10752. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10753. {
  10754. tempIndex = ((gun_index==2) ? 1: 0);
  10755. }
  10756. else
  10757. {
  10758. tempIndex = gun_index;
  10759. }
  10760. for (int index = 0; index < GB_QUANTITY; index++)
  10761. {
  10762. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  10763. {
  10764. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10765. {
  10766. match = TRUE;
  10767. GunNO = gun_index;
  10768. }
  10769. }
  10770. }// END FOR GB_QUANTITY
  10771. }
  10772. else if(gunType[gun_index] == 'O')
  10773. {
  10774. tempIndex = gun_index;
  10775. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10776. {
  10777. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  10778. {
  10779. 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
  10780. {
  10781. match = TRUE;
  10782. GunNO = gun_index;
  10783. }
  10784. }
  10785. }// END FOR GB_QUANTITY
  10786. }
  10787. else
  10788. {
  10789. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10790. {
  10791. tempIndex = 2;
  10792. }
  10793. else
  10794. {
  10795. tempIndex = gun_index;
  10796. }
  10797. for (int index = 0; index < AC_QUANTITY; index++)
  10798. {
  10799. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  10800. {
  10801. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10802. {
  10803. match = TRUE;
  10804. GunNO = gun_index;
  10805. }
  10806. }
  10807. }// END FOR CHAdeMO_QUANTITY
  10808. } // END FOR AC ELSE
  10809. }// CHECK IF ResponseTransactionId == transactionIdInt
  10810. }//END FOR
  10811. if( match == TRUE)
  10812. {
  10813. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  10814. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  10815. }
  10816. else
  10817. {
  10818. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  10819. }
  10820. }
  10821. else
  10822. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  10823. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  10824. return result;
  10825. }
  10826. int handleReserveNowTransactionRequest(char *uuid, char *payload)
  10827. {
  10828. mtrace();
  10829. int result = FAIL;
  10830. int connectorIdInt=0, reservationIdInt=0;
  10831. int tempIndex = 0;
  10832. json_object *ReserveNow;
  10833. DEBUG_INFO("handleReserveNowTransactionRequest ...\n");
  10834. ReserveNow = json_tokener_parse(payload);
  10835. if(!is_error(ReserveNow))
  10836. {
  10837. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  10838. {
  10839. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  10840. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  10841. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  10842. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  10843. }
  10844. // Required data
  10845. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  10846. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  10847. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  10848. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  10849. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  10850. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  10851. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  10852. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  10853. // Optional data
  10854. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  10855. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  10856. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  10857. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  10858. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  10859. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  10860. result = PASS;
  10861. }
  10862. json_object_put(ReserveNow);
  10863. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10864. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  10865. {
  10866. //check Transaction active
  10867. if(gunType[connectorIdInt -1] == 'J')
  10868. {
  10869. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10870. {
  10871. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  10872. }
  10873. else
  10874. {
  10875. tempIndex = connectorIdInt -1;
  10876. }
  10877. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10878. {
  10879. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  10880. {
  10881. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  10882. {
  10883. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  10884. {
  10885. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10886. {
  10887. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10888. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10889. }
  10890. 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'))
  10891. {
  10892. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10893. }
  10894. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  10895. {
  10896. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10897. }
  10898. else
  10899. {
  10900. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10901. }
  10902. }
  10903. 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
  10904. {
  10905. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10906. }
  10907. }
  10908. else
  10909. {
  10910. //replace reservation
  10911. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10912. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10913. }
  10914. }
  10915. } // END FOR CHAdeMO_QUANTITY
  10916. }
  10917. else if((gunType[connectorIdInt -1] == 'U')||(gunType[connectorIdInt -1] == 'E'))
  10918. {
  10919. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10920. {
  10921. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  10922. }
  10923. else
  10924. {
  10925. tempIndex = connectorIdInt -1;
  10926. }
  10927. for (int index = 0; index < CCS_QUANTITY; index++)
  10928. {
  10929. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  10930. {
  10931. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  10932. {
  10933. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  10934. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  10935. {
  10936. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10937. {
  10938. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10939. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10940. }
  10941. 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'))
  10942. {
  10943. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10944. }
  10945. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  10946. {
  10947. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10948. }
  10949. else
  10950. {
  10951. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10952. }
  10953. }
  10954. 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
  10955. {
  10956. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10957. }
  10958. }
  10959. else
  10960. {
  10961. //replace reservation
  10962. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10963. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10964. }
  10965. }
  10966. } // END FOR CCS_QUANTITY
  10967. }
  10968. else if(gunType[connectorIdInt -1] == 'G')
  10969. {
  10970. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10971. {
  10972. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  10973. }
  10974. else
  10975. {
  10976. tempIndex = connectorIdInt -1;
  10977. }
  10978. for (int index = 0; index < GB_QUANTITY; index++)
  10979. {
  10980. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  10981. {
  10982. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  10983. {
  10984. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  10985. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  10986. {
  10987. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10988. {
  10989. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10990. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10991. }
  10992. 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'))
  10993. {
  10994. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10995. }
  10996. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  10997. {
  10998. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10999. }
  11000. else
  11001. {
  11002. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11003. }
  11004. }
  11005. 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
  11006. {
  11007. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11008. }
  11009. }
  11010. else
  11011. {
  11012. //replace reservation
  11013. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11014. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11015. }
  11016. }
  11017. }// END FOR GB_QUANTITY
  11018. }
  11019. else
  11020. {
  11021. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11022. {
  11023. tempIndex = 2;
  11024. }
  11025. else
  11026. {
  11027. tempIndex = (connectorIdInt -1);
  11028. }
  11029. for (int index = 0; index < AC_QUANTITY; index++)
  11030. {
  11031. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  11032. {
  11033. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11034. {
  11035. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11036. {
  11037. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11038. {
  11039. 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))
  11040. {
  11041. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11042. }
  11043. else
  11044. {
  11045. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11046. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11047. }
  11048. }
  11049. 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'))
  11050. {
  11051. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11052. }
  11053. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11054. {
  11055. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11056. }
  11057. else
  11058. {
  11059. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11060. }
  11061. }
  11062. 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
  11063. {
  11064. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11065. }
  11066. }
  11067. else
  11068. {
  11069. //replace reservation
  11070. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11071. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11072. }
  11073. }
  11074. } // END FOR AC_QUANTITY
  11075. }
  11076. }
  11077. else if(connectorIdInt == 0)
  11078. {
  11079. //check Transaction active
  11080. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11081. {
  11082. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  11083. {
  11084. 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'))
  11085. {
  11086. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11087. goto end;
  11088. }
  11089. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11090. {
  11091. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11092. goto end;
  11093. }
  11094. 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
  11095. {
  11096. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11097. goto end;
  11098. }
  11099. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11100. {
  11101. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11102. goto end;
  11103. }
  11104. }
  11105. }// END FOR CHAdeMO_QUANTITY
  11106. for (int index = 0; index < CCS_QUANTITY; index++)
  11107. {
  11108. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  11109. {
  11110. 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'))
  11111. {
  11112. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11113. goto end;
  11114. }
  11115. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  11116. {
  11117. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11118. goto end;
  11119. }
  11120. 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
  11121. {
  11122. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11123. goto end;
  11124. }
  11125. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11126. {
  11127. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11128. goto end;
  11129. }
  11130. }
  11131. } // END FOR CCS_QUANTITY
  11132. for (int index = 0; index < GB_QUANTITY; index++)
  11133. {
  11134. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  11135. {
  11136. 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'))
  11137. {
  11138. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11139. goto end;
  11140. }
  11141. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11142. {
  11143. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11144. goto end;
  11145. }
  11146. 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
  11147. {
  11148. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11149. goto end;
  11150. }
  11151. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11152. {
  11153. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11154. goto end;
  11155. }
  11156. }
  11157. } // END FOR GB_QUANTITY
  11158. for (int index = 0; index < AC_QUANTITY; index++)
  11159. {
  11160. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11161. {
  11162. 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'))
  11163. {
  11164. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11165. goto end;
  11166. }
  11167. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11168. {
  11169. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11170. goto end;
  11171. }
  11172. 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
  11173. {
  11174. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11175. goto end;
  11176. }
  11177. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11178. {
  11179. 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))
  11180. {
  11181. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11182. goto end;
  11183. }
  11184. }
  11185. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11186. {
  11187. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11188. goto end;
  11189. }
  11190. }
  11191. }// END FOR AC_QUANTITY
  11192. //The connectorId is 0
  11193. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  11194. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11195. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  11196. result = TRUE;
  11197. return result;
  11198. }
  11199. else
  11200. {
  11201. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11202. }
  11203. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  11204. {
  11205. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  11206. result = TRUE;
  11207. return result;
  11208. }
  11209. end:
  11210. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  11211. return result;
  11212. }
  11213. int handleResetRequest(char *uuid, char *payload)
  11214. {
  11215. mtrace();
  11216. int result = FAIL;
  11217. json_object *Reset = json_object_new_object();
  11218. DEBUG_INFO("handleResetRequest...\n");
  11219. Reset = json_tokener_parse(payload);
  11220. if(!is_error(Reset))
  11221. {
  11222. // Required data
  11223. if(json_object_object_get(Reset, "type") != NULL)
  11224. {
  11225. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  11226. }
  11227. if(json_object_object_get(Reset, "evseId") != NULL)
  11228. {
  11229. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  11230. }
  11231. }
  11232. json_object_put(Reset);
  11233. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  11234. {
  11235. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  11236. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  11237. result = TRUE;
  11238. return result;
  11239. }
  11240. else
  11241. {
  11242. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  11243. goto errorend;
  11244. }
  11245. errorend:
  11246. sendResetConfirmation(uuid);
  11247. return result;
  11248. }
  11249. int handleSendLocalListRequest(char *uuid, char *payload)
  11250. {
  11251. mtrace();
  11252. int result = FAIL;
  11253. char updateTypestr[15]={0};
  11254. int checkState_Faulted = FALSE;
  11255. json_object *SendLocalList;
  11256. DEBUG_INFO("handleSendLocalListRequest...\n");
  11257. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  11258. {
  11259. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11260. goto end;
  11261. }
  11262. SendLocalList = json_tokener_parse(payload);
  11263. if(!is_error(SendLocalList))
  11264. {
  11265. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  11266. // Required data
  11267. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  11268. {
  11269. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  11270. }
  11271. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  11272. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  11273. // Optional data
  11274. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  11275. {
  11276. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  11277. {
  11278. // Required data
  11279. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  11280. {
  11281. 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")));
  11282. 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")));
  11283. }
  11284. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  11285. {
  11286. 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")));
  11287. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  11288. 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")));
  11289. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  11290. 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"));
  11291. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  11292. {
  11293. 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")));
  11294. 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")));
  11295. }
  11296. }
  11297. }
  11298. }
  11299. }
  11300. json_object_put(SendLocalList);
  11301. //check Charge Point state
  11302. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11303. {
  11304. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11305. {
  11306. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11307. }
  11308. }
  11309. for (int index = 0; index < CCS_QUANTITY; index++)
  11310. {
  11311. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11312. {
  11313. checkState_Faulted = TRUE; //OCPP Status
  11314. }
  11315. }
  11316. for (int index = 0; index < GB_QUANTITY; index++)
  11317. {
  11318. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11319. {
  11320. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11321. }
  11322. }
  11323. for (int index = 0; index < AC_QUANTITY; index++)
  11324. {
  11325. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11326. {
  11327. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11328. }
  11329. }
  11330. if(checkState_Faulted == TRUE)
  11331. {
  11332. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11333. goto end;
  11334. }
  11335. // Check update type
  11336. if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  11337. {
  11338. //Local list full update
  11339. DEBUG_INFO("Local list full update.\n");
  11340. DB_getListVerion();
  11341. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11342. {
  11343. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11344. goto end;
  11345. }
  11346. DB_cleanLocalList();
  11347. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11348. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11349. }
  11350. else if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  11351. {
  11352. //Local list different update
  11353. DEBUG_INFO("Local list different update.\n");
  11354. DB_getListVerion();
  11355. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11356. {
  11357. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  11358. goto end;
  11359. }
  11360. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11361. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11362. }
  11363. else
  11364. {
  11365. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11366. goto end;
  11367. }
  11368. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  11369. end:
  11370. sendSendLocalListConfirmation(uuid);
  11371. return result;
  11372. }
  11373. int handleSetChargingProfileRequest(char *uuid, char *payload)
  11374. {
  11375. mtrace();
  11376. int result = FAIL;
  11377. int8_t gun_index = -1;
  11378. uint8_t isPeriodOverMax = FALSE;
  11379. uint8_t isProfileOverMax = FALSE;
  11380. uint8_t isConnectorMismatch = FALSE;
  11381. uint8_t existProfileQuantity = 0;
  11382. uint8_t filename[128]={0};
  11383. uint8_t word[2048]={0};
  11384. FILE *filePtr;
  11385. json_object *SetChargingProfile;
  11386. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  11387. SetChargingProfile = json_tokener_parse(payload);
  11388. if(!is_error(SetChargingProfile))
  11389. {
  11390. // Required data
  11391. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  11392. {
  11393. gun_index = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  11394. }
  11395. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  11396. {
  11397. // Check periods is over max configuration
  11398. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  11399. {
  11400. isPeriodOverMax = TRUE;
  11401. }
  11402. // Check periods is over max configuration
  11403. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  11404. {
  11405. if(gun_index == 0)
  11406. {
  11407. sprintf((char*)filename, ChargePointMaxProfile_JSON);
  11408. filePtr = fopen((char*)filename, "r");
  11409. if (!filePtr)
  11410. {
  11411. DEBUG_INFO("%s not exist, create it.\n", ChargePointMaxProfile_JSON);
  11412. filePtr = fopen((char*)filename, "w+");
  11413. }
  11414. else
  11415. {
  11416. //Check Charging Profile Count
  11417. while(fscanf(filePtr, "%s", word) != EOF)
  11418. {
  11419. //DEBUG_INFO("word=%s\n",word);
  11420. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11421. {
  11422. existProfileQuantity += 1;
  11423. }
  11424. }
  11425. }
  11426. fclose(filePtr);
  11427. }
  11428. else
  11429. isConnectorMismatch = TRUE;
  11430. }
  11431. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  11432. {
  11433. if(gun_index < 5)
  11434. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", gun_index);
  11435. else
  11436. isConnectorMismatch = TRUE;
  11437. if(!isConnectorMismatch)
  11438. {
  11439. filePtr = fopen((char*)filename, "r");
  11440. if (!filePtr)
  11441. {
  11442. DEBUG_INFO("%s not exist, create it.\n", filename);
  11443. filePtr = fopen((char*)filename, "w+");
  11444. }
  11445. else
  11446. {
  11447. //Check Charging Profile Count
  11448. while(fscanf(filePtr, "%s", word) != EOF)
  11449. {
  11450. //DEBUG_INFO("word=%s\n",word);
  11451. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11452. {
  11453. existProfileQuantity += 1;
  11454. }
  11455. }
  11456. }
  11457. fclose(filePtr);
  11458. }
  11459. }
  11460. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  11461. {
  11462. if(gun_index>0)
  11463. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  11464. else
  11465. isConnectorMismatch = TRUE;
  11466. if(!isConnectorMismatch)
  11467. {
  11468. filePtr = fopen((char*)filename, "r");
  11469. if (!filePtr)
  11470. {
  11471. DEBUG_INFO("%s not exist, create it.\n", filename);
  11472. filePtr = fopen((char*)filename, "w+");
  11473. }
  11474. else
  11475. {
  11476. //Check Charging Profile Count
  11477. while(fscanf(filePtr, "%s", word) != EOF)
  11478. {
  11479. //DEBUG_INFO("word=%s\n",word);
  11480. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11481. {
  11482. existProfileQuantity += 1;
  11483. }
  11484. }
  11485. }
  11486. fclose(filePtr);
  11487. }
  11488. }
  11489. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  11490. {
  11491. }
  11492. else
  11493. {
  11494. }
  11495. if(existProfileQuantity > 3)
  11496. isProfileOverMax = TRUE;
  11497. }
  11498. // Profile replace or add info
  11499. if((gun_index > -1) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch)
  11500. {
  11501. FILE *infile;
  11502. FILE *outfile;
  11503. char tmpProfileName[32];
  11504. char rmFileCmd[128];
  11505. char tempchargingProfilePurposeStr[30]={0};
  11506. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  11507. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfile");
  11508. infile = fopen ((char*)filename, "r");
  11509. outfile = fopen ((char*)tmpProfileName, "w");
  11510. int d = fgetc(infile);
  11511. rewind(infile);
  11512. if(d == EOF)
  11513. {
  11514. // Profile is empty
  11515. fprintf(outfile,"%s\n", payload);
  11516. fclose(infile);
  11517. fclose(outfile);
  11518. sprintf(rmFileCmd,"rm -f %s",filename);
  11519. system(rmFileCmd);
  11520. rename((char*)tmpProfileName, (char*)filename);
  11521. }
  11522. else
  11523. {
  11524. // Profile is not empty
  11525. char buf[2048]={0};
  11526. int ChargingProfileAdded = FALSE;
  11527. while (fgets(buf, sizeof(buf), infile) != NULL)
  11528. {
  11529. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  11530. json_object *tmpChargingProfile;
  11531. tmpChargingProfile = json_tokener_parse(buf);
  11532. if(!is_error(tmpChargingProfile))
  11533. {
  11534. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  11535. {
  11536. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  11537. }
  11538. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  11539. {
  11540. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  11541. {
  11542. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  11543. }
  11544. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  11545. {
  11546. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  11547. }
  11548. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  11549. {
  11550. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  11551. }
  11552. }
  11553. }
  11554. json_object_put(tmpChargingProfile);
  11555. if((tempconnectorIdInt == gun_index) &&
  11556. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId"))))
  11557. {
  11558. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel"))) &&
  11559. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  11560. {
  11561. //DEBUG_INFO("update set chargingProfile to file -0\n");
  11562. if(ChargingProfileAdded == FALSE)
  11563. {
  11564. fprintf(outfile,"%s\n",payload);
  11565. ChargingProfileAdded = TRUE;
  11566. }
  11567. }
  11568. else
  11569. {
  11570. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11571. {
  11572. if(ChargingProfileAdded == FALSE)
  11573. {
  11574. fprintf(outfile,"%s\n",buf);
  11575. fprintf(outfile,"%s\n",payload);
  11576. ChargingProfileAdded = TRUE;
  11577. }
  11578. else
  11579. {
  11580. fprintf(outfile,"%s\n",buf);
  11581. }
  11582. }
  11583. else
  11584. {
  11585. if(ChargingProfileAdded == FALSE)
  11586. {
  11587. fprintf(outfile,"%s\n",buf);
  11588. fprintf(outfile,"%s\n",payload);
  11589. ChargingProfileAdded = TRUE;
  11590. }
  11591. else
  11592. {
  11593. fprintf(outfile,"%s\n",buf);
  11594. }
  11595. }
  11596. }
  11597. }
  11598. else
  11599. {
  11600. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId")))
  11601. {
  11602. if(ChargingProfileAdded == FALSE)
  11603. {
  11604. fprintf(outfile,"%s\n",buf);
  11605. fprintf(outfile,"%s\n",payload);
  11606. ChargingProfileAdded = TRUE;
  11607. }
  11608. else
  11609. {
  11610. fprintf(outfile,"%s\n",buf);
  11611. }
  11612. }
  11613. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11614. {
  11615. if(ChargingProfileAdded == FALSE)
  11616. {
  11617. fprintf(outfile,"%s\n",buf);
  11618. fprintf(outfile,"%s\n",payload);
  11619. ChargingProfileAdded = TRUE;
  11620. }
  11621. else
  11622. {
  11623. fprintf(outfile,"%s\n",buf);
  11624. }
  11625. }
  11626. else
  11627. {
  11628. if(ChargingProfileAdded == FALSE)
  11629. {
  11630. fprintf(outfile,"%s\n",buf);
  11631. fprintf(outfile,"%s\n",payload);
  11632. ChargingProfileAdded = TRUE;
  11633. }
  11634. else
  11635. {
  11636. fprintf(outfile,"%s\n",buf);
  11637. }
  11638. }
  11639. }
  11640. } // end of while loop
  11641. fclose(infile);
  11642. fclose(outfile);
  11643. sprintf(rmFileCmd,"rm -f %s",filename);
  11644. system(rmFileCmd);
  11645. rename((char*)tmpProfileName, (char*)filename);
  11646. }
  11647. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  11648. result = PASS;
  11649. }
  11650. else
  11651. {
  11652. if(gun_index == -1)
  11653. DEBUG_WARN("Connector id is wrong.\n");
  11654. if(isConnectorMismatch)
  11655. DEBUG_WARN("Connector id is mismatch.\n");
  11656. if(isPeriodOverMax)
  11657. DEBUG_WARN("Profile periods quantity is over spec.\n");
  11658. if(isProfileOverMax)
  11659. DEBUG_WARN("Profile quantity is over spec.\n");
  11660. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  11661. }
  11662. }
  11663. json_object_put(SetChargingProfile);
  11664. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  11665. {
  11666. if(gun_index == 0)
  11667. {
  11668. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  11669. {
  11670. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  11671. }
  11672. }
  11673. else
  11674. checkCompositeSchedule(gun_index, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index-1]);
  11675. }
  11676. sendSetChargingProfileConfirmation(uuid, (gun_index==0?gun_index:gun_index-1));
  11677. return result;
  11678. }
  11679. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  11680. {
  11681. mtrace();
  11682. int result = FAIL;
  11683. json_object *SetDisplayMessage;
  11684. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  11685. SetDisplayMessage = json_tokener_parse(payload);
  11686. if(!is_error(SetDisplayMessage))
  11687. {
  11688. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  11689. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  11690. // Required data
  11691. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  11692. {
  11693. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  11694. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  11695. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  11696. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  11697. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  11698. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  11699. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  11700. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  11701. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  11702. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  11703. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  11704. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  11705. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  11706. {
  11707. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  11708. 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"), "transactionId"), "format")));
  11709. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  11710. 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"), "transactionId"), "language")));
  11711. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  11712. 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"), "transactionId"), "content")));
  11713. }
  11714. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  11715. {
  11716. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  11717. 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")));
  11718. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  11719. 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")));
  11720. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  11721. {
  11722. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  11723. 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"));
  11724. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  11725. 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"));
  11726. }
  11727. }
  11728. }
  11729. }
  11730. json_object_put(SetDisplayMessage);
  11731. /*
  11732. * TODO:
  11733. * 1. Configure display message and response
  11734. */
  11735. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  11736. sendSetMonitoringBaseConfirmation(uuid);
  11737. return result;
  11738. }
  11739. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  11740. {
  11741. mtrace();
  11742. int result = FAIL;
  11743. json_object *SetMonitoringBase;
  11744. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  11745. SetMonitoringBase = json_tokener_parse(payload);
  11746. if(!is_error(SetMonitoringBase))
  11747. {
  11748. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  11749. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  11750. // Required data
  11751. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  11752. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  11753. }
  11754. json_object_put(SetMonitoringBase);
  11755. /*
  11756. * TODO:
  11757. * 1. Configure monitor base and response
  11758. */
  11759. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  11760. sendSetMonitoringBaseConfirmation(uuid);
  11761. return result;
  11762. }
  11763. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  11764. {
  11765. mtrace();
  11766. int result = FAIL;
  11767. json_object *SetMonitoringLevel;
  11768. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  11769. SetMonitoringLevel = json_tokener_parse(payload);
  11770. if(!is_error(SetMonitoringLevel))
  11771. {
  11772. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  11773. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  11774. // Required data
  11775. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  11776. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  11777. }
  11778. json_object_put(SetMonitoringLevel);
  11779. /*
  11780. * TODO:
  11781. * Configure monitor status and response
  11782. */
  11783. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  11784. sendSetMonitoringLevelConfirmation(uuid);
  11785. return result;
  11786. }
  11787. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  11788. {
  11789. mtrace();
  11790. int result = FAIL;
  11791. json_object *SetNetworkProfile;
  11792. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  11793. SetNetworkProfile = json_tokener_parse(payload);
  11794. if(!is_error(SetNetworkProfile))
  11795. {
  11796. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  11797. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  11798. // Required data
  11799. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  11800. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  11801. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  11802. {
  11803. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  11804. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  11805. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  11806. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  11807. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  11808. {
  11809. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  11810. memcpy((char*)ShmSysConfigAndInfo->SysConfig.OcppServerURL, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl));
  11811. }
  11812. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  11813. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  11814. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  11815. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  11816. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  11817. {
  11818. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  11819. 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")));
  11820. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  11821. 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")));
  11822. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  11823. 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")));
  11824. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  11825. 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")));
  11826. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  11827. 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")));
  11828. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  11829. 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")));
  11830. }
  11831. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  11832. {
  11833. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  11834. {
  11835. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  11836. 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")));
  11837. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  11838. }
  11839. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  11840. {
  11841. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  11842. 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")));
  11843. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  11844. }
  11845. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  11846. {
  11847. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  11848. 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")));
  11849. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  11850. }
  11851. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  11852. 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"));
  11853. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  11854. 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")));
  11855. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  11856. 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"));
  11857. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  11858. 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")));
  11859. }
  11860. DB_addNetworkProfile(ShmOCPP20Data->SetNetworkProfile.configurationSlot, (char*)json_object_get_string(json_object_object_get(SetNetworkProfile, "connectionData")));
  11861. }
  11862. }
  11863. json_object_put(SetNetworkProfile);
  11864. /*
  11865. * TODO:
  11866. * 1. Process network configuration and response
  11867. */
  11868. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  11869. {
  11870. }
  11871. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  11872. {
  11873. }
  11874. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  11875. {
  11876. }
  11877. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  11878. {
  11879. }
  11880. else
  11881. {
  11882. }
  11883. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  11884. {
  11885. }
  11886. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  11887. {
  11888. }
  11889. else
  11890. {
  11891. }
  11892. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  11893. {
  11894. }
  11895. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  11896. {
  11897. }
  11898. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  11899. {
  11900. }
  11901. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  11902. {
  11903. }
  11904. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  11905. {
  11906. }
  11907. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  11908. {
  11909. }
  11910. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  11911. {
  11912. }
  11913. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  11914. {
  11915. }
  11916. else
  11917. {
  11918. }
  11919. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  11920. {
  11921. }
  11922. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  11923. {
  11924. }
  11925. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  11926. {
  11927. }
  11928. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  11929. {
  11930. }
  11931. else
  11932. {
  11933. }
  11934. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  11935. {
  11936. }
  11937. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  11938. {
  11939. }
  11940. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  11941. {
  11942. }
  11943. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  11944. {
  11945. }
  11946. else
  11947. {
  11948. }
  11949. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  11950. sendSetNetworkProfileConfirmation(uuid);
  11951. return result;
  11952. }
  11953. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  11954. {
  11955. mtrace();
  11956. int result = FAIL;
  11957. json_object *SetVariableMonitoring;
  11958. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  11959. SetVariableMonitoring = json_tokener_parse(payload);
  11960. if(!is_error(SetVariableMonitoring))
  11961. {
  11962. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  11963. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  11964. // Required data
  11965. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  11966. {
  11967. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  11968. {
  11969. 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"));
  11970. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  11971. }
  11972. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  11973. {
  11974. 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"));
  11975. /*
  11976. * TODO:
  11977. * 1. Check monitor value status
  11978. */
  11979. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, MonitorEnumTypeStr[MonitorEnumType_Delta]);
  11980. }
  11981. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  11982. {
  11983. 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")));
  11984. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  11985. }
  11986. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  11987. {
  11988. 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"));
  11989. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  11990. }
  11991. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  11992. {
  11993. 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"));
  11994. }
  11995. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component") != NULL)
  11996. {
  11997. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component"), "name") != NULL)
  11998. {
  11999. sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[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, "json_object_array_get_idx"), idx), "component"), "name")));
  12000. }
  12001. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component"), "instance") != NULL)
  12002. {
  12003. sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[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, "json_object_array_get_idx"), idx), "component"), "instance")));
  12004. }
  12005. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component"), "evse") != NULL)
  12006. {
  12007. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component"), "evse"), "id") != NULL)
  12008. {
  12009. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[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, "json_object_array_get_idx"), idx), "component"), "instance"), "id"));
  12010. }
  12011. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component"), "evse"), "connectorId") != NULL)
  12012. {
  12013. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[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, "json_object_array_get_idx"), idx), "component"), "instance"), "connectorId"));
  12014. }
  12015. }
  12016. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  12017. }
  12018. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable") != NULL)
  12019. {
  12020. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable"), "name") != NULL)
  12021. {
  12022. sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[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, "json_object_array_get_idx"), idx), "variable"), "name")));
  12023. }
  12024. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable"), "instance") != NULL)
  12025. {
  12026. sprintf((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[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, "json_object_array_get_idx"), idx), "variable"), "instance")));
  12027. }
  12028. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  12029. }
  12030. }
  12031. }
  12032. json_object_put(SetVariableMonitoring);
  12033. return result;
  12034. }
  12035. int handleSetVariablesRequest(char *uuid, char *payload)
  12036. {
  12037. mtrace();
  12038. int result = FAIL;
  12039. json_object *SetVariables;
  12040. DEBUG_INFO("handleSetVariablesRequest...\n");
  12041. SetVariables = json_tokener_parse(payload);
  12042. if(!is_error(SetVariables))
  12043. {
  12044. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  12045. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  12046. // Required data
  12047. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  12048. {
  12049. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  12050. {
  12051. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  12052. {
  12053. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  12054. {
  12055. 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")));
  12056. }
  12057. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  12058. {
  12059. 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")));
  12060. }
  12061. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  12062. {
  12063. 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)
  12064. {
  12065. 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"), "instance"), "id"));
  12066. }
  12067. 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)
  12068. {
  12069. 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"), "instance"), "connectorId"));
  12070. }
  12071. }
  12072. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  12073. }
  12074. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  12075. {
  12076. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  12077. {
  12078. 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")));
  12079. }
  12080. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  12081. {
  12082. 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")));
  12083. }
  12084. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  12085. }
  12086. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  12087. {
  12088. 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")));
  12089. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  12090. }
  12091. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  12092. {
  12093. 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")));
  12094. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  12095. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  12096. {
  12097. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL) &&
  12098. (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) &&
  12099. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name) != NULL) &&
  12100. (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))
  12101. {
  12102. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  12103. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  12104. if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "NetworkConfigurationPriority") != NULL))
  12105. {
  12106. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]);
  12107. }
  12108. else
  12109. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  12110. }
  12111. }
  12112. }
  12113. }
  12114. }
  12115. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  12116. }
  12117. json_object_put(SetVariables);
  12118. return result;
  12119. }
  12120. int handleTriggerMessageRequest(char *uuid, char *payload)
  12121. {
  12122. mtrace();
  12123. int result = FAIL;
  12124. int connectorIdIsNULL = FALSE;
  12125. int connectorIdInt =0;
  12126. char requestedMessagestr[40]={0};
  12127. json_object *TriggerMessage;
  12128. DEBUG_INFO("handleTriggerMessageRequest\n");
  12129. TriggerMessage = json_tokener_parse(payload);
  12130. if(!is_error(TriggerMessage))
  12131. {
  12132. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  12133. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  12134. // Required data
  12135. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  12136. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  12137. // Optional data
  12138. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  12139. {
  12140. // Required data
  12141. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  12142. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  12143. // Optional data
  12144. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  12145. {
  12146. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  12147. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  12148. }
  12149. else
  12150. connectorIdIsNULL = TRUE;
  12151. }
  12152. }
  12153. json_object_put(TriggerMessage);
  12154. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  12155. {
  12156. if((strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  12157. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  12158. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  12159. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  12160. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  12161. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  12162. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  12163. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  12164. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  12165. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  12166. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  12167. {
  12168. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  12169. sendTriggerMessageConfirmation(uuid);
  12170. return TRUE;
  12171. }
  12172. else
  12173. {
  12174. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  12175. sendTriggerMessageConfirmation(uuid);
  12176. }
  12177. }
  12178. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  12179. {
  12180. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  12181. sendTriggerMessageConfirmation(uuid);
  12182. return TRUE;
  12183. }
  12184. //==========================
  12185. // Trigger message
  12186. //==========================
  12187. if( strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  12188. {
  12189. if((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) &&
  12190. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) &&
  12191. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) &&
  12192. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing) )
  12193. {
  12194. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  12195. }
  12196. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusNotificationStatus]);
  12197. }
  12198. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  12199. {
  12200. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[LogStatusNotificationStatus]);
  12201. }
  12202. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  12203. {
  12204. if(DB_updateBootType(BootReasonEnumType_Triggered))
  12205. server_sign = FALSE;
  12206. }
  12207. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  12208. {
  12209. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval);
  12210. }
  12211. else if (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  12212. {
  12213. if(connectorIdIsNULL == FALSE)
  12214. {
  12215. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12216. {
  12217. //sendMeterValuesRequest((connectorIdInt -1), ReadingContext_Trigger);
  12218. cpinitateMsg.bits[connectorIdInt -1].TriggerMeterValueReq = ON;
  12219. }
  12220. }
  12221. else
  12222. {
  12223. for(int idx=0;idx< gunTotalNumber;idx++)
  12224. {
  12225. //sendMeterValuesRequest(idx, ReadingContext_Trigger);
  12226. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  12227. }
  12228. }
  12229. }
  12230. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  12231. {
  12232. if(connectorIdIsNULL == FALSE)
  12233. {
  12234. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12235. {
  12236. cpinitateMsg.bits[connectorIdInt -1].StatusNotificationReq = ON;
  12237. }
  12238. }
  12239. else
  12240. {
  12241. for(int idx=0;idx< gunTotalNumber;idx++)
  12242. cpinitateMsg.bits[idx].StatusNotificationReq = ON;
  12243. }
  12244. }
  12245. return result;
  12246. }
  12247. int handleUnlockConnectorRequest(char *uuid, char *payload)
  12248. {
  12249. mtrace();
  12250. int result = FAIL;
  12251. int connectorIdInt =0;
  12252. int tempIndex = 0;
  12253. json_object *UnlockConnector;
  12254. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  12255. UnlockConnector = json_tokener_parse(payload);
  12256. if(!is_error(UnlockConnector))
  12257. {
  12258. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  12259. {
  12260. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  12261. }
  12262. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  12263. {
  12264. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  12265. }
  12266. }
  12267. json_object_put(UnlockConnector);
  12268. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  12269. if(gunTotalNumber == 0)
  12270. {
  12271. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12272. goto end;
  12273. }
  12274. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  12275. {
  12276. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12277. goto end;
  12278. }
  12279. else
  12280. {
  12281. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  12282. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  12283. //check Transaction active
  12284. if(gunType[connectorIdInt-1] == 'J')
  12285. {
  12286. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12287. {
  12288. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12289. }
  12290. else
  12291. {
  12292. tempIndex = connectorIdInt -1;
  12293. }
  12294. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12295. {
  12296. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12297. {
  12298. //stop Transaction
  12299. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12300. }
  12301. }
  12302. }
  12303. else if((gunType[connectorIdInt-1] == 'U')||(gunType[connectorIdInt-1] == 'E'))
  12304. {
  12305. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12306. {
  12307. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12308. }
  12309. else
  12310. {
  12311. tempIndex = connectorIdInt -1;
  12312. }
  12313. for (int index = 0; index < CCS_QUANTITY; index++)
  12314. {
  12315. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12316. {
  12317. //stop Transaction
  12318. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12319. }
  12320. }
  12321. }
  12322. else if(gunType[connectorIdInt-1] == 'G')
  12323. {
  12324. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12325. {
  12326. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12327. }
  12328. else
  12329. {
  12330. tempIndex = connectorIdInt -1;
  12331. }
  12332. for (int index = 0; index < GB_QUANTITY; index++)
  12333. {
  12334. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)))
  12335. {
  12336. //stop Transaction
  12337. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12338. }
  12339. }
  12340. }
  12341. else
  12342. {
  12343. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  12344. {
  12345. tempIndex = 2;
  12346. }
  12347. else
  12348. {
  12349. tempIndex = connectorIdInt-1;
  12350. }
  12351. for (int index = 0; index < AC_QUANTITY; index++)
  12352. {
  12353. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12354. {
  12355. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12356. }
  12357. }
  12358. }
  12359. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  12360. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  12361. result = TRUE;
  12362. return result;
  12363. }
  12364. end:
  12365. //json_object_put(obj); --- remove temporally
  12366. sendUnlockConnectorConfirmation(uuid, connectorIdInt-1);
  12367. return result;
  12368. }
  12369. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  12370. {
  12371. mtrace();
  12372. int result = FAIL;
  12373. json_object *UnpublishFirmware;
  12374. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  12375. UnpublishFirmware = json_tokener_parse(payload);
  12376. if(!is_error(UnpublishFirmware))
  12377. {
  12378. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  12379. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  12380. // Required data
  12381. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  12382. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  12383. }
  12384. json_object_put(UnpublishFirmware);
  12385. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  12386. /*
  12387. * TODO:
  12388. * 1. Check unpublished status
  12389. */
  12390. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  12391. sendUnpublishFirmwareConfirmation(uuid);
  12392. return result;
  12393. }
  12394. static char UpdateFirmwarepayloadData[512]={0};
  12395. void *UpdateFirmwareProcess(void *data)
  12396. {
  12397. pthread_detach(pthread_self());
  12398. mtrace();
  12399. int retriesInt =0, retryIntervalInt=0;
  12400. char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
  12401. int port=0;
  12402. char locationstr[160]={0}, retrieveDatestr[30]={0};
  12403. int isSuccess = 0;
  12404. char ftpbuf[200];
  12405. char temp[100];
  12406. char * pch;
  12407. DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
  12408. json_object *UpdateFirmware;
  12409. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  12410. if(!is_error(UpdateFirmware))
  12411. {
  12412. // Required data
  12413. if(json_object_object_get(UpdateFirmware, "location") != NULL)
  12414. sprintf((char*)locationstr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "location")));
  12415. if(json_object_object_get(UpdateFirmware, "retrieveDate") != NULL)
  12416. sprintf((char*)retrieveDatestr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "retrieveDate")));
  12417. // Optional data
  12418. if(json_object_object_get(UpdateFirmware, "retries"))
  12419. {
  12420. retriesInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  12421. }
  12422. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  12423. {
  12424. retryIntervalInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  12425. }
  12426. }
  12427. json_object_put(UpdateFirmware);
  12428. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  12429. memset(path, 0, ARRAY_SIZE(path));
  12430. system("rm -f /mnt/*");
  12431. if(strncmp(locationstr,"http", 4) == 0)
  12432. {
  12433. sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  12434. //sscanf(locationstr,"%[^:]:%*2[/]%[^:]:%[^@]@%[^/]%199[^\n]",
  12435. // protocol, user, password, host, path);
  12436. sprintf(ftppath,"/%s", path);
  12437. DEBUG_INFO("locationstr: %s\n", locationstr);
  12438. DEBUG_INFO("protocol: %s\n",protocol);
  12439. DEBUG_INFO("host: %s\n",host);
  12440. DEBUG_INFO("path: %s\n",path);
  12441. DEBUG_INFO("ftppath: %s\n",ftppath);
  12442. int ftppathlen=strlen(ftppath);
  12443. int i=1;
  12444. char filenametemp[50];
  12445. while(i < ftppathlen)
  12446. {
  12447. int len=ftppathlen-i;
  12448. if(ftppath[len]== 47) // '/' ascll code: 47
  12449. {
  12450. DEBUG_INFO("compare '/' all right\n");
  12451. break;
  12452. }
  12453. i=i+1;
  12454. }
  12455. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12456. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  12457. filenametemp[i+1] = 0;
  12458. do
  12459. {
  12460. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12461. sleep(3);
  12462. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
  12463. if(!isSuccess)
  12464. {
  12465. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12466. sleep(retryIntervalInt);
  12467. }
  12468. else
  12469. {
  12470. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12471. }
  12472. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
  12473. }
  12474. else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
  12475. {
  12476. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12477. memset(temp, 0, ARRAY_SIZE(temp));
  12478. //DEBUG_INFO("locationstr=%s\n",locationstr);
  12479. strcpy(ftpbuf, locationstr/*"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/DemoDC1_2018-07-13_185011_PSULog.zip"*/ );
  12480. int ftppathlen=strlen(ftpbuf);
  12481. int i=1;
  12482. char filenametemp[50];
  12483. while(i < ftppathlen)
  12484. {
  12485. int len=ftppathlen-i;
  12486. if(ftpbuf[len]== 47) // '/' ascll code: 47
  12487. {
  12488. DEBUG_INFO(" compare '/' all right\n");
  12489. break;
  12490. }
  12491. i=i+1;
  12492. }
  12493. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12494. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  12495. filenametemp[i+1] = 0;
  12496. strncpy(temp, ftpbuf, ftppathlen-i+1);
  12497. pch=strchr(temp,'@');
  12498. if(pch==NULL)
  12499. {
  12500. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  12501. protocol, host, &port, path);
  12502. strcpy(user,"anonymous");
  12503. strcpy(password,"");
  12504. }
  12505. else
  12506. {
  12507. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  12508. protocol, user, password, host, &port, path);
  12509. }
  12510. sscanf(host,"%[^/]%s",host1, path1);
  12511. sprintf(ftppath,"%s", path1);
  12512. //DEBUG_INFO("protocol =%s\n",protocol);
  12513. //DEBUG_INFO("user =%s\n",user);
  12514. //DEBUG_INFO("password =%s\n",password);
  12515. //DEBUG_INFO("host1 =%s\n",host1);
  12516. //DEBUG_INFO("port =%d\n",port);
  12517. //DEBUG_INFO("path1 =%s\n",path1);
  12518. //DEBUG_INFO("ftppath=%s\n",ftppath);
  12519. //ftpFile(host, user, password, port, ftppath, fname);
  12520. //download firmware pthred
  12521. if(port == 0)
  12522. {
  12523. port = 21;
  12524. }
  12525. do
  12526. {
  12527. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12528. sleep(3);
  12529. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
  12530. if(!isSuccess)
  12531. {
  12532. //BulldogUtil.sleepMs(interval*1000);
  12533. DEBUG_INFO("Update firmware request and download file fail.\n");
  12534. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12535. sleep(retryIntervalInt);
  12536. }
  12537. else
  12538. {
  12539. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12540. }
  12541. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  12542. }
  12543. else
  12544. {
  12545. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12546. }
  12547. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  12548. pthread_exit(NULL);
  12549. }
  12550. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  12551. {
  12552. mtrace();
  12553. int result = FAIL;
  12554. pthread_t t;
  12555. sendUpdateFirmwareConfirmation(uuid);
  12556. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  12557. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  12558. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  12559. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  12560. ////pthread_join(t, NULL); //
  12561. //pthread_detach(t);
  12562. //sendUpdateFirmwareConfirmation(uuid);
  12563. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  12564. return result;
  12565. }
  12566. //==========================================
  12567. // Handle server response routine
  12568. //==========================================
  12569. void handleAuthorizeResponse(char *payload, int gun_index)
  12570. {
  12571. mtrace();
  12572. DEBUG_INFO("handleAuthorizeResponse...\n");
  12573. json_object *Authorize;
  12574. Authorize = json_tokener_parse(payload);
  12575. if(!is_error(Authorize))
  12576. {
  12577. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  12578. {
  12579. // Required data
  12580. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  12581. // Optional data
  12582. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  12583. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  12584. else
  12585. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  12586. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  12587. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  12588. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  12589. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  12590. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  12591. {
  12592. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  12593. {
  12594. 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));
  12595. }
  12596. }
  12597. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  12598. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  12599. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  12600. {
  12601. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  12602. 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")));
  12603. else
  12604. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  12605. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  12606. 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")));
  12607. }
  12608. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  12609. {
  12610. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  12611. 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")));
  12612. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  12613. 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")));
  12614. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  12615. 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")));
  12616. }
  12617. }
  12618. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  12619. {
  12620. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  12621. }
  12622. }
  12623. json_object_put(Authorize);
  12624. //Update idTag information to authorization cache if supported
  12625. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  12626. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  12627. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  12628. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  12629. {
  12630. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  12631. }
  12632. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  12633. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  12634. authorizeRetryTimes = 0;
  12635. }
  12636. void handleBootNotificationResponse(char *payload, int gun_index)
  12637. {
  12638. mtrace();
  12639. char statusStr[12]={0};
  12640. char currentTimeStr[30]={0};
  12641. int intervalInt = 0;
  12642. struct tm tp;
  12643. char buf[28]={0};
  12644. char timebuf[50]={0};
  12645. DEBUG_INFO("handleBootNotificationResponse...\n");
  12646. json_object *BootNotification;
  12647. BootNotification = json_tokener_parse(payload);
  12648. if(!is_error(BootNotification))
  12649. {
  12650. // Required data
  12651. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  12652. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  12653. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  12654. }
  12655. json_object_put(BootNotification);
  12656. DEBUG_INFO("statusStr: %s\n", statusStr);
  12657. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  12658. BootNotificationInterval = intervalInt;
  12659. HeartBeatWaitTime = intervalInt;
  12660. //write back to ShmOCPP20Data->BootNotification
  12661. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  12662. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  12663. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  12664. {
  12665. server_sign = TRUE;
  12666. server_pending =FALSE;
  12667. DB_updateBootType(BootReasonEnumType_PowerUp);
  12668. }
  12669. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  12670. {
  12671. server_pending = TRUE;
  12672. }
  12673. strptime((const char *)ShmOCPP20Data->BootNotification.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  12674. tp.tm_isdst = -1;
  12675. //time_t utc = mktime(&tp);
  12676. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  12677. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  12678. sprintf(timebuf,"date -s '%s'",buf);
  12679. system(timebuf);
  12680. srand(time(NULL));
  12681. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  12682. //==============================================
  12683. // RTC sync
  12684. //==============================================
  12685. system("/sbin/hwclock -w --systohc");
  12686. SetOcppConnStatus(TRUE);
  12687. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  12688. }
  12689. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  12690. {
  12691. mtrace();
  12692. json_object *ClearedChargingLimit;
  12693. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  12694. ClearedChargingLimit = json_tokener_parse(payload);
  12695. if(!is_error(ClearedChargingLimit))
  12696. {
  12697. // Required data
  12698. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  12699. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  12700. }
  12701. json_object_put(ClearedChargingLimit);
  12702. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitReq = OFF;
  12703. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitConf = ON;
  12704. }
  12705. void handleDataTransferResponse(char *payload, int gun_index)
  12706. {
  12707. mtrace();
  12708. json_object *DataTrans;
  12709. DEBUG_INFO("handleDataTransferResponse...\n");
  12710. DataTrans = json_tokener_parse(payload);
  12711. if(!is_error(DataTrans))
  12712. {
  12713. // Required data
  12714. if(json_object_object_get(DataTrans,"status") != NULL)
  12715. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  12716. // Optional data
  12717. if(json_object_object_get(DataTrans,"data") != NULL)
  12718. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  12719. }
  12720. json_object_put(DataTrans);
  12721. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  12722. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  12723. }
  12724. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  12725. {
  12726. mtrace();
  12727. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  12728. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  12729. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  12730. }
  12731. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  12732. {
  12733. mtrace();
  12734. json_object *Get15118EVCertificate;
  12735. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  12736. Get15118EVCertificate = json_tokener_parse(payload);
  12737. if(!is_error(Get15118EVCertificate))
  12738. {
  12739. // Required data
  12740. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  12741. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  12742. // Optional data
  12743. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  12744. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  12745. }
  12746. json_object_put(Get15118EVCertificate);
  12747. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  12748. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  12749. }
  12750. void hanldeGetCertificateStatusResponse(char *payload, int gun_index)
  12751. {
  12752. mtrace();
  12753. json_object *GetCertificateStatus;
  12754. DEBUG_INFO("hanldeGetCertificateStatusResponse...\n");
  12755. GetCertificateStatus = json_tokener_parse(payload);
  12756. if(!is_error(GetCertificateStatus))
  12757. {
  12758. // Required data
  12759. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  12760. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  12761. // Optional data
  12762. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  12763. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  12764. }
  12765. json_object_put(GetCertificateStatus);
  12766. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  12767. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  12768. }
  12769. void handleHeartbeatResponse(char *payload, int gun_index)
  12770. {
  12771. mtrace();
  12772. struct tm tp;
  12773. char buf[28]={0};
  12774. char timebuf[128]={0};
  12775. DEBUG_INFO("handleHeartbeatResponse...\n");
  12776. json_object *Heartbeat;
  12777. Heartbeat = json_tokener_parse(payload);
  12778. if(!is_error(Heartbeat))
  12779. {
  12780. // Required data
  12781. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  12782. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  12783. }
  12784. json_object_put(Heartbeat);
  12785. if(FirstHeartBeat == OFF)
  12786. {
  12787. FirstHeartBeat = ON;
  12788. DEBUG_INFO("FirstHeartBeat \n");
  12789. }
  12790. HeartBeatWithNOResponse = 0;
  12791. clientTime.Heartbeat=time((time_t*)NULL);
  12792. strptime((const char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  12793. tp.tm_isdst = -1;
  12794. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  12795. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  12796. sprintf(timebuf,"date -s '%s'",buf);
  12797. system(timebuf);
  12798. //==============================================
  12799. // RTC sync
  12800. //==============================================
  12801. system("/sbin/hwclock -w --systohc");
  12802. }
  12803. void hanldeLogStatusNotificationResponse(char *payload, int gun_index)
  12804. {
  12805. mtrace();
  12806. DEBUG_INFO("hanldeLogStatusNotificationResponse...\n");
  12807. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  12808. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  12809. }
  12810. void handleMeterValuesResponse(char *payload, int gun_index)
  12811. {
  12812. mtrace();
  12813. DEBUG_INFO("handleMeterValuesResponse...\n");
  12814. }
  12815. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  12816. {
  12817. mtrace();
  12818. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  12819. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  12820. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  12821. }
  12822. void hanldeNotifyCustomerInformationResponse(char *payload, int gun_index)
  12823. {
  12824. mtrace();
  12825. DEBUG_INFO("hanldeNotifyCustomerInformationResponse...\n");
  12826. }
  12827. void hanldeNotifyDisplayMessagesResponse(char *payload, int gun_index)
  12828. {
  12829. mtrace();
  12830. DEBUG_INFO("hanldeNotifyDisplayMessagesResponse...\n");
  12831. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  12832. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  12833. }
  12834. void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  12835. {
  12836. mtrace();
  12837. json_object *NotifyEVChargingNeeds;
  12838. DEBUG_INFO("hanldeNotifyEVChargingNeedsResponse...\n");
  12839. NotifyEVChargingNeeds = json_tokener_parse(payload);
  12840. if(!is_error(NotifyEVChargingNeeds))
  12841. {
  12842. // Required data
  12843. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  12844. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  12845. }
  12846. json_object_put(NotifyEVChargingNeeds);
  12847. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  12848. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  12849. }
  12850. void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  12851. {
  12852. mtrace();
  12853. json_object *NotifyEVChargingSchedule;
  12854. DEBUG_INFO("hanldeNotifyEVChargingScheduleResponse...\n");
  12855. NotifyEVChargingSchedule = json_tokener_parse(payload);
  12856. if(!is_error(NotifyEVChargingSchedule))
  12857. {
  12858. // Required data
  12859. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  12860. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  12861. }
  12862. json_object_put(NotifyEVChargingSchedule);
  12863. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  12864. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  12865. }
  12866. void hanldeNotifyEventResponse(char *payload, int gun_index)
  12867. {
  12868. mtrace();
  12869. DEBUG_INFO("hanldeNotifyEventResponse...\n");
  12870. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  12871. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  12872. }
  12873. void hanldeNotifyMonitoringReportResponse(char *payload, int gun_index)
  12874. {
  12875. mtrace();
  12876. DEBUG_INFO("hanldeNotifyMonitoringReportResponse...\n");
  12877. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  12878. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  12879. }
  12880. void hanldeNotifyReportResponse(char *payload, int gun_index)
  12881. {
  12882. mtrace();
  12883. DEBUG_INFO("hanldeNotifyReportResponse...\n");
  12884. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  12885. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  12886. }
  12887. void hanldePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  12888. {
  12889. mtrace();
  12890. DEBUG_INFO("hanldePublishFirmwareStatusNotificationResponse...\n");
  12891. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  12892. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  12893. }
  12894. void hanldeReportChargingProfilesResponse(char *payload, int gun_index)
  12895. {
  12896. mtrace();
  12897. DEBUG_INFO("hanldeReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  12898. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  12899. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  12900. }
  12901. void hanldeReservationStatusUpdateResponse(char *payload, int gun_index)
  12902. {
  12903. mtrace();
  12904. DEBUG_INFO("hanldeReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  12905. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  12906. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  12907. }
  12908. void hanldeSecurityEventNotificationResponse(char *payload, int gun_index)
  12909. {
  12910. mtrace();
  12911. DEBUG_INFO("hanldeSecurityEventNotificationResponse...\n");
  12912. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  12913. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  12914. }
  12915. void hanldeSignCertificateResponse(char *payload, int gun_index)
  12916. {
  12917. mtrace();
  12918. json_object *SignCertificate;
  12919. DEBUG_INFO("hanldeSignCertificateResponse...\n");
  12920. SignCertificate = json_tokener_parse(payload);
  12921. if(!is_error(SignCertificate))
  12922. {
  12923. // Required data
  12924. if(json_object_object_get(SignCertificate,"status") != NULL)
  12925. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  12926. }
  12927. json_object_put(SignCertificate);
  12928. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  12929. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  12930. }
  12931. void handleStatusNotificationResponse(char *payload, int gun_index)
  12932. {
  12933. mtrace();
  12934. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  12935. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  12936. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  12937. }
  12938. void hanldeTransactionEvenResponse(char *payload, int gun_index)
  12939. {
  12940. mtrace();
  12941. json_object *TransactionEven;
  12942. DEBUG_INFO("hanldeTransactionEvenResponse...\n");
  12943. TransactionEven = json_tokener_parse(payload);
  12944. if(!is_error(TransactionEven))
  12945. {
  12946. // Required data
  12947. // Optional data
  12948. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  12949. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  12950. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  12951. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  12952. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  12953. {
  12954. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  12955. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  12956. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  12957. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  12958. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  12959. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  12960. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  12961. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  12962. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  12963. {
  12964. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  12965. 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")));
  12966. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  12967. 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")));
  12968. }
  12969. }
  12970. }
  12971. json_object_put(TransactionEven);
  12972. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  12973. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  12974. }
  12975. //==========================================
  12976. // Handle Error routine
  12977. //==========================================
  12978. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  12979. {
  12980. mtrace();
  12981. #ifdef SystemLogMessage
  12982. DEBUG_INFO("errorCode: %s\n", errorCode);
  12983. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  12984. DEBUG_INFO("errorDetails: %s\n", payload);
  12985. #endif
  12986. }
  12987. //===============================================
  12988. // Common routine
  12989. //===============================================
  12990. int initialConfigurationTable(void)
  12991. {
  12992. DEBUG_INFO("initialConfigurationTable...\n");
  12993. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  12994. DB_variableIsCreate();
  12995. DB_variableLoadFromDb();
  12996. DB_getNetworkProfileFromDb();
  12997. return 0;
  12998. }
  12999. int TransactionMessageAttemptsGet(void)
  13000. {
  13001. return TransactionMessageAttemptsValue;
  13002. }
  13003. int FirstHeartBeatResponse(void)
  13004. {
  13005. return FirstHeartBeat;
  13006. }
  13007. int TransactionMessageRetryIntervalGet(void)
  13008. {
  13009. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  13010. }
  13011. int ReadHttpStatus(int sock)
  13012. {
  13013. //char c;
  13014. char buff[1024]="",*ptr=buff+1;
  13015. int bytes_received, status;
  13016. DEBUG_INFO("Begin Response ..\n");
  13017. while((bytes_received = recv(sock, ptr, 1, 0))){
  13018. if(bytes_received==-1){
  13019. perror("ReadHttpStatus");
  13020. exit(1);
  13021. }
  13022. if((ptr[-1]=='\r') && (*ptr=='\n' )) break;
  13023. ptr++;
  13024. }
  13025. *ptr=0;
  13026. ptr=buff+1;
  13027. sscanf(ptr,"%*s %d ", &status);
  13028. DEBUG_INFO("%s\n",ptr);
  13029. DEBUG_INFO("status=%d\n",status);
  13030. DEBUG_INFO("End Response ..\n");
  13031. return (bytes_received>0)?status:0;
  13032. }
  13033. //the only filed that it parsed is 'Content-Length'
  13034. int ParseHeader(int sock)
  13035. {
  13036. //char c;
  13037. char buff[1024]="",*ptr=buff+4;
  13038. int bytes_received;
  13039. DEBUG_INFO("Begin HEADER ..\n");
  13040. while((bytes_received = recv(sock, ptr, 1, 0))){
  13041. if(bytes_received==-1){
  13042. perror("Parse Header");
  13043. exit(1);
  13044. }
  13045. if(
  13046. (ptr[-3]=='\r') && (ptr[-2]=='\n' ) &&
  13047. (ptr[-1]=='\r') && (*ptr=='\n' )
  13048. ) break;
  13049. ptr++;
  13050. }
  13051. *ptr=0;
  13052. ptr=buff+4;
  13053. //printf("%s",ptr);
  13054. if(bytes_received){
  13055. ptr=strstr(ptr,"Content-Length:");
  13056. if(ptr){
  13057. sscanf(ptr,"%*s %d",&bytes_received);
  13058. }else
  13059. bytes_received=-1; //unknown size
  13060. DEBUG_INFO("Content-Length: %d\n",bytes_received);
  13061. }
  13062. DEBUG_INFO("End HEADER ..\n");
  13063. return bytes_received ;
  13064. }
  13065. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  13066. {
  13067. char rmFileCmd[100]={0};
  13068. char FilePath[100]={0};
  13069. char ftpbuf[200];
  13070. int systemresult;
  13071. //DEBUG_INFO("filename=%s\n",filename);
  13072. //DEBUG_INFO("url=%s\n",url);
  13073. sprintf(FilePath,"/mnt/%s",filename);
  13074. system("ping 8.8.8.8 &");
  13075. if((access(FilePath,F_OK))!=-1)
  13076. {
  13077. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13078. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13079. system(rmFileCmd);
  13080. }
  13081. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13082. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13083. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13084. systemresult = system(ftpbuf);
  13085. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13086. if(systemresult != 0)
  13087. {
  13088. DEBUG_INFO("http DownLoad error!\n");
  13089. return FALSE;
  13090. }
  13091. system("pkill ping");
  13092. return TRUE;
  13093. }
  13094. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  13095. {
  13096. char rmFileCmd[100]={0};
  13097. char FilePath[100]={0};
  13098. char ftpbuf[200];
  13099. int systemresult;
  13100. //char temp[100];
  13101. sprintf(FilePath,"/mnt/%s",filename);
  13102. system("ping 8.8.8.8 &");
  13103. if((access(FilePath,F_OK))!=-1)
  13104. {
  13105. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13106. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13107. system(rmFileCmd);
  13108. }
  13109. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13110. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13111. //sprintf(ftpbuf, "ftpget -u %s -p %s %s -P %d %s %s%s",user,password,IPbuffer,port/*21*/,filename,path,filename); --- remove temporally
  13112. //DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13113. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13114. systemresult = system(ftpbuf);
  13115. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13116. if(systemresult != 0)
  13117. {
  13118. printf("wget error!\n");
  13119. return FALSE;
  13120. }
  13121. system("pkill ping");
  13122. return TRUE;
  13123. }
  13124. int httpUploadFile(char *location, char *path, char *filename,char *url)
  13125. {
  13126. char rmFileCmd[100]={0};
  13127. char FilePath[100]={0};
  13128. char ftpbuf[200];
  13129. int systemresult;
  13130. //DEBUG_INFO("filename=%s\n",filename);
  13131. //DEBUG_INFO("url=%s\n",url);
  13132. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  13133. if((access(FilePath,F_OK))!=-1)
  13134. {
  13135. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13136. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13137. system(rmFileCmd);
  13138. }
  13139. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  13140. if(fp == NULL)
  13141. {
  13142. DEBUG_INFO("log is NULL\n");
  13143. return FALSE;
  13144. }
  13145. else
  13146. {
  13147. fprintf(fp, "%s\n", url);
  13148. fprintf(fp, "%s\n", filename);
  13149. fclose(fp);
  13150. }
  13151. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13152. sprintf(ftpbuf, "%s","/bin/php-cgi /var/www/ocpp_upload.php");
  13153. systemresult = system(ftpbuf);
  13154. DEBUG_INFO("systemresult = %d\n",systemresult);
  13155. if(systemresult != 0)
  13156. {
  13157. DEBUG_INFO("http upload error!\n");
  13158. return FALSE;
  13159. }
  13160. return TRUE;
  13161. }
  13162. int ftpFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  13163. {
  13164. struct hostent* server;
  13165. char *IPbuffer;
  13166. char ftpbuf[200];
  13167. int systemresult;
  13168. // To retrieve host information
  13169. server = gethostbyname(location);
  13170. // To convert an Internet network
  13171. // address into ASCII string
  13172. IPbuffer = inet_ntoa(*((struct in_addr*)
  13173. server->h_addr_list[0]));
  13174. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13175. /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
  13176. /* format : ftpput -u username -p passwd IP target source*/
  13177. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
  13178. DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13179. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13180. systemresult = system(ftpbuf);
  13181. DEBUG_INFO("systemresult=%d\n",systemresult);
  13182. if(systemresult != 0)
  13183. {
  13184. DEBUG_INFO("ftpput error!\n");
  13185. return FALSE;
  13186. }
  13187. return TRUE;
  13188. }
  13189. //=========================================
  13190. // Routine
  13191. //=========================================
  13192. int GetOcppServerURL()
  13193. {
  13194. int result = FALSE;
  13195. struct yuarel url;
  13196. char urlStr[512];
  13197. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  13198. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  13199. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  13200. if((ShmSysConfigAndInfo->SysConfig.OcppServerURL != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0) )
  13201. {
  13202. memcpy(urlStr, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  13203. if(yuarel_parse(&url, urlStr) != -1)
  13204. {
  13205. sprintf(OcppProtocol, "%s", url.scheme);
  13206. sprintf(OcppHost, "%s", url.host);
  13207. if(url.path == NULL)
  13208. OcppTempPath[0] = '\0';
  13209. else
  13210. {
  13211. if((url.path[strlen(url.path)-1] != '/') && (strlen(url.path) > 0))
  13212. {
  13213. sprintf(OcppTempPath, "%s/", url.path);
  13214. }
  13215. else
  13216. {
  13217. sprintf(OcppTempPath, "%s", url.path);
  13218. }
  13219. }
  13220. if(url.port == 0)
  13221. {
  13222. if(strcmp(OcppProtocol, "wss") == 0)
  13223. OcppPort = 443;
  13224. else
  13225. OcppPort = 80;
  13226. }
  13227. else
  13228. OcppPort = url.port;
  13229. result = TRUE;
  13230. }
  13231. }
  13232. else if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  13233. {
  13234. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  13235. if(yuarel_parse(&url, urlStr) != -1)
  13236. {
  13237. sprintf(OcppProtocol, "%s", url.scheme);
  13238. sprintf(OcppHost, "%s", url.host);
  13239. if(url.path == NULL)
  13240. OcppTempPath[0] = '\0';
  13241. else
  13242. sprintf(OcppTempPath, "%s", url.path);
  13243. if(url.port == 0)
  13244. {
  13245. if(strcmp(OcppProtocol, "wss") == 0)
  13246. OcppPort = 443;
  13247. else
  13248. OcppPort = 80;
  13249. }
  13250. else
  13251. OcppPort = url.port;
  13252. result = TRUE;
  13253. }
  13254. }
  13255. else
  13256. {
  13257. strcpy(OcppHost,"");
  13258. }
  13259. return result;
  13260. }
  13261. int GetOcppPath()
  13262. {
  13263. int result = FALSE;
  13264. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  13265. {
  13266. if(OcppTempPath == NULL)
  13267. {
  13268. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13269. }
  13270. else
  13271. {
  13272. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13273. }
  13274. result = TRUE;
  13275. }
  13276. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  13277. {
  13278. if(OcppTempPath == NULL)
  13279. {
  13280. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  13281. }
  13282. else
  13283. {
  13284. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  13285. }
  13286. result = TRUE;
  13287. }
  13288. else
  13289. {
  13290. strcpy(OcppPath,"");
  13291. }
  13292. return result;
  13293. }
  13294. int GetOcppPort()
  13295. {
  13296. return OcppPort;
  13297. }
  13298. int GetOcppConnStatus(void)
  13299. {
  13300. return ShmOCPP20Data->OcppConnStatus;
  13301. }
  13302. void SetOcppConnStatus(uint8_t status)
  13303. {
  13304. ShmOCPP20Data->OcppConnStatus = status;
  13305. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  13306. }
  13307. int GetHeartBeatWithNOResponse(void)
  13308. {
  13309. return HeartBeatWithNOResponse;
  13310. }
  13311. void SetHeartBeatWithNOResponse(void)
  13312. {
  13313. HeartBeatWithNOResponse = 0;
  13314. }
  13315. void GetStartTransactionIdTag(int gun_index)
  13316. {
  13317. memset(StartTransactionIdTagTemp, 0 ,ARRAY_SIZE(StartTransactionIdTagTemp));
  13318. strcpy((char *)StartTransactionIdTagTemp, (const char *)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken);
  13319. }
  13320. int GetTransactionId(int gunindex, unsigned char idTag[], uint8_t isStopTransaction)
  13321. {
  13322. char ch;
  13323. FILE *fptr1;
  13324. int temptransactionId;
  13325. char str[100]={0};
  13326. temptransactionId = 0;
  13327. if((strcmp((const char*)idTag, "")==0)||(idTag[0]=='\0'))
  13328. {
  13329. DEBUG_INFO("IdTag is empty.\n");
  13330. return temptransactionId;
  13331. }
  13332. /*------ Read the file ----------------*/
  13333. fptr1=fopen("/Storage/OCPP/QueueTransactionId","r");
  13334. if (!fptr1)
  13335. {
  13336. DEBUG_INFO("QueueTransactionId file open error.\n");
  13337. //printf(" File not found or unable to open the input file!!\n");
  13338. return temptransactionId;
  13339. }
  13340. ch=fgetc(fptr1);
  13341. //printf(" Now the content of the file %s is : \n","/Storage/OCPP/QueueTransactionId");
  13342. rewind(fptr1);
  13343. if(ch!=EOF)
  13344. {
  13345. // printf("%c",ch);
  13346. while (fgets(str, 100, fptr1) != NULL)
  13347. {
  13348. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13349. if(str[0]=='\0')
  13350. {
  13351. break;
  13352. }
  13353. char *revbuf[8] = {0}; // Variable store string split
  13354. int num = 0;// Quantity after string split
  13355. DEBUG_INFO("Transaction queue data= %s\n", str);
  13356. splitstring(str,",",revbuf,&num); // String split
  13357. DEBUG_INFO(" revbuf[0]= %s\n", revbuf[0]);
  13358. DEBUG_INFO(" revbuf[1]= %s\n", revbuf[1]);
  13359. DEBUG_INFO(" revbuf[2]= %s\n", revbuf[2]);
  13360. if((revbuf[1][0] != '\0')&&(revbuf[2][0] != '\0'))
  13361. {
  13362. if(isStopTransaction)
  13363. {
  13364. if((atoi(revbuf[0])==gunindex) && (strcmp(revbuf[1],(const char *)idTag)==0))
  13365. {
  13366. temptransactionId = atoi(revbuf[2]);
  13367. break;
  13368. }
  13369. }
  13370. else
  13371. {
  13372. if((atoi(revbuf[0])==gunindex) || (strcmp(revbuf[1],(const char *)idTag)==0))
  13373. {
  13374. temptransactionId = atoi(revbuf[2]);
  13375. break;
  13376. }
  13377. }
  13378. }
  13379. }
  13380. }
  13381. else
  13382. DEBUG_INFO("EOF\n");
  13383. fclose(fptr1);
  13384. /*------- End of reading ---------------*/
  13385. return temptransactionId;
  13386. }
  13387. void SetTransactionIdZero(int transactionId)
  13388. {
  13389. char ch;
  13390. FILE *fptr1, *fptr2;
  13391. int temptransactionId = 0;
  13392. char str[100]={0}, strtemp[100]={0}, temp[] = "/Storage/OCPP/QueueTransactionIdtemp.json";
  13393. fptr1 = fopen("/Storage/OCPP/QueueTransactionId", "r");
  13394. if (!fptr1)
  13395. {
  13396. //printf(" File not found or unable to open the input file!!\n");
  13397. return ;
  13398. }
  13399. fptr2 = fopen(temp, "w"); // open the temporary file in write mode
  13400. if (!fptr2)
  13401. {
  13402. DEBUG_INFO("Unable to open a temporary file to write!!\n");
  13403. fclose(fptr1);
  13404. return ;
  13405. }
  13406. ch=fgetc(fptr1);
  13407. rewind(fptr1);
  13408. if(ch!=EOF)
  13409. {
  13410. // copy all contents to the temporary file except the specific line
  13411. while (fgets(str, 100, fptr1) != NULL)
  13412. {
  13413. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13414. if(str[0]=='\0')
  13415. {
  13416. break;
  13417. }
  13418. char *revbuf[8] = {0};
  13419. int num = 0;
  13420. strcpy(strtemp, str);
  13421. splitstring(str,",",revbuf,&num);
  13422. if(revbuf[2][0] != '\0')
  13423. {
  13424. temptransactionId = atoi(revbuf[2]);
  13425. if(transactionId != temptransactionId)
  13426. {
  13427. fprintf(fptr2, "%s\n", strtemp);
  13428. }
  13429. }
  13430. }
  13431. }
  13432. fclose(fptr1);
  13433. fclose(fptr2);
  13434. remove("/Storage/OCPP/QueueTransactionId"); // remove the original file
  13435. rename(temp, "/Storage/OCPP/QueueTransactionId"); // rename the temporary file to original name
  13436. /*------ Read the file ----------------*/
  13437. }
  13438. int InternetDisconnect(void)
  13439. {
  13440. return (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi && ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet && ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi );
  13441. }
  13442. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  13443. void storeTempStopTransaction(int gun_index)
  13444. {
  13445. }
  13446. void checkTempStopTransaction(int gun_index)
  13447. {
  13448. FILE *fptr1;
  13449. char ch;
  13450. char str[QUEUE_MESSAGE_LENGTH]={0};
  13451. char guid[37]={0};
  13452. char tempdata[65]={0};
  13453. char connectorStr[2]={0};
  13454. char TempStopTransaction[256];
  13455. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  13456. fptr1 = fopen(TempStopTransaction, "r");
  13457. //TempStopTransaction格式: 槍號,StopTransaction封包
  13458. if (!fptr1)
  13459. {
  13460. //printf(" File not found or unable to open the input file!!\n");
  13461. return ;
  13462. }
  13463. ch=fgetc(fptr1);
  13464. //printf(" Now the content of the file %s is : \n",fname);
  13465. rewind(fptr1);
  13466. if(ch!=EOF)
  13467. {
  13468. // copy all contents to the temporary file except the specific line
  13469. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  13470. {
  13471. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13472. if(str[0]=='\0')
  13473. {
  13474. break;
  13475. }
  13476. //TempStopTransaction格式: 槍號,StopTransaction封包
  13477. strncpy(connectorStr, str, 1);
  13478. if(atoi(connectorStr) != (gun_index+1))
  13479. {
  13480. DEBUG_INFO("atoi(connectorStr) = %d, gun_index = %d\n", atoi(connectorStr), gun_index);
  13481. fclose(fptr1);
  13482. return ;
  13483. }
  13484. //random_uuid(guid);
  13485. strncpy(guid, str+6, 36); //copy guid
  13486. sprintf(tempdata, "StopTransaction,%d", (gun_index));
  13487. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  13488. {
  13489. //DEBUG_INFO("StopTransaction mapitem pass\n");
  13490. }
  13491. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  13492. memset(str,0,ARRAY_SIZE(str));
  13493. }
  13494. }
  13495. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  13496. fclose(fptr1);
  13497. remove(TempStopTransaction); // remove the original file
  13498. }
  13499. void FillStartTransaction(int ConnectorId, unsigned char IdTag[], int MeterStart,int ReservationId,unsigned char Timestamp[])
  13500. {
  13501. ShmOCPP20Data->TransactionEvent[ConnectorId-1].evse.connectorId = ConnectorId;
  13502. ShmOCPP20Data->TransactionEvent[ConnectorId-1].reservationId = ReservationId;
  13503. //ShmOCPP20Data->TransactionEvent[ConnectorId-1].MeterStart = MeterStart;
  13504. strcpy((char *)ShmOCPP20Data->TransactionEvent[ConnectorId-1].idToken.idToken, (char *)IdTag);
  13505. strcpy((char *)ShmOCPP20Data->TransactionEvent[ConnectorId-1].timestamp,(char *) Timestamp);
  13506. }
  13507. int GetWebSocketPingInterval(void)
  13508. {
  13509. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  13510. }
  13511. int GetServerSign(void)
  13512. {
  13513. return server_sign;
  13514. }
  13515. uint8_t GetOcppSecurityProfile()
  13516. {
  13517. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  13518. }
  13519. void GetOcppChargerBoxId(uint8_t *data)
  13520. {
  13521. sprintf((char*)data, "%s", ShmOCPP20Data->ChargeBoxId);
  13522. }
  13523. void GetOcppSecurityPassword(uint8_t *data)
  13524. {
  13525. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  13526. }
  13527. void SetServerSign(int value)
  13528. {
  13529. server_sign = value;
  13530. }
  13531. int GetBootNotificationInterval(void)
  13532. {
  13533. return BootNotificationInterval;
  13534. }
  13535. int GetInternetConn(void)
  13536. {
  13537. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  13538. }
  13539. void InitialSystemValue(void)
  13540. {
  13541. int connectorIndex = 0;
  13542. gunTotalNumber=0;
  13543. SystemInitial = 0;
  13544. localversion=0;
  13545. BootNotificationInterval = 10;
  13546. authorizeRetryTimes = 0;
  13547. GunStatusInterval = 10;
  13548. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  13549. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  13550. //Hear Beat
  13551. HeartBeatWithNOResponse = 0;
  13552. HeartBeatCountPerHour = 0;
  13553. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  13554. FirstHeartBeat = 0;
  13555. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  13556. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  13557. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  13558. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  13559. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  13560. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  13561. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  13562. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  13563. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  13564. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  13565. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  13566. memset(gunType, 0, ARRAY_SIZE(gunType));
  13567. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13568. {
  13569. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O')
  13570. {
  13571. // DO series
  13572. for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
  13573. {
  13574. SystemInitial = SystemInitial + 1;
  13575. gunTotalNumber = gunTotalNumber + 1;
  13576. gunType[connectorIndex] = 'O';
  13577. connectorIndex = connectorIndex + 1;
  13578. }
  13579. }
  13580. else
  13581. {
  13582. // DM, DW, DS series
  13583. //check connector / socket type (index: 8, 9, 10)
  13584. for(int index=7; index <10 ; index++)
  13585. {
  13586. if(index != 8)
  13587. {
  13588. // DC Connector
  13589. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] >= 'A') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= 'Z'))
  13590. {
  13591. SystemInitial = SystemInitial + 1;
  13592. gunTotalNumber = gunTotalNumber + 1;
  13593. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13594. connectorIndex = connectorIndex + 1;
  13595. }
  13596. }
  13597. else
  13598. {
  13599. // AC Connector
  13600. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13601. {
  13602. SystemInitial = SystemInitial + 1;
  13603. gunTotalNumber = gunTotalNumber + 1;
  13604. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13605. connectorIndex = connectorIndex + 1;
  13606. }
  13607. }
  13608. }
  13609. }
  13610. //DEBUG_INFO("DC ...\n");
  13611. }
  13612. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  13613. {
  13614. //check connector / socket type (index: 8, 9, 10)
  13615. for(int index=7; index <10 ; index++)
  13616. {
  13617. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13618. {
  13619. SystemInitial = SystemInitial + 1;
  13620. gunTotalNumber = gunTotalNumber + 1;
  13621. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13622. connectorIndex = connectorIndex + 1;
  13623. //DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
  13624. }
  13625. }
  13626. }
  13627. //Status && ConnectorPlugIn Setting
  13628. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13629. {
  13630. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  13631. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  13632. }
  13633. for (int index = 0; index < CCS_QUANTITY; index++)
  13634. {
  13635. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  13636. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  13637. }
  13638. for (int index = 0; index < GB_QUANTITY; index++)
  13639. {
  13640. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  13641. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  13642. }
  13643. for (int index = 0; index < AC_QUANTITY; index++)
  13644. {
  13645. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  13646. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  13647. }
  13648. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13649. {
  13650. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  13651. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  13652. }
  13653. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  13654. {
  13655. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13656. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  13657. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  13658. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  13659. }
  13660. clientTime.Heartbeat=time((time_t*)NULL);
  13661. sleep(1);
  13662. }
  13663. void LWS_Send(char * str)
  13664. {
  13665. //=====================================================
  13666. // Check InternetConn 0: disconnected, 1: connected
  13667. //====================================================
  13668. if(GetOcppConnStatus() == 0)
  13669. {
  13670. DEBUG_INFO("offline now !!!\n");
  13671. return;
  13672. }
  13673. pthread_mutex_lock(&lock_send);
  13674. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13675. sprintf((char *)SendBuffer, "%s", str);
  13676. SendBufLen = strlen(str);
  13677. pthread_mutex_unlock(&lock_send);
  13678. lws_callback_on_writable(wsi_client);
  13679. //lws_service(context, 0);
  13680. //sleep(1);
  13681. }
  13682. void LWS_SendNow(char * str)
  13683. {
  13684. //=====================================================
  13685. // Check InternetConn 0: disconnected, 1: connected
  13686. //====================================================
  13687. if(GetOcppConnStatus() == 0)
  13688. {
  13689. DEBUG_INFO("offline now !!!\n");
  13690. return;
  13691. }
  13692. pthread_mutex_lock(&lock_send);
  13693. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13694. sprintf((char *)SendBuffer, "%s", str);
  13695. SendBufLen = strlen(str);
  13696. pthread_mutex_unlock(&lock_send);
  13697. lws_callback_on_writable(wsi_client);
  13698. lws_service(context, 0);
  13699. //sleep(1);
  13700. }