MessageHandler.c 807 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076
  1. #include "Module_OcppBackend20.h"
  2. #include "define.h"
  3. static char *APNAuthenticationEnumTypeStr[] = {
  4. MACROSTR(CHAP),
  5. MACROSTR(NONE),
  6. MACROSTR(PAP),
  7. MACROSTR(AUTO)
  8. };
  9. static char *AttributeEnumTypeStr[] = {
  10. MACROSTR(Actual),
  11. MACROSTR(Target),
  12. MACROSTR(MinSet),
  13. MACROSTR(MaxSet)
  14. };
  15. static char *AuthorizationStatusEnumTypeStr[] = {
  16. MACROSTR(Accepted),
  17. MACROSTR(Blocked),
  18. MACROSTR(ConcurrentTx),
  19. MACROSTR(Expired),
  20. MACROSTR(Invalid),
  21. MACROSTR(NoCredit),
  22. MACROSTR(NotAllowedTypeEVSE),
  23. MACROSTR(NotAtThisLocation),
  24. MACROSTR(NotAtThisTime),
  25. MACROSTR(Unknown)
  26. };
  27. #if 0
  28. static char *AuthorizeCertificateStatusEnumTypeStr[] = {
  29. MACROSTR(Accepted),
  30. MACROSTR(SignatureError),
  31. MACROSTR(CertificateExpired),
  32. MACROSTR(CertificateRevoked),
  33. MACROSTR(NoCertificateAvailable),
  34. MACROSTR(CertChainError),
  35. MACROSTR(ContractCancelled)
  36. };
  37. #endif
  38. static char *BootReasonEnumTypeStr[] = {
  39. MACROSTR(ApplicationReset),
  40. MACROSTR(FirmwareUpdate),
  41. MACROSTR(LocalReset),
  42. MACROSTR(PowerUp),
  43. MACROSTR(RemoteReset),
  44. MACROSTR(ScheduledReset),
  45. MACROSTR(Triggered),
  46. MACROSTR(Unknown),
  47. MACROSTR(Watchdog)
  48. };
  49. static char *CancelReservationStatusEnumTypeStr[] = {
  50. MACROSTR(Accepted),
  51. MACROSTR(Rejected)
  52. };
  53. static char *CertificateActionEnumTypeStr[] = {
  54. MACROSTR(Install),
  55. MACROSTR(Update)
  56. };
  57. static char *CertificateSignedStatusEnumTypeStr[] = {
  58. MACROSTR(Accepted),
  59. MACROSTR(Rejected)
  60. };
  61. static char *CertificateSigningUseEnumTypeStr[] = {
  62. MACROSTR(ChargingStationCertificate),
  63. MACROSTR(V2GCertificate)
  64. };
  65. static char *ChangeAvailabilityStatusEnumTypeStr[] = {
  66. MACROSTR(Accepted),
  67. MACROSTR(Rejected),
  68. MACROSTR(Scheduled)
  69. };
  70. #if 0
  71. static char *ChargingLimitSourceEnumTypeStr[] = {
  72. MACROSTR(EMS),
  73. MACROSTR(Other),
  74. MACROSTR(SO),
  75. MACROSTR(CSO)
  76. };
  77. #endif
  78. static char *ChargingProfileKindEnumTypeStr[] = {
  79. MACROSTR(Absolute),
  80. MACROSTR(Recurring),
  81. MACROSTR(Relative)
  82. };
  83. static char *ChargingProfilePurposeEnumTypeStr[] = {
  84. MACROSTR(ChargingStationExternalConstraints),
  85. MACROSTR(ChargingStationMaxProfile),
  86. MACROSTR(TxDefaultProfile),
  87. MACROSTR(TxProfile)
  88. };
  89. static char *ChargingProfileStatusEnumTypeStr[] = {
  90. MACROSTR(Accepted),
  91. MACROSTR(Rejected)
  92. };
  93. static char *ChargingRateUnitEnumTypeStr[] = {
  94. MACROSTR(W),
  95. MACROSTR(A)
  96. };
  97. static char *ChargingStateEnumTypeStr[] = {
  98. MACROSTR(Charging),
  99. MACROSTR(EVConnected),
  100. MACROSTR(SuspendedEV),
  101. MACROSTR(SuspendedEVSE),
  102. MACROSTR(Idle)
  103. };
  104. static char *ClearCacheStatusEnumTypeStr[] = {
  105. MACROSTR(Accepted),
  106. MACROSTR(Rejected)
  107. };
  108. static char *ClearChargingProfileStatusEnumTypeStr[] = {
  109. MACROSTR(Accepted),
  110. MACROSTR(Unknown)
  111. };
  112. static char *ClearMessageStatusEnumTypeStr[] = {
  113. MACROSTR(Accepted),
  114. MACROSTR(Unknown)
  115. };
  116. static char *ClearMonitoringStatusEnumTypeStr[] = {
  117. MACROSTR(Accepted),
  118. MACROSTR(Rejected),
  119. MACROSTR(NotFound)
  120. };
  121. static char *ComponentCriterionEnumTypeStr[] = {
  122. MACROSTR(Active),
  123. MACROSTR(Available),
  124. MACROSTR(Enabled),
  125. MACROSTR(Problem)
  126. };
  127. #if 0
  128. static char *ConnectorEnumTypeStr[] = {
  129. MACROSTR(cCCS1),
  130. MACROSTR(cCCS2),
  131. MACROSTR(cG105),
  132. MACROSTR(cTesla),
  133. MACROSTR(cType1),
  134. MACROSTR(cType2),
  135. MACROSTR(s309-1P-16A),
  136. MACROSTR(s309-1P-32A),
  137. MACROSTR(s309-3P-16A),
  138. MACROSTR(s309-3P-32A),
  139. MACROSTR(sBS1361),
  140. MACROSTR(sCEE-7-7),
  141. MACROSTR(sType2),
  142. MACROSTR(sType3),
  143. MACROSTR(Other1PhMax16A),
  144. MACROSTR(Other1PhOver16A),
  145. MACROSTR(Other3Ph),
  146. MACROSTR(Pan),
  147. MACROSTR(wInductive),
  148. MACROSTR(wResonant),
  149. MACROSTR(Undetermined),
  150. MACROSTR(Unknown)
  151. };
  152. #endif
  153. static char *ConnectorStatusEnumTypeStr[] = {
  154. MACROSTR(Available),
  155. MACROSTR(Occupied),
  156. MACROSTR(Reserved),
  157. MACROSTR(Unavailable),
  158. MACROSTR(Faulted)
  159. };
  160. #if 0
  161. static char *CostKindEnumTypeStr[] = {
  162. MACROSTR(CarbonDioxideEmission),
  163. MACROSTR(RelativePricePercentage),
  164. MACROSTR(RenewableGenerationPercentage)
  165. };
  166. #endif
  167. static char *CustomerInformationStatusEnumTypeStr[] = {
  168. MACROSTR(Accepted),
  169. MACROSTR(Rejected),
  170. MACROSTR(Invalid)
  171. };
  172. static char *DataEnumTypeStr[] = {
  173. MACROSTR(string),
  174. MACROSTR(decimal),
  175. MACROSTR(integer),
  176. MACROSTR(dateTime),
  177. MACROSTR(boolean),
  178. MACROSTR(OptionList),
  179. MACROSTR(SequenceList),
  180. MACROSTR(MemberList)
  181. };
  182. static char *DataTransferStatusEnumTypeStr[] = {
  183. MACROSTR(Accepted),
  184. MACROSTR(Rejected),
  185. MACROSTR(UnknownMessageId),
  186. MACROSTR(UnknownVendorId)
  187. };
  188. static char *DeleteCertificateStatusEnumTypeStr[] = {
  189. MACROSTR(Accepted),
  190. MACROSTR(Failed),
  191. MACROSTR(NotFound)
  192. };
  193. static char *DisplayMessageStatusEnumTypeStr[] = {
  194. MACROSTR(Accepted),
  195. MACROSTR(NotSupportedMessageFormat),
  196. MACROSTR(Rejected),
  197. MACROSTR(NotSupportedPriority),
  198. MACROSTR(NotSupportedState),
  199. MACROSTR(UnknownTransaction)
  200. };
  201. #if 0
  202. static char *EnergyTransferModeEnumTypeStr[] = {
  203. MACROSTR(DC),
  204. MACROSTR(AC_single_phase),
  205. MACROSTR(AC_two_phase),
  206. MACROSTR(AC_three_phase)
  207. };
  208. #endif
  209. static char *EventNotificationEnumTypeStr[] = {
  210. MACROSTR(HardWiredNotification),
  211. MACROSTR(HardWiredMonitor),
  212. MACROSTR(PreconfiguredMonitor),
  213. MACROSTR(CustomMonitor)
  214. };
  215. static char *EventTriggerEnumTypeStr[] = {
  216. MACROSTR(Alerting),
  217. MACROSTR(Delta),
  218. MACROSTR(Periodic)
  219. };
  220. static char *FirmwareStatusEnumTypeStr[] = {
  221. MACROSTR(Downloaded),
  222. MACROSTR(DownloadFailed),
  223. MACROSTR(Downloading),
  224. MACROSTR(DownloadScheduled),
  225. MACROSTR(DownloadPaused),
  226. MACROSTR(Idle),
  227. MACROSTR(InstallationFailed),
  228. MACROSTR(Installing),
  229. MACROSTR(Installed),
  230. MACROSTR(InstallRebooting),
  231. MACROSTR(InstallScheduled),
  232. MACROSTR(InstallVerificationFailed),
  233. MACROSTR(InvalidSignature),
  234. MACROSTR(SignatureVerified)
  235. };
  236. static char *GenericDeviceModelStatusEnumTypeStr[] = {
  237. MACROSTR(Accepted),
  238. MACROSTR(Rejected),
  239. MACROSTR(NotSupported),
  240. MACROSTR(EmptyResultSet)
  241. };
  242. static char *GenericStatusEnumTypeStr[] = {
  243. MACROSTR(Accepted),
  244. MACROSTR(Rejected)
  245. };
  246. static char *GetCertificateIdUseEnumTypeStr[] = {
  247. MACROSTR(V2GRootCertificate),
  248. MACROSTR(MORootCertificate),
  249. MACROSTR(CSMSRootCertificate),
  250. MACROSTR(V2GCertificateChain),
  251. MACROSTR(ManufacturerRootCertificate)
  252. };
  253. static char *GetCertificateStatusEnumTypeStr[] = {
  254. MACROSTR(Accepted),
  255. MACROSTR(Failed)
  256. };
  257. static char *GetChargingProfileStatusEnumTypeStr[] = {
  258. MACROSTR(Accepted),
  259. MACROSTR(NoProfiles)
  260. };
  261. static char *GetDisplayMessagesStatusEnumTypeStr[] = {
  262. MACROSTR(Accepted),
  263. MACROSTR(Unknown)
  264. };
  265. static char *GetInstalledCertificateStatusEnumTypeStr[] = {
  266. MACROSTR(Accepted),
  267. MACROSTR(NotFound)
  268. };
  269. static char *GetVariableStatusEnumTypeStr[] = {
  270. MACROSTR(Accepted),
  271. MACROSTR(Rejected),
  272. MACROSTR(UnknownComponent),
  273. MACROSTR(UnknownVariable),
  274. MACROSTR(NotSupportedAttributeType)
  275. };
  276. static char *HashAlgorithmEnumTypeStr[] = {
  277. MACROSTR(SHA256),
  278. MACROSTR(SHA384),
  279. MACROSTR(SHA512)
  280. };
  281. static char *IdTokenEnumTypeStr[] = {
  282. MACROSTR(Central),
  283. MACROSTR(eMAID),
  284. MACROSTR(ISO14443),
  285. MACROSTR(KeyCode),
  286. MACROSTR(Local),
  287. MACROSTR(NoAuthorization),
  288. MACROSTR(ISO15693)
  289. };
  290. static char *InstallCertificateUseEnumTypeStr[] = {
  291. MACROSTR(V2GRootCertificate),
  292. MACROSTR(MORootCertificate),
  293. MACROSTR(CSMSRootCertificate),
  294. MACROSTR(ManufacturerRootCertificate)
  295. };
  296. static char *InstallCertificateStatusEnumTypeStr[]={
  297. MACROSTR(Accepted),
  298. MACROSTR(Failed),
  299. MACROSTR(Rejected)
  300. };
  301. static char *Iso15118EVCertificateStatusEnumTypeStr[] = {
  302. MACROSTR(Accepted),
  303. MACROSTR(Failed)
  304. };
  305. static char *LocationEnumTypeStr[] = {
  306. MACROSTR(Body),
  307. MACROSTR(Cable),
  308. MACROSTR(EV),
  309. MACROSTR(Inlet),
  310. MACROSTR(Outlet)
  311. };
  312. static char *LogEnumTypeStr[] = {
  313. MACROSTR(DiagnosticsLog),
  314. MACROSTR(SecurityLog)
  315. };
  316. static char *LogStatusEnumTypeStr[] = {
  317. MACROSTR(Accepted),
  318. MACROSTR(Rejected),
  319. MACROSTR(AcceptedCanceled)
  320. };
  321. static char *MeasurandEnumTypeStr[] = {
  322. MACROSTR(Current.Export),
  323. MACROSTR(Current.Import),
  324. MACROSTR(Current.Offered),
  325. MACROSTR(Energy.Active.Export.Register),
  326. MACROSTR(Energy.Active.Import.Register),
  327. MACROSTR(Energy.Reactive.Export.Register),
  328. MACROSTR(Energy.Reactive.Import.Register),
  329. MACROSTR(Energy.Active.Export.Interval),
  330. MACROSTR(Energy.Active.Import.Interval),
  331. MACROSTR(Energy.Active.Net),
  332. MACROSTR(Energy.Reactive.Export.Interval),
  333. MACROSTR(Energy.Reactive.Import.Interval),
  334. MACROSTR(Energy.Reactive.Net),
  335. MACROSTR(Energy.Apparent.Net),
  336. MACROSTR(Energy.Apparent.Import),
  337. MACROSTR(Energy.Apparent.Export),
  338. MACROSTR(Frequency),
  339. MACROSTR(Power.Active.Export),
  340. MACROSTR(Power.Active.Import),
  341. MACROSTR(Power.Factor),
  342. MACROSTR(Power.Offered),
  343. MACROSTR(Power.Reactive.Export),
  344. MACROSTR(Power.Reactive.Import),
  345. MACROSTR(SoC),
  346. MACROSTR(Voltage)
  347. };
  348. static char *MessageFormatEnumTypeStr[] = {
  349. MACROSTR(ASCII),
  350. MACROSTR(HTML),
  351. MACROSTR(URI),
  352. MACROSTR(UTF8)
  353. };
  354. static char *MessagePriorityEnumTypeStr[] = {
  355. MACROSTR(AlwaysFront),
  356. MACROSTR(InFront),
  357. MACROSTR(NormalCycle)
  358. };
  359. static char *MessageStateEnumTypeStr[] = {
  360. MACROSTR(Charging),
  361. MACROSTR(Faulted),
  362. MACROSTR(Idle),
  363. MACROSTR(Unavailable)
  364. };
  365. static char *MessageTriggerEnumTypeStr[] = {
  366. MACROSTR(BootNotification),
  367. MACROSTR(LogStatusNotification),
  368. MACROSTR(FirmwareStatusNotification),
  369. MACROSTR(Heartbeat),
  370. MACROSTR(MeterValues),
  371. MACROSTR(SignChargingStationCertificate),
  372. MACROSTR(SignV2GCertificate),
  373. MACROSTR(StatusNotification),
  374. MACROSTR(TransactionEvent),
  375. MACROSTR(SignCombinedCertificate),
  376. MACROSTR(PublishFirmwareStatusNotification)
  377. };
  378. static char *MonitorEnumTypeStr[] = {
  379. MACROSTR(UpperThreshold),
  380. MACROSTR(LowerThreshold),
  381. MACROSTR(Delta),
  382. MACROSTR(Periodic),
  383. MACROSTR(PeriodicClockAligned)
  384. };
  385. static char *MonitoringBaseEnumTypeStr[] = {
  386. MACROSTR(All),
  387. MACROSTR(FactoryDefault),
  388. MACROSTR(HardWiredOnly)
  389. };
  390. static char *MonitoringCriterionEnumTypeStr[] = {
  391. MACROSTR(ThresholdMonitoring),
  392. MACROSTR(DeltaMonitoring),
  393. MACROSTR(PeriodicMonitoring)
  394. };
  395. static char *MutabilityEnumTypeStr[] = {
  396. MACROSTR(ReadOnly),
  397. MACROSTR(WriteOnly),
  398. MACROSTR(ReadWrite)
  399. };
  400. static char *NotifyEVChargingNeedsStatusEnumTypeStr[] = {
  401. MACROSTR(Accepted),
  402. MACROSTR(Rejected),
  403. MACROSTR(Processing)
  404. };
  405. static char *OCPPInterfaceEnumTypeStr[] = {
  406. MACROSTR(Wired0),
  407. MACROSTR(Wired1),
  408. MACROSTR(Wired2),
  409. MACROSTR(Wired3),
  410. MACROSTR(Wireless0),
  411. MACROSTR(Wireless1),
  412. MACROSTR(Wireless2),
  413. MACROSTR(Wireless3)
  414. };
  415. static char *OCPPTransportEnumTypeStr[] = {
  416. MACROSTR(JSON),
  417. MACROSTR(SOAP)
  418. };
  419. static char *OCPPVersionEnumTypeStr[] = {
  420. MACROSTR(OCPP12),
  421. MACROSTR(OCPP15),
  422. MACROSTR(OCPP16),
  423. MACROSTR(OCPP20)
  424. };
  425. static char *OperationalStatusEnumTypeStr[] = {
  426. MACROSTR(Inoperative),
  427. MACROSTR(Operative)
  428. };
  429. static char *PhaseEnumTypeStr[] = {
  430. MACROSTR(L1),
  431. MACROSTR(L2),
  432. MACROSTR(L3),
  433. MACROSTR(N),
  434. MACROSTR(L1-N),
  435. MACROSTR(L2-N),
  436. MACROSTR(L3-N),
  437. MACROSTR(L1-L2),
  438. MACROSTR(L2-L3),
  439. MACROSTR(L3-L1)
  440. };
  441. static char *PublishFirmwareStatusEnumTypeStr[] = {
  442. MACROSTR(Downloaded),
  443. MACROSTR(DownloadFailed),
  444. MACROSTR(Downloading),
  445. MACROSTR(DownloadScheduled),
  446. MACROSTR(DownloadPaused),
  447. MACROSTR(PublishFailed),
  448. MACROSTR(Published),
  449. MACROSTR(InvalidChecksum),
  450. MACROSTR(ChecksumVerified)
  451. };
  452. static char *ReadingContextEnumTypeStr[] = {
  453. MACROSTR(Interruption.Begin),
  454. MACROSTR(Interruption.End),
  455. MACROSTR(Other),
  456. MACROSTR(Sample.Clock),
  457. MACROSTR(Sample.Periodic),
  458. MACROSTR(Transaction.Begin),
  459. MACROSTR(Transaction.End),
  460. MACROSTR(Trigger)
  461. };
  462. #if 0
  463. static char *ReasonEnumTypeStr[] = {
  464. MACROSTR(DeAuthorized),
  465. MACROSTR(EmergencyStop),
  466. MACROSTR(EnergyLimitReached),
  467. MACROSTR(EVDisconnected),
  468. MACROSTR(GroundFault),
  469. MACROSTR(ImmediateReset),
  470. MACROSTR(Local),
  471. MACROSTR(LocalOutOfCredit),
  472. MACROSTR(MasterPass),
  473. MACROSTR(Other),
  474. MACROSTR(OvercurrentFault),
  475. MACROSTR(PowerLoss),
  476. MACROSTR(PowerQuality),
  477. MACROSTR(Reboot),
  478. MACROSTR(Remote),
  479. MACROSTR(SOCLimitReached),
  480. MACROSTR(StoppedByEV),
  481. MACROSTR(TimeLimitReached),
  482. MACROSTR(TimeLimitReached)
  483. };
  484. #endif
  485. static char *RecurrencyKindEnumTypeStr[] = {
  486. MACROSTR(Daily),
  487. MACROSTR(Weekly)
  488. };
  489. static char *RegistrationStatusEnumTypeStr[] = {
  490. MACROSTR(Accepted),
  491. MACROSTR(Pending),
  492. MACROSTR(Rejected)
  493. };
  494. static char *ReportBaseEnumTypeStr[] = {
  495. MACROSTR(ConfigurationInventory),
  496. MACROSTR(FullInventory),
  497. MACROSTR(SummaryInventory)
  498. };
  499. static char *RequestStartStopStatusEnumTypeStr[] = {
  500. MACROSTR(Accepted),
  501. MACROSTR(Rejected)
  502. };
  503. static char *ReservationUpdateStatusEnumTypeStr[] = {
  504. MACROSTR(Expired),
  505. MACROSTR(Removed)
  506. };
  507. static char *ReserveNowStatusEnumTypeStr[] = {
  508. MACROSTR(Accepted),
  509. MACROSTR(Faulted),
  510. MACROSTR(Occupied),
  511. MACROSTR(Rejected),
  512. MACROSTR(Unavailable)
  513. };
  514. static char *ResetEnumTypeStr[] = {
  515. MACROSTR(Immediate),
  516. MACROSTR(OnIdle)
  517. };
  518. static char *ResetStatusEnumTypeStr[] = {
  519. MACROSTR(Accepted),
  520. MACROSTR(Rejected),
  521. MACROSTR(Scheduled)
  522. };
  523. static char *SetMonitoringStatusEnumTypeStr[] = {
  524. MACROSTR(Accepted),
  525. MACROSTR(UnknownComponent),
  526. MACROSTR(UnknownVariable),
  527. MACROSTR(UnsupportedMonitorType),
  528. MACROSTR(Rejected),
  529. MACROSTR(OutOfRange),
  530. MACROSTR(Duplicate)
  531. };
  532. static char *SetNetworkProfileStatusEnumTypeStr[] = {
  533. MACROSTR(Accepted),
  534. MACROSTR(Rejected),
  535. MACROSTR(Failed)
  536. };
  537. static char *SetVariableStatusEnumTypeStr[] = {
  538. MACROSTR(Accepted),
  539. MACROSTR(Rejected),
  540. MACROSTR(InvalidValue),
  541. MACROSTR(UnknownComponent),
  542. MACROSTR(UnknownVariable),
  543. MACROSTR(NotSupportedAttributeType),
  544. MACROSTR(OutOfRange),
  545. MACROSTR(RebootRequired)
  546. };
  547. static char *TransactionEventEnumTypeStr[] = {
  548. MACROSTR(Ended),
  549. MACROSTR(Started),
  550. MACROSTR(Updated)
  551. };
  552. static char *TriggerMessageStatusEnumTypeStr[] = {
  553. MACROSTR(Accepted),
  554. MACROSTR(Rejected),
  555. MACROSTR(NotImplemented)
  556. };
  557. static char *TriggerReasonEnumTypeStr[] = {
  558. MACROSTR(Authorized),
  559. MACROSTR(CablePluggedIn),
  560. MACROSTR(ChargingRateChanged),
  561. MACROSTR(ChargingStateChanged),
  562. MACROSTR(Deauthorized),
  563. MACROSTR(EnergyLimitReached),
  564. MACROSTR(EVCommunicationLost),
  565. MACROSTR(EVConnectTimeout),
  566. MACROSTR(MeterValueClock),
  567. MACROSTR(MeterValuePeriodic),
  568. MACROSTR(TimeLimitReached),
  569. MACROSTR(Trigger),
  570. MACROSTR(UnlockCommand),
  571. MACROSTR(StopAuthorized),
  572. MACROSTR(EVDeparted),
  573. MACROSTR(EVDetected),
  574. MACROSTR(RemoteStop),
  575. MACROSTR(RemoteStart),
  576. MACROSTR(AbnormalCondition),
  577. MACROSTR(SignedDataReceived),
  578. MACROSTR(ResetCommand)
  579. };
  580. static char *UnlockStatusEnumTypeStr[] = {
  581. MACROSTR(Unlocked),
  582. MACROSTR(UnlockFailed),
  583. MACROSTR(OngoingAuthorizedTransaction),
  584. MACROSTR(UnknownConnector)
  585. };
  586. static char *UnpublishFirmwareStatusEnumTypeStr[] = {
  587. MACROSTR(DownloadOngoing),
  588. MACROSTR(NoFirmware),
  589. MACROSTR(Unpublished)
  590. };
  591. static char *UpdateEnumTypeStr[] = {
  592. MACROSTR(Differential),
  593. MACROSTR(Full)
  594. };
  595. static char *UpdateFirmwareStatusEnumTypeStr[] = {
  596. MACROSTR(Accepted),
  597. MACROSTR(Rejected),
  598. MACROSTR(AcceptedCanceled),
  599. MACROSTR(InvalidCertificate),
  600. MACROSTR(RevokedCertificate)
  601. };
  602. static char *UpdateStatusEnumTypeStr[] = {
  603. MACROSTR(Accepted),
  604. MACROSTR(Failed),
  605. MACROSTR(VersionMismatch)
  606. };
  607. static char *UploadLogStatusEnumTypeStr[] = {
  608. MACROSTR(BadMessage),
  609. MACROSTR(Idle),
  610. MACROSTR(NotSupportedOperation),
  611. MACROSTR(PermissionDenied),
  612. MACROSTR(Uploaded),
  613. MACROSTR(UploadFailure),
  614. MACROSTR(Uploading)
  615. };
  616. static char *VPNEnumTypeStr[] = {
  617. MACROSTR(IKEv2),
  618. MACROSTR(IPSec),
  619. MACROSTR(L2TP),
  620. MACROSTR(PPTP)
  621. };
  622. #if 0
  623. static char *ChargePointErrorCodeEnumTypeStr[] = {
  624. MACROSTR(ConnectorLockFailure),
  625. MACROSTR(EVCommunicationError),
  626. MACROSTR(GroundFailure),
  627. MACROSTR(HighTemperature),
  628. MACROSTR(InternalError),
  629. MACROSTR(LocalListConflict),
  630. MACROSTR(NoError),
  631. MACROSTR(OtherError),
  632. MACROSTR(OverCurrentFailure),
  633. MACROSTR(OverVoltage),
  634. MACROSTR(PowerMeterFailure),
  635. MACROSTR(PowerSwitchFailure),
  636. MACROSTR(ReaderFailure),
  637. MACROSTR(ResetFailure),
  638. MACROSTR(UnderVoltage),
  639. MACROSTR(WeakSignal)
  640. };
  641. #endif
  642. static char *GetCompositeScheduleStatusEnumTypeStr[] = {
  643. MACROSTR(Accepted),
  644. MACROSTR(Rejected)
  645. };
  646. static char *RemoteStartStopStatusEnumTypeStr[] = {
  647. MACROSTR(Accepted),
  648. MACROSTR(Rejected)
  649. };
  650. #if 0
  651. static char * StopTransactionReasonEnumTypeStr[] = {
  652. MACROSTR(EmergencyStop),
  653. MACROSTR(EVDisconnected),
  654. MACROSTR(HardReset),
  655. MACROSTR(Local),
  656. MACROSTR(Other),
  657. MACROSTR(PowerLoss),
  658. MACROSTR(Reboot),
  659. MACROSTR(Remote),
  660. MACROSTR(SoftReset),
  661. MACROSTR(UnlockCommand),
  662. MACROSTR(DeAuthorized)
  663. };
  664. #endif
  665. //ChargePointMaxProfile
  666. #define ChargePointMaxProfile_JSON "/Storage/OCPP/ChargePointMaxProfile_OCPP20.json"
  667. //TxDefaultProfile
  668. #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0_OCPP20.json"
  669. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  670. struct StatusCodeData *ShmStatusCodeData;
  671. struct PsuData *ShmPsuData ;
  672. struct OCPP20Data *ShmOCPP20Data;
  673. pthread_mutex_t lock_send = PTHREAD_MUTEX_INITIALIZER;
  674. char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
  675. //===============================
  676. // Gun Total Numbers
  677. //===============================
  678. static int gunTotalNumber = 0;
  679. static uint8_t gunType[4] = {0};
  680. //===============================
  681. // Local List Version
  682. //===============================
  683. static int localversion=0;
  684. //===============================
  685. // OCPP sign variable
  686. //===============================
  687. static int server_sign = FALSE;
  688. int server_pending = FALSE;
  689. static int BootNotificationInterval = 10;
  690. static int SystemInitial = 0;//= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; // System Boot UP
  691. //===============================
  692. // OCPP auth variable
  693. //===============================
  694. static int authorizeRetryTimes = 0; //number of Retry times
  695. //===============================
  696. // OCPP other variables
  697. //===============================
  698. static int HeartBeatWaitTime = 10;
  699. static int FirstHeartBeat = 0;
  700. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  701. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  702. static char CurrentChargingProfileScheduleStr[30] = {0};
  703. //========================================
  704. // OCPP status/previous related variables
  705. //========================================
  706. static int GunStatusInterval = 10;
  707. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  708. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  709. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  710. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  711. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  712. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  713. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  714. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  715. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  716. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  717. static int TransactionMessageAttemptsValue = 0;
  718. static int TransactionMessageRetryIntervalValue = 0;
  719. static int TempMeterValueInterval = 0;
  720. static struct AuthorizationData idTagQuery;
  721. //=============================================
  722. // OCPP HeartBeat Response Not Receive Counts
  723. //============================================
  724. static int HeartBeatWithNOResponse = 0;
  725. static int HeartBeatCountPerHour = 0;
  726. sqlite3 *db;
  727. int TransactionMessageAttemptsGet(void);
  728. int TransactionMessageRetryIntervalGet(void);
  729. int GetOcppConnStatus(void);
  730. void SetOcppConnStatus(uint8_t status);
  731. int setKeyValue(char *key, char *value);
  732. void OCPP_get_TableAuthlocalAllData(void);
  733. void processUnkownKey(void);
  734. struct StructOCPPMeterValue
  735. {
  736. unsigned char TimeStamp[28];
  737. struct StructSampledValue SampledValue[10];
  738. };
  739. struct ClientTime
  740. {
  741. unsigned int Heartbeat;
  742. unsigned int StatusNotification[CONNECTOR_QUANTITY];
  743. unsigned int StartTransaction;
  744. unsigned int StopTransaction;
  745. unsigned int MeterValues[CONNECTOR_QUANTITY];
  746. }clientTime;
  747. typedef union
  748. {
  749. //Operations Initiated by Central System
  750. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  751. struct
  752. {
  753. //CsMsgValue[0]
  754. unsigned char StatusNotificationReq:1; //bit 0,
  755. unsigned char StatusNotificationConf:1; //bit 1,
  756. unsigned char TriggerMeterValueReq:1; //bit 2,
  757. unsigned char TransactionEventReq:1; //bit 3,
  758. unsigned char SampleMeterReq:1; //bit 4,
  759. unsigned char ClockAlignMeterReq:1; //bit 5,
  760. unsigned char :2;
  761. }bits[CONNECTOR_QUANTITY];
  762. }CpinitiateMsg;
  763. CpinitiateMsg cpinitateMsg;
  764. //=========================================
  765. // Date time related function
  766. //=========================================
  767. void getNowDatetime(uint8_t *data)
  768. {
  769. time_t t = time(NULL);
  770. struct tm tm = *localtime(&t);
  771. 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);
  772. }
  773. //=========================================
  774. // Sqlite3 related function
  775. //=========================================
  776. int DB_Initial()
  777. {
  778. int result = PASS;
  779. char* errMsg = NULL;
  780. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  781. "idToken text UNIQUE,"
  782. "type text,"
  783. "status text,"
  784. "cacheExpiryDateTime text,"
  785. "chargingPriority integer,"
  786. "language1 text,"
  787. "evseId text,"
  788. "language2 text,"
  789. "groupIdToken_idToken text,"
  790. "groupIdToken_type text,"
  791. "personalMessage text);";
  792. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  793. "idToken text UNIQUE,"
  794. "type text,"
  795. "status text,"
  796. "cacheExpiryDateTime text,"
  797. "chargingPriority integer,"
  798. "language1 text,"
  799. "evseId text,"
  800. "language2 text,"
  801. "groupIdToken_idToken text,"
  802. "groupIdToken_type text,"
  803. "personalMessage text,"
  804. "version text);";
  805. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  806. "componentName text NOT NULL ,"
  807. "componentInstance text, "
  808. "variableName text NOT NULL, "
  809. "variableInstance text, "
  810. "variableCharacteristicsDataType integer, "
  811. "variableCharacteristicsUnit text, "
  812. "variableCharacteristicsMaxLimit real,"
  813. "variableAttributesType text, "
  814. "variableAttributesTypeMutability text, "
  815. "variableAttributesTypeValue text, "
  816. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  817. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  818. "type text);";
  819. char *sqlNetworkProfile = "create table if not exists ocpp20_networkprofile (idx integer primary key,"
  820. "slot integer UNIQUE, connectionData text);";
  821. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  822. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  823. {
  824. result = FAIL;
  825. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  826. sqlite3_close(db);
  827. }
  828. else
  829. {
  830. DEBUG_INFO( "OCPP local database open successfully.\n");
  831. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  832. {
  833. result = FAIL;
  834. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  835. }
  836. else
  837. {
  838. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  839. }
  840. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  841. {
  842. result = FAIL;
  843. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  844. }
  845. else
  846. {
  847. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  848. }
  849. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  850. {
  851. result = FAIL;
  852. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  853. }
  854. else
  855. {
  856. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  857. }
  858. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  859. {
  860. result = FAIL;
  861. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  862. }
  863. else
  864. {
  865. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  866. }
  867. if (sqlite3_exec(db, sqlNetworkProfile, 0, 0, &errMsg) != SQLITE_OK)
  868. {
  869. result = FAIL;
  870. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_networkprofile table error message: %s\n", errMsg);
  871. }
  872. else
  873. {
  874. DEBUG_INFO( "Create OCPP 2.0 ocpp20_networkprofile table successfully\n");
  875. }
  876. //sqlite3_close(db);
  877. }
  878. return result;
  879. }
  880. int DB_cbGetVersion(void *para, int columnCount, char **columnValue, char **columnName)
  881. {
  882. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  883. return 0;
  884. }
  885. void DB_getListVerion()
  886. {
  887. char sql[256];
  888. char* errMsg = NULL;
  889. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  890. /* Execute SQL statement */
  891. if( sqlite3_exec(db, sql, DB_cbGetVersion, 0, &errMsg) != SQLITE_OK )
  892. {
  893. DEBUG_INFO("SQL error: %s", errMsg);
  894. }
  895. }
  896. int DB_cbGetIdTag(void *para, int columnCount, char **columnValue, char **columnName)
  897. {
  898. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  899. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  900. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  901. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  902. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  903. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  904. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  905. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  906. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  907. return 0;
  908. }
  909. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  910. {
  911. char sql[256];
  912. char* errMsg = NULL;
  913. memset(&idTagQuery, 0, sizeof(idTagQuery));
  914. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  915. if(isQueryFromCache)
  916. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  917. else
  918. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  919. /* Execute SQL statement */
  920. if(sqlite3_exec(db, sql, DB_cbGetIdTag, 0, &errMsg) != SQLITE_OK )
  921. {
  922. DEBUG_INFO("SQL error: %s", errMsg);
  923. }
  924. }
  925. int DB_cbTableAuthlocalAllData(void *para, int columnCount, char **columnValue, char **columnName)
  926. {
  927. for (int i = 0; i < columnCount; i++)
  928. {
  929. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  930. }
  931. return 0;
  932. }
  933. void DB_get_TableAuthlocalAllData(void)
  934. {
  935. char sql[256];
  936. char* errMsg = NULL;
  937. sprintf(sql,"select * from ocpp20_auth_local;");
  938. /* Execute SQL statement */
  939. if(sqlite3_exec(db, sql, DB_cbTableAuthlocalAllData, 0,&errMsg) != SQLITE_OK)
  940. {
  941. DEBUG_INFO("SQL error: %s", errMsg);
  942. }
  943. }
  944. int DB_cbAddLocalListCache(void *para, int columnCount, char **columnValue, char **columnName)
  945. {
  946. for(int i = 0; i<columnCount; i++)
  947. {
  948. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  949. }
  950. return 0;
  951. }
  952. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  953. {
  954. int result = PASS;
  955. char sql[512];
  956. char* errMsg = NULL;
  957. 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;",
  958. data->idToken.idToken,
  959. data->idToken.type,
  960. data->idTokenInfo.status,
  961. data->idTokenInfo.cacheExpiryDateTime,
  962. data->idTokenInfo.chargingPriority,
  963. data->idTokenInfo.language1,
  964. data->idTokenInfo.language2,
  965. data->idTokenInfo.groupIdToken.idToken,
  966. data->idTokenInfo.groupIdToken.type,
  967. listVersion);
  968. //* Execute SQL statement */
  969. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  970. {
  971. DEBUG_INFO("SQL error: %s\n", errMsg);
  972. result = FAIL;
  973. }
  974. else
  975. {
  976. memset(sql, 0, ARRAY_SIZE(sql));
  977. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  978. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  979. {
  980. DEBUG_INFO("SQL error: %s\n", errMsg);
  981. result = FAIL;
  982. }
  983. }
  984. return result;
  985. }
  986. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  987. {
  988. int result = PASS;
  989. char sql[512];
  990. char* errMsg = NULL;
  991. 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;",
  992. idToken->idToken,
  993. idToken->type,
  994. idTokenInfo->status,
  995. idTokenInfo->cacheExpiryDateTime,
  996. idTokenInfo->chargingPriority,
  997. idTokenInfo->language1,
  998. idTokenInfo->language2,
  999. idTokenInfo->groupIdToken.idToken,
  1000. idTokenInfo->groupIdToken.type);
  1001. //* Execute SQL statement */
  1002. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  1003. {
  1004. DEBUG_INFO("SQL error: %s\n", errMsg);
  1005. result = FAIL;
  1006. }
  1007. return result;
  1008. }
  1009. int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  1010. {
  1011. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  1012. // printf("localversion=%d\n", localversion);
  1013. return 0;
  1014. }
  1015. void DB_deleteIdTag(char idTag[])
  1016. {
  1017. char sql[512];
  1018. char* errMsg = NULL;
  1019. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1020. //* Execute SQL statement */
  1021. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1022. {
  1023. DEBUG_INFO("SQL error: %s", errMsg);
  1024. }
  1025. }
  1026. int DB_cleanLocalList()
  1027. {
  1028. int result = PASS;
  1029. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1030. char *errMsg = 0;
  1031. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1032. {
  1033. DEBUG_INFO("%s\n", errMsg);
  1034. result = FAIL;
  1035. }
  1036. return result;
  1037. }
  1038. int DB_cleanLocalCache()
  1039. {
  1040. int result = PASS;
  1041. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1042. char *errMsg = 0;
  1043. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1044. {
  1045. DEBUG_INFO("%s\n", errMsg);
  1046. result = FAIL;
  1047. }
  1048. return result;
  1049. }
  1050. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1051. {
  1052. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1053. return 0;
  1054. }
  1055. void DB_getBooType()
  1056. {
  1057. char sql[256];
  1058. char* errMsg = NULL;
  1059. sprintf(sql,"select * from ocpp20_boot_type;");
  1060. /* Execute SQL statement */
  1061. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1062. {
  1063. DEBUG_INFO("SQL error: %s\n", errMsg);
  1064. }
  1065. }
  1066. int DB_cbUpdateBootType(void *para, int columnCount, char **columnValue, char **columnName)
  1067. {
  1068. for(int i = 0; i<columnCount; i++)
  1069. {
  1070. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1071. }
  1072. return 0;
  1073. }
  1074. int DB_updateBootType(BootReasonEnumType reason)
  1075. {
  1076. int result = PASS;
  1077. char sql[512];
  1078. char* errMsg = NULL;
  1079. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1080. //* Execute SQL statement */
  1081. if(sqlite3_exec(db, sql, DB_cbUpdateBootType, 0, &errMsg) != SQLITE_OK)
  1082. {
  1083. DEBUG_INFO("SQL error: %s\n", errMsg);
  1084. result = FAIL;
  1085. }
  1086. return result;
  1087. }
  1088. int DB_cbVariableSaveToDb(void *para, int columnCount, char **columnValue, char **columnName)
  1089. {
  1090. for(int i = 0; i<columnCount; i++)
  1091. {
  1092. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1093. }
  1094. return 0;
  1095. }
  1096. int DB_variableSaveToDb(struct ReportDataType *variable)
  1097. {
  1098. int result = FAIL;
  1099. char sql[4096];
  1100. char* errMsg = NULL;
  1101. 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;",
  1102. variable->component.name,
  1103. variable->component.instance,
  1104. variable->variable.name,
  1105. variable->variable.instance,
  1106. variable->variableCharacteristics.dataType,
  1107. variable->variableCharacteristics.unit,
  1108. variable->variableCharacteristics.maxLimit,
  1109. variable->variableAttribute[0].type,
  1110. variable->variableAttribute[0].mutability,
  1111. variable->variableAttribute[0].value);
  1112. //* Execute SQL statement */
  1113. if(sqlite3_exec(db, sql, DB_cbVariableSaveToDb, 0, &errMsg) != SQLITE_OK)
  1114. {
  1115. DEBUG_INFO("SQL error: %s\n", errMsg);
  1116. result = FAIL;
  1117. }
  1118. return result;
  1119. }
  1120. int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1121. {
  1122. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1123. if(atoi(columnValue[0]) == 0)
  1124. {
  1125. DB_updateBootType(BootReasonEnumType_PowerUp);
  1126. // Create variable table content
  1127. /* AlignedDataCtrlr Required item */
  1128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1134. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1141. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1147. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1149. else
  1150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1151. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1156. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.minLimit = 10;
  1157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1160. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1167. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1174. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1180. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1182. else
  1183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1184. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1192. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1193. /* AuthCtrlrVariable Required item */
  1194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1200. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1207. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1214. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1221. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1228. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1235. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1239. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1243. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1244. /* AuthCacheCtrlr Variable Required item*/
  1245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1251. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1258. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1266. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1270. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*100);
  1271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1274. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1281. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1282. /* ClockCtrlr Variable Required item */
  1283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1288. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1289. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1296. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1304. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1311. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1318. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1326. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1333. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1340. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1341. /* ChargingStation Required item */
  1342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1348. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1355. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1362. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1363. /* Connector Required item */
  1364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1370. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1377. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1384. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1385. /* CustomizationCtrlr Required item */
  1386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1392. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1393. /* DeviceDataCtrlr Required item */
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1401. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1409. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1416. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1417. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1425. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1428. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1433. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1436. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1440. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1441. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1449. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1457. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1458. /* DisplayMessageCtrlr Required item */
  1459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1465. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1472. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "0");
  1479. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1486. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1493. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1494. /* EVSE Required item */
  1495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1498. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1501. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1508. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1515. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1522. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1523. /* LocalAuthListCtrlr Required item */
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1530. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1535. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1536. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1537. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1543. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1544. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1551. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "50");
  1552. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1559. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "2048");
  1560. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1564. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = 1024*1024;
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1567. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "5000");
  1568. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1569. /* MonitoringCtrlr Required item */
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1575. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1576. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1580. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1583. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1590. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1591. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1598. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1599. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1606. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1607. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1613. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1614. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1615. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1621. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1622. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1623. /* OCPPCommCtrlr Required item */
  1624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1630. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1635. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1639. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1643. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1645. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1646. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1651. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1653. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1654. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1655. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1657. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1658. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1659. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1660. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "[0]");
  1661. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1666. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1667. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1668. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1673. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1674. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1675. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1676. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1682. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1683. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1684. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1688. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1690. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1691. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1692. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1693. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1695. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1696. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1697. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1698. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1699. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1700. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "3");
  1701. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1702. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1704. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1705. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1706. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1707. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1708. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1710. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1712. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1713. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1714. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1715. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1716. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1717. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1719. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1720. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1721. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1722. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1723. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1724. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1725. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1727. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1728. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1729. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1730. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1731. /* ReservationCtrlr Required item */
  1732. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1734. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1735. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1737. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1738. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1739. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1741. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1742. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1743. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1744. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1745. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1746. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1749. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1750. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1751. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1752. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1753. /* SampledDataCtrlr Required item */
  1754. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1757. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1758. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1759. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1760. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  1761. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1764. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1765. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1766. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1767. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  1768. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1772. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1773. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1774. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  1775. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  1776. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1779. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1780. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, " ");
  1781. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  1782. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  1783. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1784. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1787. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1788. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1789. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  1791. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  1792. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1793. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1795. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  1796. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1800. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1801. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1802. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, " ");
  1803. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  1804. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  1805. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  1807. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1808. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.minLimit = 10;
  1809. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1810. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1811. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "30");
  1812. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  1813. /* SecurityCtrlr Required item */
  1814. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  1815. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  1816. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1817. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1819. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1820. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, " ");
  1821. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  1822. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  1823. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  1824. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1825. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1828. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "Phihong Technology");
  1829. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  1831. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1833. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1835. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "Phihong");
  1836. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  1839. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1842. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  1843. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  1844. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  1845. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1847. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1848. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1849. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "0");
  1850. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  1851. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1854. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1855. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  1857. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  1858. /* SmartChargingCtrlr Required item */
  1859. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1862. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1864. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1865. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  1866. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1869. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1870. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1871. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  1872. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  1873. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  1874. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1876. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1877. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1878. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  1879. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  1880. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  1882. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1884. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1885. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "0");
  1886. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  1887. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  1888. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1891. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1892. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  1893. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  1894. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  1895. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1897. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1898. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1899. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  1900. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  1901. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  1902. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  1903. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1904. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1906. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  1907. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  1908. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  1909. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1911. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1912. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1913. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  1914. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  1916. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1918. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1919. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1920. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  1921. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  1922. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  1923. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1925. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1926. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1927. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "3");
  1928. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  1929. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1933. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1934. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  1935. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  1936. /* TariffCostCtrlr Required item */
  1937. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  1940. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1941. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1942. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1943. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  1944. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  1945. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  1946. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  1947. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  1948. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1949. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1950. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1951. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  1952. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  1954. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  1955. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1956. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  1957. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1958. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1959. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  1960. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  1961. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  1962. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  1963. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  1964. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1965. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1966. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1967. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  1968. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  1969. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  1970. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  1971. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  1972. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1973. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1974. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1975. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  1976. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  1977. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  1978. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  1979. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1980. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  1981. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1982. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1983. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  1984. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  1985. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  1986. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  1987. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1988. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1990. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1991. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  1992. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  1993. /* TxCtrlr Required item */
  1994. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  1995. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  1996. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1997. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1998. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1999. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2000. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  2001. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2002. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2003. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2005. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2007. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  2008. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  2009. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2010. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2012. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2014. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  2015. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  2016. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2017. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2018. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2019. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2020. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2021. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2022. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  2023. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2024. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2026. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2027. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2028. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "PowerPathClosed");
  2029. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  2030. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2031. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2032. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2034. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2035. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "PowerPathClosed");
  2036. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2037. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2038. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2039. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2040. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2041. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2042. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2043. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "60000");
  2044. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2045. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2046. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2047. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2048. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2049. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2050. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2051. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2052. }
  2053. else
  2054. {
  2055. // Variable name init
  2056. /* AlignedDataCtrlr Required item */
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2059. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2062. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2063. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2064. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2065. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2066. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2067. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2068. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2069. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2070. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2071. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2073. /* AuthCtrlrVariable Required item */
  2074. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2076. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2077. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2078. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2080. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2081. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2082. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2083. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2085. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2086. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2087. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2088. /* AuthCacheCtrlr Variable Required item */
  2089. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2090. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2091. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2092. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2095. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2099. /* ClockCtrlr Variable Required item */
  2100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2110. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2117. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2118. /* ChargingStation Required item */
  2119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2125. /* Connector Required item */
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2132. /* CustomizationCtrlr Required item */
  2133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  2135. /* DeviceDataCtrlr Required item */
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2158. /* DisplayMessageCtrlr Required item */
  2159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2169. /* EVSE Required item */
  2170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2178. /* LocalAuthListCtrlr Required item */
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2193. /* MonitoringCtrlr Required item */
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2212. /* OCPPCommCtrlr Required item */
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2244. /* ReservationCtrlr Required item */
  2245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2251. /* SampledDataCtrlr Required item */
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2268. /* SecurityCtrlr Required item */
  2269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2281. /* SmartChargingCtrlr Required item */
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2304. /* TariffCostCtrlr Required item */
  2305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2323. /* TxCtrlr Required item */
  2324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2340. }
  2341. return 0;
  2342. }
  2343. void DB_variableIsCreate()
  2344. {
  2345. char sql[512];
  2346. char* errMsg = NULL;
  2347. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2348. /* Execute SQL statement */
  2349. if(sqlite3_exec(db, sql, DB_cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2350. {
  2351. DEBUG_INFO("SQL error: %s\n", errMsg);
  2352. }
  2353. }
  2354. int DB_cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2355. {
  2356. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2357. {
  2358. if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) == 0) &&
  2359. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) == 0) &&
  2360. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) == 0) &&
  2361. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) == 0))
  2362. {
  2363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2365. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2369. }
  2370. }
  2371. return 0;
  2372. }
  2373. void DB_variableLoadFromDb()
  2374. {
  2375. char sql[512];
  2376. char* errMsg = NULL;
  2377. sprintf(sql,"select * from ocpp20_variable order by idx;");
  2378. /* Execute SQL statement */
  2379. if(sqlite3_exec(db, sql, DB_cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2380. {
  2381. DEBUG_INFO("SQL error: %s\n", errMsg);
  2382. }
  2383. }
  2384. int DB_cbGetNetworkProfileFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2385. {
  2386. memset(&ShmOCPP20Data->NetworkConnectionProfile[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile));
  2387. if(columnCount > 0)
  2388. {
  2389. for(int idx=0;idx<columnCount;idx++)
  2390. {
  2391. json_object *SetNetworkProfile;
  2392. SetNetworkProfile = json_tokener_parse(columnValue[2]);
  2393. if(!is_error(SetNetworkProfile))
  2394. {
  2395. // Required data
  2396. if(json_object_object_get(SetNetworkProfile, "ocppVersion") != NULL)
  2397. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppVersion")));
  2398. if(json_object_object_get(SetNetworkProfile, "ocppTransport") != NULL)
  2399. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppTransport")));
  2400. if(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl") != NULL)
  2401. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl")));
  2402. if(json_object_object_get(SetNetworkProfile, "messageTimeout") != NULL)
  2403. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.messageTimeout = json_object_get_int(json_object_object_get(SetNetworkProfile, "messageTimeout"));
  2404. if(json_object_object_get(SetNetworkProfile, "ocppInterface") != NULL)
  2405. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppInterface")));
  2406. if(json_object_object_get(SetNetworkProfile, "vpn") != NULL)
  2407. {
  2408. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server") != NULL)
  2409. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server")));
  2410. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user") != NULL)
  2411. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user")));
  2412. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group") != NULL)
  2413. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group")));
  2414. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password") != NULL)
  2415. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password")));
  2416. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key") != NULL)
  2417. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key")));
  2418. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type") != NULL)
  2419. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type")));
  2420. }
  2421. if(json_object_object_get(SetNetworkProfile, "apn") != NULL)
  2422. {
  2423. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn") != NULL)
  2424. {
  2425. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn));
  2426. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn")));
  2427. }
  2428. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName") != NULL)
  2429. {
  2430. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName));
  2431. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName")));
  2432. }
  2433. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword") != NULL)
  2434. {
  2435. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword));
  2436. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword")));
  2437. }
  2438. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin") != NULL)
  2439. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin"));
  2440. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork") != NULL)
  2441. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork")));
  2442. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork") != NULL)
  2443. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork"));
  2444. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication") != NULL)
  2445. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication")));
  2446. }
  2447. }
  2448. json_object_put(SetNetworkProfile);
  2449. ShmOCPP20Data->NetworkConnectionProfile[idx].slot = atoi(columnValue[1]);
  2450. }
  2451. }
  2452. return 0;
  2453. }
  2454. void DB_getNetworkProfileFromDb()
  2455. {
  2456. char sql[512];
  2457. char* errMsg = NULL;
  2458. sprintf(sql,"select * from ocpp20_networkprofile order by slot;");
  2459. /* Execute SQL statement */
  2460. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2461. {
  2462. DEBUG_INFO("SQL error: %s\n", errMsg);
  2463. }
  2464. }
  2465. int DB_addNetworkProfile(int slot, char *data)
  2466. {
  2467. int result = PASS;
  2468. char sql[512];
  2469. char* errMsg = NULL;
  2470. sprintf(sql,"insert or replace into ocpp20_networkprofile (slot, connectionData) VALUES('%d', '%s'); SELECT * from ocpp20_networkprofile order by slot;",
  2471. slot,
  2472. data);
  2473. //* Execute SQL statement */
  2474. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK)
  2475. {
  2476. DEBUG_INFO("SQL error: %s\n", errMsg);
  2477. result = FAIL;
  2478. }
  2479. return result;
  2480. }
  2481. int DB_deleteNetworkProfile(int slot)
  2482. {
  2483. int result = PASS;
  2484. char sql[512];
  2485. char* errMsg = NULL;
  2486. sprintf(sql,"DELETE from ocpp20_networkprofile where slot=%d; SELECT * from ocpp20_networkprofile order by slot;", slot);
  2487. //* Execute SQL statement */
  2488. if( sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2489. {
  2490. DEBUG_INFO("SQL error: %s", errMsg);
  2491. result = FAIL;
  2492. }
  2493. return result;
  2494. }
  2495. //==========================================
  2496. // Check time passed since today
  2497. //==========================================
  2498. long long DiffTimebWithNow(struct timeb ST)
  2499. {
  2500. //return milli-second
  2501. struct timeb ET;
  2502. long long StartTime,StopTime;
  2503. ftime(&ET);
  2504. StartTime=(long long)ST.time;
  2505. StopTime=(long long)ET.time;
  2506. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2507. }
  2508. int getTimePassSinceToday()
  2509. {
  2510. int result = -1;
  2511. time_t t;
  2512. struct tm *tmStartToday;
  2513. struct timeb tbStartToday;
  2514. t=time(NULL);
  2515. tmStartToday=localtime(&t);
  2516. tmStartToday->tm_hour = 0;
  2517. tmStartToday->tm_min = 0;
  2518. tmStartToday->tm_sec = 0;
  2519. tbStartToday.time = mktime(tmStartToday);
  2520. tbStartToday.millitm = 0;
  2521. result = DiffTimebWithNow(tbStartToday)/1000;
  2522. return result;
  2523. }
  2524. //==========================================
  2525. // GetCompositeSchedule logic related function
  2526. //==========================================
  2527. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2528. {
  2529. //return milli-second
  2530. unsigned int StartTime,StopTime;
  2531. StartTime=(unsigned int)ST.time;
  2532. StopTime=(unsigned int)ET.time;
  2533. return (StopTime-StartTime);
  2534. }
  2535. int DiffTimebWithNowSec(struct timeb ST)
  2536. {
  2537. //return milli-second
  2538. struct timeb ET;
  2539. unsigned int StartTime,StopTime;
  2540. ftime(&ET);
  2541. StartTime=(unsigned int)ST.time;
  2542. StopTime=(unsigned int)ET.time;
  2543. return (StopTime-StartTime);
  2544. }
  2545. int getStartStop(uint8_t *start, uint8_t *stop)
  2546. {
  2547. int result = -1;
  2548. struct tm tmStart;
  2549. struct timeb tbStart;
  2550. struct tm tmStop;
  2551. struct timeb tbStop;
  2552. 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) &&
  2553. (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))
  2554. {
  2555. //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);
  2556. //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);
  2557. tmStart.tm_year -= 1900;
  2558. tmStart.tm_mon -= 1;
  2559. tbStart.time = mktime(&tmStart);
  2560. tbStart.millitm = 0;
  2561. tmStop.tm_year -= 1900;
  2562. tmStop.tm_mon -= 1;
  2563. tbStop.time = mktime(&tmStop);
  2564. tbStop.millitm = 0;
  2565. result = DiffTimebSec(tbStart, tbStop);
  2566. //DEBUG_INFO("getStartStop(): %d\n", result);
  2567. }
  2568. else
  2569. {
  2570. DEBUG_WARN("Start or stop date parsing error.\r\n");
  2571. }
  2572. return result;
  2573. }
  2574. int isOvertNow(uint8_t *start)
  2575. {
  2576. int result = YES;
  2577. struct tm tmStart;
  2578. struct timeb tbStart;
  2579. 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))
  2580. {
  2581. //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);
  2582. tmStart.tm_year -= 1900;
  2583. tmStart.tm_mon -= 1;
  2584. tbStart.time = mktime(&tmStart);
  2585. tbStart.millitm = 0;
  2586. if(DiffTimebWithNowSec(tbStart) <= 0)
  2587. result = NO;
  2588. }
  2589. else
  2590. {
  2591. DEBUG_WARN("Start date parsing error.\r\n");
  2592. }
  2593. return result;
  2594. }
  2595. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  2596. {
  2597. int result = -1;
  2598. struct tm tmStart;
  2599. struct timeb tbStart;
  2600. struct tm tmStop;
  2601. struct timeb tbStop;
  2602. 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) &&
  2603. (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))
  2604. {
  2605. tmStart.tm_year -= 1900;
  2606. tmStart.tm_mon -= 1;
  2607. tbStart.time = mktime(&tmStart);
  2608. tbStart.millitm = 0;
  2609. tmStop.tm_year -= 1900;
  2610. tmStop.tm_mon -= 1;
  2611. tbStop.time = mktime(&tmStop);
  2612. tbStop.millitm = 0;
  2613. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  2614. }
  2615. return result;
  2616. }
  2617. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *compositeProfile)
  2618. {
  2619. FILE *fp;
  2620. char profileFileName[128];
  2621. char *line = NULL;
  2622. size_t len = 0;
  2623. time_t CurrentTime;
  2624. struct tm *tmComposite;
  2625. struct ChargingProfileType maxProfile;
  2626. struct ChargingProfileType defaultTxProfile;
  2627. struct ChargingProfileType txProfile;
  2628. struct ChargingSchedulePeriodType tmpPeriod;
  2629. uint8_t limitMax=0;
  2630. uint8_t limitDef=0;
  2631. uint8_t limitTx=0;
  2632. int compositePeriodIdx = 0;
  2633. CurrentTime = time(NULL);
  2634. tmComposite=localtime(&CurrentTime);
  2635. 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);
  2636. sprintf((char*)compositeProfile->chargingSchedule[0].chargingRateUnit, "A");
  2637. compositeProfile->chargingSchedule[0].duration = durationReq;
  2638. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2639. {
  2640. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2641. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2642. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2643. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  2644. }
  2645. compositeProfile->id = 0;
  2646. compositeProfile->stackLevel = 99 ;
  2647. sprintf((char*)compositeProfile->chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  2648. maxProfile.id = -1;
  2649. defaultTxProfile.id = -1;
  2650. txProfile.id = -1;
  2651. maxProfile.chargingSchedule[0].duration = -1;
  2652. defaultTxProfile.chargingSchedule[0].duration = -1;
  2653. txProfile.chargingSchedule[0].duration = -1;
  2654. system("yes|rm /tmp/*.json");
  2655. system("cp /Storage/OCPP/*.json /tmp");
  2656. /*
  2657. * Search valid charging profile
  2658. */
  2659. //DEBUG_INFO("====================================\n");
  2660. // Search tx profile
  2661. sprintf(profileFileName, "/tmp/TxProfile_%d.json", connectorId);
  2662. if((access(profileFileName, F_OK))!=-1)
  2663. {
  2664. fp = fopen(profileFileName, "r");
  2665. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2666. {
  2667. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2668. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2669. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2670. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2671. }
  2672. txProfile.id = -1;
  2673. txProfile.stackLevel = -1;
  2674. while(getline(&line, &len, fp) != -1)
  2675. {
  2676. json_object *obj = NULL;
  2677. obj = json_tokener_parse(line);
  2678. if(is_error(obj))
  2679. {
  2680. DEBUG_ERROR("Parse txProfile from file error.\n");
  2681. }
  2682. else
  2683. {
  2684. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != txProfile.id) &&
  2685. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= txProfile.stackLevel)
  2686. )
  2687. {
  2688. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2689. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2690. )
  2691. {
  2692. struct tm tmFrom, tmTo;
  2693. struct timeb tbFrom, tbTo;
  2694. 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) &&
  2695. (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))
  2696. {
  2697. tmFrom.tm_year -= 1900;
  2698. tmFrom.tm_mon -= 1;
  2699. tbFrom.time = mktime(&tmFrom);
  2700. tmTo.tm_year -= 1900;
  2701. tmTo.tm_mon -= 1;
  2702. tbTo.time = mktime(&tmTo);
  2703. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2704. {
  2705. if(txProfile.id == -1)
  2706. DEBUG_INFO("TxProfile found.\n");
  2707. else
  2708. DEBUG_INFO("TxProfile updated.\n");
  2709. // Required item
  2710. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2711. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2712. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2713. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2714. 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++)
  2715. {
  2716. 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"));
  2717. 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")));
  2718. 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?
  2719. 3:
  2720. 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")));
  2721. }
  2722. // Optional item
  2723. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2724. {
  2725. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2726. }
  2727. else
  2728. {
  2729. sprintf((char*)txProfile.validFrom, " ");
  2730. }
  2731. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2732. {
  2733. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2734. }
  2735. else
  2736. {
  2737. sprintf((char*)txProfile.validTo, " ");
  2738. }
  2739. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2740. {
  2741. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2742. }
  2743. else
  2744. {
  2745. sprintf((char*)txProfile.recurrencyKind, " ");
  2746. }
  2747. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2748. {
  2749. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2750. }
  2751. else
  2752. {
  2753. sprintf((char*)txProfile.transactionId, " ");
  2754. }
  2755. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2756. {
  2757. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2758. }
  2759. else
  2760. {
  2761. txProfile.chargingSchedule[0].duration = 86400;
  2762. }
  2763. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2764. {
  2765. 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")));
  2766. }
  2767. else
  2768. {
  2769. 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));
  2770. }
  2771. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2772. {
  2773. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2774. }
  2775. else
  2776. {
  2777. txProfile.chargingSchedule[0].minChargingRate = -1;
  2778. }
  2779. }
  2780. }
  2781. }
  2782. else
  2783. {
  2784. if(txProfile.id == -1)
  2785. DEBUG_INFO("TxProfile found.\n");
  2786. else
  2787. DEBUG_INFO("TxProfile updated.\n");
  2788. // Required item
  2789. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2790. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2791. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2792. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2793. 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++)
  2794. {
  2795. 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"));
  2796. 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")));
  2797. 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?
  2798. 3:
  2799. 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")));
  2800. }
  2801. // Optional item
  2802. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2803. {
  2804. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2805. }
  2806. else
  2807. {
  2808. sprintf((char*)txProfile.validFrom, " ");
  2809. }
  2810. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2811. {
  2812. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2813. }
  2814. else
  2815. {
  2816. sprintf((char*)txProfile.validTo, " ");
  2817. }
  2818. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2819. {
  2820. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2821. }
  2822. else
  2823. {
  2824. sprintf((char*)txProfile.recurrencyKind, " ");
  2825. }
  2826. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2827. {
  2828. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2829. }
  2830. else
  2831. {
  2832. sprintf((char*)txProfile.transactionId, " ");
  2833. }
  2834. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2835. {
  2836. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2837. }
  2838. else
  2839. {
  2840. txProfile.chargingSchedule[0].duration = 86400;
  2841. }
  2842. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2843. {
  2844. 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")));
  2845. }
  2846. else
  2847. {
  2848. 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));
  2849. }
  2850. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2851. {
  2852. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2853. }
  2854. else
  2855. {
  2856. txProfile.chargingSchedule[0].minChargingRate = -1;
  2857. }
  2858. }
  2859. }
  2860. }
  2861. json_object_put(obj);
  2862. }
  2863. fclose(fp);
  2864. /*
  2865. if(txProfile.ChargingProfileId != -1)
  2866. {
  2867. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  2868. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  2869. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  2870. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  2871. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  2872. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  2873. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  2874. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[0].StartSchedule);
  2875. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  2876. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  2877. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  2878. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  2879. {
  2880. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  2881. {
  2882. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  2883. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  2884. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  2885. }
  2886. }
  2887. }
  2888. else
  2889. DEBUG_INFO("TxProfile not found.\n");*/
  2890. }
  2891. // Search default tx profile
  2892. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d.json", connectorId);
  2893. if((access(profileFileName, F_OK))==-1)
  2894. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  2895. if((access(profileFileName, F_OK))!=-1)
  2896. {
  2897. fp = fopen(profileFileName, "r");
  2898. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2899. {
  2900. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2901. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2902. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2903. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2904. }
  2905. defaultTxProfile.id = -1;
  2906. defaultTxProfile.stackLevel = -1;
  2907. while(getline(&line, &len, fp) != -1)
  2908. {
  2909. json_object *obj = NULL;
  2910. obj = json_tokener_parse(line);
  2911. if(is_error(obj))
  2912. {
  2913. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  2914. }
  2915. else
  2916. {
  2917. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != defaultTxProfile.id) &&
  2918. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= defaultTxProfile.stackLevel)
  2919. )
  2920. {
  2921. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2922. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2923. )
  2924. {
  2925. struct tm tmFrom, tmTo;
  2926. struct timeb tbFrom, tbTo;
  2927. 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) &&
  2928. (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))
  2929. {
  2930. tmFrom.tm_year -= 1900;
  2931. tmFrom.tm_mon -= 1;
  2932. tbFrom.time = mktime(&tmFrom);
  2933. tmTo.tm_year -= 1900;
  2934. tmTo.tm_mon -= 1;
  2935. tbTo.time = mktime(&tmTo);
  2936. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2937. {
  2938. if(defaultTxProfile.id == -1)
  2939. DEBUG_INFO("TxDefaultProfile found.\n");
  2940. else
  2941. DEBUG_INFO("TxDefaultProfile updated.\n");
  2942. // Required item
  2943. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2944. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2945. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2946. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  2947. 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++)
  2948. {
  2949. 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"));
  2950. 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")));
  2951. 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?
  2952. 3:
  2953. 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")));
  2954. }
  2955. // Optional item
  2956. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2957. {
  2958. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2959. }
  2960. else
  2961. {
  2962. sprintf((char*)defaultTxProfile.validFrom, " ");
  2963. }
  2964. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2965. {
  2966. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2967. }
  2968. else
  2969. {
  2970. sprintf((char*)defaultTxProfile.validTo, " ");
  2971. }
  2972. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2973. {
  2974. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2975. }
  2976. else
  2977. {
  2978. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  2979. }
  2980. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2981. {
  2982. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2983. }
  2984. else
  2985. {
  2986. sprintf((char*)defaultTxProfile.transactionId, " ");
  2987. }
  2988. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2989. {
  2990. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2991. }
  2992. else
  2993. {
  2994. defaultTxProfile.chargingSchedule[0].duration = 86400;
  2995. }
  2996. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2997. {
  2998. 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")));
  2999. }
  3000. else
  3001. {
  3002. 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));
  3003. }
  3004. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3005. {
  3006. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3007. }
  3008. else
  3009. {
  3010. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  3011. }
  3012. }
  3013. }
  3014. }
  3015. else
  3016. {
  3017. if(defaultTxProfile.id == -1)
  3018. DEBUG_INFO("TxDefaultProfile found.\n");
  3019. else
  3020. DEBUG_INFO("TxDefaultProfile updated.\n");
  3021. // Required item
  3022. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3023. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3024. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3025. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3026. 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++)
  3027. {
  3028. 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"));
  3029. 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")));
  3030. 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?
  3031. 3:
  3032. 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")));
  3033. }
  3034. // Optional item
  3035. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3036. {
  3037. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3038. }
  3039. else
  3040. {
  3041. sprintf((char*)defaultTxProfile.validFrom, " ");
  3042. }
  3043. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3044. {
  3045. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3046. }
  3047. else
  3048. {
  3049. sprintf((char*)defaultTxProfile.validTo, " ");
  3050. }
  3051. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3052. {
  3053. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3054. }
  3055. else
  3056. {
  3057. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  3058. }
  3059. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3060. {
  3061. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3062. }
  3063. else
  3064. {
  3065. sprintf((char*)defaultTxProfile.transactionId, " ");
  3066. }
  3067. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3068. {
  3069. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3070. }
  3071. else
  3072. {
  3073. defaultTxProfile.chargingSchedule[0].duration = 86400;
  3074. }
  3075. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3076. {
  3077. 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")));
  3078. }
  3079. else
  3080. {
  3081. 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));
  3082. }
  3083. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3084. {
  3085. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3086. }
  3087. else
  3088. {
  3089. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  3090. }
  3091. }
  3092. }
  3093. }
  3094. json_object_put(obj);
  3095. }
  3096. fclose(fp);
  3097. /*
  3098. if(defaultTxProfile.ChargingProfileId != -1)
  3099. {
  3100. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3101. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3102. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3103. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3104. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3105. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3106. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3107. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[0].StartSchedule);
  3108. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3109. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3110. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3111. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3112. {
  3113. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3114. {
  3115. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3116. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3117. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3118. }
  3119. }
  3120. }
  3121. else
  3122. DEBUG_INFO("TxDefaultProfile not found.\n");
  3123. DEBUG_INFO("------------------------------------\n");*/
  3124. }
  3125. // Search max profile
  3126. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  3127. if((access(profileFileName, F_OK))!=-1)
  3128. {
  3129. fp = fopen(profileFileName, "r");
  3130. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3131. {
  3132. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3133. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  3134. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3135. }
  3136. maxProfile.id = -1;
  3137. maxProfile.stackLevel = -1;
  3138. while(getline(&line, &len, fp) != -1)
  3139. {
  3140. json_object *obj = NULL;
  3141. obj = json_tokener_parse(line);
  3142. if(is_error(obj))
  3143. {
  3144. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  3145. }
  3146. else
  3147. {
  3148. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != maxProfile.id) &&
  3149. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= maxProfile.stackLevel)
  3150. )
  3151. {
  3152. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3153. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3154. )
  3155. {
  3156. struct tm tmFrom, tmTo;
  3157. struct timeb tbFrom, tbTo;
  3158. 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) &&
  3159. (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))
  3160. {
  3161. tmFrom.tm_year -= 1900;
  3162. tmFrom.tm_mon -= 1;
  3163. tbFrom.time = mktime(&tmFrom);
  3164. tmTo.tm_year -= 1900;
  3165. tmTo.tm_mon -= 1;
  3166. tbTo.time = mktime(&tmTo);
  3167. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3168. {
  3169. if(maxProfile.id == -1)
  3170. DEBUG_INFO("MaxProfile found.\n");
  3171. else
  3172. DEBUG_INFO("MaxProfile updated.\n");
  3173. // Required item
  3174. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3175. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3176. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3177. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3178. 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++)
  3179. {
  3180. 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"));
  3181. 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")));
  3182. 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?
  3183. 3:
  3184. 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")));
  3185. }
  3186. // Optional item
  3187. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3188. {
  3189. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3190. }
  3191. else
  3192. {
  3193. sprintf((char*)maxProfile.validFrom, " ");
  3194. }
  3195. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3196. {
  3197. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3198. }
  3199. else
  3200. {
  3201. sprintf((char*)maxProfile.validTo, " ");
  3202. }
  3203. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3204. {
  3205. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3206. }
  3207. else
  3208. {
  3209. sprintf((char*)maxProfile.recurrencyKind, " ");
  3210. }
  3211. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3212. {
  3213. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3214. }
  3215. else
  3216. {
  3217. sprintf((char*)maxProfile.transactionId, " ");
  3218. }
  3219. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3220. {
  3221. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3222. }
  3223. else
  3224. {
  3225. maxProfile.chargingSchedule[0].duration = 86400;
  3226. }
  3227. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3228. {
  3229. 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")));
  3230. }
  3231. else
  3232. {
  3233. 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));
  3234. }
  3235. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3236. {
  3237. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3238. }
  3239. else
  3240. {
  3241. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3242. }
  3243. }
  3244. }
  3245. }
  3246. else
  3247. {
  3248. if(maxProfile.id == -1)
  3249. DEBUG_INFO("MaxProfile found.\n");
  3250. else
  3251. DEBUG_INFO("MaxProfile updated.\n");
  3252. // Required item
  3253. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3254. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3255. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3256. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3257. 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++)
  3258. {
  3259. 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"));
  3260. 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")));
  3261. 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?
  3262. 3:
  3263. 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")));
  3264. }
  3265. // Optional item
  3266. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3267. {
  3268. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3269. }
  3270. else
  3271. {
  3272. sprintf((char*)maxProfile.validFrom, " ");
  3273. }
  3274. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3275. {
  3276. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3277. }
  3278. else
  3279. {
  3280. sprintf((char*)maxProfile.validTo, " ");
  3281. }
  3282. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3283. {
  3284. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3285. }
  3286. else
  3287. {
  3288. sprintf((char*)maxProfile.recurrencyKind, " ");
  3289. }
  3290. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3291. {
  3292. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3293. }
  3294. else
  3295. {
  3296. sprintf((char*)maxProfile.transactionId, " ");
  3297. }
  3298. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3299. {
  3300. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3301. }
  3302. else
  3303. {
  3304. maxProfile.chargingSchedule[0].duration = 86400;
  3305. }
  3306. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3307. {
  3308. 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")));
  3309. }
  3310. else
  3311. {
  3312. 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));
  3313. }
  3314. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3315. {
  3316. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3317. }
  3318. else
  3319. {
  3320. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3321. }
  3322. }
  3323. }
  3324. }
  3325. json_object_put(obj);
  3326. }
  3327. fclose(fp);
  3328. /*
  3329. if(maxProfile.ChargingProfileId !=-1)
  3330. {
  3331. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3332. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3333. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3334. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3335. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3336. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3337. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3338. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[0].StartSchedule);
  3339. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3340. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3341. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3342. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3343. {
  3344. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3345. {
  3346. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3347. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3348. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3349. }
  3350. }
  3351. }
  3352. else
  3353. DEBUG_INFO("MaxProfile not found.\n");
  3354. DEBUG_INFO("------------------------------------\n");*/
  3355. }
  3356. /*
  3357. * Align found profile start schedule & periods
  3358. */
  3359. //DEBUG_INFO("====================================\n");
  3360. /*
  3361. // For local test usage, force modify found profile start schedule info
  3362. 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);
  3363. 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);
  3364. 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);
  3365. */
  3366. if(txProfile.id != -1)
  3367. {
  3368. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3369. {
  3370. if(txProfile.chargingSchedule[0].duration != -1)
  3371. {
  3372. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3373. 0:
  3374. (txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3375. }
  3376. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3377. {
  3378. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3379. {
  3380. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3381. 0:
  3382. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3383. if(idxPeriod > 0)
  3384. {
  3385. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3386. {
  3387. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3388. }
  3389. }
  3390. }
  3391. }
  3392. }
  3393. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3394. {
  3395. if(txProfile.chargingSchedule[0].duration != -1)
  3396. {
  3397. 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?
  3398. 0:
  3399. (txProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3400. }
  3401. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3402. {
  3403. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3404. {
  3405. 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?
  3406. 0:
  3407. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3408. if(idxPeriod > 0)
  3409. {
  3410. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3411. {
  3412. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3413. }
  3414. }
  3415. }
  3416. }
  3417. }
  3418. else
  3419. {
  3420. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3421. {
  3422. if(txProfile.chargingSchedule[0].duration != -1)
  3423. {
  3424. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3425. 0:
  3426. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3427. }
  3428. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3429. {
  3430. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3431. {
  3432. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3433. 0:
  3434. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3435. if(idxPeriod > 0)
  3436. {
  3437. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3438. {
  3439. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3440. }
  3441. }
  3442. }
  3443. }
  3444. }
  3445. else
  3446. {
  3447. if(txProfile.chargingSchedule[0].duration != -1)
  3448. {
  3449. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3450. 0:
  3451. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3452. }
  3453. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3454. {
  3455. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3456. {
  3457. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3458. 0:
  3459. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3460. if(idxPeriod > 0)
  3461. {
  3462. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3463. {
  3464. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3465. }
  3466. }
  3467. }
  3468. }
  3469. }
  3470. }
  3471. /*
  3472. DEBUG_INFO("txProfile after align.\n");
  3473. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  3474. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3475. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3476. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3477. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3478. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3479. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  3480. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3481. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  3482. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  3483. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  3484. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3485. {
  3486. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3487. {
  3488. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3489. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3490. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3491. }
  3492. }*/
  3493. }
  3494. if(defaultTxProfile.id != -1)
  3495. {
  3496. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3497. {
  3498. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3499. {
  3500. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3501. 0:
  3502. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3503. }
  3504. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3505. {
  3506. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3507. {
  3508. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3509. 0:
  3510. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3511. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3512. {
  3513. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3514. }
  3515. if(idxPeriod > 0)
  3516. {
  3517. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3518. {
  3519. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3520. }
  3521. }
  3522. }
  3523. }
  3524. }
  3525. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3526. {
  3527. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3528. {
  3529. 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?
  3530. 0:
  3531. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3532. }
  3533. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3534. {
  3535. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3536. {
  3537. 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?
  3538. 0:
  3539. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3540. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3541. {
  3542. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3543. }
  3544. if(idxPeriod > 0)
  3545. {
  3546. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3547. {
  3548. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3549. }
  3550. }
  3551. }
  3552. }
  3553. }
  3554. else
  3555. {
  3556. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3557. {
  3558. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3559. {
  3560. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3561. 0:
  3562. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3563. }
  3564. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3565. {
  3566. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3567. {
  3568. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3569. 0:
  3570. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3571. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3572. {
  3573. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3574. }
  3575. if(idxPeriod > 0)
  3576. {
  3577. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3578. {
  3579. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3580. }
  3581. }
  3582. }
  3583. }
  3584. }
  3585. else
  3586. {
  3587. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3588. {
  3589. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3590. 0:
  3591. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3592. }
  3593. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3594. {
  3595. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3596. {
  3597. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3598. 0:
  3599. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3600. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3601. {
  3602. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3603. }
  3604. if(idxPeriod > 0)
  3605. {
  3606. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3607. {
  3608. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3609. }
  3610. }
  3611. }
  3612. }
  3613. }
  3614. }
  3615. /*
  3616. DEBUG_INFO("defaultTxProfile after align.\n");
  3617. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3618. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3619. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3620. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3621. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3622. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3623. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3624. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3625. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3626. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3627. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3628. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3629. {
  3630. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3631. {
  3632. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3633. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3634. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3635. }
  3636. }
  3637. DEBUG_INFO("------------------------------------\n");*/
  3638. }
  3639. if(maxProfile.id != -1)
  3640. {
  3641. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3642. {
  3643. if(maxProfile.chargingSchedule[0].duration != -1)
  3644. {
  3645. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3646. 0:
  3647. (maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3648. }
  3649. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3650. {
  3651. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3652. {
  3653. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3654. 0:
  3655. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3656. if(idxPeriod > 0)
  3657. {
  3658. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3659. {
  3660. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3661. }
  3662. }
  3663. }
  3664. }
  3665. }
  3666. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3667. {
  3668. if(maxProfile.chargingSchedule[0].duration != -1)
  3669. {
  3670. 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?
  3671. 0:
  3672. (maxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[9].startSchedule)));
  3673. }
  3674. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3675. {
  3676. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3677. {
  3678. 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?
  3679. 0:
  3680. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3681. if(idxPeriod > 0)
  3682. {
  3683. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3684. {
  3685. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3686. }
  3687. }
  3688. }
  3689. }
  3690. }
  3691. else
  3692. {
  3693. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3694. {
  3695. if(maxProfile.chargingSchedule[0].duration != -1)
  3696. {
  3697. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3698. 0:
  3699. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3700. }
  3701. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3702. {
  3703. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3704. {
  3705. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3706. 0:
  3707. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3708. if(idxPeriod > 0)
  3709. {
  3710. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3711. {
  3712. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3713. }
  3714. }
  3715. }
  3716. }
  3717. }
  3718. else
  3719. {
  3720. if(maxProfile.chargingSchedule[0].duration != -1)
  3721. {
  3722. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3723. 0:
  3724. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3725. }
  3726. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3727. {
  3728. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3729. {
  3730. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3731. 0:
  3732. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3733. if(idxPeriod > 0)
  3734. {
  3735. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3736. {
  3737. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3738. }
  3739. }
  3740. }
  3741. }
  3742. }
  3743. }
  3744. /*
  3745. DEBUG_INFO("MaxProfile after align.\n");
  3746. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3747. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3748. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3749. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3750. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3751. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3752. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3753. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3754. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3755. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3756. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3757. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3758. {
  3759. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3760. {
  3761. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3762. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3763. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3764. }
  3765. }
  3766. DEBUG_INFO("------------------------------------\n");*/
  3767. }
  3768. /*
  3769. * Merge to conposite schedule
  3770. */
  3771. //DEBUG_INFO("====================================\n");
  3772. // Find each profile period quantity
  3773. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3774. {
  3775. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3776. limitMax = idx+1;
  3777. }
  3778. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3779. {
  3780. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3781. limitDef = idx+1;
  3782. }
  3783. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3784. {
  3785. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3786. limitTx = idx+1;
  3787. }
  3788. // TxProfile found, composite schedule based on it
  3789. if(txProfile.id != -1)
  3790. {
  3791. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  3792. {
  3793. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  3794. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  3795. (txProfile.chargingSchedule[0].duration > 0))
  3796. {
  3797. if(maxProfile.id != -1)
  3798. {
  3799. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3800. {
  3801. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  3802. {
  3803. if((maxProfile.chargingSchedule[0].duration > 0))
  3804. {
  3805. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3806. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3807. 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);
  3808. }
  3809. else
  3810. {
  3811. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3812. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3813. tmpPeriod.limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit;
  3814. }
  3815. }
  3816. if(idxMaxPeriod == (limitMax-1))
  3817. {
  3818. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3819. {
  3820. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3821. {
  3822. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3823. compositePeriodIdx++;
  3824. }
  3825. else
  3826. {
  3827. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3828. }
  3829. }
  3830. }
  3831. }
  3832. }
  3833. else
  3834. {
  3835. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3836. {
  3837. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3838. compositePeriodIdx++;
  3839. }
  3840. else
  3841. {
  3842. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3843. }
  3844. }
  3845. }
  3846. if(idxTxPeriod == (limitTx-1))
  3847. {
  3848. if(defaultTxProfile.id != -1)
  3849. {
  3850. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3851. {
  3852. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  3853. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3854. (defaultTxProfile.chargingSchedule[0].duration>0))
  3855. {
  3856. if(maxProfile.id != -1)
  3857. {
  3858. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3859. {
  3860. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3861. {
  3862. if((maxProfile.chargingSchedule[0].duration > 0))
  3863. {
  3864. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3865. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3866. 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);
  3867. }
  3868. else
  3869. {
  3870. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3871. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3872. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3873. }
  3874. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3875. {
  3876. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3877. {
  3878. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3879. compositePeriodIdx++;
  3880. }
  3881. else
  3882. {
  3883. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3884. }
  3885. }
  3886. break;
  3887. }
  3888. }
  3889. }
  3890. else
  3891. {
  3892. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3893. {
  3894. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3895. compositePeriodIdx++;
  3896. }
  3897. else
  3898. {
  3899. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3900. }
  3901. }
  3902. }
  3903. }
  3904. }
  3905. }
  3906. }
  3907. }
  3908. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  3909. else if(defaultTxProfile.id != -1)
  3910. {
  3911. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3912. {
  3913. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  3914. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3915. (defaultTxProfile.chargingSchedule[0].duration > 0))
  3916. {
  3917. if(maxProfile.id != -1)
  3918. {
  3919. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3920. {
  3921. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3922. {
  3923. if((maxProfile.chargingSchedule[0].duration > 0))
  3924. {
  3925. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3926. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3927. 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);
  3928. }
  3929. else
  3930. {
  3931. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3932. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3933. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3934. }
  3935. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3936. {
  3937. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3938. {
  3939. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3940. compositePeriodIdx++;
  3941. }
  3942. else
  3943. {
  3944. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3945. }
  3946. }
  3947. break;
  3948. }
  3949. }
  3950. }
  3951. else
  3952. {
  3953. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3954. {
  3955. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3956. compositePeriodIdx++;
  3957. }
  3958. else
  3959. {
  3960. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3961. }
  3962. }
  3963. }
  3964. }
  3965. }
  3966. // Fill other period by MaxProfile
  3967. if(maxProfile.id != -1)
  3968. {
  3969. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3970. {
  3971. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3972. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3973. (maxProfile.chargingSchedule[0].duration > 0))
  3974. {
  3975. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod >= compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod) &&
  3976. (maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3977. {
  3978. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod;
  3979. tmpPeriod.numberPhases = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].numberPhases;
  3980. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3981. }
  3982. if((maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3983. {
  3984. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].duration;
  3985. tmpPeriod.numberPhases = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  3986. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3987. }
  3988. if(tmpPeriod.limit != -1)
  3989. {
  3990. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3991. {
  3992. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3993. {
  3994. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3995. compositePeriodIdx++;
  3996. }
  3997. else
  3998. {
  3999. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  4000. }
  4001. }
  4002. }
  4003. }
  4004. }
  4005. }
  4006. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  4007. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[0].startSchedule);
  4008. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[0].duration);
  4009. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[0].chargingRateUnit);
  4010. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  4011. {
  4012. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  4013. {
  4014. compositeProfile->id = 1;
  4015. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  4016. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit);
  4017. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases);
  4018. }
  4019. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit == -1)
  4020. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit =0;
  4021. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  4022. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  4023. }
  4024. if(line)
  4025. free(line);
  4026. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  4027. }
  4028. //==========================================
  4029. // Init all share memory
  4030. //==========================================
  4031. int InitShareMemory()
  4032. {
  4033. int result = PASS;
  4034. int MeterSMId;
  4035. //creat ShmSysConfigAndInfo
  4036. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  4037. {
  4038. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  4039. result = FAIL;
  4040. }
  4041. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4042. {
  4043. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  4044. result = FAIL;
  4045. }
  4046. else
  4047. {}
  4048. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  4049. {
  4050. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  4051. result = FAIL;
  4052. }
  4053. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4054. {
  4055. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  4056. result = FAIL;
  4057. }
  4058. else
  4059. {}
  4060. //creat ShmPsuData
  4061. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  4062. {
  4063. DEBUG_ERROR("shmget ShmPsuData NG\n");
  4064. result = FAIL;
  4065. }
  4066. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4067. {
  4068. DEBUG_ERROR("shmat ShmPsuData NG\n");
  4069. result = FAIL;
  4070. }
  4071. else
  4072. {}
  4073. //creat ShmOCPP20Data
  4074. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  4075. {
  4076. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  4077. result = FAIL;
  4078. }
  4079. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4080. {
  4081. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  4082. result = FAIL;
  4083. }
  4084. else
  4085. {}
  4086. /****************************** For Initial Settings************************************************/
  4087. //offline MeterValue Interval
  4088. TempMeterValueInterval = 0;
  4089. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  4090. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  4091. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  4092. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  4093. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  4094. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  4095. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  4096. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  4097. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  4098. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  4099. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  4100. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  4101. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  4102. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  4103. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  4104. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  4105. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  4106. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  4107. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  4108. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  4109. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  4110. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  4111. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  4112. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  4113. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  4114. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  4115. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  4116. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  4117. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  4118. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  4119. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  4120. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  4121. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  4122. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  4123. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  4124. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  4125. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  4126. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  4127. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  4128. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  4129. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  4130. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  4131. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  4132. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  4133. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  4134. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  4135. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  4136. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  4137. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  4138. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  4139. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  4140. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  4141. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  4142. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  4143. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  4144. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  4145. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  4146. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  4147. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  4148. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  4149. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  4150. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  4151. return result;
  4152. }
  4153. int ProcessShareMemory()
  4154. {
  4155. if(InitShareMemory() == FAIL)
  4156. {
  4157. DEBUG_ERROR("InitShareMemory NG\n");
  4158. if(ShmStatusCodeData!=NULL)
  4159. {
  4160. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  4161. }
  4162. sleep(5);
  4163. return FAIL;
  4164. }
  4165. return PASS;
  4166. }
  4167. //---------------------common routine---------------------------//
  4168. void checkNetworkProfile(void)
  4169. {
  4170. uint8_t isGetProfile = FALSE;
  4171. json_object *priority;
  4172. priority = json_tokener_parse((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value);
  4173. if(!is_error(priority))
  4174. {
  4175. for(uint8_t idxPriority=0;idxPriority<json_object_array_length(priority);idxPriority++)
  4176. {
  4177. for(uint8_t idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile);idx++)
  4178. {
  4179. if((ShmOCPP20Data->NetworkConnectionProfile[idx].slot == json_object_get_int(json_object_array_get_idx(priority, idxPriority))) &&
  4180. (strlen((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl) > 0) &&
  4181. (ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount < 3))
  4182. {
  4183. memcpy(ShmOCPP20Data->OcppServerURL, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  4184. memcpy(ShmSysConfigAndInfo->SysConfig.OcppServerURL, ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl));
  4185. isGetProfile = TRUE;
  4186. ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount++;
  4187. break;
  4188. }
  4189. }
  4190. }
  4191. }
  4192. json_object_put(priority);
  4193. if(!isGetProfile && (strlen((char*)ShmOCPP20Data->OcppServerURL) > 0))
  4194. {
  4195. memcpy(ShmSysConfigAndInfo->SysConfig.OcppServerURL, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  4196. }
  4197. DEBUG_INFO("Get network profile URL: %s\n", ShmSysConfigAndInfo->SysConfig.OcppServerURL);
  4198. }
  4199. void CheckSystemValue(void)
  4200. {
  4201. char filenmae[100]={0};
  4202. char str[100]={0};
  4203. int tempIndex = 0;
  4204. //===============================
  4205. // EVSE operation check
  4206. //===============================
  4207. //===============================
  4208. // Heartbeat check
  4209. //===============================
  4210. if((difftime(time((time_t*)NULL), clientTime.Heartbeat) < 0) || (HeartBeatWaitTime <= 0))
  4211. {
  4212. clientTime.Heartbeat = time((time_t*)NULL);
  4213. if(server_sign == TRUE)
  4214. {
  4215. HeartBeatWaitTime = ShmOCPP20Data->BootNotification.Response_interval;
  4216. }
  4217. else
  4218. {
  4219. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);
  4220. }
  4221. }
  4222. if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  4223. {
  4224. //parameter for test
  4225. sendHeartbeatRequest(0);
  4226. //==============================================
  4227. // Reset Waiting Time
  4228. //==============================================
  4229. HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
  4230. }
  4231. //===============================
  4232. // CSU Trigger Reset Conf
  4233. //===============================
  4234. if(isWebsocketSendable && (ShmOCPP20Data->MsMsg.bits.ResetConf == ON))
  4235. {
  4236. sendResetConfirmation((char *)ShmOCPP20Data->Reset.guid);
  4237. }
  4238. //===============================
  4239. // CSU Trigger Authorize Request
  4240. //===============================
  4241. if(isWebsocketSendable &&
  4242. (server_sign == TRUE) &&
  4243. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4244. (authorizeRetryTimes < 3))
  4245. {
  4246. sendAuthorizeRequest(0);
  4247. authorizeRetryTimes = authorizeRetryTimes + 1;
  4248. if(authorizeRetryTimes < 3)
  4249. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4250. }
  4251. else if((server_sign == TRUE) &&
  4252. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4253. (authorizeRetryTimes >= 3))
  4254. {
  4255. authorizeRetryTimes = 0;
  4256. SetOcppConnStatus(FALSE);
  4257. server_sign = FALSE;
  4258. }
  4259. else if((server_sign == FALSE) &&
  4260. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  4261. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  4262. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  4263. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  4264. {
  4265. sendAuthorizeRequest(0);
  4266. }
  4267. if(isWebsocketSendable &&
  4268. (server_sign == TRUE) &&
  4269. (ShmOCPP20Data->GetReport.requestId > 0))
  4270. {
  4271. for(uint8_t idxCriterion=0;idxCriterion<ARRAY_SIZE(ShmOCPP20Data->GetReport.componentCriteria);idxCriterion++)
  4272. {
  4273. if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Active]) == 0)
  4274. {
  4275. /*
  4276. * TODO:
  4277. * 1. Report component that are active
  4278. */
  4279. }
  4280. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Available]) == 0)
  4281. {
  4282. /*
  4283. * TODO:
  4284. * 1. Report component that are available
  4285. */
  4286. }
  4287. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Enabled]) == 0)
  4288. {
  4289. /*
  4290. * TODO:
  4291. * 1. Report component that are enable
  4292. */
  4293. }
  4294. else if(strcmp((char*)ShmOCPP20Data->GetReport.componentCriteria[idxCriterion], ComponentCriterionEnumTypeStr[ComponentCriterionEnumType_Problem]) == 0)
  4295. {
  4296. /*
  4297. * TODO:
  4298. * 1. Report component that are problem
  4299. */
  4300. }
  4301. else
  4302. {
  4303. /*
  4304. * TODO:
  4305. * 1. Process unknown criteria condition
  4306. */
  4307. }
  4308. }
  4309. ShmOCPP20Data->GetReport.requestId = 0;
  4310. }
  4311. if(isWebsocketSendable &&
  4312. (server_sign == TRUE) &&
  4313. (ShmOCPP20Data->GetBaseReport.requestId > 0))
  4314. {
  4315. uint8_t reportIdx = 0;
  4316. ShmOCPP20Data->NotifyReport.requestId = ShmOCPP20Data->GetBaseReport.requestId;
  4317. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_ConfigurationInventory]) == 0)
  4318. {
  4319. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  4320. {
  4321. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  4322. {
  4323. if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].mutability, MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]) == 0) || (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].mutability, MutabilityEnumTypeStr[MutabilityEnumType_WriteOnly]) == 0))
  4324. {
  4325. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  4326. reportIdx++;
  4327. }
  4328. }
  4329. else
  4330. {
  4331. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  4332. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  4333. ShmOCPP20Data->NotifyReport.seqNo += 1;
  4334. else
  4335. ShmOCPP20Data->NotifyReport.seqNo = 0;
  4336. sendNotifyReportRequest();
  4337. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  4338. reportIdx = 0;
  4339. }
  4340. }
  4341. }
  4342. else if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_FullInventory]) == 0)
  4343. {
  4344. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  4345. {
  4346. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  4347. {
  4348. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  4349. reportIdx++;
  4350. }
  4351. else
  4352. {
  4353. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  4354. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  4355. ShmOCPP20Data->NotifyReport.seqNo += 1;
  4356. else
  4357. ShmOCPP20Data->NotifyReport.seqNo = 0;
  4358. sendNotifyReportRequest();
  4359. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  4360. reportIdx = 0;
  4361. }
  4362. }
  4363. }
  4364. else
  4365. {
  4366. /*
  4367. * TODO:
  4368. * 1. Fill out summary inventory to response message, currently not support
  4369. */
  4370. }
  4371. if(reportIdx > 0)
  4372. {
  4373. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  4374. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  4375. ShmOCPP20Data->NotifyReport.seqNo += 1;
  4376. else
  4377. ShmOCPP20Data->NotifyReport.seqNo = 0;
  4378. sendNotifyReportRequest();
  4379. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  4380. reportIdx = 0;
  4381. }
  4382. ShmOCPP20Data->GetBaseReport.requestId = 0;
  4383. }
  4384. if(isWebsocketSendable &&
  4385. (server_sign == TRUE) &&
  4386. ShmOCPP20Data->SpMsg.bits.NotifyEventReq)
  4387. {
  4388. getNowDatetime(ShmOCPP20Data->NotifyEvent.generatedAt);
  4389. ShmOCPP20Data->NotifyEvent.tbc = FALSE;
  4390. if(ShmOCPP20Data->NotifyEvent.seqNo < INT_MAX)
  4391. ShmOCPP20Data->NotifyEvent.seqNo += 1;
  4392. else
  4393. ShmOCPP20Data->NotifyEvent.seqNo = 0;
  4394. sendNotifyEventRequest();
  4395. memset(&ShmOCPP20Data->NotifyEvent.eventData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)* sizeof(struct EventDataType ));
  4396. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  4397. }
  4398. if(isWebsocketSendable &&
  4399. (server_sign == TRUE) &&
  4400. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq)
  4401. {
  4402. if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Install]) == 0)
  4403. {
  4404. }
  4405. else if(strcmp((char*)ShmOCPP20Data->Get15118EVCertificate.action, CertificateActionEnumTypeStr[CertificateActionEnumType_Update]) == 0)
  4406. {
  4407. }
  4408. else
  4409. {
  4410. }
  4411. sendGet15118EVCertificateRequest();
  4412. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  4413. }
  4414. //===============================
  4415. // Each connector operation check
  4416. //===============================
  4417. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  4418. {
  4419. //==========================================
  4420. // csu trigger DataTransferReq
  4421. //==========================================
  4422. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  4423. {
  4424. sendDataTransferRequest(gun_index);
  4425. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  4426. }
  4427. //===============================
  4428. // CSU Trigger Smart Charging Profilw
  4429. //===============================
  4430. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  4431. {
  4432. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index]);
  4433. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  4434. }
  4435. //==============================================
  4436. // Charger start transaction
  4437. //==============================================
  4438. /*
  4439. if((ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq == ON))
  4440. {
  4441. ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq = OFF;
  4442. sendStartTransactionRequest(gun_index);
  4443. clientTime.StartTransaction = time((time_t*)NULL);
  4444. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4445. }*/
  4446. //==============================================
  4447. // Charger stop transaction
  4448. //==============================================
  4449. /*
  4450. if(((ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq == ON)))
  4451. {
  4452. ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq =OFF;
  4453. sendStopTransactionRequest(gun_index);
  4454. clientTime.StopTransaction = time((time_t*)NULL);
  4455. }*/
  4456. //==============================================
  4457. // Charger status notification & Transaction event report
  4458. //==============================================
  4459. //--- Check Mode Change ---//
  4460. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  4461. if(gunType[gun_index] == 'J')
  4462. {
  4463. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4464. {
  4465. tempIndex = ((gun_index==2) ? 1: 0);
  4466. }
  4467. else
  4468. {
  4469. tempIndex = gun_index;
  4470. }
  4471. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4472. {
  4473. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4474. {
  4475. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  4476. {
  4477. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  4478. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  4479. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4480. if((SystemInitial == 0) &&
  4481. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4482. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4483. {
  4484. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4485. }
  4486. }
  4487. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4488. {
  4489. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4490. if((access(filenmae,F_OK))!=-1)
  4491. {
  4492. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4493. sprintf(str,"rm -f %s",filenmae);
  4494. system(str);
  4495. }
  4496. }
  4497. #if 1 // for TempStopTransaction
  4498. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4499. {
  4500. checkTempStopTransaction(gun_index);
  4501. }
  4502. #endif
  4503. }
  4504. }
  4505. }
  4506. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4507. {
  4508. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4509. {
  4510. tempIndex = ((gun_index==2) ? 1: 0);
  4511. }
  4512. else
  4513. {
  4514. tempIndex = gun_index;
  4515. }
  4516. for (int index = 0; index < CCS_QUANTITY; index++)
  4517. {
  4518. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4519. {
  4520. 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]*/ )
  4521. {
  4522. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  4523. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  4524. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4525. if((SystemInitial == 0) &&
  4526. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4527. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4528. {
  4529. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4530. }
  4531. }
  4532. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4533. {
  4534. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4535. if((access(filenmae,F_OK))!=-1)
  4536. {
  4537. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4538. sprintf(str,"rm -f %s",filenmae);
  4539. system(str);
  4540. }
  4541. }
  4542. #if 1 // for TempStopTransaction
  4543. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4544. {
  4545. checkTempStopTransaction(gun_index);
  4546. }
  4547. #endif
  4548. }
  4549. }
  4550. }
  4551. else if(gunType[gun_index] == 'G')
  4552. {
  4553. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4554. {
  4555. tempIndex = ((gun_index==2) ? 1: 0);
  4556. }
  4557. else
  4558. {
  4559. tempIndex = gun_index;
  4560. }
  4561. for (int index = 0; index < GB_QUANTITY; index++)
  4562. {
  4563. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4564. {
  4565. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  4566. {
  4567. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  4568. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  4569. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4570. if((SystemInitial == 0) &&
  4571. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4572. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4573. {
  4574. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4575. }
  4576. }
  4577. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4578. {
  4579. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4580. if((access(filenmae,F_OK))!=-1)
  4581. {
  4582. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4583. sprintf(str,"rm -f %s",filenmae);
  4584. system(str);
  4585. }
  4586. }
  4587. #if 1 // for TempStopTransaction
  4588. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4589. {
  4590. checkTempStopTransaction(gun_index);
  4591. }
  4592. #endif
  4593. }
  4594. }
  4595. }
  4596. else if(gunType[gun_index] == 'O')
  4597. {
  4598. tempIndex = gun_index;
  4599. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4600. {
  4601. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4602. {
  4603. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  4604. {
  4605. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  4606. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  4607. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4608. if((SystemInitial == 0) &&
  4609. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING) &&
  4610. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_COMPLETE))
  4611. {
  4612. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4613. }
  4614. }
  4615. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // complete
  4616. {
  4617. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4618. if((access(filenmae,F_OK))!=-1)
  4619. {
  4620. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4621. sprintf(str,"rm -f %s",filenmae);
  4622. system(str);
  4623. }
  4624. }
  4625. #if 1 // for TempStopTransaction
  4626. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4627. {
  4628. checkTempStopTransaction(gun_index);
  4629. }
  4630. #endif
  4631. }
  4632. }
  4633. }
  4634. else
  4635. {
  4636. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4637. {
  4638. tempIndex = 2;
  4639. }
  4640. else
  4641. {
  4642. tempIndex = gun_index;
  4643. }
  4644. for (int index = 0; index < AC_QUANTITY; index++)
  4645. {
  4646. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4647. {
  4648. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  4649. {
  4650. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  4651. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  4652. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4653. if((SystemInitial == 0) &&
  4654. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4655. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4656. {
  4657. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4658. }
  4659. }
  4660. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4661. {
  4662. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4663. if((access(filenmae,F_OK))!=-1)
  4664. {
  4665. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4666. sprintf(str,"rm -f %s",filenmae);
  4667. system(str);
  4668. }
  4669. }
  4670. #if 1 // for TempStopTransaction
  4671. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4672. {
  4673. checkTempStopTransaction(gun_index);
  4674. }
  4675. #endif
  4676. }
  4677. }// END
  4678. }
  4679. if(isWebsocketSendable &&
  4680. (cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) &&
  4681. ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 5) )
  4682. {
  4683. if(SystemInitial > 0)
  4684. SystemInitial -= 1;
  4685. sendStatusNotificationRequest(gun_index);
  4686. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  4687. }
  4688. if(isWebsocketSendable && (server_sign == TRUE) && (cpinitateMsg.bits[gun_index].TransactionEventReq == ON))
  4689. {
  4690. sendTransactionEventRequest(gun_index);
  4691. cpinitateMsg.bits[gun_index].TransactionEventReq = OFF;
  4692. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], 0x00, sizeof(struct MeterValueType));
  4693. }
  4694. //==============================================
  4695. // Meter report
  4696. //==============================================
  4697. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  4698. {
  4699. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  4700. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  4701. }
  4702. // ClockAlign MeterValue
  4703. 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))
  4704. {
  4705. //check Transaction active
  4706. if(gunType[gun_index] == 'J')
  4707. {
  4708. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4709. {
  4710. tempIndex = ((gun_index==2) ? 1: 0);
  4711. }
  4712. else
  4713. {
  4714. tempIndex = gun_index;
  4715. }
  4716. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4717. {
  4718. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4719. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4720. {
  4721. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4722. {
  4723. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4724. }
  4725. }
  4726. }// End for CHAdeMO
  4727. }
  4728. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4729. {
  4730. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4731. {
  4732. tempIndex = ((gun_index==2) ? 1: 0);
  4733. }
  4734. else
  4735. {
  4736. tempIndex = gun_index;
  4737. }
  4738. for (int index = 0; index < CCS_QUANTITY; index++)
  4739. {
  4740. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4741. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4742. {
  4743. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4744. {
  4745. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4746. }
  4747. }
  4748. } // End for CCS
  4749. }
  4750. else if(gunType[gun_index] == 'G')
  4751. {
  4752. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4753. {
  4754. tempIndex = ((gun_index==2) ? 1: 0);
  4755. }
  4756. else
  4757. {
  4758. tempIndex = gun_index;
  4759. }
  4760. for (int index = 0; index < GB_QUANTITY; index++)
  4761. {
  4762. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4763. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4764. {
  4765. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4766. {
  4767. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4768. }
  4769. }
  4770. }// End for GB
  4771. }
  4772. else if(gunType[gun_index] == 'O')
  4773. {
  4774. tempIndex = gun_index;
  4775. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4776. {
  4777. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4778. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4779. {
  4780. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_CHARGING)
  4781. {
  4782. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4783. }
  4784. }
  4785. }
  4786. }
  4787. else
  4788. {
  4789. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4790. {
  4791. tempIndex = 2;
  4792. }
  4793. else
  4794. {
  4795. tempIndex = gun_index;
  4796. }
  4797. for (int index = 0; index < AC_QUANTITY; index++)
  4798. {
  4799. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4800. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4801. {
  4802. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4803. {
  4804. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4805. }
  4806. }
  4807. }//End for AC
  4808. }
  4809. if(cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON)
  4810. {
  4811. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  4812. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  4813. }
  4814. }
  4815. // Sample period MeterValue
  4816. if(((time((time_t*)NULL) - clientTime.MeterValues[gun_index]) > (atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1)))
  4817. {
  4818. //check Transaction active
  4819. if(gunType[gun_index] == 'J')
  4820. {
  4821. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4822. {
  4823. tempIndex = ((gun_index==2) ? 1: 0);
  4824. }
  4825. else
  4826. {
  4827. tempIndex = gun_index;
  4828. }
  4829. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4830. {
  4831. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4832. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4833. {
  4834. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4835. {
  4836. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4837. }
  4838. }
  4839. }// End for CHAdeMO
  4840. }
  4841. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4842. {
  4843. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4844. {
  4845. tempIndex = ((gun_index==2) ? 1: 0);
  4846. }
  4847. else
  4848. {
  4849. tempIndex = gun_index;
  4850. }
  4851. for (int index = 0; index < CCS_QUANTITY; index++)
  4852. {
  4853. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4854. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4855. {
  4856. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4857. {
  4858. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4859. }
  4860. }
  4861. } // End for CCS
  4862. }
  4863. else if(gunType[gun_index] == 'G')
  4864. {
  4865. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4866. {
  4867. tempIndex = ((gun_index==2) ? 1: 0);
  4868. }
  4869. else
  4870. {
  4871. tempIndex = gun_index;
  4872. }
  4873. for (int index = 0; index < GB_QUANTITY; index++)
  4874. {
  4875. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4876. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4877. {
  4878. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4879. {
  4880. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4881. }
  4882. }
  4883. }// End for GB
  4884. }
  4885. else if(gunType[gun_index] == 'O')
  4886. {
  4887. tempIndex = gun_index;
  4888. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4889. {
  4890. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4891. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4892. {
  4893. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  4894. {
  4895. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4896. }
  4897. }
  4898. }
  4899. }
  4900. else
  4901. {
  4902. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4903. {
  4904. tempIndex = 2;
  4905. }
  4906. else
  4907. {
  4908. tempIndex = gun_index;
  4909. }
  4910. for (int index = 0; index < AC_QUANTITY; index++)
  4911. {
  4912. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4913. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4914. {
  4915. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4916. {
  4917. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4918. }
  4919. }
  4920. }//End for AC
  4921. }
  4922. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  4923. {
  4924. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  4925. storeTempStopTransaction(gun_index);
  4926. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  4927. }
  4928. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4929. }
  4930. //==============================================
  4931. // Check Connector reserved
  4932. //==============================================
  4933. //===============================
  4934. // Check if Reserve is expired
  4935. //===============================
  4936. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0) )
  4937. {
  4938. double diff_t;
  4939. struct tm tp;
  4940. // current time
  4941. time_t t = time(NULL);
  4942. strptime((char *)ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime, "%Y-%m-%dT%H:%M:%S", &tp);
  4943. tp.tm_isdst = -1;
  4944. time_t utc = mktime(&tp);
  4945. diff_t = difftime(utc, t);
  4946. if(diff_t <= 0)
  4947. {
  4948. DEBUG_INFO("reserve expired.\n");
  4949. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  4950. }
  4951. }//END OF Check if Reserve is expired
  4952. //==========================================
  4953. // csu trigger FirmwareStatusNotificationReq
  4954. //==========================================
  4955. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  4956. {
  4957. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  4958. }
  4959. //==========================================
  4960. // csu cleared charging limit request
  4961. //==========================================
  4962. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq == ON))
  4963. {
  4964. sendClearedChargingLimitRequest(gun_index);
  4965. }
  4966. //==========================================
  4967. // csu trigger CancelReservationConf
  4968. //==========================================
  4969. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  4970. {
  4971. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  4972. }
  4973. //==========================================
  4974. // csu notify EV charging need request
  4975. //==========================================
  4976. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CSUMsg.bits[gun_index].NotifyEVChargingNeedsReq == ON))
  4977. {
  4978. sendNotifyEVChargingNeedsRequest(gun_index);
  4979. }
  4980. //==========================================
  4981. // csu trigger ChangeAvailabilityConf
  4982. //==========================================
  4983. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  4984. {
  4985. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  4986. }
  4987. //==========================================
  4988. // csu trigger UnlockConnectorConf
  4989. //==========================================
  4990. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  4991. {
  4992. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  4993. }
  4994. //==========================================
  4995. // csu trigger ReserveNowConf
  4996. //==========================================
  4997. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  4998. {
  4999. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  5000. }
  5001. }
  5002. }
  5003. //==========================================
  5004. // send request routine
  5005. //==========================================
  5006. int sendAuthorizeRequest(int gun_index)
  5007. {
  5008. mtrace();
  5009. int result = FAIL;
  5010. char message[4096]={0};
  5011. char guid[37];
  5012. char tempdata[128]={0};
  5013. json_object *Authorize = json_object_new_object();
  5014. json_object *idToken = json_object_new_object();
  5015. DEBUG_INFO("sendAuthorizeRequest...\n");
  5016. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  5017. //Local Authorize
  5018. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) && (ShmOCPP20Data->OcppConnStatus == 0))
  5019. {
  5020. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  5021. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  5022. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  5023. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  5024. result = PASS;
  5025. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5026. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  5027. authorizeRetryTimes = 0;
  5028. return result;
  5029. }
  5030. 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)) ||
  5031. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  5032. {
  5033. // Query idtag from cache
  5034. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  5035. // Query idtag from list
  5036. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  5037. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  5038. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  5039. {
  5040. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  5041. {
  5042. DEBUG_INFO("Card %s does not find in list or cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  5043. }
  5044. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  5045. {
  5046. DEBUG_INFO("Card %s does not accepted in list and cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  5047. }
  5048. // Return authorize result if does not connect to server
  5049. if(!ShmOCPP20Data->OcppConnStatus)
  5050. {
  5051. DEBUG_INFO("Local Authorization Fail.\n");
  5052. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  5053. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  5054. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  5055. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  5056. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5057. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  5058. authorizeRetryTimes = 0;
  5059. return result;
  5060. }
  5061. }
  5062. else
  5063. {
  5064. DEBUG_INFO("Local Authorization get result.\n");
  5065. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  5066. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  5067. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  5068. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  5069. else
  5070. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  5071. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  5072. result = PASS;
  5073. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5074. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  5075. authorizeRetryTimes = 0;
  5076. return result;
  5077. }
  5078. }
  5079. //get data from shared memory
  5080. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  5081. /*
  5082. if(strlen((char*)ShmOCPP20Data->Authorize.idToken.type) == 0)
  5083. strcpy((char *)ShmOCPP20Data->Authorize.idToken.type, IdTokenEnumTypeStr[IdTokenEnumType_ISO14443]);
  5084. */
  5085. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  5086. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  5087. json_object_object_add(Authorize, "idToken", idToken);
  5088. random_uuid(guid);
  5089. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  5090. json_object_put(Authorize);
  5091. LWS_Send(message);
  5092. sprintf(tempdata, "Authorize,%d", gun_index);
  5093. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5094. {
  5095. result = PASS;
  5096. }
  5097. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5098. return result;
  5099. }
  5100. int sendBootNotificationRequest()
  5101. {
  5102. mtrace();
  5103. int result = FAIL;
  5104. char message[4096]={0};
  5105. char guid[37]={0};
  5106. char tempdata[128]={0};
  5107. json_object *BootNotification = json_object_new_object();
  5108. json_object *chargingStation = json_object_new_object();
  5109. json_object *modem = json_object_new_object();
  5110. DEBUG_INFO("sendBootNotificationRequest...\n");
  5111. // Fill BootNotification fields
  5112. DB_getBooType();
  5113. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  5114. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  5115. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  5116. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  5117. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  5118. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  5119. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  5120. {
  5121. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  5122. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  5123. json_object_object_add(chargingStation, "modem", modem);
  5124. }
  5125. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  5126. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  5127. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  5128. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  5129. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  5130. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  5131. random_uuid(guid);
  5132. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  5133. json_object_put(BootNotification);
  5134. LWS_Send(message);
  5135. sprintf(tempdata, "BootNotification,0");
  5136. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5137. {
  5138. result = PASS;
  5139. }
  5140. return result;
  5141. }
  5142. int sendClearedChargingLimitRequest(int gun_index)
  5143. {
  5144. mtrace();
  5145. int result = FAIL;
  5146. char message[4096]={0};
  5147. char guid[37]={0};
  5148. char tempdata[128]={0};
  5149. json_object *ClearedChargingLimit = json_object_new_object();
  5150. DEBUG_INFO("sendClearedChargingLimitRequest...\n");
  5151. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  5152. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  5153. random_uuid(guid);
  5154. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  5155. json_object_put(ClearedChargingLimit);
  5156. LWS_Send(message);
  5157. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  5158. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5159. {
  5160. result = PASS;
  5161. }
  5162. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  5163. return result;
  5164. }
  5165. int sendDataTransferRequest(int gun_index)
  5166. {
  5167. mtrace();
  5168. char message[1000]={0};
  5169. char guid[37]={0};
  5170. char tempdata[65]={0};
  5171. int result = FAIL;
  5172. DEBUG_INFO("sendDataTransferRequest...\n");
  5173. random_uuid(guid);
  5174. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  5175. MESSAGE_TYPE_CALL,
  5176. guid,
  5177. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  5178. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  5179. ShmOCPP20Data->DataTransfer[gun_index].data);
  5180. LWS_Send(message);
  5181. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  5182. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5183. {
  5184. result = PASS;
  5185. }
  5186. return result;
  5187. }
  5188. int sendFirmwareStatusNotificationRequest(char *status)
  5189. {
  5190. mtrace();
  5191. int result = FAIL;
  5192. char message[110]={0};
  5193. char guid[37]={0};
  5194. char tempdata[65]={0};
  5195. json_object *FirmwareStatusNotification = json_object_new_object();
  5196. DEBUG_INFO("sendFirmwareStatusNotificationRequest...\n");
  5197. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  5198. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  5199. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  5200. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  5201. random_uuid(guid);
  5202. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  5203. json_object_put(FirmwareStatusNotification);
  5204. LWS_SendNow(message);
  5205. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  5206. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5207. {
  5208. result = PASS;
  5209. }
  5210. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  5211. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  5212. //record status
  5213. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  5214. {
  5215. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  5216. }
  5217. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  5218. {
  5219. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  5220. }
  5221. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  5222. {
  5223. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  5224. }
  5225. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  5226. {
  5227. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  5228. }
  5229. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  5230. {
  5231. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  5232. }
  5233. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  5234. {
  5235. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  5236. }
  5237. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  5238. {
  5239. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  5240. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5241. }
  5242. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  5243. {
  5244. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  5245. }
  5246. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  5247. {
  5248. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  5249. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5250. }
  5251. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  5252. {
  5253. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  5254. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5255. }
  5256. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  5257. {
  5258. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  5259. }
  5260. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  5261. {
  5262. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  5263. }
  5264. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  5265. {
  5266. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  5267. }
  5268. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  5269. {
  5270. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  5271. }
  5272. return result;
  5273. }
  5274. int sendGet15118EVCertificateRequest()
  5275. {
  5276. mtrace();
  5277. int result = FAIL;
  5278. char message[4096]={0};
  5279. char guid[37]={0};
  5280. char tempdata[128]={0};
  5281. json_object *Get15118EVCertificate = json_object_new_object();
  5282. DEBUG_INFO("sendGet15118EVCertificateRequest...\n");
  5283. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  5284. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  5285. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  5286. random_uuid(guid);
  5287. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  5288. json_object_put(Get15118EVCertificate);
  5289. LWS_Send(message);
  5290. sprintf(tempdata, "Get15118EVCertificate,0");
  5291. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5292. {
  5293. result = PASS;
  5294. }
  5295. return result;
  5296. }
  5297. int sendGetCertificateStatusRequest()
  5298. {
  5299. mtrace();
  5300. int result = FAIL;
  5301. char message[4096]={0};
  5302. char guid[37]={0};
  5303. char tempdata[128]={0};
  5304. json_object *GetCertificateStatus = json_object_new_object();
  5305. json_object *ocspRequestData = json_object_new_object();
  5306. DEBUG_INFO("sendGetCertificateStatusRequest...\n");
  5307. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  5308. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  5309. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  5310. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  5311. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  5312. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  5313. random_uuid(guid);
  5314. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  5315. json_object_put(GetCertificateStatus);
  5316. LWS_Send(message);
  5317. sprintf(tempdata, "GetCertificateStatus,0");
  5318. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5319. {
  5320. result = PASS;
  5321. }
  5322. return result;
  5323. }
  5324. int sendHeartbeatRequest()
  5325. {
  5326. mtrace();
  5327. int result = FAIL;
  5328. char message[40096]={0};
  5329. char guid[37]={0};
  5330. char tempdata[128]={0};
  5331. DEBUG_INFO("sendHeartbeatRequest...\n");
  5332. random_uuid(guid);
  5333. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  5334. , MESSAGE_TYPE_CALL
  5335. , guid );
  5336. LWS_Send(message);
  5337. sprintf(tempdata, "Heartbeat,%d", 0);
  5338. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5339. {
  5340. result = PASS;
  5341. }
  5342. return result;
  5343. }
  5344. int sendLogStatusNotificationRequest(char *status)
  5345. {
  5346. mtrace();
  5347. int result = FAIL;
  5348. char message[4096]={0};
  5349. char guid[37]={0};
  5350. char tempdata[128]={0};
  5351. json_object *LogStatusNotification = json_object_new_object();
  5352. DEBUG_INFO("sendLogStatusNotificationRequest...\n");
  5353. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  5354. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  5355. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  5356. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  5357. random_uuid(guid);
  5358. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  5359. json_object_put(LogStatusNotification);
  5360. LWS_SendNow(message);
  5361. sprintf(tempdata, "LogStatusNotification,%d", 0);
  5362. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5363. {
  5364. result = PASS;
  5365. }
  5366. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  5367. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  5368. //record status
  5369. if(strcmp(status,"BadMessage")==0)
  5370. {
  5371. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  5372. }
  5373. else if(strcmp(status,"Idle")==0)
  5374. {
  5375. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  5376. }
  5377. else if(strcmp(status,"NotSupportedOperation")==0)
  5378. {
  5379. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  5380. }
  5381. else if(strcmp(status,"PermissionDenied")==0)
  5382. {
  5383. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  5384. }
  5385. else if(strcmp(status,"Uploaded")==0)
  5386. {
  5387. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  5388. }
  5389. else if(strcmp(status,"UploadFailure")==0)
  5390. {
  5391. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  5392. }
  5393. else if(strcmp(status,"Uploading")==0)
  5394. {
  5395. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  5396. }
  5397. return result;
  5398. }
  5399. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  5400. {
  5401. mtrace();
  5402. int result = FAIL;
  5403. char guid[37]={0};
  5404. char tempdata[65]={0};
  5405. int tempIndex = 0;
  5406. json_object *MeterValueReq = json_object_new_object();
  5407. json_object *meterValues = json_object_new_array();
  5408. json_object *sampledValues = json_object_new_array();
  5409. DEBUG_INFO("sendMeterValuesRequest...\n");
  5410. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  5411. //set value
  5412. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  5413. //UTC Date time
  5414. struct timeval tmnow;
  5415. struct tm *tm;
  5416. char buf[28];//, usec_buf[6];
  5417. gettimeofday(&tmnow, NULL);
  5418. time_t t;
  5419. t = time(NULL);
  5420. /*UTC time and date*/
  5421. tm = gmtime(&t);
  5422. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  5423. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  5424. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  5425. //idx_sample=0;
  5426. //********************************(1)Current.Import L1************************************************/
  5427. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5428. if(gunType[gun_index] == 'J')
  5429. {
  5430. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5431. {
  5432. tempIndex = ((gun_index==2) ? 1: 0);
  5433. }
  5434. else
  5435. {
  5436. tempIndex = gun_index;
  5437. }
  5438. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5439. {
  5440. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5441. {
  5442. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent;
  5443. }
  5444. }
  5445. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5446. }
  5447. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5448. {
  5449. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5450. {
  5451. tempIndex = ((gun_index==2) ? 1: 0);
  5452. }
  5453. else
  5454. {
  5455. tempIndex = gun_index;
  5456. }
  5457. for (int index = 0; index < CCS_QUANTITY; index++)
  5458. {
  5459. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5460. {
  5461. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent;
  5462. }
  5463. }
  5464. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5465. }
  5466. else if(gunType[gun_index] == 'G')
  5467. {
  5468. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5469. {
  5470. tempIndex = ((gun_index==2) ? 1: 0);
  5471. }
  5472. else
  5473. {
  5474. tempIndex = gun_index;
  5475. }
  5476. for (int index = 0; index < GB_QUANTITY; index++)
  5477. {
  5478. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5479. {
  5480. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent;
  5481. }
  5482. }
  5483. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5484. }
  5485. else if(gunType[gun_index] == 'O')
  5486. {
  5487. tempIndex = gun_index;
  5488. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5489. {
  5490. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5491. {
  5492. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent;
  5493. }
  5494. }
  5495. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5496. }
  5497. else
  5498. {
  5499. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5500. {
  5501. tempIndex = 2;
  5502. }
  5503. else
  5504. {
  5505. tempIndex = gun_index;
  5506. }
  5507. for (int index = 0; index < AC_QUANTITY; index++)
  5508. {
  5509. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5510. {
  5511. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent;
  5512. }
  5513. }
  5514. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5515. }
  5516. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  5517. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5518. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5519. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  5520. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  5521. //idx_sample=1;
  5522. //********************************(2)Energy.Active.Import.Register ************************************************/
  5523. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5524. if(gunType[gun_index] == 'J')
  5525. {
  5526. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5527. {
  5528. tempIndex = ((gun_index==2) ? 1: 0);
  5529. }
  5530. else
  5531. {
  5532. tempIndex = gun_index;
  5533. }
  5534. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5535. {
  5536. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5537. {
  5538. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  5539. }
  5540. }
  5541. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5542. }
  5543. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5544. {
  5545. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5546. {
  5547. tempIndex = ((gun_index==2) ? 1: 0);
  5548. }
  5549. else
  5550. {
  5551. tempIndex = gun_index;
  5552. }
  5553. for (int index = 0; index < CCS_QUANTITY; index++)
  5554. {
  5555. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5556. {
  5557. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  5558. }
  5559. }
  5560. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5561. }
  5562. else if(gunType[gun_index] == 'G')
  5563. {
  5564. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5565. {
  5566. tempIndex = ((gun_index==2) ? 1: 0);
  5567. }
  5568. else
  5569. {
  5570. tempIndex = gun_index;
  5571. }
  5572. for (int index = 0; index < GB_QUANTITY; index++)
  5573. {
  5574. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5575. {
  5576. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  5577. }
  5578. }
  5579. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5580. }
  5581. else if(gunType[gun_index] == 'O')
  5582. {
  5583. tempIndex = gun_index;
  5584. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5585. {
  5586. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5587. {
  5588. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  5589. }
  5590. }
  5591. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5592. }
  5593. else
  5594. {
  5595. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5596. {
  5597. tempIndex = 2;
  5598. }
  5599. else
  5600. {
  5601. tempIndex = gun_index;
  5602. }
  5603. for (int index = 0; index < AC_QUANTITY; index++)
  5604. {
  5605. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5606. {
  5607. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  5608. }
  5609. }
  5610. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5611. }
  5612. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  5613. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  5614. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5615. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  5616. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5617. //idx_sample=2;
  5618. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  5619. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5620. if(gunType[gun_index] == 'J')
  5621. {
  5622. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5623. {
  5624. tempIndex = ((gun_index==2) ? 1: 0);
  5625. }
  5626. else
  5627. {
  5628. tempIndex = gun_index;
  5629. }
  5630. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5631. {
  5632. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5633. {
  5634. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
  5635. }
  5636. } // END OF FOR CHAdeMO_QUANTITY
  5637. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5638. }
  5639. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5640. {
  5641. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5642. {
  5643. tempIndex = ((gun_index==2) ? 1: 0);
  5644. }
  5645. else
  5646. {
  5647. tempIndex = gun_index;
  5648. }
  5649. for (int index = 0; index < CCS_QUANTITY; index++)
  5650. {
  5651. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5652. {
  5653. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
  5654. }
  5655. } // END OF CCS_QUANTITY
  5656. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5657. }
  5658. else if(gunType[gun_index] == 'G')
  5659. {
  5660. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5661. {
  5662. tempIndex = ((gun_index==2) ? 1: 0);
  5663. }
  5664. else
  5665. {
  5666. tempIndex = gun_index;
  5667. }
  5668. for (int index = 0; index < GB_QUANTITY; index++)
  5669. {
  5670. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5671. {
  5672. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
  5673. }
  5674. } // END OF GB_QUANTITY
  5675. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5676. }
  5677. else if(gunType[gun_index] == 'O')
  5678. {
  5679. tempIndex = gun_index;
  5680. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5681. {
  5682. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5683. {
  5684. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy;
  5685. }
  5686. }
  5687. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5688. }
  5689. else
  5690. {
  5691. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5692. {
  5693. tempIndex = 2;
  5694. }
  5695. else
  5696. {
  5697. tempIndex = gun_index;
  5698. }
  5699. for (int index = 0; index < AC_QUANTITY; index++)
  5700. {
  5701. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5702. {
  5703. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
  5704. }
  5705. }
  5706. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5707. }
  5708. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  5709. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  5710. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5711. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  5712. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5713. //idx_sample=3;
  5714. //********************************(4)Power.Active.Import************************************************/
  5715. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5716. if(gunType[gun_index] == 'J')
  5717. {
  5718. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5719. {
  5720. tempIndex = ((gun_index==2) ? 1: 0);
  5721. }
  5722. else
  5723. {
  5724. tempIndex = gun_index;
  5725. }
  5726. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5727. {
  5728. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5729. {
  5730. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower;
  5731. }
  5732. } // END OF FOR
  5733. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5734. }
  5735. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5736. {
  5737. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5738. {
  5739. tempIndex = ((gun_index==2) ? 1: 0);
  5740. }
  5741. else
  5742. {
  5743. tempIndex = gun_index;
  5744. }
  5745. for (int index = 0; index < CCS_QUANTITY; index++)
  5746. {
  5747. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5748. {
  5749. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower;
  5750. }
  5751. }
  5752. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5753. }
  5754. else if(gunType[gun_index] == 'G')
  5755. {
  5756. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5757. {
  5758. tempIndex = ((gun_index==2) ? 1: 0);
  5759. }
  5760. else
  5761. {
  5762. tempIndex = gun_index;
  5763. }
  5764. for (int index = 0; index < GB_QUANTITY; index++)
  5765. {
  5766. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5767. {
  5768. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5769. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower;
  5770. }
  5771. }
  5772. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5773. }
  5774. else if(gunType[gun_index] == 'O')
  5775. {
  5776. tempIndex = gun_index;
  5777. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5778. {
  5779. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5780. {
  5781. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5782. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower;
  5783. }
  5784. }
  5785. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5786. }
  5787. else
  5788. {
  5789. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5790. {
  5791. tempIndex = 2;
  5792. }
  5793. else
  5794. {
  5795. tempIndex = gun_index;
  5796. }
  5797. for (int index = 0; index < AC_QUANTITY; index++)
  5798. {
  5799. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5800. {
  5801. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower;
  5802. }
  5803. }
  5804. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5805. }
  5806. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  5807. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  5808. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5809. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  5810. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  5811. //idx_sample=4;
  5812. //***********************************************(5)VOLTAGE L1******************************************************/
  5813. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5814. if(gunType[gun_index] == 'J')
  5815. {
  5816. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5817. {
  5818. tempIndex = ((gun_index==2) ? 1: 0);
  5819. }
  5820. else
  5821. {
  5822. tempIndex = gun_index;
  5823. }
  5824. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5825. {
  5826. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5827. {
  5828. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage;
  5829. }
  5830. }
  5831. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5832. }
  5833. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5834. {
  5835. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5836. {
  5837. tempIndex = ((gun_index==2) ? 1: 0);
  5838. }
  5839. else
  5840. {
  5841. tempIndex = gun_index;
  5842. }
  5843. for (int index = 0; index < CCS_QUANTITY; index++)
  5844. {
  5845. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5846. {
  5847. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage;
  5848. }
  5849. }
  5850. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5851. }
  5852. else if(gunType[gun_index] == 'G')
  5853. {
  5854. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5855. {
  5856. tempIndex = ((gun_index==2) ? 1: 0);
  5857. }
  5858. else
  5859. {
  5860. tempIndex = gun_index;
  5861. }
  5862. for (int index = 0; index < GB_QUANTITY; index++)
  5863. {
  5864. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5865. {
  5866. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage;
  5867. }
  5868. }
  5869. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5870. }
  5871. else if(gunType[gun_index] == 'O')
  5872. {
  5873. tempIndex = gun_index;
  5874. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5875. {
  5876. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5877. {
  5878. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage;
  5879. }
  5880. }
  5881. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5882. }
  5883. else
  5884. {
  5885. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5886. {
  5887. tempIndex = 2;
  5888. }
  5889. else
  5890. {
  5891. tempIndex = gun_index;
  5892. }
  5893. for (int index = 0; index < AC_QUANTITY; index++)
  5894. {
  5895. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5896. {
  5897. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage;
  5898. }
  5899. }
  5900. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5901. }
  5902. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  5903. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5904. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5905. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  5906. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  5907. //***********************************************(6)SOC******************************************************/
  5908. if((gunType[gun_index] == 'J')||(gunType[gun_index] == 'U')||(gunType[gun_index] == 'E')||(gunType[gun_index] == 'G'))
  5909. {
  5910. //idx_sample=5;
  5911. //sampledValue = NULL;
  5912. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5913. {
  5914. tempIndex = ((gun_index==2) ? 1: 0);
  5915. }
  5916. else
  5917. {
  5918. tempIndex = gun_index;
  5919. }
  5920. if(gunType[gun_index] == 'J')
  5921. {
  5922. //tempIndex = ((gun_index==2) ? 1: 0);
  5923. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5924. {
  5925. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5926. {
  5927. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  5928. }
  5929. }
  5930. }
  5931. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5932. {
  5933. //tempIndex = ((gun_index==2) ? 1: 0);
  5934. for (int index = 0; index < CCS_QUANTITY; index++)
  5935. {
  5936. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5937. {
  5938. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  5939. }
  5940. }
  5941. }
  5942. else if(gunType[gun_index] == 'G')
  5943. {
  5944. //tempIndex = ((gun_index==2) ? 1: 0);
  5945. for (int index = 0; index < GB_QUANTITY; index++)
  5946. {
  5947. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5948. {
  5949. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  5950. }
  5951. }
  5952. }
  5953. else if(gunType[gun_index] == 'O')
  5954. {
  5955. //tempIndex = ((gun_index==2) ? 1: 0);
  5956. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5957. {
  5958. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5959. {
  5960. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  5961. }
  5962. }
  5963. }
  5964. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  5965. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  5966. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5967. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  5968. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  5969. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  5970. }
  5971. //********************************(7)Current.Import L2************************************************/
  5972. // Only for AC 3 phase
  5973. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5974. {
  5975. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5976. {
  5977. tempIndex = 2;
  5978. }
  5979. else
  5980. {
  5981. tempIndex = gun_index;
  5982. }
  5983. for (int index = 0; index < AC_QUANTITY; index++)
  5984. {
  5985. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5986. {
  5987. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2;
  5988. }
  5989. }
  5990. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5991. }
  5992. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  5993. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5994. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5995. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  5996. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  5997. //********************************(8)Current.Import L3************************************************/
  5998. // Only for AC 3 phase
  5999. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  6000. {
  6001. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6002. {
  6003. tempIndex = 2;
  6004. }
  6005. else
  6006. {
  6007. tempIndex = gun_index;
  6008. }
  6009. for (int index = 0; index < AC_QUANTITY; index++)
  6010. {
  6011. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6012. {
  6013. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3;
  6014. }
  6015. }
  6016. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6017. }
  6018. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  6019. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  6020. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6021. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  6022. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  6023. //***********************************************(9)VOLTAGE L2******************************************************/
  6024. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  6025. {
  6026. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6027. {
  6028. tempIndex = 2;
  6029. }
  6030. else
  6031. {
  6032. tempIndex = gun_index;
  6033. }
  6034. for (int index = 0; index < AC_QUANTITY; index++)
  6035. {
  6036. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6037. {
  6038. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2;
  6039. }
  6040. }
  6041. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  6042. }
  6043. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  6044. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  6045. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6046. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  6047. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  6048. //***********************************************(10)VOLTAGE L3******************************************************/
  6049. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  6050. {
  6051. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6052. {
  6053. tempIndex = 2;
  6054. }
  6055. else
  6056. {
  6057. tempIndex = gun_index;
  6058. }
  6059. for (int index = 0; index < AC_QUANTITY; index++)
  6060. {
  6061. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6062. {
  6063. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3;
  6064. }
  6065. }
  6066. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  6067. }
  6068. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  6069. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  6070. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  6071. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  6072. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  6073. // Message create ====================================================================================================
  6074. random_uuid(guid);
  6075. for(uint8_t idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue);idxMeter++)
  6076. {
  6077. json_object *meterValue = json_object_new_object();
  6078. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  6079. {
  6080. if(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value > 0)
  6081. {
  6082. json_object *sampledValue = json_object_new_object();
  6083. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  6084. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  6085. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  6086. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  6087. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  6088. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  6089. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  6090. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  6091. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  6092. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  6093. {
  6094. json_object *unitOfMeasure = json_object_new_object();
  6095. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  6096. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  6097. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  6098. }
  6099. json_object_array_add(sampledValues, sampledValue);
  6100. }
  6101. }
  6102. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  6103. json_object_object_add(meterValue, "sampledValue", sampledValues);
  6104. json_object_array_add(meterValues, meterValue);
  6105. idxMeter++;
  6106. }
  6107. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  6108. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  6109. sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",%s]"
  6110. ,gun_index + 1
  6111. ,MESSAGE_TYPE_CALL
  6112. ,guid
  6113. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  6114. json_object_put(MeterValueReq);
  6115. if((strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]) == 0) ||
  6116. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]) == 0) ||
  6117. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]) == 0))
  6118. {
  6119. // Transaction meter value send by TransactionEvent message
  6120. memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
  6121. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  6122. result = PASS;
  6123. }
  6124. else
  6125. {
  6126. // Put request guid to hash map
  6127. sprintf(tempdata, "MeterValues,%d", (gun_index));
  6128. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6129. {
  6130. result = PASS;
  6131. }
  6132. if((dataType != ReadingContextEnumType_Trigger) &&
  6133. (dataType != ReadingContextEnumType_Sample_Clock))
  6134. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  6135. else
  6136. {
  6137. if(FirstHeartBeat)
  6138. LWS_Send(queuedata +2);
  6139. }
  6140. }
  6141. return result;
  6142. }
  6143. int sendNotifyChargingLimitRequest(int gun_index)
  6144. {
  6145. mtrace();
  6146. int result = FAIL;
  6147. char message[4096]={0};
  6148. char guid[37]={0};
  6149. char tempdata[128]={0};
  6150. json_object *NotifyChargingLimit = json_object_new_object();
  6151. json_object *chargingLimit = json_object_new_object();
  6152. DEBUG_INFO("sendNotifyChargingLimitRequest...\n");
  6153. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  6154. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  6155. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  6156. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  6157. random_uuid(guid);
  6158. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  6159. json_object_put(NotifyChargingLimit);
  6160. LWS_Send(message);
  6161. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  6162. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6163. {
  6164. result = PASS;
  6165. }
  6166. return result;
  6167. }
  6168. int sendNotifyCustomerInformationRequest()
  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 *NotifyCustomerInformation = json_object_new_object();
  6176. DEBUG_INFO("sendNotifyCustomerInformationRequest...\n");
  6177. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  6178. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  6179. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  6180. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  6181. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  6182. random_uuid(guid);
  6183. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  6184. json_object_put(NotifyCustomerInformation);
  6185. LWS_Send(message);
  6186. sprintf(tempdata, "NotifyCustomerInformation,0");
  6187. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6188. {
  6189. result = PASS;
  6190. }
  6191. return result;
  6192. }
  6193. int sendNotifyDisplayMessagesRequest()
  6194. {
  6195. mtrace();
  6196. int result = FAIL;
  6197. char message[4096]={0};
  6198. char guid[37]={0};
  6199. char tempdata[128]={0};
  6200. json_object *NotifyDisplayMessages = json_object_new_object();
  6201. json_object *messageInfos = json_object_new_array();
  6202. DEBUG_INFO("sendNotifyDisplayMessagesRequest...\n");
  6203. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  6204. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  6205. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  6206. {
  6207. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  6208. {
  6209. json_object *messageInfo = json_object_new_object();
  6210. json_object *message = json_object_new_object();
  6211. json_object *display = json_object_new_object();
  6212. json_object *evse = json_object_new_object();
  6213. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  6214. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  6215. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  6216. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  6217. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  6218. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  6219. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  6220. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  6221. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  6222. json_object_object_add(messageInfo, "message", message);
  6223. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  6224. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  6225. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  6226. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  6227. json_object_object_add(display, "evse",evse);
  6228. json_object_object_add(messageInfo, "evse", display);
  6229. json_object_array_add(messageInfos, messageInfo);
  6230. }
  6231. }
  6232. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  6233. random_uuid(guid);
  6234. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  6235. json_object_put(NotifyDisplayMessages);
  6236. LWS_Send(message);
  6237. sprintf(tempdata, "NotifyDisplayMessages,0");
  6238. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6239. {
  6240. result = PASS;
  6241. }
  6242. return result;
  6243. }
  6244. int sendNotifyEVChargingNeedsRequest(int gun_index)
  6245. {
  6246. mtrace();
  6247. int result = FAIL;
  6248. char message[4096]={0};
  6249. char guid[37]={0};
  6250. char tempdata[128]={0};
  6251. json_object *NotifyEVChargingNeeds = json_object_new_object();
  6252. json_object *chargingNeeds = json_object_new_object();
  6253. json_object *acChargingParameters = json_object_new_object();
  6254. json_object *dcChargingParameters = json_object_new_object();
  6255. DEBUG_INFO("sendNotifyEVChargingNeedsRequest...\n");
  6256. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  6257. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  6258. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  6259. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  6260. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  6261. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  6262. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  6263. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  6264. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  6265. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  6266. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  6267. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  6268. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  6269. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  6270. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  6271. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  6272. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  6273. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  6274. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  6275. random_uuid(guid);
  6276. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  6277. json_object_put(NotifyEVChargingNeeds);
  6278. LWS_Send(message);
  6279. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  6280. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6281. {
  6282. result = PASS;
  6283. }
  6284. return result;
  6285. }
  6286. int sendNotifyEVChargingScheduleRequest(int gun_index)
  6287. {
  6288. mtrace();
  6289. int result = FAIL;
  6290. char message[4096]={0};
  6291. char guid[37]={0};
  6292. char tempdata[128]={0};
  6293. json_object *NotifyEVChargingSchedule = json_object_new_object();
  6294. json_object *chargingSchedule = json_object_new_object();
  6295. json_object *periods = json_object_new_array();
  6296. DEBUG_INFO("sendNotifyEVChargingScheduleRequest...\n");
  6297. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  6298. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  6299. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  6300. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  6301. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  6302. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  6303. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  6304. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  6305. {
  6306. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  6307. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  6308. {
  6309. json_object *Period = json_object_new_object();
  6310. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  6311. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  6312. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  6313. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  6314. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  6315. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  6316. json_object_array_add(periods, Period);
  6317. }
  6318. }
  6319. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  6320. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  6321. random_uuid(guid);
  6322. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  6323. json_object_put(NotifyEVChargingSchedule);
  6324. LWS_Send(message);
  6325. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  6326. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6327. {
  6328. result = PASS;
  6329. }
  6330. return result;
  6331. }
  6332. int sendNotifyEventRequest()
  6333. {
  6334. mtrace();
  6335. int result = FAIL;
  6336. char message[4096]={0};
  6337. char guid[37]={0};
  6338. char tempdata[128]={0};
  6339. json_object *NotifyEvent = json_object_new_object();
  6340. json_object *eventDatas = json_object_new_array();
  6341. DEBUG_INFO("sendNotifyEventRequest...\n");
  6342. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  6343. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  6344. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  6345. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  6346. {
  6347. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  6348. {
  6349. json_object *eventData = json_object_new_object();
  6350. json_object *component = json_object_new_object();
  6351. json_object *evse = json_object_new_object();
  6352. json_object *variable = json_object_new_object();
  6353. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  6354. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  6355. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  6356. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  6357. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  6358. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  6359. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  6360. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  6361. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  6362. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  6363. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  6364. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  6365. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  6366. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  6367. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  6368. json_object_object_add(component, "evse",evse);
  6369. json_object_object_add(eventData, "component", component);
  6370. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  6371. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  6372. json_object_object_add(eventData, "variable", variable);
  6373. json_object_array_add(eventDatas, eventData);
  6374. }
  6375. }
  6376. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  6377. random_uuid(guid);
  6378. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  6379. json_object_put(NotifyEvent);
  6380. LWS_Send(message);
  6381. sprintf(tempdata, "NotifyEvent,0");
  6382. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6383. {
  6384. result = PASS;
  6385. }
  6386. return result;
  6387. }
  6388. int sendNotifyMonitoringReportRequest()
  6389. {
  6390. mtrace();
  6391. int result = FAIL;
  6392. char message[4096]={0};
  6393. char guid[37]={0};
  6394. char tempdata[128]={0};
  6395. json_object *NotifyMonitoringReport = json_object_new_object();
  6396. json_object *monitors = json_object_new_array();
  6397. DEBUG_INFO("sendNotifyMonitoringReportRequest...\n");
  6398. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  6399. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  6400. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  6401. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  6402. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  6403. {
  6404. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  6405. {
  6406. json_object *monitor = json_object_new_object();
  6407. json_object *component = json_object_new_object();
  6408. json_object *evse = json_object_new_object();
  6409. json_object *variable = json_object_new_object();
  6410. json_object *variableMonitorings = json_object_new_array();
  6411. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  6412. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  6413. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  6414. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  6415. json_object_object_add(component, "evse",evse);
  6416. json_object_object_add(monitor, "component", component);
  6417. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  6418. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  6419. json_object_object_add(monitor, "variable", variable);
  6420. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  6421. {
  6422. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  6423. {
  6424. json_object *variableMonitoring = json_object_new_object();
  6425. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  6426. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  6427. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  6428. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  6429. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  6430. json_object_array_add(variableMonitorings, variableMonitoring);
  6431. }
  6432. }
  6433. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  6434. json_object_array_add(monitors, monitor);
  6435. }
  6436. }
  6437. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  6438. random_uuid(guid);
  6439. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  6440. json_object_put(NotifyMonitoringReport);
  6441. LWS_Send(message);
  6442. sprintf(tempdata, "NotifyMonitoringReport,0");
  6443. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6444. {
  6445. result = PASS;
  6446. }
  6447. return result;
  6448. }
  6449. int sendNotifyReportRequest()
  6450. {
  6451. mtrace();
  6452. int result = FAIL;
  6453. char message[4096]={0};
  6454. char guid[37]={0};
  6455. char tempdata[128]={0};
  6456. json_object *NotifyReport = json_object_new_object();
  6457. json_object *reportDatas = json_object_new_array();
  6458. DEBUG_INFO("sendNotifyReportRequest...\n");
  6459. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  6460. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  6461. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  6462. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  6463. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  6464. {
  6465. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  6466. {
  6467. json_object *reportData = json_object_new_object();
  6468. json_object *component = json_object_new_object();
  6469. json_object *evse = json_object_new_object();
  6470. json_object *variable = json_object_new_object();
  6471. json_object *variableAttributes = json_object_new_array();
  6472. json_object *variableCharacteristics = json_object_new_object();
  6473. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  6474. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  6475. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  6476. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  6477. json_object_object_add(component, "evse",evse);
  6478. json_object_object_add(reportData, "component", component);
  6479. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  6480. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  6481. json_object_object_add(reportData, "variable",variable);
  6482. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  6483. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  6484. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  6485. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  6486. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  6487. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  6488. {
  6489. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  6490. {
  6491. json_object *variableAttribute = json_object_new_object();
  6492. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  6493. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  6494. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  6495. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  6496. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  6497. json_object_array_add(variableAttributes, variableAttribute);
  6498. }
  6499. }
  6500. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  6501. json_object_array_add(reportDatas, reportData);
  6502. }
  6503. }
  6504. json_object_object_add(NotifyReport, "reportData", reportDatas);
  6505. random_uuid(guid);
  6506. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  6507. json_object_put(NotifyReport);
  6508. LWS_SendNow(message);
  6509. sprintf(tempdata, "NotifyReport,0");
  6510. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6511. {
  6512. result = PASS;
  6513. }
  6514. return result;
  6515. }
  6516. int sendPublishFirmwareStatusNotificationRequest()
  6517. {
  6518. mtrace();
  6519. int result = FAIL;
  6520. char message[4096]={0};
  6521. char guid[37]={0};
  6522. char tempdata[128]={0};
  6523. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  6524. json_object *locations = json_object_new_array();
  6525. DEBUG_INFO("sendPublishFirmwareStatusNotificationRequest...\n");
  6526. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  6527. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  6528. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  6529. {
  6530. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  6531. }
  6532. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  6533. random_uuid(guid);
  6534. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  6535. json_object_put(PublishFirmwareStatusNotification);
  6536. LWS_Send(message);
  6537. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  6538. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6539. {
  6540. result = PASS;
  6541. }
  6542. return result;
  6543. }
  6544. int sendReportChargingProfilesRequest(int gun_index)
  6545. {
  6546. mtrace();
  6547. int result = FAIL;
  6548. char message[4096]={0};
  6549. char guid[37]={0};
  6550. char tempdata[128]={0};
  6551. json_object *ReportChargingProfiles = json_object_new_object();
  6552. json_object *chargingProfiles = json_object_new_array();
  6553. DEBUG_INFO("sendReportChargingProfilesRequest...\n");
  6554. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  6555. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  6556. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  6557. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  6558. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  6559. {
  6560. json_object *chargingProfile = json_object_new_object();
  6561. json_object *chargingSchedules = json_object_new_array();
  6562. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  6563. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  6564. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  6565. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  6566. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  6567. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  6568. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  6569. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  6570. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  6571. {
  6572. json_object *chargingSchedule = json_object_new_object();
  6573. json_object *chargingSchedulePeriods = json_object_new_array();
  6574. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  6575. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  6576. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  6577. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  6578. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  6579. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  6580. {
  6581. json_object *chargingSchedulePeriod = json_object_new_object();
  6582. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  6583. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  6584. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  6585. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  6586. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  6587. }
  6588. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  6589. json_object_array_add(chargingSchedules, chargingSchedule);
  6590. }
  6591. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  6592. json_object_array_add(chargingProfiles, chargingProfile);
  6593. }
  6594. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  6595. random_uuid(guid);
  6596. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  6597. json_object_put(ReportChargingProfiles);
  6598. LWS_Send(message);
  6599. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  6600. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6601. {
  6602. result = PASS;
  6603. }
  6604. return result;
  6605. }
  6606. int sendReservationStatusUpdateRequest(int gun_index)
  6607. {
  6608. mtrace();
  6609. int result = FAIL;
  6610. char message[4096]={0};
  6611. char guid[37]={0};
  6612. char tempdata[128]={0};
  6613. json_object *ReservationStatusUpdate = json_object_new_object();
  6614. DEBUG_INFO("sendReservationStatusUpdateRequest...\n");
  6615. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  6616. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  6617. random_uuid(guid);
  6618. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  6619. json_object_put(ReservationStatusUpdate);
  6620. LWS_Send(message);
  6621. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  6622. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6623. {
  6624. result = PASS;
  6625. }
  6626. return result;
  6627. }
  6628. int sendSecurityEventNotificationRequest()
  6629. {
  6630. mtrace();
  6631. int result = FAIL;
  6632. char message[4096]={0};
  6633. char guid[37]={0};
  6634. char tempdata[128]={0};
  6635. json_object *SecurityEventNotification = json_object_new_object();
  6636. DEBUG_INFO("sendSecurityEventNotificationRequest...\n");
  6637. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  6638. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  6639. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techinfo));
  6640. random_uuid(guid);
  6641. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  6642. json_object_put(SecurityEventNotification);
  6643. LWS_Send(message);
  6644. sprintf(tempdata, "SecurityEventNotification,0");
  6645. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6646. {
  6647. result = PASS;
  6648. }
  6649. return result;
  6650. }
  6651. int sendSignCertificateRequest()
  6652. {
  6653. mtrace();
  6654. int result = FAIL;
  6655. char message[4096]={0};
  6656. char guid[37]={0};
  6657. char tempdata[128]={0};
  6658. json_object *SignCertificate = json_object_new_object();
  6659. DEBUG_INFO("sendSignCertificateRequest...\n");
  6660. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  6661. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  6662. random_uuid(guid);
  6663. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  6664. json_object_put(SignCertificate);
  6665. LWS_Send(message);
  6666. sprintf(tempdata, "SignCertificate,0");
  6667. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6668. {
  6669. result = PASS;
  6670. }
  6671. return result;
  6672. }
  6673. int sendStatusNotificationRequest(int gun_index)
  6674. {
  6675. mtrace();
  6676. int result = FAIL;
  6677. char message[600]={0};
  6678. char guid[37];
  6679. int currentStatus = 0;
  6680. struct timeval tmnow;
  6681. struct tm *tm;
  6682. char buf[28];//, usec_buf[6];
  6683. char tempdata[65]={0};
  6684. int tempIndex = 0;
  6685. DEBUG_INFO("sendStatusNotificationRequest...\n");
  6686. gettimeofday(&tmnow, NULL);
  6687. time_t t;
  6688. t = time(NULL);
  6689. /*UTC time and date*/
  6690. tm = gmtime(&t);
  6691. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  6692. #if 0 // remove temporally
  6693. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  6694. strcat(buf,".");
  6695. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  6696. strcat(buf,usec_buf);
  6697. #endif
  6698. printf("%s",buf);
  6699. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  6700. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  6701. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  6702. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  6703. /*
  6704. enum _SYSTEM_STATUS
  6705. {
  6706. S_BOOTING = 0,
  6707. S_IDLE, = 1
  6708. S_AUTHORIZING, =2
  6709. S_REASSIGN_CHECK, =3
  6710. S_REASSIGN, =4
  6711. S_PRECHARGE, =5
  6712. S_PREPARING_FOR_EV, =6
  6713. S_PREPARING_FOR_EVSE, =7
  6714. S_CHARGING, =8
  6715. S_TERMINATING, =9
  6716. S_COMPLETE, =10
  6717. S_ALARM, =11
  6718. S_FAULT =12
  6719. }
  6720. */
  6721. //check Transaction active
  6722. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  6723. if(gunType[gun_index] == 'J')
  6724. {
  6725. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6726. {
  6727. tempIndex = ((gun_index==2) ? 1: 0);
  6728. }
  6729. else
  6730. {
  6731. tempIndex = gun_index;
  6732. }
  6733. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6734. {
  6735. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6736. {
  6737. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6738. {
  6739. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6740. {
  6741. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6742. }
  6743. else
  6744. {
  6745. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6746. }
  6747. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6748. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6749. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6750. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6751. }
  6752. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6753. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6754. ) //S_PRECHARGE
  6755. {
  6756. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6757. }
  6758. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6759. {
  6760. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6761. }
  6762. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6763. {
  6764. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6765. }
  6766. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6767. {
  6768. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6769. }
  6770. 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
  6771. {
  6772. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6773. }
  6774. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6775. {
  6776. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6777. }
  6778. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6779. {
  6780. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6781. }
  6782. } //end of the same index
  6783. }//end of for CHAdeMO_QUANTITY
  6784. }
  6785. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  6786. {
  6787. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6788. {
  6789. tempIndex = ((gun_index==2) ? 1: 0);
  6790. }
  6791. else
  6792. {
  6793. tempIndex = gun_index;
  6794. }
  6795. for (int index = 0; index < CCS_QUANTITY; index++)
  6796. {
  6797. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6798. {
  6799. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6800. {
  6801. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  6802. {
  6803. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6804. }
  6805. else
  6806. {
  6807. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6808. }
  6809. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6810. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6811. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6812. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6813. }
  6814. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6815. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6816. ) //S_PRECHARGE
  6817. {
  6818. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6819. }
  6820. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6821. {
  6822. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6823. }
  6824. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6825. {
  6826. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6827. }
  6828. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  6829. {
  6830. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6831. }
  6832. 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
  6833. {
  6834. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  6835. }
  6836. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6837. {
  6838. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6839. }
  6840. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6841. {
  6842. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6843. }
  6844. } //end of the same index
  6845. } // end of for CCS_QUANTITY
  6846. }
  6847. else if(gunType[gun_index] == 'G')
  6848. {
  6849. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6850. {
  6851. tempIndex = ((gun_index==2) ? 1: 0);
  6852. }
  6853. else
  6854. {
  6855. tempIndex = gun_index;
  6856. }
  6857. for (int index = 0; index < GB_QUANTITY; index++)
  6858. {
  6859. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6860. {
  6861. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6862. {
  6863. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6864. {
  6865. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6866. }
  6867. else
  6868. {
  6869. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6870. }
  6871. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6872. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6873. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6874. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6875. }
  6876. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6877. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6878. ) //S_PRECHARGE
  6879. {
  6880. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6881. }
  6882. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6883. {
  6884. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6885. }
  6886. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6887. {
  6888. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6889. }
  6890. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6891. {
  6892. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6893. }
  6894. 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
  6895. {
  6896. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6897. }
  6898. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6899. {
  6900. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6901. }
  6902. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6903. {
  6904. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6905. }
  6906. } //end of the same index
  6907. } // end of for GB_QUANTITY
  6908. }
  6909. else if(gunType[gun_index] == 'O')
  6910. {
  6911. tempIndex = gun_index;
  6912. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6913. {
  6914. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6915. {
  6916. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6917. {
  6918. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6919. {
  6920. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6921. }
  6922. else
  6923. {
  6924. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6925. }
  6926. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6927. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6928. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6929. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6930. }
  6931. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6932. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6933. ) //S_PRECHARGE
  6934. {
  6935. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6936. }
  6937. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6938. {
  6939. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6940. }
  6941. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6942. {
  6943. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6944. }
  6945. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6946. {
  6947. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6948. }
  6949. 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
  6950. {
  6951. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6952. }
  6953. 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
  6954. {
  6955. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6956. }
  6957. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6958. {
  6959. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6960. }
  6961. } //end of the same index
  6962. }
  6963. }
  6964. else
  6965. {
  6966. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6967. {
  6968. tempIndex = 2;
  6969. }
  6970. else
  6971. {
  6972. tempIndex = gun_index;
  6973. }
  6974. for (int index = 0; index < AC_QUANTITY; index++)
  6975. {
  6976. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6977. {
  6978. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  6979. {
  6980. 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))
  6981. {
  6982. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6983. }
  6984. else
  6985. {
  6986. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6987. }
  6988. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6989. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6990. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6991. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6992. }
  6993. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  6994. {
  6995. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6996. }
  6997. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  6998. {
  6999. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  7000. }
  7001. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  7002. {
  7003. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  7004. }
  7005. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7006. {
  7007. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  7008. }
  7009. 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
  7010. {
  7011. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  7012. }
  7013. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7014. {
  7015. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  7016. }
  7017. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7018. {
  7019. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  7020. }
  7021. }//end of the same index
  7022. }//end of for AC_QUANTITY
  7023. }
  7024. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  7025. random_uuid(guid);
  7026. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  7027. , MESSAGE_TYPE_CALL
  7028. , guid
  7029. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  7030. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  7031. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  7032. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  7033. if((server_sign == TRUE))
  7034. {
  7035. LWS_Send(message);
  7036. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  7037. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7038. {
  7039. result = PASS;
  7040. }
  7041. }
  7042. else
  7043. {
  7044. result = PASS;
  7045. }
  7046. return result;
  7047. }
  7048. int sendTransactionEventRequest(int gun_index)
  7049. {
  7050. mtrace();
  7051. int result = FAIL;
  7052. char message[1024*20]={0};
  7053. char guid[37]={0};
  7054. char tempdata[128]={0};
  7055. uint8_t tempIndex;
  7056. json_object *TransactionEvent = json_object_new_object();
  7057. json_object *transactionInfo = json_object_new_object();
  7058. json_object *idToken = json_object_new_object();
  7059. json_object *evse = json_object_new_object();
  7060. json_object *meterValues = json_object_new_array();
  7061. DEBUG_INFO("sendTransactionEventRequest...\n");
  7062. if(gunType[gun_index] == 'J')
  7063. {
  7064. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7065. {
  7066. tempIndex = ((gun_index==2) ? 1: 0);
  7067. }
  7068. else
  7069. {
  7070. tempIndex = gun_index;
  7071. }
  7072. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7073. {
  7074. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  7075. {
  7076. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7077. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7078. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7079. else
  7080. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7081. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7082. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7083. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7084. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  7085. {
  7086. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7087. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7088. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7089. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7090. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7091. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7092. {
  7093. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7094. }
  7095. else
  7096. {
  7097. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7098. }
  7099. }
  7100. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7101. {
  7102. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7103. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7104. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7105. }
  7106. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7107. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7108. ) //S_PRECHARGE
  7109. {
  7110. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7111. {
  7112. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7113. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  7114. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7115. }
  7116. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7117. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7118. else
  7119. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7120. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7121. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7122. }
  7123. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7124. {
  7125. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7126. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7127. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7128. }
  7129. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7130. {
  7131. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7132. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7133. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7134. }
  7135. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7136. {
  7137. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7138. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7139. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7140. }
  7141. 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
  7142. {
  7143. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7144. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7145. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7146. }
  7147. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7148. {
  7149. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7150. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7151. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7152. }
  7153. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7154. {
  7155. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7156. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7157. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7158. }
  7159. } //end of the same index
  7160. }//end of for CHAdeMO_QUANTITY
  7161. }
  7162. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  7163. {
  7164. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7165. {
  7166. tempIndex = ((gun_index==2) ? 1: 0);
  7167. }
  7168. else
  7169. {
  7170. tempIndex = gun_index;
  7171. }
  7172. for (int index = 0; index < CCS_QUANTITY; index++)
  7173. {
  7174. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7175. {
  7176. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7177. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7178. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7179. else
  7180. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7181. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7182. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7183. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7184. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7185. {
  7186. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7187. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7188. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7189. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7190. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7191. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7192. {
  7193. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7194. }
  7195. else
  7196. {
  7197. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7198. }
  7199. }
  7200. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7201. {
  7202. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7203. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7204. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7205. }
  7206. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7207. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7208. ) //S_PRECHARGE
  7209. {
  7210. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7211. {
  7212. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7213. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  7214. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7215. }
  7216. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7217. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7218. else
  7219. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7220. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7221. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7222. }
  7223. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7224. {
  7225. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7226. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7227. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7228. }
  7229. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7230. {
  7231. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7232. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7233. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7234. }
  7235. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7236. {
  7237. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7238. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7239. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7240. }
  7241. 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
  7242. {
  7243. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7244. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7245. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7246. }
  7247. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7248. {
  7249. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7250. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7251. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7252. }
  7253. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7254. {
  7255. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7256. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7257. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7258. }
  7259. } //end of the same index
  7260. } // end of for CCS_QUANTITY
  7261. }
  7262. else if(gunType[gun_index] == 'G')
  7263. {
  7264. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7265. {
  7266. tempIndex = ((gun_index==2) ? 1: 0);
  7267. }
  7268. else
  7269. {
  7270. tempIndex = gun_index;
  7271. }
  7272. for (int index = 0; index < GB_QUANTITY; index++)
  7273. {
  7274. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7275. {
  7276. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7277. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7278. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7279. else
  7280. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7281. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7282. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7283. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7284. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7285. {
  7286. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7287. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7288. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7289. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7290. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7291. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7292. {
  7293. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7294. }
  7295. else
  7296. {
  7297. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7298. }
  7299. }
  7300. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7301. {
  7302. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7303. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7304. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7305. }
  7306. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7307. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7308. ) //S_PRECHARGE
  7309. {
  7310. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7311. {
  7312. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7313. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  7314. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7315. }
  7316. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7317. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7318. else
  7319. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7320. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7321. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7322. }
  7323. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7324. {
  7325. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7326. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7327. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7328. }
  7329. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7330. {
  7331. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7332. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7333. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7334. }
  7335. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7336. {
  7337. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7338. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7339. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7340. }
  7341. 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
  7342. {
  7343. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7344. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7345. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7346. }
  7347. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7348. {
  7349. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7350. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7351. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7352. }
  7353. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7354. {
  7355. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7356. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7357. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7358. }
  7359. } //end of the same index
  7360. } // end of for GB_QUANTITY
  7361. }
  7362. else if(gunType[gun_index] == 'O')
  7363. {
  7364. tempIndex = gun_index;
  7365. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7366. {
  7367. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7368. {
  7369. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7370. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7371. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7372. else
  7373. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7374. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7375. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7376. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7377. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7378. {
  7379. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7380. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7381. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7382. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7383. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7384. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7385. {
  7386. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7387. }
  7388. else
  7389. {
  7390. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7391. }
  7392. }
  7393. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7394. {
  7395. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7396. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7397. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7398. }
  7399. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7400. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7401. ) //S_PRECHARGE
  7402. {
  7403. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7404. {
  7405. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7406. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  7407. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7408. }
  7409. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7410. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7411. else
  7412. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7413. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7414. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7415. }
  7416. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7417. {
  7418. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7419. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7420. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7421. }
  7422. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7423. {
  7424. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7425. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7426. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7427. }
  7428. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7429. {
  7430. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7431. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7432. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7433. }
  7434. 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
  7435. {
  7436. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7437. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7438. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7439. }
  7440. 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
  7441. {
  7442. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7443. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7444. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7445. }
  7446. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7447. {
  7448. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7449. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7450. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7451. }
  7452. } //end of the same index
  7453. }
  7454. }
  7455. else
  7456. {
  7457. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7458. {
  7459. tempIndex = 2;
  7460. }
  7461. else
  7462. {
  7463. tempIndex = gun_index;
  7464. }
  7465. for (int index = 0; index < AC_QUANTITY; index++)
  7466. {
  7467. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7468. {
  7469. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7470. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7471. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7472. else
  7473. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7474. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7475. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7476. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7477. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  7478. {
  7479. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7480. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7481. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7482. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7483. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7484. 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))
  7485. {
  7486. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7487. }
  7488. else
  7489. {
  7490. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7491. }
  7492. }
  7493. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7494. {
  7495. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7496. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7497. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7498. }
  7499. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7500. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7501. ) //S_PRECHARGE
  7502. {
  7503. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7504. {
  7505. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7506. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  7507. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7508. }
  7509. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7510. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7511. else
  7512. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7513. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7514. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7515. }
  7516. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7517. {
  7518. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7519. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7520. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7521. }
  7522. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7523. {
  7524. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7525. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7526. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7527. }
  7528. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7529. {
  7530. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7531. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7532. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7533. }
  7534. 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
  7535. {
  7536. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7537. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7538. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7539. }
  7540. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7541. {
  7542. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7543. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7544. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7545. }
  7546. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7547. {
  7548. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7549. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7550. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7551. }
  7552. }//end of the same index
  7553. }//end of for AC_QUANTITY
  7554. }
  7555. // Message
  7556. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7557. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  7558. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  7559. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  7560. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  7561. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  7562. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  7563. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  7564. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  7565. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  7566. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  7567. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  7568. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  7569. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  7570. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  7571. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  7572. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  7573. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  7574. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  7575. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  7576. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  7577. {
  7578. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  7579. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  7580. json_object_object_add(TransactionEvent, "idToken", idToken);
  7581. }
  7582. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  7583. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  7584. json_object_object_add(TransactionEvent, "evse", evse);
  7585. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  7586. {
  7587. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  7588. {
  7589. json_object *meterValue = json_object_new_object();
  7590. json_object *sampledValues = json_object_new_array();
  7591. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  7592. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  7593. {
  7594. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  7595. ((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) == 0)))
  7596. {
  7597. json_object *sampledValue = json_object_new_object();
  7598. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  7599. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7600. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  7601. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  7602. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  7603. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  7604. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  7605. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  7606. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  7607. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  7608. {
  7609. json_object *unitOfMeasure = json_object_new_object();
  7610. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  7611. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  7612. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  7613. }
  7614. json_object_array_add(sampledValues, sampledValue);
  7615. }
  7616. }
  7617. json_object_object_add(meterValue, "sampledValue", sampledValues);
  7618. json_object_array_add(meterValues, meterValue);
  7619. }
  7620. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  7621. }
  7622. random_uuid(guid);
  7623. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  7624. json_object_put(TransactionEvent);
  7625. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  7626. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7627. {
  7628. result = PASS;
  7629. }
  7630. queue_operation(QUEUE_OPERATION_ADD, guid, message);
  7631. return result;
  7632. }
  7633. //==========================================
  7634. // send confirm routine
  7635. //==========================================
  7636. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  7637. {
  7638. mtrace();
  7639. int result = FAIL;
  7640. char message[4096]={0};
  7641. json_object *CancelReservation = json_object_new_object();
  7642. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  7643. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  7644. sprintf(message,"[%d,\"%s\",%s]"
  7645. ,MESSAGE_TYPE_CALLRESULT
  7646. ,uuid
  7647. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  7648. json_object_put(CancelReservation);
  7649. ShmOCPP20Data->CsMsg.bits[0].CancelReservationConf = OFF;
  7650. LWS_Send(message);
  7651. result = TRUE;
  7652. return result;
  7653. }
  7654. int sendCertificateSignedConfirmation(char *uuid)
  7655. {
  7656. mtrace();
  7657. int result = FAIL;
  7658. char message[4096]={0};
  7659. json_object *CertificateSigned = json_object_new_object();
  7660. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  7661. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  7662. sprintf(message,"[%d,\"%s\",%s]"
  7663. ,MESSAGE_TYPE_CALLRESULT
  7664. ,uuid
  7665. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  7666. json_object_put(CertificateSigned);
  7667. LWS_Send(message);
  7668. result = TRUE;
  7669. return result;
  7670. }
  7671. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  7672. {
  7673. mtrace();
  7674. int result = FAIL;
  7675. char message[4096]={0};
  7676. json_object *ChangeAvailability = json_object_new_object();
  7677. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  7678. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  7679. sprintf(message,"[%d,\"%s\",%s]"
  7680. ,MESSAGE_TYPE_CALLRESULT
  7681. ,uuid
  7682. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  7683. json_object_put(ChangeAvailability);
  7684. LWS_Send(message);
  7685. result = TRUE;
  7686. return result;
  7687. }
  7688. int sendClearCacheConfirmation(char *uuid)
  7689. {
  7690. mtrace();
  7691. int result = FAIL;
  7692. char message[4096]={0};
  7693. json_object *ClearCache = json_object_new_object();
  7694. DEBUG_INFO("sendClearCacheConfirmation...\n");
  7695. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  7696. sprintf(message,"[%d,\"%s\",%s]"
  7697. ,MESSAGE_TYPE_CALLRESULT
  7698. ,uuid
  7699. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  7700. json_object_put(ClearCache);
  7701. LWS_Send(message);
  7702. result = TRUE;
  7703. return result;
  7704. }
  7705. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  7706. {
  7707. mtrace();
  7708. int result = FAIL;
  7709. char message[500]={0};
  7710. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  7711. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  7712. LWS_Send(message);
  7713. return result;
  7714. }
  7715. int sendClearDisplayMessageConfirmation(char *uuid)
  7716. {
  7717. mtrace();
  7718. int result = FAIL;
  7719. char message[4096]={0};
  7720. json_object *ClearDisplayMessage = json_object_new_object();
  7721. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  7722. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  7723. sprintf(message,"[%d,\"%s\",%s]"
  7724. ,MESSAGE_TYPE_CALLRESULT
  7725. ,uuid
  7726. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  7727. json_object_put(ClearDisplayMessage);
  7728. LWS_Send(message);
  7729. result = TRUE;
  7730. return result;
  7731. }
  7732. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  7733. {
  7734. mtrace();
  7735. int result = FAIL;
  7736. char message[4096]={0};
  7737. json_object *ClearVariableMonitoring = json_object_new_object();
  7738. json_object *clearMonitoringResults = json_object_new_array();
  7739. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  7740. for(int idx=0;idx<variableQuantity;idx++)
  7741. {
  7742. json_object *clearMonitoringResult = json_object_new_object();
  7743. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  7744. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  7745. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  7746. }
  7747. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  7748. sprintf(message,"[%d,\"%s\",%s]"
  7749. ,MESSAGE_TYPE_CALLRESULT
  7750. ,uuid
  7751. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  7752. json_object_put(ClearVariableMonitoring);
  7753. LWS_Send(message);
  7754. result = TRUE;
  7755. return result;
  7756. }
  7757. int sendCostUpdatedConfirmation(char *uuid)
  7758. {
  7759. mtrace();
  7760. int result = FAIL;
  7761. char message[4096]={0};
  7762. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  7763. sprintf(message,"[%d,\"%s\",{}]"
  7764. ,MESSAGE_TYPE_CALLRESULT
  7765. ,uuid);
  7766. LWS_Send(message);
  7767. result = TRUE;
  7768. return result;
  7769. }
  7770. int sendCustomerInformationConfirmation(char *uuid)
  7771. {
  7772. mtrace();
  7773. int result = FAIL;
  7774. char message[4096]={0};
  7775. json_object *CustomerInformation = json_object_new_object();
  7776. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  7777. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  7778. sprintf(message,"[%d,\"%s\",%s]"
  7779. ,MESSAGE_TYPE_CALLRESULT
  7780. ,uuid
  7781. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  7782. json_object_put(CustomerInformation);
  7783. LWS_Send(message);
  7784. result = TRUE;
  7785. return result;
  7786. }
  7787. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  7788. {
  7789. mtrace();
  7790. int result = FAIL;
  7791. char message[4096]={0};
  7792. json_object *DataTransfer = json_object_new_object();
  7793. DEBUG_INFO("sendDataTransferConfirmation...\n");
  7794. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  7795. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  7796. sprintf(message,"[%d,\"%s\",%s]"
  7797. ,MESSAGE_TYPE_CALLRESULT
  7798. ,uuid
  7799. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  7800. json_object_put(DataTransfer);
  7801. LWS_Send(message);
  7802. result = TRUE;
  7803. return result;
  7804. }
  7805. int sendDeleteCertificateConfirmation(char *uuid)
  7806. {
  7807. mtrace();
  7808. int result = FAIL;
  7809. char message[4096]={0};
  7810. json_object *DeleteCertificate = json_object_new_object();
  7811. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  7812. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  7813. sprintf(message,"[%d,\"%s\",%s]"
  7814. ,MESSAGE_TYPE_CALLRESULT
  7815. ,uuid
  7816. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  7817. json_object_put(DeleteCertificate);
  7818. LWS_Send(message);
  7819. result = TRUE;
  7820. return result;
  7821. }
  7822. int sendGetBaseReportConfirmation(char *uuid)
  7823. {
  7824. mtrace();
  7825. int result = FAIL;
  7826. char message[4096]={0};
  7827. json_object *GetBaseReport = json_object_new_object();
  7828. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  7829. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  7830. sprintf(message,"[%d,\"%s\",%s]"
  7831. ,MESSAGE_TYPE_CALLRESULT
  7832. ,uuid
  7833. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  7834. json_object_put(GetBaseReport);
  7835. LWS_Send(message);
  7836. result = TRUE;
  7837. return result;
  7838. }
  7839. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  7840. {
  7841. mtrace();
  7842. int result = FAIL;
  7843. char message[4096]={0};
  7844. json_object *GetChargingProfiles = json_object_new_object();
  7845. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  7846. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  7847. sprintf(message,"[%d,\"%s\",%s]"
  7848. ,MESSAGE_TYPE_CALLRESULT
  7849. ,uuid
  7850. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  7851. json_object_put(GetChargingProfiles);
  7852. LWS_Send(message);
  7853. result = TRUE;
  7854. return result;
  7855. }
  7856. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  7857. {
  7858. mtrace();
  7859. int result = FAIL;
  7860. char message[4096]={0};
  7861. int CompositeScheduleIndex = 0;
  7862. json_object *GetCompositeSchedule = json_object_new_object();
  7863. json_object *schedule = json_object_new_object();
  7864. json_object *chargingSchedule = json_object_new_object();
  7865. json_object *chargingSchedulePeriod = json_object_new_array();
  7866. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  7867. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  7868. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  7869. if(nPeriod == 0)
  7870. {
  7871. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  7872. {
  7873. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7874. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7875. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7876. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7877. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7878. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7879. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7880. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7881. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7882. {
  7883. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7884. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7885. {
  7886. json_object *Period = json_object_new_object();
  7887. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7888. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7889. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7890. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7891. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7892. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7893. json_object_array_add(chargingSchedulePeriod, Period);
  7894. }
  7895. }
  7896. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7897. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7898. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7899. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7900. }
  7901. }
  7902. else
  7903. {
  7904. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7905. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7906. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7907. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7908. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7909. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7910. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7911. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7912. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7913. {
  7914. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7915. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7916. {
  7917. json_object *Period = json_object_new_object();
  7918. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7919. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7920. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7921. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7922. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7923. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7924. json_object_array_add(chargingSchedulePeriod, Period);
  7925. }
  7926. }
  7927. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7928. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7929. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7930. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7931. }
  7932. sprintf(message,"[%d,\"%s\",%s]"
  7933. ,MESSAGE_TYPE_CALLRESULT
  7934. ,uuid
  7935. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  7936. json_object_put(GetCompositeSchedule);
  7937. LWS_Send(message);
  7938. result = TRUE;
  7939. return result;
  7940. }
  7941. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  7942. {
  7943. mtrace();
  7944. int result = FAIL;
  7945. char message[4096]={0};
  7946. json_object *GetGetDisplayMessages = json_object_new_object();
  7947. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  7948. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  7949. sprintf(message,"[%d,\"%s\",%s]"
  7950. ,MESSAGE_TYPE_CALLRESULT
  7951. ,uuid
  7952. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  7953. json_object_put(GetGetDisplayMessages);
  7954. LWS_Send(message);
  7955. result = TRUE;
  7956. return result;
  7957. }
  7958. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  7959. {
  7960. mtrace();
  7961. int result = FAIL;
  7962. char message[4096]={0};
  7963. json_object *GetInstalledCertificateIds = json_object_new_object();
  7964. json_object *certificateHashDataChains = json_object_new_array();
  7965. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  7966. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  7967. for(int idx=0;idx<certQuantity;idx++)
  7968. {
  7969. json_object *cert = json_object_new_object();
  7970. json_object *certificateHashData = json_object_new_object();
  7971. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  7972. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  7973. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  7974. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  7975. json_object_object_add(cert, "certificateHashData", certificateHashData);
  7976. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  7977. json_object_array_add(certificateHashDataChains, cert);
  7978. }
  7979. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  7980. sprintf(message,"[%d,\"%s\",%s]"
  7981. ,MESSAGE_TYPE_CALLRESULT
  7982. ,uuid
  7983. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  7984. json_object_put(GetInstalledCertificateIds);
  7985. LWS_Send(message);
  7986. result = TRUE;
  7987. return result;
  7988. }
  7989. int sendGetLocalListVersionConfirmation(char *uuid)
  7990. {
  7991. mtrace();
  7992. int result = FAIL;
  7993. char message[4096]={0};
  7994. json_object *GetLocalListVersion = json_object_new_object();
  7995. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  7996. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  7997. sprintf(message,"[%d,\"%s\",%s]"
  7998. ,MESSAGE_TYPE_CALLRESULT
  7999. ,uuid
  8000. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  8001. json_object_put(GetLocalListVersion);
  8002. LWS_Send(message);
  8003. result = TRUE;
  8004. return result;
  8005. }
  8006. int sendGetLogConfirmation(char *uuid)
  8007. {
  8008. mtrace();
  8009. int result = FAIL;
  8010. char message[4096]={0};
  8011. json_object *GetLog = json_object_new_object();
  8012. DEBUG_INFO("sendGetLogConfirmation...\n");
  8013. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  8014. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  8015. sprintf(message,"[%d,\"%s\",%s]"
  8016. ,MESSAGE_TYPE_CALLRESULT
  8017. ,uuid
  8018. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  8019. json_object_put(GetLog);
  8020. LWS_Send(message);
  8021. result = TRUE;
  8022. return result;
  8023. }
  8024. int sendGetMonitoringReportConfirmation(char *uuid)
  8025. {
  8026. mtrace();
  8027. int result = FAIL;
  8028. char message[4096]={0};
  8029. json_object *GetMonitoringReport = json_object_new_object();
  8030. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  8031. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  8032. sprintf(message,"[%d,\"%s\",%s]"
  8033. ,MESSAGE_TYPE_CALLRESULT
  8034. ,uuid
  8035. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  8036. json_object_put(GetMonitoringReport);
  8037. LWS_Send(message);
  8038. result = TRUE;
  8039. return result;
  8040. }
  8041. int sendGetReportConfirmation(char *uuid)
  8042. {
  8043. mtrace();
  8044. int result = FAIL;
  8045. char message[4096]={0};
  8046. json_object *GetReport = json_object_new_object();
  8047. DEBUG_INFO("sendGetReportConfirmation...\n");
  8048. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  8049. sprintf(message,"[%d,\"%s\",%s]"
  8050. ,MESSAGE_TYPE_CALLRESULT
  8051. ,uuid
  8052. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  8053. json_object_put(GetReport);
  8054. LWS_Send(message);
  8055. result = TRUE;
  8056. return result;
  8057. }
  8058. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  8059. {
  8060. mtrace();
  8061. int result = FAIL;
  8062. char message[4096]={0};
  8063. json_object *GetTransactionStatus = json_object_new_object();
  8064. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  8065. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  8066. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  8067. sprintf(message,"[%d,\"%s\",%s]"
  8068. ,MESSAGE_TYPE_CALLRESULT
  8069. ,uuid
  8070. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  8071. json_object_put(GetTransactionStatus);
  8072. LWS_Send(message);
  8073. result = TRUE;
  8074. return result;
  8075. }
  8076. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  8077. {
  8078. mtrace();
  8079. int result = FAIL;
  8080. char message[4096]={0};
  8081. json_object *GetVariables = json_object_new_object();
  8082. json_object *getVariableResults = json_object_new_array();
  8083. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  8084. for(int idx=0;idx<variableQuantity;idx++)
  8085. {
  8086. json_object *variableResult = json_object_new_object();
  8087. json_object *component = json_object_new_object();
  8088. json_object *variable = json_object_new_object();
  8089. json_object *evse = json_object_new_object();
  8090. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  8091. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  8092. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  8093. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  8094. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  8095. json_object_object_add(component, "evse", evse);
  8096. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  8097. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  8098. json_object_object_add(variableResult, "component", component);
  8099. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  8100. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  8101. json_object_object_add(variableResult, "variable", variable);
  8102. json_object_array_add(getVariableResults, variableResult);
  8103. }
  8104. json_object_object_add(GetVariables , "getVariableResult", getVariableResults);
  8105. sprintf(message,"[%d,\"%s\",%s]"
  8106. ,MESSAGE_TYPE_CALLRESULT
  8107. ,uuid
  8108. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  8109. json_object_put(GetVariables);
  8110. LWS_Send(message);
  8111. result = TRUE;
  8112. return result;
  8113. }
  8114. int sendInstallCertificateConfirmation(char *uuid)
  8115. {
  8116. mtrace();
  8117. int result = FAIL;
  8118. char message[4096]={0};
  8119. json_object *InstallCertificate = json_object_new_object();
  8120. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  8121. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  8122. sprintf(message,"[%d,\"%s\",%s]"
  8123. ,MESSAGE_TYPE_CALLRESULT
  8124. ,uuid
  8125. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  8126. json_object_put(InstallCertificate);
  8127. LWS_Send(message);
  8128. result = TRUE;
  8129. return result;
  8130. }
  8131. int sendPublishFirmwareConfirmation(char *uuid)
  8132. {
  8133. mtrace();
  8134. int result = FAIL;
  8135. char message[4096]={0};
  8136. json_object *PublishFirmware = json_object_new_object();
  8137. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  8138. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  8139. sprintf(message,"[%d,\"%s\",%s]"
  8140. ,MESSAGE_TYPE_CALLRESULT
  8141. ,uuid
  8142. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  8143. json_object_put(PublishFirmware);
  8144. LWS_Send(message);
  8145. result = TRUE;
  8146. return result;
  8147. }
  8148. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  8149. {
  8150. mtrace();
  8151. int result = FAIL;
  8152. char message[4096]={0};
  8153. json_object *RemoteStartTransaction = json_object_new_object();
  8154. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  8155. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  8156. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  8157. sprintf(message,"[%d,\"%s\",%s]"
  8158. ,MESSAGE_TYPE_CALLRESULT
  8159. ,uuid
  8160. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  8161. json_object_put(RemoteStartTransaction);
  8162. LWS_Send(message);
  8163. result = TRUE;
  8164. return result;
  8165. }
  8166. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  8167. {
  8168. mtrace();
  8169. int result = FAIL;
  8170. char message[4096]={0};
  8171. json_object *RemoteStopTransaction = json_object_new_object();
  8172. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  8173. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  8174. sprintf(message,"[%d,\"%s\",%s]"
  8175. ,MESSAGE_TYPE_CALLRESULT
  8176. ,uuid
  8177. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  8178. json_object_put(RemoteStopTransaction);
  8179. LWS_Send(message);
  8180. result = TRUE;
  8181. return result;
  8182. }
  8183. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  8184. {
  8185. mtrace();
  8186. int result = FAIL;
  8187. char message[4096]={0};
  8188. json_object *ReserveNow = json_object_new_object();
  8189. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  8190. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  8191. sprintf(message,"[%d,\"%s\",%s]"
  8192. ,MESSAGE_TYPE_CALLRESULT
  8193. ,uuid
  8194. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  8195. json_object_put(ReserveNow);
  8196. LWS_Send(message);
  8197. result = TRUE;
  8198. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  8199. return result;
  8200. }
  8201. int sendResetConfirmation(char *uuid)
  8202. {
  8203. mtrace();
  8204. int result = FAIL;
  8205. char message[4096]={0};
  8206. json_object *Reset = json_object_new_object();
  8207. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  8208. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  8209. sprintf(message,"[%d,\"%s\",%s]"
  8210. ,MESSAGE_TYPE_CALLRESULT
  8211. ,uuid
  8212. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  8213. json_object_put(Reset);
  8214. LWS_Send(message);
  8215. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  8216. {
  8217. DB_updateBootType(BootReasonEnumType_RemoteReset);
  8218. }
  8219. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  8220. {
  8221. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  8222. }
  8223. result = TRUE;
  8224. return result;
  8225. }
  8226. int sendSendLocalListConfirmation(char *uuid)
  8227. {
  8228. mtrace();
  8229. int result = FAIL;
  8230. char message[4096]={0};
  8231. json_object *SendLocalList = json_object_new_object();
  8232. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  8233. sprintf(message,"[%d,\"%s\",%s]"
  8234. ,MESSAGE_TYPE_CALLRESULT
  8235. ,uuid
  8236. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  8237. json_object_put(SendLocalList);
  8238. LWS_Send(message);
  8239. result = TRUE;
  8240. return result;
  8241. }
  8242. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  8243. {
  8244. mtrace();
  8245. int result = FAIL;
  8246. char message[4096]={0};
  8247. json_object *SetChargingProfile = json_object_new_object();
  8248. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  8249. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  8250. sprintf(message,"[%d,\"%s\",%s]"
  8251. ,MESSAGE_TYPE_CALLRESULT
  8252. ,uuid
  8253. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  8254. json_object_put(SetChargingProfile);
  8255. LWS_Send(message);
  8256. result = TRUE;
  8257. return result;
  8258. }
  8259. int sendSetDisplayMessageConfirmation(char *uuid)
  8260. {
  8261. mtrace();
  8262. int result = FAIL;
  8263. char message[4096]={0};
  8264. json_object *SetDisplayMessage = json_object_new_object();
  8265. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  8266. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  8267. sprintf(message,"[%d,\"%s\",%s]"
  8268. ,MESSAGE_TYPE_CALLRESULT
  8269. ,uuid
  8270. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  8271. json_object_put(SetDisplayMessage);
  8272. LWS_Send(message);
  8273. result = TRUE;
  8274. return result;
  8275. }
  8276. int sendSetMonitoringBaseConfirmation(char *uuid)
  8277. {
  8278. mtrace();
  8279. int result = FAIL;
  8280. char message[4096]={0};
  8281. json_object *SetMonitoringBase = json_object_new_object();
  8282. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  8283. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  8284. sprintf(message,"[%d,\"%s\",%s]"
  8285. ,MESSAGE_TYPE_CALLRESULT
  8286. ,uuid
  8287. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  8288. json_object_put(SetMonitoringBase);
  8289. LWS_Send(message);
  8290. result = TRUE;
  8291. return result;
  8292. }
  8293. int sendSetMonitoringLevelConfirmation(char *uuid)
  8294. {
  8295. mtrace();
  8296. int result = FAIL;
  8297. char message[4096]={0};
  8298. json_object *SetMonitoringLevel = json_object_new_object();
  8299. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  8300. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  8301. sprintf(message,"[%d,\"%s\",%s]"
  8302. ,MESSAGE_TYPE_CALLRESULT
  8303. ,uuid
  8304. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  8305. json_object_put(SetMonitoringLevel);
  8306. LWS_Send(message);
  8307. result = TRUE;
  8308. return result;
  8309. }
  8310. int sendSetNetworkProfileConfirmation(char *uuid)
  8311. {
  8312. mtrace();
  8313. int result = FAIL;
  8314. char message[4096]={0};
  8315. json_object *SetNetworkProfile = json_object_new_object();
  8316. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  8317. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  8318. sprintf(message,"[%d,\"%s\",%s]"
  8319. ,MESSAGE_TYPE_CALLRESULT
  8320. ,uuid
  8321. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  8322. json_object_put(SetNetworkProfile);
  8323. LWS_Send(message);
  8324. result = TRUE;
  8325. return result;
  8326. }
  8327. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  8328. {
  8329. mtrace();
  8330. int result = FAIL;
  8331. char message[4096]={0};
  8332. json_object *SetVariableMonitoring = json_object_new_object();
  8333. json_object *setMonitoringResults = json_object_new_array();
  8334. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  8335. for(int idx=0;idx<variableQuantity;idx++)
  8336. {
  8337. json_object *variableMonitorResult = json_object_new_object();
  8338. json_object *component = json_object_new_object();
  8339. json_object *variable = json_object_new_object();
  8340. json_object *evse = json_object_new_object();
  8341. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  8342. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  8343. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  8344. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  8345. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  8346. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  8347. json_object_object_add(component, "component", evse);
  8348. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  8349. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  8350. json_object_object_add(variableMonitorResult, "component", component);
  8351. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  8352. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  8353. json_object_object_add(variableMonitorResult, "variable", variable);
  8354. json_object_array_add(setMonitoringResults, variableMonitorResult);
  8355. }
  8356. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  8357. sprintf(message,"[%d,\"%s\",%s]"
  8358. ,MESSAGE_TYPE_CALLRESULT
  8359. ,uuid
  8360. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  8361. json_object_put(SetVariableMonitoring);
  8362. LWS_Send(message);
  8363. result = TRUE;
  8364. return result;
  8365. }
  8366. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  8367. {
  8368. mtrace();
  8369. int result = FAIL;
  8370. char message[4096]={0};
  8371. json_object *SetVariable = json_object_new_object();
  8372. json_object *setVariableResults = json_object_new_array();
  8373. DEBUG_INFO("sendSetVariableConfirmation...\n");
  8374. for(int idx=0;idx<variableQuantity;idx++)
  8375. {
  8376. json_object *variableResult = json_object_new_object();
  8377. json_object *component = json_object_new_object();
  8378. json_object *variable = json_object_new_object();
  8379. json_object *evse = json_object_new_object();
  8380. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  8381. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  8382. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  8383. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  8384. json_object_object_add(component, "component", evse);
  8385. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  8386. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  8387. json_object_object_add(variableResult, "component", component);
  8388. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  8389. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  8390. json_object_object_add(variableResult, "variable", variable);
  8391. json_object_array_add(setVariableResults, variableResult);
  8392. }
  8393. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  8394. sprintf(message,"[%d,\"%s\",%s]"
  8395. ,MESSAGE_TYPE_CALLRESULT
  8396. ,uuid
  8397. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  8398. json_object_put(SetVariable);
  8399. LWS_Send(message);
  8400. result = TRUE;
  8401. return result;
  8402. }
  8403. int sendTriggerMessageConfirmation(char *uuid)
  8404. {
  8405. mtrace();
  8406. int result = FAIL;
  8407. char message[4096]={0};
  8408. json_object *TriggerMessage = json_object_new_object();
  8409. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  8410. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  8411. sprintf(message,"[%d,\"%s\",%s]",
  8412. MESSAGE_TYPE_CALLRESULT,
  8413. uuid,
  8414. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  8415. json_object_put(TriggerMessage);
  8416. LWS_Send(message);
  8417. result = TRUE;
  8418. return result;
  8419. }
  8420. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  8421. {
  8422. mtrace();
  8423. int result = FAIL;
  8424. char message[4096]={0};
  8425. json_object *UnlockConnector = json_object_new_object();
  8426. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  8427. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  8428. sprintf(message,"[%d,\"%s\",%s]",
  8429. MESSAGE_TYPE_CALLRESULT,
  8430. uuid,
  8431. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  8432. json_object_put(UnlockConnector);
  8433. LWS_Send(message);
  8434. result = TRUE;
  8435. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  8436. return result;
  8437. }
  8438. int sendUnpublishFirmwareConfirmation(char *uuid)
  8439. {
  8440. mtrace();
  8441. int result = FAIL;
  8442. char message[4096]={0};
  8443. json_object *UnpublishFirmware = json_object_new_object();
  8444. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  8445. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  8446. sprintf(message,"[%d,\"%s\",%s]"
  8447. ,MESSAGE_TYPE_CALLRESULT
  8448. ,uuid
  8449. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  8450. json_object_put(UnpublishFirmware);
  8451. LWS_Send(message);
  8452. result = TRUE;
  8453. return result;
  8454. }
  8455. int sendUpdateFirmwareConfirmation(char *uuid)
  8456. {
  8457. mtrace();
  8458. int result = FAIL;
  8459. char message[4096]={0};
  8460. json_object *UpdateFirmware = json_object_new_object();
  8461. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  8462. sprintf((char*)ShmOCPP20Data->UpdateFirmware.Response_status, "%s", UpdateFirmwareStatusEnumTypeStr[UpdateFirmwareStatusEnumType_Accepted]);
  8463. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  8464. sprintf(message,"[%d,\"%s\",%s]"
  8465. ,MESSAGE_TYPE_CALLRESULT
  8466. ,uuid
  8467. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  8468. json_object_put(UpdateFirmware);
  8469. LWS_Send(message);
  8470. result = TRUE;
  8471. return result;
  8472. }
  8473. //==========================================
  8474. // send CallError routine
  8475. //==========================================
  8476. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  8477. {
  8478. mtrace();
  8479. char message[220]={0};
  8480. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  8481. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  8482. LWS_Send(message);
  8483. }
  8484. //==========================================
  8485. // Handle server request routine Start
  8486. //==========================================
  8487. int handleCancelReservationRequest(char *uuid, char *payload)
  8488. {
  8489. mtrace();
  8490. int result = FAIL;
  8491. int gunNO = 0;
  8492. int reservationIdInt = -1;
  8493. DEBUG_INFO("handleCancelReservationRequest...\n");
  8494. json_object *CancelReservation;
  8495. CancelReservation = json_tokener_parse(payload);
  8496. if(!is_error(CancelReservation))
  8497. {
  8498. // Required data
  8499. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  8500. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  8501. }
  8502. json_object_put(CancelReservation);
  8503. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  8504. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  8505. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  8506. if(reservationIdInt != -1)
  8507. {
  8508. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  8509. //check Transaction active
  8510. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  8511. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8512. {
  8513. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  8514. {
  8515. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8516. if(gunType[2] == 'J')
  8517. {
  8518. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  8519. }
  8520. else
  8521. {
  8522. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  8523. }
  8524. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8525. goto end;
  8526. }
  8527. }
  8528. for (int index = 0; index < CCS_QUANTITY; index++)
  8529. {
  8530. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  8531. {
  8532. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8533. if((gunType[2] == 'U') || (gunType[2] == 'E'))
  8534. {
  8535. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  8536. }
  8537. else
  8538. {
  8539. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  8540. }
  8541. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8542. goto end;
  8543. }
  8544. }
  8545. for (int index = 0; index < GB_QUANTITY; index++)
  8546. {
  8547. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  8548. {
  8549. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8550. if(gunType[2] == 'G')
  8551. {
  8552. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  8553. }
  8554. else
  8555. {
  8556. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  8557. }
  8558. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8559. goto end;
  8560. }
  8561. }
  8562. for (int index = 0; index < AC_QUANTITY; index++)
  8563. {
  8564. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  8565. {
  8566. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8567. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8568. {
  8569. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  8570. }
  8571. else
  8572. {
  8573. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  8574. }
  8575. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8576. goto end;
  8577. }
  8578. }
  8579. }
  8580. //The reservationId does NOT match the reservationId
  8581. sendCancelReservationConfirmation(uuid, gunNO);
  8582. end:
  8583. // Fill in ocpp packet uuid
  8584. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  8585. return result;
  8586. }
  8587. int handleCertificateSignedRequest(char *uuid, char *payload)
  8588. {
  8589. mtrace();
  8590. int result = FAIL;
  8591. json_object *CertificateSigned;
  8592. DEBUG_INFO("handleCertificateSignedRequest...\n");
  8593. CertificateSigned = json_tokener_parse(payload);
  8594. if(!is_error(CertificateSigned))
  8595. {
  8596. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  8597. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  8598. // Required data
  8599. if(json_object_array_length(json_object_object_get(CertificateSigned, "certificate")) <= ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.certificate))
  8600. {
  8601. for(int idx=0;idx<json_object_array_length(json_object_object_get(CertificateSigned, "certificate"));idx++)
  8602. {
  8603. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificate[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(CertificateSigned, "certificateType"), idx)));
  8604. /*
  8605. * TODO:
  8606. * 1. Certificate install response
  8607. */
  8608. }
  8609. }
  8610. // Optional data
  8611. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  8612. {
  8613. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  8614. if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_ChargingStationCertificate]) == 0)
  8615. {
  8616. }
  8617. else if(strcmp((char*)ShmOCPP20Data->CertificateSigned.certificateType, CertificateSigningUseEnumTypeStr[CertificateSignedStatusEnumType_V2GCertificate]) == 0)
  8618. {
  8619. }
  8620. else
  8621. {
  8622. }
  8623. }
  8624. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  8625. }
  8626. else
  8627. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  8628. json_object_put(CertificateSigned);
  8629. sendCertificateSignedConfirmation(uuid);
  8630. return result;
  8631. }
  8632. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  8633. {
  8634. mtrace();
  8635. int result = FAIL;
  8636. int evseId = 0, gunIndex = 0;
  8637. char operationalStatus[16]={0};
  8638. char comfirmstr[20];
  8639. int specificId = FALSE;
  8640. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  8641. json_object *ChangeAvailability;
  8642. ChangeAvailability = json_tokener_parse(payload);
  8643. if(!is_error(ChangeAvailability))
  8644. {
  8645. // Required data
  8646. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  8647. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  8648. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  8649. {
  8650. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  8651. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  8652. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  8653. }
  8654. }
  8655. json_object_put(ChangeAvailability);
  8656. if((evseId != 0) && (evseId <= gunTotalNumber))
  8657. {
  8658. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  8659. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  8660. }
  8661. else if(evseId == 0)
  8662. {
  8663. for(int i=0; i < gunTotalNumber; i++)
  8664. {
  8665. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  8666. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8667. }
  8668. }
  8669. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8670. {
  8671. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  8672. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  8673. }
  8674. else if(gunIndex == 0)
  8675. {
  8676. for(int i=0; i < gunTotalNumber; i++)
  8677. {
  8678. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  8679. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8680. }
  8681. }
  8682. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  8683. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8684. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  8685. {
  8686. specificId = TRUE;
  8687. }
  8688. if(specificId == FALSE)
  8689. goto end;
  8690. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  8691. {
  8692. //----------------------gunIndex is 0 ------------------------------------------------//
  8693. if(gunIndex == 0)
  8694. {
  8695. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8696. {
  8697. for(int i=0; i < gunTotalNumber; i++)
  8698. {
  8699. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8700. {
  8701. if ((gunType[i] == 'J')&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  8702. {
  8703. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8704. {
  8705. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8706. goto end;
  8707. }
  8708. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8709. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8710. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8711. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8712. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8713. {
  8714. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8715. goto end;
  8716. }
  8717. }
  8718. }//END FOR CHAdeMO_QUANTITY
  8719. for (int index = 0; index < CCS_QUANTITY; index++)
  8720. {
  8721. if (((gunType[i] == 'U')||(gunType[i] == 'E'))&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  8722. {
  8723. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  8724. {
  8725. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8726. goto end;
  8727. }
  8728. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8729. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8730. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8731. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8732. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8733. {
  8734. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8735. goto end;
  8736. }
  8737. }
  8738. }//END FOR CCS_QUANTITY
  8739. for (int index = 0; index < GB_QUANTITY; index++)
  8740. {
  8741. if ((gunType[i] == 'G')&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  8742. {
  8743. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8744. {
  8745. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8746. goto end;
  8747. }
  8748. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8749. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8750. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8751. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8752. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8753. {
  8754. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8755. goto end;
  8756. }
  8757. }
  8758. }// END FOR GB_QUANTITY
  8759. for (int index = 0; index < AC_QUANTITY; index++)
  8760. {
  8761. if (((gunType[i] > '0')&&(gunType[i] <= '9'))&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  8762. {
  8763. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8764. {
  8765. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8766. goto end;
  8767. }
  8768. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8769. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8770. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8771. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8772. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8773. {
  8774. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8775. goto end;
  8776. }
  8777. }
  8778. }//END FOR AC_QUANTITY
  8779. }// END FOR gunTotalNumber
  8780. }
  8781. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8782. {
  8783. for(int i=0; i < gunTotalNumber; i++)
  8784. {
  8785. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8786. {
  8787. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8788. goto end;
  8789. }
  8790. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8791. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  8792. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  8793. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  8794. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8795. {
  8796. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8797. goto end;
  8798. }
  8799. }
  8800. }
  8801. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8802. goto end;
  8803. }
  8804. //----------------------gunIndex is not 0 ------------------------------------------------//
  8805. //check Transaction active
  8806. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8807. {
  8808. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J'))
  8809. {
  8810. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  8811. {
  8812. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8813. goto end;
  8814. }
  8815. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8816. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8817. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8818. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8819. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8820. {
  8821. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8822. goto end;
  8823. }
  8824. else
  8825. {
  8826. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  8827. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8828. goto end;
  8829. }
  8830. }
  8831. }//END FOR CHAdeMO_QUANTITY
  8832. for (int index = 0; index < CCS_QUANTITY; index++)
  8833. {
  8834. if ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E')))
  8835. {
  8836. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  8837. {
  8838. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8839. goto end;
  8840. }
  8841. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8842. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8843. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8844. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8845. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8846. {
  8847. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8848. goto end;
  8849. }
  8850. else
  8851. {
  8852. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  8853. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8854. goto end;
  8855. }
  8856. }
  8857. }//END FOR CCS_QUANTITY
  8858. for (int index = 0; index < GB_QUANTITY; index++)
  8859. {
  8860. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))
  8861. {
  8862. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8863. {
  8864. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8865. goto end;
  8866. }
  8867. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8868. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8869. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8870. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8871. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8872. {
  8873. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8874. goto end;
  8875. }
  8876. else
  8877. {
  8878. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  8879. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8880. goto end;
  8881. }
  8882. }
  8883. }// END FOR GB_QUANTITY
  8884. for (int index = 0; index < AC_QUANTITY; index++)
  8885. {
  8886. if ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))
  8887. {
  8888. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8889. {
  8890. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8891. goto end;
  8892. }
  8893. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8894. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8895. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8896. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8897. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8898. {
  8899. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8900. goto end;
  8901. }
  8902. else
  8903. {
  8904. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  8905. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8906. goto end;
  8907. }
  8908. }
  8909. }//END FOR AC_QUANTITY
  8910. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  8911. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  8912. {
  8913. //----------------------gunIndex is 0 ------------------------------------------------//
  8914. if(gunIndex == 0)
  8915. {
  8916. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8917. {
  8918. for(int i=0; i < gunTotalNumber; i++)
  8919. {
  8920. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8921. {
  8922. 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
  8923. {
  8924. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8925. goto end;
  8926. }
  8927. }//END FOR CHAdeMO_QUANTITY
  8928. for (int index = 0; index < CCS_QUANTITY; index++)
  8929. {
  8930. 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
  8931. {
  8932. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8933. goto end;
  8934. }
  8935. }//END FOR CCS_QUANTITY
  8936. for (int index = 0; index < GB_QUANTITY; index++)
  8937. {
  8938. 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
  8939. {
  8940. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8941. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8942. goto end;
  8943. }
  8944. }// END FOR GB_QUANTITY
  8945. for (int index = 0; index < AC_QUANTITY; index++)
  8946. {
  8947. 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
  8948. {
  8949. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8950. goto end;
  8951. }
  8952. }//END FOR CHAdeMO_QUANTITY
  8953. }// END FOR gunTotalNumber
  8954. }
  8955. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8956. {
  8957. for(int i=0; i < gunTotalNumber; i++)
  8958. {
  8959. for (int index = 0; index < AC_QUANTITY; index++)
  8960. {
  8961. 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
  8962. {
  8963. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8964. goto end;
  8965. }
  8966. }//END FOR CHAdeMO_QUANTITY
  8967. } // END FOR gunTotalNumber
  8968. }
  8969. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8970. goto end;
  8971. }
  8972. //----------------------gunIndex is not 0 ------------------------------------------------//
  8973. //check Transaction active
  8974. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8975. {
  8976. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'J') ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8977. {
  8978. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8979. goto end;
  8980. }
  8981. }//END FOR CHAdeMO_QUANTITY
  8982. for (int index = 0; index < CCS_QUANTITY; index++)
  8983. {
  8984. if ((((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8985. {
  8986. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8987. goto end;
  8988. }
  8989. }//END FOR CCS_QUANTITY
  8990. for (int index = 0; index < GB_QUANTITY; index++)
  8991. {
  8992. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8993. {
  8994. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8995. goto end;
  8996. }
  8997. }// END FOR GB_QUANTITY
  8998. for (int index = 0; index < AC_QUANTITY; index++)
  8999. {
  9000. if (((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9'))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  9001. {
  9002. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  9003. goto end;
  9004. }
  9005. }//END FOR AC_QUANTITY
  9006. }//END FOR AvailabilityEnumTypeStr[Operative]
  9007. end:
  9008. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  9009. {
  9010. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  9011. }
  9012. else
  9013. {
  9014. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  9015. }
  9016. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  9017. {
  9018. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  9019. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  9020. }
  9021. else if(gunIndex == 0)
  9022. {
  9023. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  9024. {
  9025. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  9026. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  9027. }
  9028. }
  9029. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  9030. return result;
  9031. }
  9032. int handleClearCacheRequest(char *uuid, char *payload)
  9033. {
  9034. mtrace();
  9035. int result = FAIL;
  9036. char rmFileCmd[100]={0};
  9037. struct stat stats;
  9038. DEBUG_INFO("handleClearCacheRequest...\n");
  9039. stat("/Storage/OCPP", &stats);
  9040. // Check for directory existence
  9041. if (S_ISDIR(stats.st_mode) == 1)
  9042. {}
  9043. else
  9044. {
  9045. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  9046. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  9047. system(rmFileCmd);
  9048. }
  9049. /*
  9050. * TODO:
  9051. * 1. Clear cache from sqlite db
  9052. */
  9053. if(1)
  9054. {
  9055. DEBUG_INFO("open AuthorizationCache file failed\n");
  9056. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  9057. }
  9058. else
  9059. {
  9060. DEBUG_INFO("open AuthorizationCache file successful\n");
  9061. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  9062. }
  9063. sendClearCacheConfirmation(uuid);
  9064. return result;
  9065. }
  9066. int handleClearChargingProfileRequest(char *uuid, char *payload)
  9067. {
  9068. mtrace();
  9069. int result = FAIL;
  9070. int resultRename;
  9071. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  9072. char chargingProfilePurposeStr[26]={0};
  9073. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  9074. char tempchargingProfilePurposeStr[26]={0};
  9075. char sstr[160]={0};
  9076. char str[100]={0};
  9077. int c = 0;
  9078. char *loc;
  9079. char fname[200]={0};
  9080. char comfirmstr[20]={0};
  9081. char word[1600]={0};
  9082. int clearflag = FALSE;
  9083. int chargingProfileIdIsNULL = FALSE;
  9084. int connectorIsNULL = FALSE;
  9085. int chargingProfilePurposeIsNULL = FALSE;
  9086. int stackLevelIsNULL = FALSE;
  9087. //int GotoEnd = FALSE;
  9088. FILE *fptr1, *fptr2;
  9089. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  9090. int n_chargingProfile=0;
  9091. int isEmptyFile = FALSE;
  9092. char sLineWord[1600]={0};
  9093. char chargingProfiles[10][100]={0};
  9094. int ChargeProfileCount = 0;
  9095. int ch;
  9096. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  9097. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  9098. json_object *ClearChargingProfile;
  9099. ClearChargingProfile = json_tokener_parse(payload);
  9100. if(!is_error(ClearChargingProfile))
  9101. {
  9102. // Optional data
  9103. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  9104. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  9105. else
  9106. chargingProfileIdIsNULL = TRUE;
  9107. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  9108. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  9109. else
  9110. connectorIsNULL = TRUE;
  9111. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  9112. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  9113. else
  9114. chargingProfilePurposeIsNULL = TRUE;
  9115. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  9116. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  9117. else
  9118. stackLevelIsNULL = TRUE;
  9119. }
  9120. json_object_put(ClearChargingProfile);
  9121. if(connectorIsNULL == FALSE)
  9122. {
  9123. switch(connectorIdInt)
  9124. {
  9125. case 0:
  9126. if(chargingProfilePurposeIsNULL == TRUE)
  9127. {
  9128. int l = 0;
  9129. strcpy(fname, ChargePointMaxProfile_JSON);
  9130. if((access(fname,F_OK))!=-1)
  9131. {
  9132. strcpy(chargingProfiles[l], fname);
  9133. l = l + 1;
  9134. }
  9135. strcpy(fname, TxDefaultProfile_0_JSON);
  9136. if((access(fname,F_OK))!=-1)
  9137. {
  9138. strcpy(chargingProfiles[l], fname);
  9139. l = l + 1;
  9140. }
  9141. ChargeProfileCount = l;
  9142. }
  9143. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  9144. {
  9145. strcpy(fname, ChargePointMaxProfile_JSON);
  9146. if((access(fname,F_OK))!=-1)
  9147. {
  9148. strcpy(chargingProfiles[0], fname);
  9149. ChargeProfileCount = 1;
  9150. }
  9151. }
  9152. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  9153. {
  9154. strcpy(fname, TxDefaultProfile_0_JSON);
  9155. if((access(fname,F_OK))!=-1)
  9156. {
  9157. strcpy(chargingProfiles[0], fname);
  9158. ChargeProfileCount = 1;
  9159. }
  9160. }
  9161. break;
  9162. default:
  9163. if(chargingProfilePurposeIsNULL == TRUE)
  9164. {
  9165. int m = 0;
  9166. memset(fname, 0, ARRAY_SIZE(fname));
  9167. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  9168. if((access(fname,F_OK))!=-1)
  9169. {
  9170. strcpy(chargingProfiles[m], fname);
  9171. m = m + 1;
  9172. }
  9173. memset(fname, 0, ARRAY_SIZE(fname));
  9174. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  9175. if((access(fname,F_OK))!=-1)
  9176. {
  9177. strcpy(chargingProfiles[m], fname);
  9178. m = m + 1;
  9179. }
  9180. ChargeProfileCount = m;
  9181. }
  9182. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  9183. {
  9184. //strcpy(fname, TxDefaultProfile_1_JSON);
  9185. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  9186. if((access(fname,F_OK))!=-1)
  9187. {
  9188. strcpy(chargingProfiles[0], fname);
  9189. ChargeProfileCount = 1;
  9190. }
  9191. }
  9192. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  9193. {
  9194. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  9195. if((access(fname,F_OK))!=-1)
  9196. {
  9197. strcpy(chargingProfiles[0], fname);
  9198. ChargeProfileCount = 1;
  9199. }
  9200. }
  9201. //strcpy(fname, ChargePointMaxProfile_JSON );
  9202. break;
  9203. }
  9204. }
  9205. else // Check all Charging Profiles
  9206. {
  9207. int i = 0;
  9208. char fnametemp[200]={0};
  9209. ChargeProfileCount = 0;
  9210. //Check ChargePointMaxProfile.json exit
  9211. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  9212. {
  9213. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  9214. i = i + 1;
  9215. }
  9216. //Check TxDefaultProfile_0.json exit
  9217. if((access("/Storage/OCPP/TxDefaultProfile_0.json",F_OK))!=-1)
  9218. {
  9219. strcpy(chargingProfiles[i], "/Storage/OCPP/TxDefaultProfile_0.json");
  9220. i = i + 1;
  9221. }
  9222. //Check TxDefaultProfile_%d.json
  9223. for(int j=1; j <= gunTotalNumber; j++)
  9224. {
  9225. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  9226. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d.json", j);
  9227. if((access(fnametemp,F_OK))!=-1)
  9228. {
  9229. strcpy(chargingProfiles[i], fnametemp);
  9230. i = i + 1;
  9231. }
  9232. }
  9233. //Check TxProfile_%d.json
  9234. for(int j=1; j <= gunTotalNumber; j++)
  9235. {
  9236. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  9237. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d.json", j);
  9238. if((access(fnametemp,F_OK))!=-1)
  9239. {
  9240. strcpy(chargingProfiles[i], fnametemp);
  9241. i = i + 1;
  9242. }
  9243. }
  9244. ChargeProfileCount = i;
  9245. }// End connectorIsNULL is TRUE
  9246. if(ChargeProfileCount == 0)
  9247. {
  9248. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9249. goto end;
  9250. }
  9251. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  9252. {
  9253. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9254. goto end;
  9255. }
  9256. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  9257. {
  9258. memset(str, 0, ARRAY_SIZE(str));
  9259. // clear temp file
  9260. sprintf(str,"rm -f %s",temp);
  9261. system(str);
  9262. for(int k=0; k < ChargeProfileCount; k++)
  9263. {
  9264. memset(str, 0, ARRAY_SIZE(str));
  9265. //clear file in C
  9266. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9267. system(str);
  9268. }
  9269. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9270. goto end;
  9271. }
  9272. else if(connectorIsNULL == TRUE)
  9273. {
  9274. for(int k=0; k < ChargeProfileCount; k++)
  9275. {
  9276. fptr1 = fopen(chargingProfiles[k], "r");
  9277. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  9278. //Check Charging Profile Count
  9279. while(fscanf(fptr1, "%s", word) != EOF)
  9280. {
  9281. //DEBUG_INFO("word=%s\n",word);
  9282. if(strstr(word, "chargingProfileId")!= NULL)
  9283. {
  9284. //DEBUG_INFO("test chargingProfileId \n");
  9285. n_chargingProfile = n_chargingProfile + 1;
  9286. //DEBUG_INFO("chargingProfileId Found\n");
  9287. }
  9288. }
  9289. rewind(fptr1);
  9290. //search Charging Profile Element
  9291. //int i= 0;
  9292. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9293. {
  9294. //------------------------tempconnectorIdInt------------------------//
  9295. loc = strstr(sLineWord, "connectorId");
  9296. c = 0;
  9297. memset(sstr ,0, sizeof(sstr) );
  9298. while (loc[strlen("connectorId")+2+c] != ',')
  9299. {
  9300. sstr[c] = loc[strlen("connectorId")+2+c];
  9301. c++;
  9302. }
  9303. sstr[c] = '\0';
  9304. tempconnectorIdInt = atoi(sstr);
  9305. printf("file's gun number is %d\n", tempconnectorIdInt);
  9306. //--------------------------chargingProfileId--------------------//
  9307. c = 0;
  9308. loc = strstr(sLineWord, "chargingProfileId");
  9309. memset(sstr ,0, ARRAY_SIZE(sstr));
  9310. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9311. {
  9312. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9313. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9314. c++;
  9315. }
  9316. sstr[c] = '\0';
  9317. tempchargingProfileIdInt = atoi(sstr);
  9318. //stackLevel
  9319. c = 0;
  9320. loc = strstr(sLineWord, "stackLevel");
  9321. memset(sstr ,0, ARRAY_SIZE(sstr));
  9322. while (loc[strlen("stackLevel")+2+c] != ',')
  9323. {
  9324. sstr[c] = loc[strlen("stackLevel")+2+c];
  9325. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9326. c++;
  9327. }
  9328. sstr[c] = '\0';
  9329. tempstackLevelInt = atoi(sstr);
  9330. c = 0;
  9331. loc = strstr(sLineWord, "chargingProfilePurpose");
  9332. memset(sstr ,0, ARRAY_SIZE(sstr));
  9333. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9334. {
  9335. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9336. c++;
  9337. }
  9338. sstr[c] = '\0';
  9339. strcpy(tempchargingProfilePurposeStr, sstr);
  9340. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9341. {
  9342. //------- not write to fptr2-------//
  9343. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9344. //clearflag = TRUE;
  9345. }
  9346. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  9347. {
  9348. //------- not write to fptr2-------//
  9349. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9350. }
  9351. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9352. {
  9353. //------- not write to fptr2-------//
  9354. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9355. }
  9356. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  9357. {
  9358. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9359. }
  9360. else
  9361. {
  9362. fprintf(fptr2, sLineWord);//writing data into file
  9363. }
  9364. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9365. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9366. if(clearflag == TRUE)
  9367. {
  9368. fclose(fptr1);
  9369. fclose(fptr2);
  9370. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9371. system(str);
  9372. // clear temp file
  9373. sprintf(str,"rm -f %s",temp);
  9374. system(str);
  9375. }
  9376. else
  9377. {
  9378. fclose(fptr1);
  9379. fclose(fptr2);
  9380. memset(str, 0, ARRAY_SIZE(str));
  9381. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9382. system(str);
  9383. resultRename = rename(temp, chargingProfiles[k]);
  9384. if(resultRename == 0)
  9385. {
  9386. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  9387. }
  9388. else
  9389. {
  9390. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  9391. }
  9392. if(comfirmstr[0]== 0)
  9393. {
  9394. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9395. }
  9396. //Check chargingProfile is empty file
  9397. /*------ Read the file ----------------*/
  9398. fptr1=fopen(chargingProfiles[k],"r");
  9399. ch=fgetc(fptr1);
  9400. rewind(fptr1);
  9401. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9402. if(ch!=EOF)
  9403. {
  9404. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9405. {
  9406. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9407. if(sLineWord[0]=='\0')
  9408. {
  9409. isEmptyFile = TRUE;
  9410. break;
  9411. }
  9412. else
  9413. {
  9414. isEmptyFile = FALSE;
  9415. break;
  9416. }
  9417. }
  9418. }
  9419. else
  9420. isEmptyFile = TRUE;
  9421. fclose(fptr1);
  9422. if(isEmptyFile == TRUE)
  9423. {
  9424. memset(str, 0, ARRAY_SIZE(str));
  9425. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9426. system(str);
  9427. }
  9428. }
  9429. }// End of while(int k=0; k < ChargePointCount; k++)
  9430. }
  9431. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  9432. {
  9433. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  9434. for(int k=0; k < ChargeProfileCount; k++)
  9435. {
  9436. fptr1 = fopen(chargingProfiles[k], "r");
  9437. fptr2 = fopen(temp, "w+");
  9438. //Check Charging Profile Count
  9439. while(fscanf(fptr1, "%s", word) != EOF)
  9440. {
  9441. //DEBUG_INFO("word=%s\n",word);
  9442. if(strstr(word, "chargingProfileId")!= NULL)
  9443. {
  9444. n_chargingProfile = n_chargingProfile + 1;
  9445. }
  9446. }
  9447. rewind(fptr1);
  9448. //search Charging Profile Element
  9449. //int i= 0;
  9450. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9451. {
  9452. //*************************tempconnectorIdInt*********************************/
  9453. loc = strstr(sLineWord, "connectorId");
  9454. c = 0;
  9455. memset(sstr ,0, ARRAY_SIZE(sstr));
  9456. while (loc[strlen("connectorId")+2+c] != ',')
  9457. {
  9458. sstr[c] = loc[strlen("connectorId")+2+c];
  9459. c++;
  9460. }
  9461. sstr[c] = '\0';
  9462. tempconnectorIdInt = atoi(sstr);
  9463. //chargingProfileId
  9464. c = 0;
  9465. loc = strstr(sLineWord, "chargingProfileId");
  9466. memset(sstr ,0, ARRAY_SIZE(sstr));
  9467. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9468. {
  9469. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9470. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9471. c++;
  9472. }
  9473. sstr[c] = '\0';
  9474. tempchargingProfileIdInt = atoi(sstr);
  9475. //stackLevel
  9476. c = 0;
  9477. loc = strstr(sLineWord, "stackLevel");
  9478. memset(sstr ,0, ARRAY_SIZE(sstr));
  9479. while (loc[strlen("stackLevel")+2+c] != ',')
  9480. {
  9481. sstr[c] = loc[strlen("stackLevel")+2+c];
  9482. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9483. c++;
  9484. }
  9485. sstr[c] = '\0';
  9486. tempstackLevelInt = atoi(sstr);
  9487. c = 0;
  9488. loc = strstr(sLineWord, "chargingProfilePurpose");
  9489. memset(sstr ,0, ARRAY_SIZE(sstr));
  9490. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9491. {
  9492. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9493. c++;
  9494. }
  9495. sstr[c] = '\0';
  9496. strcpy(tempchargingProfilePurposeStr, sstr);
  9497. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9498. {
  9499. //------- not write to fptr2-------//
  9500. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9501. //clearflag = TRUE;
  9502. }
  9503. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9504. {
  9505. //------- not write to fptr2-------//
  9506. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9507. }
  9508. else if(stackLevelIsNULL == TRUE)
  9509. {
  9510. //Clear Whole File
  9511. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9512. clearflag = TRUE;
  9513. break;
  9514. }
  9515. else
  9516. {
  9517. fprintf(fptr2, sLineWord);//writing data into file
  9518. }
  9519. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9520. }
  9521. if(clearflag == TRUE)
  9522. {
  9523. fclose(fptr1);
  9524. fclose(fptr2);
  9525. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9526. system(str);
  9527. // clear temp file
  9528. sprintf(str,"rm -f %s",temp);
  9529. system(str);
  9530. }
  9531. else
  9532. {
  9533. fclose(fptr1);
  9534. fclose(fptr2);
  9535. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9536. system(str);
  9537. resultRename = rename(temp, chargingProfiles[k]);
  9538. if(resultRename == 0)
  9539. {
  9540. DEBUG_INFO("File ChargingProfile renamed successfully");
  9541. }
  9542. else
  9543. {
  9544. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  9545. }
  9546. if(comfirmstr[0]== 0)
  9547. {
  9548. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9549. }
  9550. //Check chargingProfile is empty file
  9551. /*------ Read the file ----------------*/
  9552. fptr1=fopen(chargingProfiles[k],"r");
  9553. ch=fgetc(fptr1);
  9554. rewind(fptr1);
  9555. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9556. if(ch!=EOF)
  9557. {
  9558. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9559. {
  9560. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9561. if(sLineWord[0]=='\0')
  9562. {
  9563. isEmptyFile = TRUE;
  9564. break;
  9565. }
  9566. else
  9567. {
  9568. isEmptyFile = FALSE;
  9569. break;
  9570. }
  9571. }
  9572. }
  9573. else
  9574. isEmptyFile = TRUE;
  9575. fclose(fptr1);
  9576. if(isEmptyFile == TRUE)
  9577. {
  9578. memset(str, 0, ARRAY_SIZE(str));
  9579. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9580. system(str);
  9581. }
  9582. /*------- End of reading ---------------*/
  9583. }
  9584. } // while(int k=0; k < ChargeProfileCount; k++)
  9585. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  9586. end:
  9587. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  9588. {
  9589. if(connectorIdInt == 0)
  9590. {
  9591. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  9592. {
  9593. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  9594. }
  9595. }
  9596. else
  9597. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1]);
  9598. }
  9599. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  9600. return result;
  9601. }
  9602. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  9603. {
  9604. mtrace();
  9605. int result = FAIL;
  9606. json_object *ClearDisplayMessage;
  9607. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  9608. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  9609. ClearDisplayMessage = json_tokener_parse(payload);
  9610. if(!is_error(ClearDisplayMessage))
  9611. {
  9612. // Required data
  9613. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  9614. {
  9615. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  9616. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  9617. }
  9618. }
  9619. json_object_put(ClearDisplayMessage);
  9620. sendCostUpdatedConfirmation(uuid);
  9621. return result;
  9622. }
  9623. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  9624. {
  9625. mtrace();
  9626. int result = FAIL;
  9627. json_object *ClearVariableMonitorin;
  9628. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  9629. ClearVariableMonitorin = json_tokener_parse(payload);
  9630. if(!is_error(ClearVariableMonitorin))
  9631. {
  9632. // Required data
  9633. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  9634. {
  9635. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  9636. {
  9637. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  9638. /*
  9639. * TODO:
  9640. * 1. Check response
  9641. */
  9642. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  9643. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  9644. }
  9645. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  9646. }
  9647. }
  9648. json_object_put(ClearVariableMonitorin);
  9649. return result;
  9650. }
  9651. int handleCostUpdatedRequest(char *uuid, char *payload)
  9652. {
  9653. mtrace();
  9654. int result = FAIL;
  9655. json_object *CostUpdate;
  9656. DEBUG_INFO("handleCostUpdatedRequest...\n");
  9657. CostUpdate = json_tokener_parse(payload);
  9658. if(!is_error(CostUpdate))
  9659. {
  9660. // Required data
  9661. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  9662. {
  9663. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  9664. }
  9665. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  9666. {
  9667. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  9668. }
  9669. }
  9670. json_object_put(CostUpdate);
  9671. sendCostUpdatedConfirmation(uuid);
  9672. return result;
  9673. }
  9674. int handleCustomerInformationRequest(char *uuid, char *payload)
  9675. {
  9676. mtrace();
  9677. int result = FAIL;
  9678. json_object *CustomerInformation;
  9679. DEBUG_INFO("handleCustomerInformationRequest...\n");
  9680. CustomerInformation = json_tokener_parse(payload);
  9681. if(!is_error(CustomerInformation))
  9682. {
  9683. // Required data
  9684. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  9685. {
  9686. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  9687. }
  9688. if(json_object_object_get(CustomerInformation, "report") != NULL)
  9689. {
  9690. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  9691. }
  9692. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  9693. {
  9694. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  9695. }
  9696. // Optional data
  9697. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  9698. {
  9699. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  9700. {
  9701. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  9702. }
  9703. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  9704. {
  9705. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  9706. }
  9707. }
  9708. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  9709. {
  9710. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  9711. {
  9712. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  9713. }
  9714. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  9715. {
  9716. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  9717. }
  9718. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  9719. {
  9720. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  9721. }
  9722. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  9723. {
  9724. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  9725. }
  9726. }
  9727. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  9728. }
  9729. else
  9730. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  9731. json_object_put(CustomerInformation);
  9732. sendCustomerInformationConfirmation(uuid);
  9733. return result;
  9734. }
  9735. void createFirmwareVersionByDataTransfer(void)
  9736. {
  9737. json_object *FirmwareDataTransfer = json_object_new_object();
  9738. // AC & DC model
  9739. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  9740. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  9741. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  9742. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  9743. // DC model
  9744. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]!='O')
  9745. {
  9746. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  9747. {
  9748. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  9749. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  9750. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  9751. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  9752. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  9753. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  9754. }
  9755. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
  9756. ((gunType[1] != '0') || (gunType[2] != '0') || (gunType[3] != '0')))
  9757. {
  9758. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  9759. }
  9760. }
  9761. else
  9762. {
  9763. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  9764. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  9765. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  9766. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  9767. json_object_object_add(FirmwareDataTransfer, "DD0_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuBootLoadFwRev));
  9768. json_object_object_add(FirmwareDataTransfer, "DD0_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuKernelFwRev));
  9769. json_object_object_add(FirmwareDataTransfer, "DD0_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuRootFsFwRev));
  9770. json_object_object_add(FirmwareDataTransfer, "DD0_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuPrimFwRev));
  9771. json_object_object_add(FirmwareDataTransfer, "DD0_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].FanModuleFwRev));
  9772. json_object_object_add(FirmwareDataTransfer, "DD0_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].RelayModuleFwRev));
  9773. json_object_object_add(FirmwareDataTransfer, "DD0_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].LedModuleFwRev));
  9774. json_object_object_add(FirmwareDataTransfer, "DD0_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector1FwRev));
  9775. json_object_object_add(FirmwareDataTransfer, "DD0_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector2FwRev));
  9776. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev) > 0)
  9777. json_object_object_add(FirmwareDataTransfer, "DD1_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev));
  9778. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev) > 0)
  9779. json_object_object_add(FirmwareDataTransfer, "DD1_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev));
  9780. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev) > 0)
  9781. json_object_object_add(FirmwareDataTransfer, "DD1_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev));
  9782. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev) > 0)
  9783. json_object_object_add(FirmwareDataTransfer, "DD1_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev));
  9784. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev) > 0)
  9785. json_object_object_add(FirmwareDataTransfer, "DD1_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev));
  9786. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev) > 0)
  9787. json_object_object_add(FirmwareDataTransfer, "DD1_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev));
  9788. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev) > 0)
  9789. json_object_object_add(FirmwareDataTransfer, "DD1_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev));
  9790. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev) > 0)
  9791. json_object_object_add(FirmwareDataTransfer, "DD1_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev));
  9792. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev) > 0)
  9793. json_object_object_add(FirmwareDataTransfer, "DD1_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev));
  9794. }
  9795. // 4G model
  9796. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  9797. {
  9798. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  9799. }
  9800. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "Phihong Technology");
  9801. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion");
  9802. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, json_object_to_json_string(FirmwareDataTransfer));
  9803. }
  9804. int handleDataTransferRequest(char *uuid, char *payload)
  9805. {
  9806. mtrace();
  9807. int result = PASS;
  9808. DEBUG_INFO("handleDataTransferRequest...\n");
  9809. if((uuid != NULL) && (payload != NULL))
  9810. {
  9811. json_object *DataTransfer;
  9812. DataTransfer = json_tokener_parse(payload);
  9813. if(!is_error(DataTransfer))
  9814. {
  9815. // Required data
  9816. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  9817. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  9818. // Optional data
  9819. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  9820. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  9821. if(json_object_object_get(DataTransfer, "data") != NULL)
  9822. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  9823. result = PASS;
  9824. }
  9825. json_object_put(DataTransfer);
  9826. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  9827. {
  9828. // Send all moudle firmware version on EVSE
  9829. createFirmwareVersionByDataTransfer();
  9830. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9831. }
  9832. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_Tmate") != NULL)
  9833. {
  9834. system("/usr/bin/run_tmate_restart.sh &");
  9835. }
  9836. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  9837. {
  9838. json_object *data;
  9839. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  9840. if(!is_error(data))
  9841. {
  9842. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  9843. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  9844. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  9845. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  9846. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  9847. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  9848. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  9849. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  9850. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  9851. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  9852. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9853. }
  9854. else
  9855. {
  9856. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  9857. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  9858. }
  9859. json_object_put(data);
  9860. }
  9861. else
  9862. {
  9863. // Can not find valid message id
  9864. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9865. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  9866. ,ShmOCPP20Data->DataTransfer[0].vendorId
  9867. ,ShmOCPP20Data->DataTransfer[0].messageId
  9868. ,ShmOCPP20Data->DataTransfer[0].data);
  9869. }
  9870. }
  9871. else
  9872. {
  9873. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9874. result = FAIL;
  9875. }
  9876. sendDataTransferConfirmation(uuid, 0);
  9877. return result;
  9878. }
  9879. int handleDeleteCertificateRequest(char *uuid, char *payload)
  9880. {
  9881. mtrace();
  9882. int result = FAIL;
  9883. json_object *DeleteCertificate;
  9884. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  9885. DeleteCertificate = json_tokener_parse(payload);
  9886. if(!is_error(DeleteCertificate))
  9887. {
  9888. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  9889. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  9890. // Required data
  9891. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  9892. {
  9893. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  9894. {
  9895. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  9896. }
  9897. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  9898. {
  9899. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  9900. }
  9901. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  9902. {
  9903. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  9904. }
  9905. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  9906. {
  9907. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  9908. }
  9909. /*
  9910. * TODO:
  9911. * 1. Delete certification and response
  9912. */
  9913. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  9914. }
  9915. }
  9916. else
  9917. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  9918. json_object_put(DeleteCertificate);
  9919. sendDeleteCertificateConfirmation(uuid);
  9920. return result;
  9921. }
  9922. int handleGetBaseReportRequest(char *uuid, char *payload)
  9923. {
  9924. mtrace();
  9925. int result = FAIL;
  9926. json_object *GetBaseRepor;
  9927. DEBUG_INFO("handleGetBaseReportRequest...\n");
  9928. GetBaseRepor = json_tokener_parse(payload);
  9929. if(!is_error(GetBaseRepor))
  9930. {
  9931. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  9932. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  9933. // Required data
  9934. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  9935. {
  9936. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  9937. }
  9938. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  9939. {
  9940. sprintf((char*)ShmOCPP20Data->GetBaseReport.reportBase, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  9941. }
  9942. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_SummaryInventory]) == 0)
  9943. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  9944. else
  9945. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  9946. }
  9947. else
  9948. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  9949. json_object_put(GetBaseRepor);
  9950. sendGetBaseReportConfirmation(uuid);
  9951. return result;
  9952. }
  9953. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  9954. {
  9955. mtrace();
  9956. int result = FAIL;
  9957. int gun_index = -1;
  9958. json_object *GetChargingProfiles;
  9959. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  9960. GetChargingProfiles = json_tokener_parse(payload);
  9961. if(!is_error(GetChargingProfiles))
  9962. {
  9963. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  9964. {
  9965. 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;
  9966. }
  9967. if(gun_index >-1)
  9968. {
  9969. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  9970. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  9971. // Required data
  9972. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  9973. {
  9974. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  9975. }
  9976. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  9977. {
  9978. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  9979. {
  9980. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  9981. }
  9982. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  9983. {
  9984. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  9985. }
  9986. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  9987. {
  9988. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  9989. {
  9990. 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)));
  9991. }
  9992. }
  9993. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  9994. {
  9995. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  9996. {
  9997. 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));
  9998. }
  9999. }
  10000. }
  10001. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  10002. }
  10003. else
  10004. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  10005. }
  10006. json_object_put(GetChargingProfiles);
  10007. sendGetChargingProfilesConfirmation(uuid, gun_index);
  10008. return result;
  10009. }
  10010. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  10011. {
  10012. mtrace();
  10013. int result = FAIL;
  10014. int connectorIdInt, durationInt;
  10015. char chargingRateUnitStr[4]={0};
  10016. char comfirmstr[20];
  10017. int confirmPeriods = 0;
  10018. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  10019. json_object *GetCompositeSchedule;
  10020. GetCompositeSchedule = json_tokener_parse(payload);
  10021. if(!is_error(GetCompositeSchedule))
  10022. {
  10023. // Required data
  10024. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  10025. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  10026. else
  10027. connectorIdInt = -1;
  10028. if(json_object_object_get(GetCompositeSchedule, "duration"))
  10029. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  10030. else
  10031. durationInt = 86400;
  10032. // Optional data
  10033. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  10034. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  10035. }
  10036. json_object_put(GetCompositeSchedule);
  10037. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  10038. if((connectorIdInt == 0) ||
  10039. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  10040. {
  10041. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  10042. struct ChargingProfileType tmpProfile[1];
  10043. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  10044. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  10045. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0]);
  10046. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  10047. {
  10048. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  10049. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  10050. }
  10051. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  10052. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  10053. {
  10054. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  10055. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  10056. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  10057. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0))
  10058. {
  10059. confirmPeriods = idx;
  10060. break;
  10061. }
  10062. }
  10063. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10064. }
  10065. else
  10066. {
  10067. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  10068. }
  10069. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  10070. return result;
  10071. }
  10072. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  10073. {
  10074. mtrace();
  10075. int result = FAIL;
  10076. json_object *GetDisplayMessages;
  10077. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  10078. GetDisplayMessages = json_tokener_parse(payload);
  10079. if(!is_error(GetDisplayMessages))
  10080. {
  10081. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  10082. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  10083. // Required data
  10084. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  10085. {
  10086. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  10087. }
  10088. // Optional data
  10089. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  10090. {
  10091. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  10092. }
  10093. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  10094. {
  10095. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  10096. }
  10097. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  10098. {
  10099. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  10100. {
  10101. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  10102. }
  10103. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  10104. }
  10105. else
  10106. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  10107. }
  10108. json_object_put(GetDisplayMessages);
  10109. return result;
  10110. }
  10111. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  10112. {
  10113. mtrace();
  10114. int result = FAIL;
  10115. json_object *GetInstalledCertificateIds;
  10116. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  10117. GetInstalledCertificateIds = json_tokener_parse(payload);
  10118. if(!is_error(GetInstalledCertificateIds))
  10119. {
  10120. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  10121. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  10122. // Optional data
  10123. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  10124. {
  10125. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  10126. {
  10127. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  10128. /*
  10129. * TODO:
  10130. * 1. Get installed certificate info for response
  10131. */
  10132. }
  10133. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  10134. }
  10135. else
  10136. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  10137. }
  10138. json_object_put(GetInstalledCertificateIds);
  10139. sendInstallCertificateConfirmation(uuid);
  10140. return result;
  10141. }
  10142. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  10143. {
  10144. mtrace();
  10145. int result = FAIL;
  10146. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  10147. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  10148. {
  10149. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  10150. localversion = -1;
  10151. }
  10152. else
  10153. {
  10154. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  10155. DB_getListVerion();
  10156. }
  10157. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  10158. sendGetLocalListVersionConfirmation(uuid);
  10159. return result;
  10160. }
  10161. static char fnamePlusPath[100]={0};
  10162. static char fnamePWithNoPath[60]={0};
  10163. void checkUploadLog(void)
  10164. {
  10165. FILE *fp;
  10166. /* Open the command for reading. */
  10167. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  10168. if (fp == NULL) {
  10169. printf("Failed to run command\n" );
  10170. exit(1);
  10171. }
  10172. int ftppathlen = 0;
  10173. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  10174. int i = 0;
  10175. /* Read the output a line at a time - output it. */
  10176. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  10177. if(i==0)
  10178. {
  10179. ftppathlen = strlen(fnamePlusPath);
  10180. printf("%s\n", fnamePlusPath);
  10181. fnamePlusPath[ftppathlen]='\0';
  10182. break;
  10183. }
  10184. i= i+1;
  10185. }
  10186. /* close */
  10187. pclose(fp);
  10188. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  10189. {
  10190. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  10191. {
  10192. fnamePlusPath[k]='\0';
  10193. }
  10194. }
  10195. i=1;
  10196. //char fname[60]={0};
  10197. while(i < ftppathlen)
  10198. {
  10199. int len=ftppathlen-i;
  10200. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  10201. {
  10202. printf("compare '/' all right\n");
  10203. break;
  10204. }
  10205. i=i+1;
  10206. }
  10207. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  10208. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  10209. fnamePWithNoPath[i+1] = '\0';
  10210. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  10211. {
  10212. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  10213. {
  10214. fnamePWithNoPath[j]='\0';
  10215. }
  10216. }
  10217. FILE* fp1 = fopen(fnamePlusPath, "r");
  10218. if (fp1)
  10219. {
  10220. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  10221. // file exists
  10222. fclose(fp1);
  10223. }
  10224. else
  10225. {
  10226. // file doesn't exist
  10227. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  10228. }
  10229. }
  10230. void* GetLogProcess(void* data)
  10231. {
  10232. pthread_detach(pthread_self());
  10233. mtrace();
  10234. int requestId, retriesInt=0, retryIntervalInt=0;
  10235. char logType[32], remoteLocation[512]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  10236. 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};
  10237. int port=0;
  10238. int isSuccess = FALSE;
  10239. char ftpbuf[200]={0};
  10240. json_object *GetLog;
  10241. DEBUG_INFO("GetGetProcess...\n");
  10242. GetLog = json_tokener_parse(data);
  10243. if(!is_error(GetLog))
  10244. {
  10245. // Required data
  10246. if(json_object_object_get(GetLog, "requestId") != NULL)
  10247. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  10248. if(json_object_object_get(GetLog, "logType") != NULL)
  10249. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  10250. if(json_object_object_get(GetLog, "log") != NULL)
  10251. {
  10252. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  10253. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  10254. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  10255. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  10256. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  10257. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  10258. }
  10259. // Optional data
  10260. if(json_object_object_get(GetLog, "retries") != NULL)
  10261. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  10262. else
  10263. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  10264. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  10265. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  10266. else
  10267. retryIntervalInt = 30;
  10268. }
  10269. json_object_put(GetLog);
  10270. ShmOCPP20Data->GetLog.requestId = requestId;
  10271. //****************location*******************/
  10272. if(strcmp(remoteLocation,"")==0)
  10273. {
  10274. DEBUG_INFO("remoteLocation is <Empty>!\n");
  10275. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10276. goto end;
  10277. }
  10278. memset(protocol, 0, ARRAY_SIZE(protocol));
  10279. memset(user, 0, ARRAY_SIZE(user) );
  10280. memset(password, 0, ARRAY_SIZE(password));
  10281. memset(host, 0, ARRAY_SIZE(host));
  10282. memset(path, 0, ARRAY_SIZE(path));
  10283. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  10284. memset(host1, 0, ARRAY_SIZE(host1));
  10285. memset(path1, 0, ARRAY_SIZE(path1));
  10286. /*location: ftp://user:password@host:port/path*/
  10287. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  10288. if((access(fnamePlusPath,F_OK))!=-1)
  10289. {
  10290. DEBUG_INFO("fnamePlusPath exist.\n");
  10291. }
  10292. else
  10293. {
  10294. DEBUG_INFO("fnamePlusPath not exist!\n");
  10295. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10296. goto end;
  10297. }
  10298. if(strchr(remoteLocation,'@')==NULL)
  10299. {
  10300. sscanf(remoteLocation,
  10301. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  10302. protocol, host, &port, path);
  10303. strcpy(user,"anonymous");
  10304. strcpy(password,"");
  10305. }
  10306. else
  10307. {
  10308. //DEBUG_INFO("pch=%s\n", pch);
  10309. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  10310. protocol, user, password, host, &port, path);
  10311. }
  10312. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
  10313. {
  10314. DEBUG_INFO("protocol is not ftp/http ! \n");
  10315. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10316. goto end;
  10317. }
  10318. if(strncmp(remoteLocation,"http", 4) == 0)
  10319. {
  10320. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  10321. sprintf(ftppath,"/%s", path);
  10322. do
  10323. {
  10324. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  10325. sleep(3);
  10326. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  10327. if(!isSuccess)
  10328. {
  10329. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  10330. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10331. sleep(retryIntervalInt);
  10332. }
  10333. else
  10334. {
  10335. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  10336. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  10337. }
  10338. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt--));
  10339. }
  10340. else
  10341. {
  10342. sscanf(host,"%[^/]%s",host1, path1);
  10343. sprintf(ftppath,"%s", path1);
  10344. int ftppathlen=strlen(ftppath);
  10345. int i=1;
  10346. char filenametemp[50];
  10347. while(i < ftppathlen)
  10348. {
  10349. int len=ftppathlen-i;
  10350. if(ftppath[len]== 47) // '/' ascll code: 47
  10351. {
  10352. DEBUG_INFO("find '/' all right\n");
  10353. break;
  10354. }
  10355. i=i+1;
  10356. }
  10357. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  10358. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  10359. filenametemp[i+1] = 0;
  10360. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  10361. if(port == 0)
  10362. port = 21;
  10363. do
  10364. {
  10365. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  10366. sleep(3);
  10367. isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  10368. if(!isSuccess)
  10369. {
  10370. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  10371. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10372. sleep(retryIntervalInt);
  10373. }
  10374. else
  10375. {
  10376. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  10377. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  10378. }
  10379. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  10380. }
  10381. end:
  10382. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  10383. pthread_exit(NULL);
  10384. }
  10385. int handleGetLogRequest(char *uuid, char *payload)
  10386. {
  10387. mtrace();
  10388. int result = FAIL;
  10389. char cmdBuf[512];
  10390. char fName[258];
  10391. time_t CurrentTime;
  10392. struct tm *tm;
  10393. pthread_t th_Status;
  10394. CurrentTime = time(NULL);
  10395. tm = localtime(&CurrentTime);
  10396. 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);
  10397. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  10398. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  10399. sendGetLogConfirmation(uuid);
  10400. system("exec /root/logPackTools 'log' 6");
  10401. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", fName);
  10402. system(cmdBuf);
  10403. checkUploadLog();
  10404. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  10405. return result;
  10406. }
  10407. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  10408. {
  10409. mtrace();
  10410. int result = FAIL;
  10411. json_object *GetMonitoringReport;
  10412. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  10413. GetMonitoringReport = json_tokener_parse(payload);
  10414. if(!is_error(GetMonitoringReport))
  10415. {
  10416. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  10417. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  10418. // Required data
  10419. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  10420. {
  10421. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  10422. }
  10423. // Optional data
  10424. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  10425. {
  10426. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  10427. }
  10428. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  10429. {
  10430. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  10431. {
  10432. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  10433. {
  10434. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  10435. {
  10436. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  10437. {
  10438. 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")));
  10439. }
  10440. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10441. {
  10442. 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")));
  10443. }
  10444. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10445. {
  10446. 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)
  10447. {
  10448. 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"));
  10449. }
  10450. 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)
  10451. {
  10452. 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"));
  10453. }
  10454. }
  10455. }
  10456. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  10457. {
  10458. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10459. {
  10460. 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")));
  10461. }
  10462. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10463. {
  10464. 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")));
  10465. }
  10466. }
  10467. }
  10468. }
  10469. }
  10470. }
  10471. json_object_put(GetMonitoringReport);
  10472. /*
  10473. * TODO:
  10474. * 1. Response result
  10475. */
  10476. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10477. sendGetMonitoringReportConfirmation(uuid);
  10478. return result;
  10479. }
  10480. int handleGetReportRequest(char *uuid, char *payload)
  10481. {
  10482. mtrace();
  10483. int result = FAIL;
  10484. json_object *GetReport;
  10485. DEBUG_INFO("handleGetReportRequest...\n");
  10486. GetReport = json_tokener_parse(payload);
  10487. if(!is_error(GetReport))
  10488. {
  10489. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  10490. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  10491. // Required data
  10492. if(json_object_object_get(GetReport, "requestId") != NULL)
  10493. {
  10494. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  10495. }
  10496. // Optional data
  10497. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  10498. {
  10499. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  10500. }
  10501. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  10502. {
  10503. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  10504. {
  10505. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  10506. {
  10507. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  10508. {
  10509. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  10510. {
  10511. 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")));
  10512. }
  10513. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10514. {
  10515. 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")));
  10516. }
  10517. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10518. {
  10519. 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)
  10520. {
  10521. 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"));
  10522. }
  10523. 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)
  10524. {
  10525. 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"));
  10526. }
  10527. }
  10528. }
  10529. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  10530. {
  10531. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10532. {
  10533. 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")));
  10534. }
  10535. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10536. {
  10537. 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")));
  10538. }
  10539. }
  10540. }
  10541. }
  10542. }
  10543. }
  10544. json_object_put(GetReport);
  10545. /*
  10546. * TODO:
  10547. * 1. Response result
  10548. */
  10549. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10550. sendGetReportConfirmation(uuid);
  10551. return result;
  10552. }
  10553. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  10554. {
  10555. mtrace();
  10556. int result = FAIL;
  10557. int8_t gun_index = -1;
  10558. json_object *GetTransactionStatus;
  10559. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  10560. GetTransactionStatus = json_tokener_parse(payload);
  10561. if(!is_error(GetTransactionStatus))
  10562. {
  10563. /*
  10564. * TODO:
  10565. * 1. Check transaction locate which connector
  10566. */
  10567. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  10568. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  10569. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  10570. {
  10571. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  10572. }
  10573. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  10574. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  10575. }
  10576. json_object_put(GetTransactionStatus);
  10577. sendGetTransactionStatusConfirmation(uuid, gun_index);
  10578. return result;
  10579. }
  10580. int handleGetVariablesRequest(char *uuid, char *payload)
  10581. {
  10582. mtrace();
  10583. int result = FAIL;
  10584. json_object *GetVariables;
  10585. DEBUG_INFO("handleGetVariablesRequest...\n");
  10586. GetVariables = json_tokener_parse(payload);
  10587. if(!is_error(GetVariables))
  10588. {
  10589. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  10590. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  10591. // Required data
  10592. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  10593. {
  10594. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  10595. {
  10596. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  10597. {
  10598. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  10599. {
  10600. 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")));
  10601. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  10602. }
  10603. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  10604. {
  10605. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  10606. {
  10607. 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")));
  10608. }
  10609. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  10610. {
  10611. 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")));
  10612. }
  10613. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  10614. {
  10615. 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)
  10616. {
  10617. 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"));
  10618. }
  10619. 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)
  10620. {
  10621. 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"));
  10622. }
  10623. }
  10624. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  10625. }
  10626. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  10627. {
  10628. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  10629. {
  10630. 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")));
  10631. }
  10632. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  10633. {
  10634. 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")));
  10635. }
  10636. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  10637. }
  10638. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  10639. {
  10640. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) == 0) &&
  10641. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance) == 0) &&
  10642. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) == 0) &&
  10643. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance) == 0))
  10644. {
  10645. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  10646. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  10647. break;
  10648. }
  10649. else
  10650. {
  10651. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  10652. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  10653. }
  10654. }
  10655. }
  10656. }
  10657. }
  10658. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  10659. }
  10660. json_object_put(GetVariables);
  10661. return result;
  10662. }
  10663. int handleInstallCertificateRequest(char *uuid, char *payload)
  10664. {
  10665. mtrace();
  10666. int result = FAIL;
  10667. json_object *InstallCertificate;
  10668. DEBUG_INFO("handleInstallCertificateRequest...\n");
  10669. InstallCertificate = json_tokener_parse(payload);
  10670. if(!is_error(InstallCertificate))
  10671. {
  10672. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  10673. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  10674. // Required data
  10675. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  10676. {
  10677. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  10678. }
  10679. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  10680. {
  10681. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  10682. }
  10683. }
  10684. json_object_put(InstallCertificate);
  10685. /*
  10686. * TODO:
  10687. * 1. Install certification preocess and response
  10688. */
  10689. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10690. sendInstallCertificateConfirmation(uuid);
  10691. return result;
  10692. }
  10693. int handlePublishFirmwareRequest(char *uuid, char *payload)
  10694. {
  10695. mtrace();
  10696. int result = FAIL;
  10697. json_object *PublishFirmware;
  10698. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  10699. PublishFirmware = json_tokener_parse(payload);
  10700. if(!is_error(PublishFirmware))
  10701. {
  10702. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  10703. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  10704. // Required data
  10705. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  10706. {
  10707. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  10708. }
  10709. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  10710. {
  10711. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  10712. }
  10713. // Optional data
  10714. if(json_object_object_get(PublishFirmware, "location") != NULL)
  10715. {
  10716. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  10717. }
  10718. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  10719. {
  10720. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  10721. }
  10722. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  10723. {
  10724. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  10725. }
  10726. }
  10727. json_object_put(PublishFirmware);
  10728. /*
  10729. * TODO:
  10730. * 1. Publish firmware preocess and response
  10731. */
  10732. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10733. sendPublishFirmwareConfirmation(uuid);
  10734. return result;
  10735. }
  10736. int handleRemoteStartTransactionRequest(char *uuid, char *payload)
  10737. {
  10738. mtrace();
  10739. int result = FAIL;
  10740. int8_t gun_index = -1;
  10741. uint8_t isPeriodOverMax = FALSE;
  10742. uint8_t isProfileOverMax = FALSE;
  10743. uint8_t isConnectorMismatch = FALSE;
  10744. uint8_t isTxProfile = FALSE;
  10745. uint8_t existProfileQuantity = 0;
  10746. uint8_t filename[128]={0};
  10747. uint8_t word[2048]={0};
  10748. FILE *filePtr;
  10749. json_object *RemoteStartTransaction;
  10750. DEBUG_INFO("handleRemoteStartTransactionRequest...\n");
  10751. RemoteStartTransaction = json_tokener_parse(payload);
  10752. if(!is_error(RemoteStartTransaction))
  10753. {
  10754. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  10755. {
  10756. gun_index = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
  10757. }
  10758. else
  10759. {
  10760. /*
  10761. * TODO:
  10762. * 1. Selected connector process
  10763. */
  10764. gun_index = 0;
  10765. }
  10766. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  10767. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  10768. // Required data
  10769. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  10770. {
  10771. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  10772. }
  10773. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  10774. {
  10775. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  10776. {
  10777. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  10778. }
  10779. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  10780. {
  10781. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  10782. }
  10783. }
  10784. // Optional data
  10785. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  10786. {
  10787. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  10788. {
  10789. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  10790. }
  10791. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  10792. {
  10793. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  10794. }
  10795. }
  10796. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  10797. {
  10798. // Check periods is over max configuration
  10799. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  10800. {
  10801. isPeriodOverMax = TRUE;
  10802. }
  10803. // Check periods is over max configuration
  10804. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  10805. {
  10806. if(gun_index > 0)
  10807. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  10808. else
  10809. isConnectorMismatch = TRUE;
  10810. if(!isConnectorMismatch)
  10811. {
  10812. filePtr = fopen((char*)filename, "r");
  10813. if (!filePtr)
  10814. {
  10815. DEBUG_INFO("%s not exist, create it.\n", filename);
  10816. filePtr = fopen((char*)filename, "w+");
  10817. }
  10818. else
  10819. {
  10820. //Check Charging Profile Count
  10821. while(fscanf(filePtr, "%s", word) != EOF)
  10822. {
  10823. //DEBUG_INFO("word=%s\n",word);
  10824. if(strstr((char*)word, "chargingProfileId")!= NULL)
  10825. {
  10826. existProfileQuantity += 1;
  10827. }
  10828. }
  10829. }
  10830. fclose(filePtr);
  10831. }
  10832. }
  10833. else
  10834. {
  10835. }
  10836. if(existProfileQuantity > 3)
  10837. isProfileOverMax = TRUE;
  10838. }
  10839. // Profile replace or add info
  10840. if((gun_index > 0) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTxProfile)
  10841. {
  10842. FILE *infile;
  10843. FILE *outfile;
  10844. char tmpProfileName[32];
  10845. char rmFileCmd[128];
  10846. char tempchargingProfilePurposeStr[30]={0};
  10847. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  10848. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfileRemote");
  10849. infile = fopen ((char*)filename, "r");
  10850. outfile = fopen ((char*)tmpProfileName, "w");
  10851. int d = fgetc(infile);
  10852. rewind(infile);
  10853. if(d == EOF)
  10854. {
  10855. // Profile is empty
  10856. fprintf(outfile,"%s\n", payload);
  10857. fclose(infile);
  10858. fclose(outfile);
  10859. sprintf(rmFileCmd,"rm -f %s",filename);
  10860. system(rmFileCmd);
  10861. rename((char*)tmpProfileName, (char*)filename);
  10862. }
  10863. else
  10864. {
  10865. // Profile is not empty
  10866. char buf[2048]={0};
  10867. int ChargingProfileAdded = FALSE;
  10868. while (fgets(buf, sizeof(buf), infile) != NULL)
  10869. {
  10870. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  10871. json_object *tmpChargingProfile;
  10872. tmpChargingProfile = json_tokener_parse(buf);
  10873. if(!is_error(tmpChargingProfile))
  10874. {
  10875. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  10876. {
  10877. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  10878. }
  10879. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  10880. {
  10881. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  10882. {
  10883. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  10884. }
  10885. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  10886. {
  10887. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  10888. }
  10889. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  10890. {
  10891. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  10892. }
  10893. }
  10894. }
  10895. json_object_put(tmpChargingProfile);
  10896. if((tempconnectorIdInt == gun_index) &&
  10897. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId"))))
  10898. {
  10899. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel"))) &&
  10900. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  10901. {
  10902. if(ChargingProfileAdded == FALSE)
  10903. {
  10904. fprintf(outfile,"%s\n",payload);
  10905. ChargingProfileAdded = TRUE;
  10906. }
  10907. }
  10908. else
  10909. {
  10910. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10911. {
  10912. if(ChargingProfileAdded == FALSE)
  10913. {
  10914. fprintf(outfile,"%s\n",buf);
  10915. fprintf(outfile,"%s\n",payload);
  10916. ChargingProfileAdded = TRUE;
  10917. }
  10918. else
  10919. {
  10920. fprintf(outfile,"%s\n",buf);
  10921. }
  10922. }
  10923. else
  10924. {
  10925. if(ChargingProfileAdded == FALSE)
  10926. {
  10927. fprintf(outfile,"%s\n",buf);
  10928. fprintf(outfile,"%s\n",payload);
  10929. ChargingProfileAdded = TRUE;
  10930. }
  10931. else
  10932. {
  10933. fprintf(outfile,"%s\n",buf);
  10934. }
  10935. }
  10936. }
  10937. }
  10938. else
  10939. {
  10940. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId")))
  10941. {
  10942. if(ChargingProfileAdded == FALSE)
  10943. {
  10944. fprintf(outfile,"%s\n",buf);
  10945. fprintf(outfile,"%s\n",payload);
  10946. ChargingProfileAdded = TRUE;
  10947. }
  10948. else
  10949. {
  10950. fprintf(outfile,"%s\n",buf);
  10951. }
  10952. }
  10953. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10954. {
  10955. if(ChargingProfileAdded == FALSE)
  10956. {
  10957. fprintf(outfile,"%s\n",buf);
  10958. fprintf(outfile,"%s\n",payload);
  10959. ChargingProfileAdded = TRUE;
  10960. }
  10961. else
  10962. {
  10963. fprintf(outfile,"%s\n",buf);
  10964. }
  10965. }
  10966. else
  10967. {
  10968. if(ChargingProfileAdded == FALSE)
  10969. {
  10970. fprintf(outfile,"%s\n",buf);
  10971. fprintf(outfile,"%s\n",payload);
  10972. ChargingProfileAdded = TRUE;
  10973. }
  10974. else
  10975. {
  10976. fprintf(outfile,"%s\n",buf);
  10977. }
  10978. }
  10979. }
  10980. } // end of while loop
  10981. fclose(infile);
  10982. fclose(outfile);
  10983. sprintf(rmFileCmd,"rm -f %s",filename);
  10984. system(rmFileCmd);
  10985. rename((char*)tmpProfileName, (char*)filename);
  10986. }
  10987. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted] );
  10988. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_transactionId);
  10989. result = PASS;
  10990. }
  10991. else
  10992. {
  10993. if(gun_index <= 0)
  10994. DEBUG_WARN("Connector id is wrong.\n");
  10995. if(isConnectorMismatch)
  10996. DEBUG_WARN("Connector id is mismatch.\n");
  10997. if(isPeriodOverMax)
  10998. DEBUG_WARN("Profile periods quantity is over spec.\n");
  10999. if(isProfileOverMax)
  11000. DEBUG_WARN("Profile quantity is over spec.\n");
  11001. if(!isTxProfile)
  11002. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  11003. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  11004. }
  11005. }
  11006. json_object_put(RemoteStartTransaction);
  11007. sendRemoteStartTransactionConfirmation(uuid, gun_index);
  11008. return result;
  11009. }
  11010. int handleRemoteStopTransactionRequest(char *uuid, char *payload)
  11011. {
  11012. mtrace();
  11013. int result = FAIL;
  11014. int match = FALSE;
  11015. int GunNO = 0;
  11016. int tempIndex = 0;
  11017. char transactionIdStr[37];
  11018. int transactionIdIsNULL= TRUE;
  11019. json_object *RemoteStopTransaction;
  11020. DEBUG_INFO("handleRemoteStopTransactionRequest...\n");
  11021. if(server_pending == TRUE)
  11022. {
  11023. return 0;
  11024. }
  11025. RemoteStopTransaction = json_tokener_parse(payload);
  11026. if(!is_error(RemoteStopTransaction))
  11027. {
  11028. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  11029. {
  11030. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  11031. transactionIdIsNULL = FALSE;
  11032. }
  11033. }
  11034. json_object_put(RemoteStopTransaction);
  11035. if(transactionIdIsNULL == FALSE)
  11036. {
  11037. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  11038. {
  11039. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  11040. {
  11041. //check Transaction active
  11042. if(gunType[gun_index] == 'J')
  11043. {
  11044. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11045. {
  11046. tempIndex = ((gun_index==2) ? 1: 0);
  11047. }
  11048. else
  11049. {
  11050. tempIndex = gun_index;
  11051. }
  11052. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11053. {
  11054. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  11055. {
  11056. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11057. {
  11058. match = TRUE;
  11059. GunNO = gun_index;
  11060. }
  11061. }
  11062. }// END FOR CHAdeMO_QUANTITY
  11063. }
  11064. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  11065. {
  11066. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11067. {
  11068. tempIndex = ((gun_index==2) ? 1: 0);
  11069. }
  11070. else
  11071. {
  11072. tempIndex = gun_index;
  11073. }
  11074. for (int index = 0; index < CCS_QUANTITY; index++)
  11075. {
  11076. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  11077. {
  11078. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11079. {
  11080. match = TRUE;
  11081. GunNO = gun_index;
  11082. }
  11083. }
  11084. }// END FOR CCS_QUANTITY
  11085. }
  11086. else if(gunType[gun_index] == 'G')
  11087. {
  11088. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11089. {
  11090. tempIndex = ((gun_index==2) ? 1: 0);
  11091. }
  11092. else
  11093. {
  11094. tempIndex = gun_index;
  11095. }
  11096. for (int index = 0; index < GB_QUANTITY; index++)
  11097. {
  11098. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  11099. {
  11100. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11101. {
  11102. match = TRUE;
  11103. GunNO = gun_index;
  11104. }
  11105. }
  11106. }// END FOR GB_QUANTITY
  11107. }
  11108. else if(gunType[gun_index] == 'O')
  11109. {
  11110. tempIndex = gun_index;
  11111. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11112. {
  11113. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  11114. {
  11115. 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
  11116. {
  11117. match = TRUE;
  11118. GunNO = gun_index;
  11119. }
  11120. }
  11121. }// END FOR GB_QUANTITY
  11122. }
  11123. else
  11124. {
  11125. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11126. {
  11127. tempIndex = 2;
  11128. }
  11129. else
  11130. {
  11131. tempIndex = gun_index;
  11132. }
  11133. for (int index = 0; index < AC_QUANTITY; index++)
  11134. {
  11135. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  11136. {
  11137. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11138. {
  11139. match = TRUE;
  11140. GunNO = gun_index;
  11141. }
  11142. }
  11143. }// END FOR CHAdeMO_QUANTITY
  11144. } // END FOR AC ELSE
  11145. }// CHECK IF ResponseTransactionId == transactionIdInt
  11146. }//END FOR
  11147. if( match == TRUE)
  11148. {
  11149. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  11150. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  11151. }
  11152. else
  11153. {
  11154. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  11155. }
  11156. }
  11157. else
  11158. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  11159. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  11160. return result;
  11161. }
  11162. int handleReserveNowRequest(char *uuid, char *payload)
  11163. {
  11164. mtrace();
  11165. int result = FAIL;
  11166. int connectorIdInt=0, reservationIdInt=0;
  11167. int tempIndex = 0;
  11168. json_object *ReserveNow;
  11169. DEBUG_INFO("handleReserveNowRequest ...\n");
  11170. ReserveNow = json_tokener_parse(payload);
  11171. if(!is_error(ReserveNow))
  11172. {
  11173. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  11174. {
  11175. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  11176. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  11177. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  11178. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  11179. }
  11180. // Required data
  11181. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  11182. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  11183. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  11184. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  11185. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  11186. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  11187. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  11188. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  11189. // Optional data
  11190. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  11191. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  11192. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  11193. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  11194. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  11195. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  11196. result = PASS;
  11197. }
  11198. json_object_put(ReserveNow);
  11199. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11200. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  11201. {
  11202. //check Transaction active
  11203. if(gunType[connectorIdInt -1] == 'J')
  11204. {
  11205. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11206. {
  11207. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11208. }
  11209. else
  11210. {
  11211. tempIndex = connectorIdInt -1;
  11212. }
  11213. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11214. {
  11215. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  11216. {
  11217. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  11218. {
  11219. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  11220. {
  11221. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11222. {
  11223. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11224. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11225. }
  11226. 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'))
  11227. {
  11228. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11229. }
  11230. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11231. {
  11232. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11233. }
  11234. else
  11235. {
  11236. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11237. }
  11238. }
  11239. 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
  11240. {
  11241. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11242. }
  11243. }
  11244. else
  11245. {
  11246. //replace reservation
  11247. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11248. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11249. }
  11250. }
  11251. } // END FOR CHAdeMO_QUANTITY
  11252. }
  11253. else if((gunType[connectorIdInt -1] == 'U')||(gunType[connectorIdInt -1] == 'E'))
  11254. {
  11255. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11256. {
  11257. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11258. }
  11259. else
  11260. {
  11261. tempIndex = connectorIdInt -1;
  11262. }
  11263. for (int index = 0; index < CCS_QUANTITY; index++)
  11264. {
  11265. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  11266. {
  11267. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  11268. {
  11269. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11270. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  11271. {
  11272. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11273. {
  11274. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11275. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11276. }
  11277. 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'))
  11278. {
  11279. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11280. }
  11281. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  11282. {
  11283. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11284. }
  11285. else
  11286. {
  11287. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11288. }
  11289. }
  11290. 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
  11291. {
  11292. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11293. }
  11294. }
  11295. else
  11296. {
  11297. //replace reservation
  11298. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11299. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11300. }
  11301. }
  11302. } // END FOR CCS_QUANTITY
  11303. }
  11304. else if(gunType[connectorIdInt -1] == 'G')
  11305. {
  11306. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11307. {
  11308. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11309. }
  11310. else
  11311. {
  11312. tempIndex = connectorIdInt -1;
  11313. }
  11314. for (int index = 0; index < GB_QUANTITY; index++)
  11315. {
  11316. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  11317. {
  11318. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  11319. {
  11320. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11321. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11322. {
  11323. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11324. {
  11325. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11326. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11327. }
  11328. 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'))
  11329. {
  11330. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11331. }
  11332. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11333. {
  11334. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11335. }
  11336. else
  11337. {
  11338. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11339. }
  11340. }
  11341. 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
  11342. {
  11343. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11344. }
  11345. }
  11346. else
  11347. {
  11348. //replace reservation
  11349. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11350. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11351. }
  11352. }
  11353. }// END FOR GB_QUANTITY
  11354. }
  11355. else
  11356. {
  11357. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11358. {
  11359. tempIndex = 2;
  11360. }
  11361. else
  11362. {
  11363. tempIndex = (connectorIdInt -1);
  11364. }
  11365. for (int index = 0; index < AC_QUANTITY; index++)
  11366. {
  11367. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  11368. {
  11369. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11370. {
  11371. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11372. {
  11373. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11374. {
  11375. 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))
  11376. {
  11377. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11378. }
  11379. else
  11380. {
  11381. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11382. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11383. }
  11384. }
  11385. 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'))
  11386. {
  11387. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11388. }
  11389. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11390. {
  11391. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11392. }
  11393. else
  11394. {
  11395. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11396. }
  11397. }
  11398. 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
  11399. {
  11400. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11401. }
  11402. }
  11403. else
  11404. {
  11405. //replace reservation
  11406. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11407. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11408. }
  11409. }
  11410. } // END FOR AC_QUANTITY
  11411. }
  11412. }
  11413. else if(connectorIdInt == 0)
  11414. {
  11415. //check Transaction active
  11416. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11417. {
  11418. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  11419. {
  11420. 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'))
  11421. {
  11422. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11423. goto end;
  11424. }
  11425. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11426. {
  11427. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11428. goto end;
  11429. }
  11430. 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
  11431. {
  11432. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11433. goto end;
  11434. }
  11435. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11436. {
  11437. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11438. goto end;
  11439. }
  11440. }
  11441. }// END FOR CHAdeMO_QUANTITY
  11442. for (int index = 0; index < CCS_QUANTITY; index++)
  11443. {
  11444. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  11445. {
  11446. 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'))
  11447. {
  11448. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11449. goto end;
  11450. }
  11451. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  11452. {
  11453. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11454. goto end;
  11455. }
  11456. 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
  11457. {
  11458. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11459. goto end;
  11460. }
  11461. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11462. {
  11463. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11464. goto end;
  11465. }
  11466. }
  11467. } // END FOR CCS_QUANTITY
  11468. for (int index = 0; index < GB_QUANTITY; index++)
  11469. {
  11470. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  11471. {
  11472. 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'))
  11473. {
  11474. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11475. goto end;
  11476. }
  11477. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11478. {
  11479. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11480. goto end;
  11481. }
  11482. 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
  11483. {
  11484. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11485. goto end;
  11486. }
  11487. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11488. {
  11489. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11490. goto end;
  11491. }
  11492. }
  11493. } // END FOR GB_QUANTITY
  11494. for (int index = 0; index < AC_QUANTITY; index++)
  11495. {
  11496. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11497. {
  11498. 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'))
  11499. {
  11500. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11501. goto end;
  11502. }
  11503. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11504. {
  11505. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11506. goto end;
  11507. }
  11508. 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
  11509. {
  11510. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11511. goto end;
  11512. }
  11513. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11514. {
  11515. 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))
  11516. {
  11517. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11518. goto end;
  11519. }
  11520. }
  11521. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11522. {
  11523. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11524. goto end;
  11525. }
  11526. }
  11527. }// END FOR AC_QUANTITY
  11528. //The connectorId is 0
  11529. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  11530. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11531. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  11532. result = TRUE;
  11533. return result;
  11534. }
  11535. else
  11536. {
  11537. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11538. }
  11539. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  11540. {
  11541. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  11542. result = TRUE;
  11543. return result;
  11544. }
  11545. end:
  11546. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  11547. return result;
  11548. }
  11549. int handleResetRequest(char *uuid, char *payload)
  11550. {
  11551. mtrace();
  11552. int result = FAIL;
  11553. json_object *Reset = json_object_new_object();
  11554. DEBUG_INFO("handleResetRequest...\n");
  11555. Reset = json_tokener_parse(payload);
  11556. if(!is_error(Reset))
  11557. {
  11558. // Required data
  11559. if(json_object_object_get(Reset, "type") != NULL)
  11560. {
  11561. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  11562. }
  11563. if(json_object_object_get(Reset, "evseId") != NULL)
  11564. {
  11565. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  11566. }
  11567. }
  11568. json_object_put(Reset);
  11569. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  11570. {
  11571. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  11572. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  11573. result = TRUE;
  11574. return result;
  11575. }
  11576. else
  11577. {
  11578. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  11579. goto errorend;
  11580. }
  11581. errorend:
  11582. sendResetConfirmation(uuid);
  11583. return result;
  11584. }
  11585. int handleSendLocalListRequest(char *uuid, char *payload)
  11586. {
  11587. mtrace();
  11588. int result = FAIL;
  11589. char updateTypestr[15]={0};
  11590. int checkState_Faulted = FALSE;
  11591. json_object *SendLocalList;
  11592. DEBUG_INFO("handleSendLocalListRequest...\n");
  11593. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  11594. {
  11595. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11596. goto end;
  11597. }
  11598. SendLocalList = json_tokener_parse(payload);
  11599. if(!is_error(SendLocalList))
  11600. {
  11601. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  11602. // Required data
  11603. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  11604. {
  11605. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  11606. }
  11607. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  11608. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  11609. // Optional data
  11610. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  11611. {
  11612. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  11613. {
  11614. // Required data
  11615. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  11616. {
  11617. 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")));
  11618. 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")));
  11619. }
  11620. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  11621. {
  11622. 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")));
  11623. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  11624. 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")));
  11625. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  11626. 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"));
  11627. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  11628. {
  11629. 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")));
  11630. 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")));
  11631. }
  11632. }
  11633. }
  11634. }
  11635. }
  11636. json_object_put(SendLocalList);
  11637. //check Charge Point state
  11638. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11639. {
  11640. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11641. {
  11642. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11643. }
  11644. }
  11645. for (int index = 0; index < CCS_QUANTITY; index++)
  11646. {
  11647. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11648. {
  11649. checkState_Faulted = TRUE; //OCPP Status
  11650. }
  11651. }
  11652. for (int index = 0; index < GB_QUANTITY; index++)
  11653. {
  11654. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11655. {
  11656. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11657. }
  11658. }
  11659. for (int index = 0; index < AC_QUANTITY; index++)
  11660. {
  11661. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11662. {
  11663. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11664. }
  11665. }
  11666. if(checkState_Faulted == TRUE)
  11667. {
  11668. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11669. goto end;
  11670. }
  11671. // Check update type
  11672. if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  11673. {
  11674. //Local list full update
  11675. DEBUG_INFO("Local list full update.\n");
  11676. DB_getListVerion();
  11677. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11678. {
  11679. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11680. goto end;
  11681. }
  11682. DB_cleanLocalList();
  11683. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11684. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11685. }
  11686. else if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  11687. {
  11688. //Local list different update
  11689. DEBUG_INFO("Local list different update.\n");
  11690. DB_getListVerion();
  11691. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11692. {
  11693. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  11694. goto end;
  11695. }
  11696. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11697. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11698. }
  11699. else
  11700. {
  11701. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11702. goto end;
  11703. }
  11704. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  11705. end:
  11706. sendSendLocalListConfirmation(uuid);
  11707. return result;
  11708. }
  11709. int handleSetChargingProfileRequest(char *uuid, char *payload)
  11710. {
  11711. mtrace();
  11712. int result = FAIL;
  11713. int8_t gun_index = -1;
  11714. uint8_t isPeriodOverMax = FALSE;
  11715. uint8_t isProfileOverMax = FALSE;
  11716. uint8_t isConnectorMismatch = FALSE;
  11717. uint8_t existProfileQuantity = 0;
  11718. uint8_t filename[128]={0};
  11719. uint8_t word[2048]={0};
  11720. FILE *filePtr;
  11721. json_object *SetChargingProfile;
  11722. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  11723. SetChargingProfile = json_tokener_parse(payload);
  11724. if(!is_error(SetChargingProfile))
  11725. {
  11726. // Required data
  11727. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  11728. {
  11729. gun_index = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  11730. }
  11731. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  11732. {
  11733. // Check periods is over max configuration
  11734. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  11735. {
  11736. isPeriodOverMax = TRUE;
  11737. }
  11738. // Check periods is over max configuration
  11739. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  11740. {
  11741. if(gun_index == 0)
  11742. {
  11743. sprintf((char*)filename, ChargePointMaxProfile_JSON);
  11744. filePtr = fopen((char*)filename, "r");
  11745. if (!filePtr)
  11746. {
  11747. DEBUG_INFO("%s not exist, create it.\n", ChargePointMaxProfile_JSON);
  11748. filePtr = fopen((char*)filename, "w+");
  11749. }
  11750. else
  11751. {
  11752. //Check Charging Profile Count
  11753. while(fscanf(filePtr, "%s", word) != EOF)
  11754. {
  11755. //DEBUG_INFO("word=%s\n",word);
  11756. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11757. {
  11758. existProfileQuantity += 1;
  11759. }
  11760. }
  11761. }
  11762. fclose(filePtr);
  11763. }
  11764. else
  11765. isConnectorMismatch = TRUE;
  11766. }
  11767. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  11768. {
  11769. if(gun_index < 5)
  11770. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", gun_index);
  11771. else
  11772. isConnectorMismatch = TRUE;
  11773. if(!isConnectorMismatch)
  11774. {
  11775. filePtr = fopen((char*)filename, "r");
  11776. if (!filePtr)
  11777. {
  11778. DEBUG_INFO("%s not exist, create it.\n", filename);
  11779. filePtr = fopen((char*)filename, "w+");
  11780. }
  11781. else
  11782. {
  11783. //Check Charging Profile Count
  11784. while(fscanf(filePtr, "%s", word) != EOF)
  11785. {
  11786. //DEBUG_INFO("word=%s\n",word);
  11787. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11788. {
  11789. existProfileQuantity += 1;
  11790. }
  11791. }
  11792. }
  11793. fclose(filePtr);
  11794. }
  11795. }
  11796. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  11797. {
  11798. if(gun_index>0)
  11799. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  11800. else
  11801. isConnectorMismatch = TRUE;
  11802. if(!isConnectorMismatch)
  11803. {
  11804. filePtr = fopen((char*)filename, "r");
  11805. if (!filePtr)
  11806. {
  11807. DEBUG_INFO("%s not exist, create it.\n", filename);
  11808. filePtr = fopen((char*)filename, "w+");
  11809. }
  11810. else
  11811. {
  11812. //Check Charging Profile Count
  11813. while(fscanf(filePtr, "%s", word) != EOF)
  11814. {
  11815. //DEBUG_INFO("word=%s\n",word);
  11816. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11817. {
  11818. existProfileQuantity += 1;
  11819. }
  11820. }
  11821. }
  11822. fclose(filePtr);
  11823. }
  11824. }
  11825. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  11826. {
  11827. }
  11828. else
  11829. {
  11830. }
  11831. if(existProfileQuantity > 3)
  11832. isProfileOverMax = TRUE;
  11833. }
  11834. // Profile replace or add info
  11835. if((gun_index > -1) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch)
  11836. {
  11837. FILE *infile;
  11838. FILE *outfile;
  11839. char tmpProfileName[32];
  11840. char rmFileCmd[128];
  11841. char tempchargingProfilePurposeStr[30]={0};
  11842. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  11843. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfile");
  11844. infile = fopen ((char*)filename, "r");
  11845. outfile = fopen ((char*)tmpProfileName, "w");
  11846. int d = fgetc(infile);
  11847. rewind(infile);
  11848. if(d == EOF)
  11849. {
  11850. // Profile is empty
  11851. fprintf(outfile,"%s\n", payload);
  11852. fclose(infile);
  11853. fclose(outfile);
  11854. sprintf(rmFileCmd,"rm -f %s",filename);
  11855. system(rmFileCmd);
  11856. rename((char*)tmpProfileName, (char*)filename);
  11857. }
  11858. else
  11859. {
  11860. // Profile is not empty
  11861. char buf[2048]={0};
  11862. int ChargingProfileAdded = FALSE;
  11863. while (fgets(buf, sizeof(buf), infile) != NULL)
  11864. {
  11865. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  11866. json_object *tmpChargingProfile;
  11867. tmpChargingProfile = json_tokener_parse(buf);
  11868. if(!is_error(tmpChargingProfile))
  11869. {
  11870. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  11871. {
  11872. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  11873. }
  11874. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  11875. {
  11876. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  11877. {
  11878. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  11879. }
  11880. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  11881. {
  11882. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  11883. }
  11884. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  11885. {
  11886. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  11887. }
  11888. }
  11889. }
  11890. json_object_put(tmpChargingProfile);
  11891. if((tempconnectorIdInt == gun_index) &&
  11892. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId"))))
  11893. {
  11894. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel"))) &&
  11895. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  11896. {
  11897. //DEBUG_INFO("update set chargingProfile to file -0\n");
  11898. if(ChargingProfileAdded == FALSE)
  11899. {
  11900. fprintf(outfile,"%s\n",payload);
  11901. ChargingProfileAdded = TRUE;
  11902. }
  11903. }
  11904. else
  11905. {
  11906. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11907. {
  11908. if(ChargingProfileAdded == FALSE)
  11909. {
  11910. fprintf(outfile,"%s\n",buf);
  11911. fprintf(outfile,"%s\n",payload);
  11912. ChargingProfileAdded = TRUE;
  11913. }
  11914. else
  11915. {
  11916. fprintf(outfile,"%s\n",buf);
  11917. }
  11918. }
  11919. else
  11920. {
  11921. if(ChargingProfileAdded == FALSE)
  11922. {
  11923. fprintf(outfile,"%s\n",buf);
  11924. fprintf(outfile,"%s\n",payload);
  11925. ChargingProfileAdded = TRUE;
  11926. }
  11927. else
  11928. {
  11929. fprintf(outfile,"%s\n",buf);
  11930. }
  11931. }
  11932. }
  11933. }
  11934. else
  11935. {
  11936. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId")))
  11937. {
  11938. if(ChargingProfileAdded == FALSE)
  11939. {
  11940. fprintf(outfile,"%s\n",buf);
  11941. fprintf(outfile,"%s\n",payload);
  11942. ChargingProfileAdded = TRUE;
  11943. }
  11944. else
  11945. {
  11946. fprintf(outfile,"%s\n",buf);
  11947. }
  11948. }
  11949. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11950. {
  11951. if(ChargingProfileAdded == FALSE)
  11952. {
  11953. fprintf(outfile,"%s\n",buf);
  11954. fprintf(outfile,"%s\n",payload);
  11955. ChargingProfileAdded = TRUE;
  11956. }
  11957. else
  11958. {
  11959. fprintf(outfile,"%s\n",buf);
  11960. }
  11961. }
  11962. else
  11963. {
  11964. if(ChargingProfileAdded == FALSE)
  11965. {
  11966. fprintf(outfile,"%s\n",buf);
  11967. fprintf(outfile,"%s\n",payload);
  11968. ChargingProfileAdded = TRUE;
  11969. }
  11970. else
  11971. {
  11972. fprintf(outfile,"%s\n",buf);
  11973. }
  11974. }
  11975. }
  11976. } // end of while loop
  11977. fclose(infile);
  11978. fclose(outfile);
  11979. sprintf(rmFileCmd,"rm -f %s",filename);
  11980. system(rmFileCmd);
  11981. rename((char*)tmpProfileName, (char*)filename);
  11982. }
  11983. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  11984. result = PASS;
  11985. }
  11986. else
  11987. {
  11988. if(gun_index == -1)
  11989. DEBUG_WARN("Connector id is wrong.\n");
  11990. if(isConnectorMismatch)
  11991. DEBUG_WARN("Connector id is mismatch.\n");
  11992. if(isPeriodOverMax)
  11993. DEBUG_WARN("Profile periods quantity is over spec.\n");
  11994. if(isProfileOverMax)
  11995. DEBUG_WARN("Profile quantity is over spec.\n");
  11996. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  11997. }
  11998. }
  11999. json_object_put(SetChargingProfile);
  12000. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  12001. {
  12002. if(gun_index == 0)
  12003. {
  12004. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  12005. {
  12006. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  12007. }
  12008. }
  12009. else
  12010. checkCompositeSchedule(gun_index, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index-1]);
  12011. }
  12012. sendSetChargingProfileConfirmation(uuid, (gun_index==0?gun_index:gun_index-1));
  12013. return result;
  12014. }
  12015. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  12016. {
  12017. mtrace();
  12018. int result = FAIL;
  12019. json_object *SetDisplayMessage;
  12020. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  12021. SetDisplayMessage = json_tokener_parse(payload);
  12022. if(!is_error(SetDisplayMessage))
  12023. {
  12024. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  12025. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  12026. // Required data
  12027. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  12028. {
  12029. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  12030. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  12031. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  12032. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  12033. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  12034. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  12035. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  12036. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  12037. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  12038. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  12039. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  12040. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  12041. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  12042. {
  12043. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  12044. 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")));
  12045. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  12046. 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")));
  12047. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  12048. 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")));
  12049. }
  12050. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  12051. {
  12052. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  12053. 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")));
  12054. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  12055. 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")));
  12056. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  12057. {
  12058. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  12059. 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"));
  12060. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  12061. 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"));
  12062. }
  12063. }
  12064. }
  12065. }
  12066. json_object_put(SetDisplayMessage);
  12067. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  12068. sendSetMonitoringBaseConfirmation(uuid);
  12069. // Anouce CSU there is display request come from server
  12070. ShmOCPP20Data->MsMsg.bits.SetDisplayMessageReq = ON;
  12071. return result;
  12072. }
  12073. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  12074. {
  12075. mtrace();
  12076. int result = FAIL;
  12077. json_object *SetMonitoringBase;
  12078. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  12079. SetMonitoringBase = json_tokener_parse(payload);
  12080. if(!is_error(SetMonitoringBase))
  12081. {
  12082. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  12083. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  12084. // Required data
  12085. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  12086. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  12087. }
  12088. json_object_put(SetMonitoringBase);
  12089. /*
  12090. * TODO:
  12091. * 1. Configure monitor base and response
  12092. */
  12093. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  12094. sendSetMonitoringBaseConfirmation(uuid);
  12095. return result;
  12096. }
  12097. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  12098. {
  12099. mtrace();
  12100. int result = FAIL;
  12101. json_object *SetMonitoringLevel;
  12102. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  12103. SetMonitoringLevel = json_tokener_parse(payload);
  12104. if(!is_error(SetMonitoringLevel))
  12105. {
  12106. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  12107. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  12108. // Required data
  12109. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  12110. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  12111. }
  12112. json_object_put(SetMonitoringLevel);
  12113. /*
  12114. * TODO:
  12115. * Configure monitor status and response
  12116. */
  12117. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  12118. sendSetMonitoringLevelConfirmation(uuid);
  12119. return result;
  12120. }
  12121. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  12122. {
  12123. mtrace();
  12124. int result = FAIL;
  12125. json_object *SetNetworkProfile;
  12126. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  12127. SetNetworkProfile = json_tokener_parse(payload);
  12128. if(!is_error(SetNetworkProfile))
  12129. {
  12130. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  12131. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  12132. // Required data
  12133. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  12134. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  12135. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  12136. {
  12137. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  12138. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  12139. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  12140. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  12141. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  12142. {
  12143. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  12144. memcpy((char*)ShmSysConfigAndInfo->SysConfig.OcppServerURL, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl));
  12145. }
  12146. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  12147. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  12148. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  12149. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  12150. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  12151. {
  12152. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  12153. 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")));
  12154. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  12155. 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")));
  12156. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  12157. 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")));
  12158. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  12159. 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")));
  12160. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  12161. 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")));
  12162. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  12163. 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")));
  12164. }
  12165. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  12166. {
  12167. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  12168. {
  12169. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  12170. 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")));
  12171. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  12172. }
  12173. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  12174. {
  12175. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  12176. 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")));
  12177. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  12178. }
  12179. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  12180. {
  12181. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  12182. 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")));
  12183. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  12184. }
  12185. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  12186. 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"));
  12187. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  12188. 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")));
  12189. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  12190. 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"));
  12191. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  12192. 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")));
  12193. }
  12194. DB_addNetworkProfile(ShmOCPP20Data->SetNetworkProfile.configurationSlot, (char*)json_object_get_string(json_object_object_get(SetNetworkProfile, "connectionData")));
  12195. }
  12196. }
  12197. json_object_put(SetNetworkProfile);
  12198. /*
  12199. * TODO:
  12200. * 1. Process network configuration and response
  12201. */
  12202. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  12203. {
  12204. }
  12205. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  12206. {
  12207. }
  12208. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  12209. {
  12210. }
  12211. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  12212. {
  12213. }
  12214. else
  12215. {
  12216. }
  12217. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  12218. {
  12219. }
  12220. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  12221. {
  12222. }
  12223. else
  12224. {
  12225. }
  12226. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  12227. {
  12228. }
  12229. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  12230. {
  12231. }
  12232. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  12233. {
  12234. }
  12235. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  12236. {
  12237. }
  12238. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  12239. {
  12240. }
  12241. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  12242. {
  12243. }
  12244. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  12245. {
  12246. }
  12247. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  12248. {
  12249. }
  12250. else
  12251. {
  12252. }
  12253. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  12254. {
  12255. }
  12256. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  12257. {
  12258. }
  12259. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  12260. {
  12261. }
  12262. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  12263. {
  12264. }
  12265. else
  12266. {
  12267. }
  12268. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  12269. {
  12270. }
  12271. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  12272. {
  12273. }
  12274. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  12275. {
  12276. }
  12277. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  12278. {
  12279. }
  12280. else
  12281. {
  12282. }
  12283. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  12284. sendSetNetworkProfileConfirmation(uuid);
  12285. return result;
  12286. }
  12287. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  12288. {
  12289. mtrace();
  12290. int result = FAIL;
  12291. json_object *SetVariableMonitoring;
  12292. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  12293. SetVariableMonitoring = json_tokener_parse(payload);
  12294. if(!is_error(SetVariableMonitoring))
  12295. {
  12296. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  12297. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  12298. // Required data
  12299. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  12300. {
  12301. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  12302. {
  12303. 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"));
  12304. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  12305. }
  12306. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  12307. {
  12308. 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"));
  12309. /*
  12310. * TODO:
  12311. * 1. Check monitor value status
  12312. */
  12313. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, MonitorEnumTypeStr[MonitorEnumType_Delta]);
  12314. }
  12315. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  12316. {
  12317. 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")));
  12318. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  12319. }
  12320. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  12321. {
  12322. 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"));
  12323. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  12324. }
  12325. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  12326. {
  12327. 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"));
  12328. }
  12329. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component") != NULL)
  12330. {
  12331. 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)
  12332. {
  12333. 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")));
  12334. }
  12335. 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)
  12336. {
  12337. 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")));
  12338. }
  12339. 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)
  12340. {
  12341. 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)
  12342. {
  12343. 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"));
  12344. }
  12345. 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)
  12346. {
  12347. 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"));
  12348. }
  12349. }
  12350. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  12351. }
  12352. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable") != NULL)
  12353. {
  12354. 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)
  12355. {
  12356. 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")));
  12357. }
  12358. 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)
  12359. {
  12360. 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")));
  12361. }
  12362. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  12363. }
  12364. }
  12365. }
  12366. json_object_put(SetVariableMonitoring);
  12367. return result;
  12368. }
  12369. int handleSetVariablesRequest(char *uuid, char *payload)
  12370. {
  12371. mtrace();
  12372. int result = FAIL;
  12373. json_object *SetVariables;
  12374. DEBUG_INFO("handleSetVariablesRequest...\n");
  12375. SetVariables = json_tokener_parse(payload);
  12376. if(!is_error(SetVariables))
  12377. {
  12378. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  12379. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  12380. // Required data
  12381. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  12382. {
  12383. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  12384. {
  12385. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  12386. {
  12387. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  12388. {
  12389. 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")));
  12390. }
  12391. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  12392. {
  12393. 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")));
  12394. }
  12395. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  12396. {
  12397. 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)
  12398. {
  12399. 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"));
  12400. }
  12401. 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)
  12402. {
  12403. 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"));
  12404. }
  12405. }
  12406. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  12407. }
  12408. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  12409. {
  12410. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  12411. {
  12412. 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")));
  12413. }
  12414. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  12415. {
  12416. 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")));
  12417. }
  12418. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  12419. }
  12420. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  12421. {
  12422. 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")));
  12423. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  12424. }
  12425. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  12426. {
  12427. 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")));
  12428. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  12429. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  12430. {
  12431. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL) &&
  12432. (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) &&
  12433. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name) != NULL) &&
  12434. (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))
  12435. {
  12436. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  12437. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  12438. if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "NetworkConfigurationPriority") != NULL))
  12439. {
  12440. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]);
  12441. }
  12442. else
  12443. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  12444. }
  12445. }
  12446. }
  12447. }
  12448. }
  12449. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  12450. }
  12451. json_object_put(SetVariables);
  12452. return result;
  12453. }
  12454. int handleTriggerMessageRequest(char *uuid, char *payload)
  12455. {
  12456. mtrace();
  12457. int result = FAIL;
  12458. int connectorIdIsNULL = FALSE;
  12459. int connectorIdInt =0;
  12460. char requestedMessagestr[40]={0};
  12461. json_object *TriggerMessage;
  12462. DEBUG_INFO("handleTriggerMessageRequest\n");
  12463. TriggerMessage = json_tokener_parse(payload);
  12464. if(!is_error(TriggerMessage))
  12465. {
  12466. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  12467. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  12468. // Required data
  12469. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  12470. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  12471. // Optional data
  12472. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  12473. {
  12474. // Required data
  12475. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  12476. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  12477. // Optional data
  12478. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  12479. {
  12480. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  12481. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  12482. }
  12483. else
  12484. connectorIdIsNULL = TRUE;
  12485. }
  12486. }
  12487. json_object_put(TriggerMessage);
  12488. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  12489. {
  12490. if((strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  12491. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  12492. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  12493. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  12494. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  12495. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  12496. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  12497. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  12498. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  12499. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  12500. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  12501. {
  12502. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  12503. sendTriggerMessageConfirmation(uuid);
  12504. return TRUE;
  12505. }
  12506. else
  12507. {
  12508. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  12509. sendTriggerMessageConfirmation(uuid);
  12510. }
  12511. }
  12512. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  12513. {
  12514. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  12515. sendTriggerMessageConfirmation(uuid);
  12516. return TRUE;
  12517. }
  12518. //==========================
  12519. // Trigger message
  12520. //==========================
  12521. if( strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  12522. {
  12523. if((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) &&
  12524. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) &&
  12525. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) &&
  12526. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing) )
  12527. {
  12528. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  12529. }
  12530. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusNotificationStatus]);
  12531. }
  12532. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  12533. {
  12534. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[LogStatusNotificationStatus]);
  12535. }
  12536. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  12537. {
  12538. if(DB_updateBootType(BootReasonEnumType_Triggered))
  12539. server_sign = FALSE;
  12540. }
  12541. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  12542. {
  12543. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval);
  12544. }
  12545. else if (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  12546. {
  12547. if(connectorIdIsNULL == FALSE)
  12548. {
  12549. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12550. {
  12551. //sendMeterValuesRequest((connectorIdInt -1), ReadingContext_Trigger);
  12552. cpinitateMsg.bits[connectorIdInt -1].TriggerMeterValueReq = ON;
  12553. }
  12554. }
  12555. else
  12556. {
  12557. for(int idx=0;idx< gunTotalNumber;idx++)
  12558. {
  12559. //sendMeterValuesRequest(idx, ReadingContext_Trigger);
  12560. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  12561. }
  12562. }
  12563. }
  12564. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  12565. {
  12566. if(connectorIdIsNULL == FALSE)
  12567. {
  12568. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12569. {
  12570. cpinitateMsg.bits[connectorIdInt -1].StatusNotificationReq = ON;
  12571. }
  12572. }
  12573. else
  12574. {
  12575. for(int idx=0;idx< gunTotalNumber;idx++)
  12576. cpinitateMsg.bits[idx].StatusNotificationReq = ON;
  12577. }
  12578. }
  12579. return result;
  12580. }
  12581. int handleUnlockConnectorRequest(char *uuid, char *payload)
  12582. {
  12583. mtrace();
  12584. int result = FAIL;
  12585. int connectorIdInt =0;
  12586. int tempIndex = 0;
  12587. json_object *UnlockConnector;
  12588. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  12589. UnlockConnector = json_tokener_parse(payload);
  12590. if(!is_error(UnlockConnector))
  12591. {
  12592. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  12593. {
  12594. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  12595. }
  12596. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  12597. {
  12598. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  12599. }
  12600. }
  12601. json_object_put(UnlockConnector);
  12602. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  12603. if(gunTotalNumber == 0)
  12604. {
  12605. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12606. goto end;
  12607. }
  12608. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  12609. {
  12610. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12611. goto end;
  12612. }
  12613. else
  12614. {
  12615. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  12616. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  12617. //check Transaction active
  12618. if(gunType[connectorIdInt-1] == 'J')
  12619. {
  12620. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12621. {
  12622. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12623. }
  12624. else
  12625. {
  12626. tempIndex = connectorIdInt -1;
  12627. }
  12628. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12629. {
  12630. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12631. {
  12632. //stop Transaction
  12633. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12634. }
  12635. }
  12636. }
  12637. else if((gunType[connectorIdInt-1] == 'U')||(gunType[connectorIdInt-1] == 'E'))
  12638. {
  12639. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12640. {
  12641. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12642. }
  12643. else
  12644. {
  12645. tempIndex = connectorIdInt -1;
  12646. }
  12647. for (int index = 0; index < CCS_QUANTITY; index++)
  12648. {
  12649. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12650. {
  12651. //stop Transaction
  12652. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12653. }
  12654. }
  12655. }
  12656. else if(gunType[connectorIdInt-1] == 'G')
  12657. {
  12658. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12659. {
  12660. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12661. }
  12662. else
  12663. {
  12664. tempIndex = connectorIdInt -1;
  12665. }
  12666. for (int index = 0; index < GB_QUANTITY; index++)
  12667. {
  12668. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)))
  12669. {
  12670. //stop Transaction
  12671. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12672. }
  12673. }
  12674. }
  12675. else
  12676. {
  12677. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  12678. {
  12679. tempIndex = 2;
  12680. }
  12681. else
  12682. {
  12683. tempIndex = connectorIdInt-1;
  12684. }
  12685. for (int index = 0; index < AC_QUANTITY; index++)
  12686. {
  12687. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12688. {
  12689. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12690. }
  12691. }
  12692. }
  12693. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  12694. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  12695. result = TRUE;
  12696. return result;
  12697. }
  12698. end:
  12699. //json_object_put(obj); --- remove temporally
  12700. sendUnlockConnectorConfirmation(uuid, connectorIdInt-1);
  12701. return result;
  12702. }
  12703. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  12704. {
  12705. mtrace();
  12706. int result = FAIL;
  12707. json_object *UnpublishFirmware;
  12708. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  12709. UnpublishFirmware = json_tokener_parse(payload);
  12710. if(!is_error(UnpublishFirmware))
  12711. {
  12712. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  12713. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  12714. // Required data
  12715. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  12716. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  12717. }
  12718. json_object_put(UnpublishFirmware);
  12719. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  12720. /*
  12721. * TODO:
  12722. * 1. Check unpublished status
  12723. */
  12724. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  12725. sendUnpublishFirmwareConfirmation(uuid);
  12726. return result;
  12727. }
  12728. static char UpdateFirmwarepayloadData[512]={0};
  12729. void *UpdateFirmwareProcess(void *data)
  12730. {
  12731. pthread_detach(pthread_self());
  12732. mtrace();
  12733. int retriesInt =0, retryIntervalInt=0;
  12734. char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
  12735. int port=0;
  12736. char locationstr[160]={0}, retrieveDatestr[30]={0};
  12737. int isSuccess = 0;
  12738. char ftpbuf[200];
  12739. char temp[100];
  12740. char * pch;
  12741. DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
  12742. json_object *UpdateFirmware;
  12743. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  12744. if(!is_error(UpdateFirmware))
  12745. {
  12746. // Required data
  12747. if(json_object_object_get(UpdateFirmware, "location") != NULL)
  12748. sprintf((char*)locationstr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "location")));
  12749. if(json_object_object_get(UpdateFirmware, "retrieveDate") != NULL)
  12750. sprintf((char*)retrieveDatestr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "retrieveDate")));
  12751. // Optional data
  12752. if(json_object_object_get(UpdateFirmware, "retries"))
  12753. {
  12754. retriesInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  12755. }
  12756. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  12757. {
  12758. retryIntervalInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  12759. }
  12760. }
  12761. json_object_put(UpdateFirmware);
  12762. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  12763. memset(path, 0, ARRAY_SIZE(path));
  12764. system("rm -f /mnt/*");
  12765. if(strncmp(locationstr,"http", 4) == 0)
  12766. {
  12767. sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  12768. //sscanf(locationstr,"%[^:]:%*2[/]%[^:]:%[^@]@%[^/]%199[^\n]",
  12769. // protocol, user, password, host, path);
  12770. sprintf(ftppath,"/%s", path);
  12771. DEBUG_INFO("locationstr: %s\n", locationstr);
  12772. DEBUG_INFO("protocol: %s\n",protocol);
  12773. DEBUG_INFO("host: %s\n",host);
  12774. DEBUG_INFO("path: %s\n",path);
  12775. DEBUG_INFO("ftppath: %s\n",ftppath);
  12776. int ftppathlen=strlen(ftppath);
  12777. int i=1;
  12778. char filenametemp[50];
  12779. while(i < ftppathlen)
  12780. {
  12781. int len=ftppathlen-i;
  12782. if(ftppath[len]== 47) // '/' ascll code: 47
  12783. {
  12784. DEBUG_INFO("compare '/' all right\n");
  12785. break;
  12786. }
  12787. i=i+1;
  12788. }
  12789. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12790. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  12791. filenametemp[i+1] = 0;
  12792. do
  12793. {
  12794. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12795. sleep(3);
  12796. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
  12797. if(!isSuccess)
  12798. {
  12799. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12800. sleep(retryIntervalInt);
  12801. }
  12802. else
  12803. {
  12804. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12805. }
  12806. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
  12807. }
  12808. else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
  12809. {
  12810. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12811. memset(temp, 0, ARRAY_SIZE(temp));
  12812. //DEBUG_INFO("locationstr=%s\n",locationstr);
  12813. strcpy(ftpbuf, locationstr/*"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/DemoDC1_2018-07-13_185011_PSULog.zip"*/ );
  12814. int ftppathlen=strlen(ftpbuf);
  12815. int i=1;
  12816. char filenametemp[50];
  12817. while(i < ftppathlen)
  12818. {
  12819. int len=ftppathlen-i;
  12820. if(ftpbuf[len]== 47) // '/' ascll code: 47
  12821. {
  12822. DEBUG_INFO(" compare '/' all right\n");
  12823. break;
  12824. }
  12825. i=i+1;
  12826. }
  12827. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12828. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  12829. filenametemp[i+1] = 0;
  12830. strncpy(temp, ftpbuf, ftppathlen-i+1);
  12831. pch=strchr(temp,'@');
  12832. if(pch==NULL)
  12833. {
  12834. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  12835. protocol, host, &port, path);
  12836. strcpy(user,"anonymous");
  12837. strcpy(password,"");
  12838. }
  12839. else
  12840. {
  12841. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  12842. protocol, user, password, host, &port, path);
  12843. }
  12844. sscanf(host,"%[^/]%s",host1, path1);
  12845. sprintf(ftppath,"%s", path1);
  12846. //DEBUG_INFO("protocol =%s\n",protocol);
  12847. //DEBUG_INFO("user =%s\n",user);
  12848. //DEBUG_INFO("password =%s\n",password);
  12849. //DEBUG_INFO("host1 =%s\n",host1);
  12850. //DEBUG_INFO("port =%d\n",port);
  12851. //DEBUG_INFO("path1 =%s\n",path1);
  12852. //DEBUG_INFO("ftppath=%s\n",ftppath);
  12853. //ftpFile(host, user, password, port, ftppath, fname);
  12854. //download firmware pthred
  12855. if(port == 0)
  12856. {
  12857. port = 21;
  12858. }
  12859. do
  12860. {
  12861. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12862. sleep(3);
  12863. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
  12864. if(!isSuccess)
  12865. {
  12866. //BulldogUtil.sleepMs(interval*1000);
  12867. DEBUG_INFO("Update firmware request and download file fail.\n");
  12868. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12869. sleep(retryIntervalInt);
  12870. }
  12871. else
  12872. {
  12873. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12874. }
  12875. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  12876. }
  12877. else
  12878. {
  12879. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12880. }
  12881. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  12882. pthread_exit(NULL);
  12883. }
  12884. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  12885. {
  12886. mtrace();
  12887. int result = FAIL;
  12888. pthread_t t;
  12889. sendUpdateFirmwareConfirmation(uuid);
  12890. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  12891. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  12892. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  12893. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  12894. ////pthread_join(t, NULL); //
  12895. //pthread_detach(t);
  12896. //sendUpdateFirmwareConfirmation(uuid);
  12897. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  12898. return result;
  12899. }
  12900. //==========================================
  12901. // Handle server response routine
  12902. //==========================================
  12903. void handleAuthorizeResponse(char *payload, int gun_index)
  12904. {
  12905. mtrace();
  12906. DEBUG_INFO("handleAuthorizeResponse...\n");
  12907. json_object *Authorize;
  12908. Authorize = json_tokener_parse(payload);
  12909. if(!is_error(Authorize))
  12910. {
  12911. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  12912. {
  12913. // Required data
  12914. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  12915. // Optional data
  12916. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  12917. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  12918. else
  12919. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  12920. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  12921. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  12922. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  12923. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  12924. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  12925. {
  12926. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  12927. {
  12928. 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));
  12929. }
  12930. }
  12931. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  12932. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  12933. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  12934. {
  12935. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  12936. 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")));
  12937. else
  12938. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  12939. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  12940. 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")));
  12941. }
  12942. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  12943. {
  12944. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  12945. 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")));
  12946. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  12947. 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")));
  12948. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  12949. 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")));
  12950. }
  12951. }
  12952. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  12953. {
  12954. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  12955. }
  12956. }
  12957. json_object_put(Authorize);
  12958. //Update idTag information to authorization cache if supported
  12959. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  12960. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  12961. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  12962. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  12963. {
  12964. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  12965. }
  12966. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  12967. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  12968. authorizeRetryTimes = 0;
  12969. }
  12970. void handleBootNotificationResponse(char *payload, int gun_index)
  12971. {
  12972. mtrace();
  12973. char statusStr[12]={0};
  12974. char currentTimeStr[30]={0};
  12975. int intervalInt = 0;
  12976. struct tm tp;
  12977. char buf[28]={0};
  12978. char timebuf[50]={0};
  12979. DEBUG_INFO("handleBootNotificationResponse...\n");
  12980. json_object *BootNotification;
  12981. BootNotification = json_tokener_parse(payload);
  12982. if(!is_error(BootNotification))
  12983. {
  12984. // Required data
  12985. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  12986. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  12987. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  12988. }
  12989. json_object_put(BootNotification);
  12990. DEBUG_INFO("statusStr: %s\n", statusStr);
  12991. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  12992. BootNotificationInterval = intervalInt;
  12993. HeartBeatWaitTime = intervalInt;
  12994. //write back to ShmOCPP20Data->BootNotification
  12995. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  12996. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  12997. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  12998. {
  12999. server_sign = TRUE;
  13000. server_pending =FALSE;
  13001. DB_updateBootType(BootReasonEnumType_PowerUp);
  13002. }
  13003. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  13004. {
  13005. server_pending = TRUE;
  13006. }
  13007. strptime((const char *)ShmOCPP20Data->BootNotification.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  13008. tp.tm_isdst = -1;
  13009. //time_t utc = mktime(&tp);
  13010. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  13011. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  13012. sprintf(timebuf,"date -s '%s'",buf);
  13013. system(timebuf);
  13014. srand(time(NULL));
  13015. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  13016. //==============================================
  13017. // RTC sync
  13018. //==============================================
  13019. system("/sbin/hwclock -w --systohc");
  13020. SetOcppConnStatus(TRUE);
  13021. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  13022. }
  13023. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  13024. {
  13025. mtrace();
  13026. json_object *ClearedChargingLimit;
  13027. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  13028. ClearedChargingLimit = json_tokener_parse(payload);
  13029. if(!is_error(ClearedChargingLimit))
  13030. {
  13031. // Required data
  13032. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  13033. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  13034. }
  13035. json_object_put(ClearedChargingLimit);
  13036. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitReq = OFF;
  13037. ShmOCPP20Data->CSUMsg.bits[gun_index].ClearedChargingLimitConf = ON;
  13038. }
  13039. void handleDataTransferResponse(char *payload, int gun_index)
  13040. {
  13041. mtrace();
  13042. json_object *DataTrans;
  13043. DEBUG_INFO("handleDataTransferResponse...\n");
  13044. DataTrans = json_tokener_parse(payload);
  13045. if(!is_error(DataTrans))
  13046. {
  13047. // Required data
  13048. if(json_object_object_get(DataTrans,"status") != NULL)
  13049. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  13050. // Optional data
  13051. if(json_object_object_get(DataTrans,"data") != NULL)
  13052. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  13053. }
  13054. json_object_put(DataTrans);
  13055. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  13056. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  13057. }
  13058. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  13059. {
  13060. mtrace();
  13061. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  13062. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  13063. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  13064. }
  13065. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  13066. {
  13067. mtrace();
  13068. json_object *Get15118EVCertificate;
  13069. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  13070. Get15118EVCertificate = json_tokener_parse(payload);
  13071. if(!is_error(Get15118EVCertificate))
  13072. {
  13073. // Required data
  13074. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  13075. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  13076. // Optional data
  13077. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  13078. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  13079. }
  13080. json_object_put(Get15118EVCertificate);
  13081. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  13082. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  13083. }
  13084. void hanldeGetCertificateStatusResponse(char *payload, int gun_index)
  13085. {
  13086. mtrace();
  13087. json_object *GetCertificateStatus;
  13088. DEBUG_INFO("hanldeGetCertificateStatusResponse...\n");
  13089. GetCertificateStatus = json_tokener_parse(payload);
  13090. if(!is_error(GetCertificateStatus))
  13091. {
  13092. // Required data
  13093. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  13094. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  13095. // Optional data
  13096. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  13097. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  13098. }
  13099. json_object_put(GetCertificateStatus);
  13100. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  13101. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  13102. }
  13103. void handleHeartbeatResponse(char *payload, int gun_index)
  13104. {
  13105. mtrace();
  13106. struct tm tp;
  13107. char buf[28]={0};
  13108. char timebuf[128]={0};
  13109. DEBUG_INFO("handleHeartbeatResponse...\n");
  13110. json_object *Heartbeat;
  13111. Heartbeat = json_tokener_parse(payload);
  13112. if(!is_error(Heartbeat))
  13113. {
  13114. // Required data
  13115. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  13116. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  13117. }
  13118. json_object_put(Heartbeat);
  13119. if(FirstHeartBeat == OFF)
  13120. {
  13121. FirstHeartBeat = ON;
  13122. DEBUG_INFO("FirstHeartBeat \n");
  13123. }
  13124. HeartBeatWithNOResponse = 0;
  13125. clientTime.Heartbeat=time((time_t*)NULL);
  13126. strptime((const char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  13127. tp.tm_isdst = -1;
  13128. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  13129. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  13130. sprintf(timebuf,"date -s '%s'",buf);
  13131. system(timebuf);
  13132. //==============================================
  13133. // RTC sync
  13134. //==============================================
  13135. system("/sbin/hwclock -w --systohc");
  13136. }
  13137. void hanldeLogStatusNotificationResponse(char *payload, int gun_index)
  13138. {
  13139. mtrace();
  13140. DEBUG_INFO("hanldeLogStatusNotificationResponse...\n");
  13141. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  13142. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  13143. }
  13144. void handleMeterValuesResponse(char *payload, int gun_index)
  13145. {
  13146. mtrace();
  13147. DEBUG_INFO("handleMeterValuesResponse...\n");
  13148. }
  13149. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  13150. {
  13151. mtrace();
  13152. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  13153. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  13154. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  13155. }
  13156. void hanldeNotifyCustomerInformationResponse(char *payload, int gun_index)
  13157. {
  13158. mtrace();
  13159. DEBUG_INFO("hanldeNotifyCustomerInformationResponse...\n");
  13160. }
  13161. void hanldeNotifyDisplayMessagesResponse(char *payload, int gun_index)
  13162. {
  13163. mtrace();
  13164. DEBUG_INFO("hanldeNotifyDisplayMessagesResponse...\n");
  13165. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  13166. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  13167. }
  13168. void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  13169. {
  13170. mtrace();
  13171. json_object *NotifyEVChargingNeeds;
  13172. DEBUG_INFO("hanldeNotifyEVChargingNeedsResponse...\n");
  13173. NotifyEVChargingNeeds = json_tokener_parse(payload);
  13174. if(!is_error(NotifyEVChargingNeeds))
  13175. {
  13176. // Required data
  13177. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  13178. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  13179. }
  13180. json_object_put(NotifyEVChargingNeeds);
  13181. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  13182. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  13183. }
  13184. void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  13185. {
  13186. mtrace();
  13187. json_object *NotifyEVChargingSchedule;
  13188. DEBUG_INFO("hanldeNotifyEVChargingScheduleResponse...\n");
  13189. NotifyEVChargingSchedule = json_tokener_parse(payload);
  13190. if(!is_error(NotifyEVChargingSchedule))
  13191. {
  13192. // Required data
  13193. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  13194. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  13195. }
  13196. json_object_put(NotifyEVChargingSchedule);
  13197. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  13198. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  13199. }
  13200. void hanldeNotifyEventResponse(char *payload, int gun_index)
  13201. {
  13202. mtrace();
  13203. DEBUG_INFO("hanldeNotifyEventResponse...\n");
  13204. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  13205. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  13206. }
  13207. void hanldeNotifyMonitoringReportResponse(char *payload, int gun_index)
  13208. {
  13209. mtrace();
  13210. DEBUG_INFO("hanldeNotifyMonitoringReportResponse...\n");
  13211. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  13212. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  13213. }
  13214. void hanldeNotifyReportResponse(char *payload, int gun_index)
  13215. {
  13216. mtrace();
  13217. DEBUG_INFO("hanldeNotifyReportResponse...\n");
  13218. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  13219. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  13220. }
  13221. void hanldePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  13222. {
  13223. mtrace();
  13224. DEBUG_INFO("hanldePublishFirmwareStatusNotificationResponse...\n");
  13225. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  13226. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  13227. }
  13228. void hanldeReportChargingProfilesResponse(char *payload, int gun_index)
  13229. {
  13230. mtrace();
  13231. DEBUG_INFO("hanldeReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  13232. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  13233. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  13234. }
  13235. void hanldeReservationStatusUpdateResponse(char *payload, int gun_index)
  13236. {
  13237. mtrace();
  13238. DEBUG_INFO("hanldeReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  13239. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  13240. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  13241. }
  13242. void hanldeSecurityEventNotificationResponse(char *payload, int gun_index)
  13243. {
  13244. mtrace();
  13245. DEBUG_INFO("hanldeSecurityEventNotificationResponse...\n");
  13246. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  13247. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  13248. }
  13249. void hanldeSignCertificateResponse(char *payload, int gun_index)
  13250. {
  13251. mtrace();
  13252. json_object *SignCertificate;
  13253. DEBUG_INFO("hanldeSignCertificateResponse...\n");
  13254. SignCertificate = json_tokener_parse(payload);
  13255. if(!is_error(SignCertificate))
  13256. {
  13257. // Required data
  13258. if(json_object_object_get(SignCertificate,"status") != NULL)
  13259. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  13260. }
  13261. json_object_put(SignCertificate);
  13262. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  13263. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  13264. }
  13265. void handleStatusNotificationResponse(char *payload, int gun_index)
  13266. {
  13267. mtrace();
  13268. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  13269. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13270. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  13271. }
  13272. void hanldeTransactionEvenResponse(char *payload, int gun_index)
  13273. {
  13274. mtrace();
  13275. json_object *TransactionEven;
  13276. DEBUG_INFO("hanldeTransactionEvenResponse...\n");
  13277. TransactionEven = json_tokener_parse(payload);
  13278. if(!is_error(TransactionEven))
  13279. {
  13280. // Required data
  13281. // Optional data
  13282. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  13283. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  13284. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  13285. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  13286. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  13287. {
  13288. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  13289. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  13290. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  13291. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  13292. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  13293. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  13294. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  13295. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  13296. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  13297. {
  13298. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  13299. 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")));
  13300. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  13301. 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")));
  13302. }
  13303. }
  13304. }
  13305. json_object_put(TransactionEven);
  13306. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  13307. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  13308. }
  13309. //==========================================
  13310. // Handle Error routine
  13311. //==========================================
  13312. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  13313. {
  13314. mtrace();
  13315. #ifdef SystemLogMessage
  13316. DEBUG_INFO("errorCode: %s\n", errorCode);
  13317. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  13318. DEBUG_INFO("errorDetails: %s\n", payload);
  13319. #endif
  13320. }
  13321. //===============================================
  13322. // Common routine
  13323. //===============================================
  13324. int initialConfigurationTable(void)
  13325. {
  13326. DEBUG_INFO("initialConfigurationTable...\n");
  13327. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  13328. DB_variableIsCreate();
  13329. DB_variableLoadFromDb();
  13330. DB_getNetworkProfileFromDb();
  13331. return 0;
  13332. }
  13333. int TransactionMessageAttemptsGet(void)
  13334. {
  13335. return TransactionMessageAttemptsValue;
  13336. }
  13337. int FirstHeartBeatResponse(void)
  13338. {
  13339. return FirstHeartBeat;
  13340. }
  13341. int TransactionMessageRetryIntervalGet(void)
  13342. {
  13343. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  13344. }
  13345. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  13346. {
  13347. char rmFileCmd[100]={0};
  13348. char FilePath[100]={0};
  13349. char ftpbuf[200];
  13350. int systemresult;
  13351. //DEBUG_INFO("filename=%s\n",filename);
  13352. //DEBUG_INFO("url=%s\n",url);
  13353. sprintf(FilePath,"/mnt/%s",filename);
  13354. system("ping 8.8.8.8 &");
  13355. if((access(FilePath,F_OK))!=-1)
  13356. {
  13357. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13358. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13359. system(rmFileCmd);
  13360. }
  13361. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13362. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13363. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13364. systemresult = system(ftpbuf);
  13365. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13366. if(systemresult != 0)
  13367. {
  13368. DEBUG_INFO("http DownLoad error!\n");
  13369. return FALSE;
  13370. }
  13371. system("pkill ping");
  13372. return TRUE;
  13373. }
  13374. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  13375. {
  13376. char rmFileCmd[100]={0};
  13377. char FilePath[100]={0};
  13378. char ftpbuf[200];
  13379. int systemresult;
  13380. //char temp[100];
  13381. sprintf(FilePath,"/mnt/%s",filename);
  13382. system("ping 8.8.8.8 &");
  13383. if((access(FilePath,F_OK))!=-1)
  13384. {
  13385. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13386. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13387. system(rmFileCmd);
  13388. }
  13389. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13390. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13391. //sprintf(ftpbuf, "ftpget -u %s -p %s %s -P %d %s %s%s",user,password,IPbuffer,port/*21*/,filename,path,filename); --- remove temporally
  13392. //DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13393. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13394. systemresult = system(ftpbuf);
  13395. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13396. if(systemresult != 0)
  13397. {
  13398. printf("wget error!\n");
  13399. return FALSE;
  13400. }
  13401. system("pkill ping");
  13402. return TRUE;
  13403. }
  13404. int httpUploadFile(char *location, char *path, char *filename,char *url)
  13405. {
  13406. char rmFileCmd[100]={0};
  13407. char FilePath[100]={0};
  13408. char ftpbuf[200];
  13409. int systemresult;
  13410. //DEBUG_INFO("filename=%s\n",filename);
  13411. //DEBUG_INFO("url=%s\n",url);
  13412. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  13413. if((access(FilePath,F_OK))!=-1)
  13414. {
  13415. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13416. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13417. system(rmFileCmd);
  13418. }
  13419. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  13420. if(fp == NULL)
  13421. {
  13422. DEBUG_INFO("log is NULL\n");
  13423. return FALSE;
  13424. }
  13425. else
  13426. {
  13427. fprintf(fp, "%s\n", url);
  13428. fprintf(fp, "%s\n", filename);
  13429. fclose(fp);
  13430. }
  13431. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13432. sprintf(ftpbuf, "%s","/bin/php-cgi /var/www/ocpp_upload.php");
  13433. systemresult = system(ftpbuf);
  13434. DEBUG_INFO("systemresult = %d\n",systemresult);
  13435. if(systemresult != 0)
  13436. {
  13437. DEBUG_INFO("http upload error!\n");
  13438. return FALSE;
  13439. }
  13440. return TRUE;
  13441. }
  13442. int ftpUploadFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  13443. {
  13444. struct hostent* server;
  13445. char *IPbuffer;
  13446. char ftpbuf[200];
  13447. int systemresult;
  13448. // To retrieve host information
  13449. server = gethostbyname(location);
  13450. // To convert an Internet network
  13451. // address into ASCII string
  13452. IPbuffer = inet_ntoa(*((struct in_addr*)
  13453. server->h_addr_list[0]));
  13454. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13455. /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
  13456. /* format : ftpput -u username -p passwd IP target source*/
  13457. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
  13458. DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13459. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13460. systemresult = system(ftpbuf);
  13461. DEBUG_INFO("systemresult=%d\n",systemresult);
  13462. if(systemresult != 0)
  13463. {
  13464. DEBUG_INFO("ftpput error!\n");
  13465. return FALSE;
  13466. }
  13467. return TRUE;
  13468. }
  13469. //=========================================
  13470. // Routine
  13471. //=========================================
  13472. int GetOcppServerURL()
  13473. {
  13474. int result = FALSE;
  13475. struct yuarel url;
  13476. char urlStr[512];
  13477. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  13478. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  13479. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  13480. if((ShmSysConfigAndInfo->SysConfig.OcppServerURL != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0) )
  13481. {
  13482. memcpy(urlStr, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  13483. if(yuarel_parse(&url, urlStr) != -1)
  13484. {
  13485. sprintf(OcppProtocol, "%s", url.scheme);
  13486. sprintf(OcppHost, "%s", url.host);
  13487. if(url.path == NULL)
  13488. OcppTempPath[0] = '\0';
  13489. else
  13490. {
  13491. if((url.path[strlen(url.path)-1] != '/') && (strlen(url.path) > 0))
  13492. {
  13493. sprintf(OcppTempPath, "%s/", url.path);
  13494. }
  13495. else
  13496. {
  13497. sprintf(OcppTempPath, "%s", url.path);
  13498. }
  13499. }
  13500. if(url.port == 0)
  13501. {
  13502. if(strcmp(OcppProtocol, "wss") == 0)
  13503. OcppPort = 443;
  13504. else
  13505. OcppPort = 80;
  13506. }
  13507. else
  13508. OcppPort = url.port;
  13509. result = TRUE;
  13510. }
  13511. }
  13512. else if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  13513. {
  13514. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  13515. if(yuarel_parse(&url, urlStr) != -1)
  13516. {
  13517. sprintf(OcppProtocol, "%s", url.scheme);
  13518. sprintf(OcppHost, "%s", url.host);
  13519. if(url.path == NULL)
  13520. OcppTempPath[0] = '\0';
  13521. else
  13522. sprintf(OcppTempPath, "%s", url.path);
  13523. if(url.port == 0)
  13524. {
  13525. if(strcmp(OcppProtocol, "wss") == 0)
  13526. OcppPort = 443;
  13527. else
  13528. OcppPort = 80;
  13529. }
  13530. else
  13531. OcppPort = url.port;
  13532. result = TRUE;
  13533. }
  13534. }
  13535. else
  13536. {
  13537. strcpy(OcppHost,"");
  13538. }
  13539. return result;
  13540. }
  13541. int GetOcppPath()
  13542. {
  13543. int result = FALSE;
  13544. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  13545. {
  13546. if(OcppTempPath == NULL)
  13547. {
  13548. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13549. }
  13550. else
  13551. {
  13552. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13553. }
  13554. result = TRUE;
  13555. }
  13556. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  13557. {
  13558. if(OcppTempPath == NULL)
  13559. {
  13560. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  13561. }
  13562. else
  13563. {
  13564. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  13565. }
  13566. result = TRUE;
  13567. }
  13568. else
  13569. {
  13570. strcpy(OcppPath,"");
  13571. }
  13572. return result;
  13573. }
  13574. int GetOcppPort()
  13575. {
  13576. return OcppPort;
  13577. }
  13578. int GetOcppConnStatus(void)
  13579. {
  13580. return ShmOCPP20Data->OcppConnStatus;
  13581. }
  13582. void SetOcppConnStatus(uint8_t status)
  13583. {
  13584. ShmOCPP20Data->OcppConnStatus = status;
  13585. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  13586. }
  13587. int GetHeartBeatWithNOResponse(void)
  13588. {
  13589. return HeartBeatWithNOResponse;
  13590. }
  13591. void SetHeartBeatWithNOResponse(void)
  13592. {
  13593. HeartBeatWithNOResponse = 0;
  13594. }
  13595. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  13596. void storeTempStopTransaction(int gun_index)
  13597. {
  13598. }
  13599. void checkTempStopTransaction(int gun_index)
  13600. {
  13601. FILE *fptr1;
  13602. char ch;
  13603. char str[QUEUE_MESSAGE_LENGTH]={0};
  13604. char guid[37]={0};
  13605. char tempdata[65]={0};
  13606. char connectorStr[2]={0};
  13607. char TempStopTransaction[256];
  13608. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  13609. fptr1 = fopen(TempStopTransaction, "r");
  13610. if (!fptr1)
  13611. {
  13612. //DEBUG_INFO("TempStopTransaction_%d not found or unable to open the input file!\n", (gun_index+1));
  13613. return ;
  13614. }
  13615. ch=fgetc(fptr1);
  13616. rewind(fptr1);
  13617. if(ch!=EOF)
  13618. {
  13619. // copy all contents to the temporary file except the specific line
  13620. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  13621. {
  13622. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13623. if(str[0]=='\0')
  13624. {
  13625. break;
  13626. }
  13627. //TempStopTransaction格式: 槍號,StopTransaction封包
  13628. strncpy(connectorStr, str, 1);
  13629. if(atoi(connectorStr) != (gun_index+1))
  13630. {
  13631. DEBUG_INFO("atoi(connectorStr) = %d, gun_index = %d\n", atoi(connectorStr), gun_index);
  13632. fclose(fptr1);
  13633. return ;
  13634. }
  13635. //random_uuid(guid);
  13636. strncpy(guid, str+6, 36); //copy guid
  13637. sprintf(tempdata, "StopTransaction,%d", (gun_index));
  13638. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  13639. {
  13640. //DEBUG_INFO("StopTransaction mapitem pass\n");
  13641. }
  13642. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  13643. memset(str,0,ARRAY_SIZE(str));
  13644. }
  13645. }
  13646. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  13647. fclose(fptr1);
  13648. remove(TempStopTransaction); // remove the original file
  13649. }
  13650. int GetWebSocketPingInterval(void)
  13651. {
  13652. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  13653. }
  13654. int GetServerSign(void)
  13655. {
  13656. return server_sign;
  13657. }
  13658. uint8_t GetOcppSecurityProfile()
  13659. {
  13660. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  13661. }
  13662. void GetOcppChargerBoxId(uint8_t *data)
  13663. {
  13664. sprintf((char*)data, "%s", ShmOCPP20Data->ChargeBoxId);
  13665. }
  13666. void GetOcppSecurityPassword(uint8_t *data)
  13667. {
  13668. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  13669. }
  13670. void SetServerSign(int value)
  13671. {
  13672. server_sign = value;
  13673. }
  13674. int GetBootNotificationInterval(void)
  13675. {
  13676. return BootNotificationInterval;
  13677. }
  13678. int GetInternetConn(void)
  13679. {
  13680. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  13681. }
  13682. void InitialSystemValue(void)
  13683. {
  13684. int connectorIndex = 0;
  13685. gunTotalNumber=0;
  13686. SystemInitial = 0;
  13687. localversion=0;
  13688. BootNotificationInterval = 10;
  13689. authorizeRetryTimes = 0;
  13690. GunStatusInterval = 10;
  13691. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  13692. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  13693. //Hear Beat
  13694. HeartBeatWithNOResponse = 0;
  13695. HeartBeatCountPerHour = 0;
  13696. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  13697. FirstHeartBeat = 0;
  13698. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  13699. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  13700. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  13701. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  13702. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  13703. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  13704. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  13705. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  13706. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  13707. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  13708. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  13709. memset(gunType, 0, ARRAY_SIZE(gunType));
  13710. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13711. {
  13712. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O')
  13713. {
  13714. // DO series
  13715. for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
  13716. {
  13717. SystemInitial = SystemInitial + 1;
  13718. gunTotalNumber = gunTotalNumber + 1;
  13719. gunType[connectorIndex] = 'O';
  13720. connectorIndex = connectorIndex + 1;
  13721. }
  13722. }
  13723. else
  13724. {
  13725. // DM, DW, DS series
  13726. //check connector / socket type (index: 8, 9, 10)
  13727. for(int index=7; index <10 ; index++)
  13728. {
  13729. if(index != 8)
  13730. {
  13731. // DC Connector
  13732. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] >= 'A') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= 'Z'))
  13733. {
  13734. SystemInitial = SystemInitial + 1;
  13735. gunTotalNumber = gunTotalNumber + 1;
  13736. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13737. connectorIndex = connectorIndex + 1;
  13738. }
  13739. }
  13740. else
  13741. {
  13742. // AC Connector
  13743. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13744. {
  13745. SystemInitial = SystemInitial + 1;
  13746. gunTotalNumber = gunTotalNumber + 1;
  13747. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13748. connectorIndex = connectorIndex + 1;
  13749. }
  13750. }
  13751. }
  13752. }
  13753. //DEBUG_INFO("DC ...\n");
  13754. }
  13755. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  13756. {
  13757. //check connector / socket type (index: 8, 9, 10)
  13758. for(int index=7; index <10 ; index++)
  13759. {
  13760. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13761. {
  13762. SystemInitial = SystemInitial + 1;
  13763. gunTotalNumber = gunTotalNumber + 1;
  13764. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13765. connectorIndex = connectorIndex + 1;
  13766. //DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
  13767. }
  13768. }
  13769. }
  13770. //Status && ConnectorPlugIn Setting
  13771. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13772. {
  13773. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  13774. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  13775. }
  13776. for (int index = 0; index < CCS_QUANTITY; index++)
  13777. {
  13778. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  13779. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  13780. }
  13781. for (int index = 0; index < GB_QUANTITY; index++)
  13782. {
  13783. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  13784. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  13785. }
  13786. for (int index = 0; index < AC_QUANTITY; index++)
  13787. {
  13788. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  13789. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  13790. }
  13791. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13792. {
  13793. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  13794. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  13795. }
  13796. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  13797. {
  13798. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13799. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  13800. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  13801. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  13802. }
  13803. clientTime.Heartbeat=time((time_t*)NULL);
  13804. sleep(1);
  13805. }
  13806. void LWS_Send(char * str)
  13807. {
  13808. //=====================================================
  13809. // Check InternetConn 0: disconnected, 1: connected
  13810. //====================================================
  13811. if(GetOcppConnStatus() == 0)
  13812. {
  13813. DEBUG_INFO("offline now !!!\n");
  13814. return;
  13815. }
  13816. pthread_mutex_lock(&lock_send);
  13817. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13818. sprintf((char *)SendBuffer, "%s", str);
  13819. SendBufLen = strlen(str);
  13820. pthread_mutex_unlock(&lock_send);
  13821. lws_callback_on_writable(wsi_client);
  13822. //lws_service(context, 0);
  13823. //sleep(1);
  13824. }
  13825. void LWS_SendNow(char * str)
  13826. {
  13827. //=====================================================
  13828. // Check InternetConn 0: disconnected, 1: connected
  13829. //====================================================
  13830. if(GetOcppConnStatus() == 0)
  13831. {
  13832. DEBUG_INFO("offline now !!!\n");
  13833. return;
  13834. }
  13835. pthread_mutex_lock(&lock_send);
  13836. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13837. sprintf((char *)SendBuffer, "%s", str);
  13838. SendBufLen = strlen(str);
  13839. pthread_mutex_unlock(&lock_send);
  13840. lws_callback_on_writable(wsi_client);
  13841. lws_service(context, 0);
  13842. //sleep(1);
  13843. }