MessageHandler.c 804 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965
  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. static char *ChargingLimitSourceEnumTypeStr[] = {
  71. MACROSTR(EMS),
  72. MACROSTR(Other),
  73. MACROSTR(SO),
  74. MACROSTR(CSO)
  75. };
  76. static char *ChargingProfileKindEnumTypeStr[] = {
  77. MACROSTR(Absolute),
  78. MACROSTR(Recurring),
  79. MACROSTR(Relative)
  80. };
  81. static char *ChargingProfilePurposeEnumTypeStr[] = {
  82. MACROSTR(ChargingStationExternalConstraints),
  83. MACROSTR(ChargingStationMaxProfile),
  84. MACROSTR(TxDefaultProfile),
  85. MACROSTR(TxProfile)
  86. };
  87. static char *ChargingProfileStatusEnumTypeStr[] = {
  88. MACROSTR(Accepted),
  89. MACROSTR(Rejected)
  90. };
  91. static char *ChargingRateUnitEnumTypeStr[] = {
  92. MACROSTR(W),
  93. MACROSTR(A)
  94. };
  95. static char *ChargingStateEnumTypeStr[] = {
  96. MACROSTR(Charging),
  97. MACROSTR(EVConnected),
  98. MACROSTR(SuspendedEV),
  99. MACROSTR(SuspendedEVSE),
  100. MACROSTR(Idle)
  101. };
  102. static char *ClearCacheStatusEnumTypeStr[] = {
  103. MACROSTR(Accepted),
  104. MACROSTR(Rejected)
  105. };
  106. static char *ClearChargingProfileStatusEnumTypeStr[] = {
  107. MACROSTR(Accepted),
  108. MACROSTR(Unknown)
  109. };
  110. static char *ClearMessageStatusEnumTypeStr[] = {
  111. MACROSTR(Accepted),
  112. MACROSTR(Unknown)
  113. };
  114. static char *ClearMonitoringStatusEnumTypeStr[] = {
  115. MACROSTR(Accepted),
  116. MACROSTR(Rejected),
  117. MACROSTR(NotFound)
  118. };
  119. static char *ComponentCriterionEnumTypeStr[] = {
  120. MACROSTR(Active),
  121. MACROSTR(Available),
  122. MACROSTR(Enabled),
  123. MACROSTR(Problem)
  124. };
  125. static char *ConnectorEnumTypeStr[] = {
  126. MACROSTR(cCCS1),
  127. MACROSTR(cCCS2),
  128. MACROSTR(cG105),
  129. MACROSTR(cTesla),
  130. MACROSTR(cType1),
  131. MACROSTR(cType2),
  132. MACROSTR(s309-1P-16A),
  133. MACROSTR(s309-1P-32A),
  134. MACROSTR(s309-3P-16A),
  135. MACROSTR(s309-3P-32A),
  136. MACROSTR(sBS1361),
  137. MACROSTR(sCEE-7-7),
  138. MACROSTR(sType2),
  139. MACROSTR(sType3),
  140. MACROSTR(Other1PhMax16A),
  141. MACROSTR(Other1PhOver16A),
  142. MACROSTR(Other3Ph),
  143. MACROSTR(Pan),
  144. MACROSTR(wInductive),
  145. MACROSTR(wResonant),
  146. MACROSTR(Undetermined),
  147. MACROSTR(Unknown)
  148. };
  149. static char *ConnectorStatusEnumTypeStr[] = {
  150. MACROSTR(Available),
  151. MACROSTR(Occupied),
  152. MACROSTR(Reserved),
  153. MACROSTR(Unavailable),
  154. MACROSTR(Faulted)
  155. };
  156. static char *CostKindEnumTypeStr[] = {
  157. MACROSTR(CarbonDioxideEmission),
  158. MACROSTR(RelativePricePercentage),
  159. MACROSTR(RenewableGenerationPercentage)
  160. };
  161. static char *CustomerInformationStatusEnumTypeStr[] = {
  162. MACROSTR(Accepted),
  163. MACROSTR(Rejected),
  164. MACROSTR(Invalid)
  165. };
  166. static char *DataEnumTypeStr[] = {
  167. MACROSTR(string),
  168. MACROSTR(decimal),
  169. MACROSTR(integer),
  170. MACROSTR(dateTime),
  171. MACROSTR(boolean),
  172. MACROSTR(OptionList),
  173. MACROSTR(SequenceList),
  174. MACROSTR(MemberList)
  175. };
  176. static char *DataTransferStatusEnumTypeStr[] = {
  177. MACROSTR(Accepted),
  178. MACROSTR(Rejected),
  179. MACROSTR(UnknownMessageId),
  180. MACROSTR(UnknownVendorId)
  181. };
  182. static char *DeleteCertificateStatusEnumTypeStr[] = {
  183. MACROSTR(Accepted),
  184. MACROSTR(Failed),
  185. MACROSTR(NotFound)
  186. };
  187. static char *DisplayMessageStatusEnumTypeStr[] = {
  188. MACROSTR(Accepted),
  189. MACROSTR(NotSupportedMessageFormat),
  190. MACROSTR(Rejected),
  191. MACROSTR(NotSupportedPriority),
  192. MACROSTR(NotSupportedState),
  193. MACROSTR(UnknownTransaction)
  194. };
  195. static char *EnergyTransferModeEnumTypeStr[] = {
  196. MACROSTR(DC),
  197. MACROSTR(AC_single_phase),
  198. MACROSTR(AC_two_phase),
  199. MACROSTR(AC_three_phase)
  200. };
  201. static char *EventNotificationEnumTypeStr[] = {
  202. MACROSTR(HardWiredNotification),
  203. MACROSTR(HardWiredMonitor),
  204. MACROSTR(PreconfiguredMonitor),
  205. MACROSTR(CustomMonitor)
  206. };
  207. static char *EventTriggerEnumTypeStr[] = {
  208. MACROSTR(Alerting),
  209. MACROSTR(Delta),
  210. MACROSTR(Periodic)
  211. };
  212. static char *FirmwareStatusEnumTypeStr[] = {
  213. MACROSTR(Downloaded),
  214. MACROSTR(DownloadFailed),
  215. MACROSTR(Downloading),
  216. MACROSTR(DownloadScheduled),
  217. MACROSTR(DownloadPaused),
  218. MACROSTR(Idle),
  219. MACROSTR(InstallationFailed),
  220. MACROSTR(Installing),
  221. MACROSTR(Installed),
  222. MACROSTR(InstallRebooting),
  223. MACROSTR(InstallScheduled),
  224. MACROSTR(InstallVerificationFailed),
  225. MACROSTR(InvalidSignature),
  226. MACROSTR(SignatureVerified)
  227. };
  228. static char *GenericDeviceModelStatusEnumTypeStr[] = {
  229. MACROSTR(Accepted),
  230. MACROSTR(Rejected),
  231. MACROSTR(NotSupported),
  232. MACROSTR(EmptyResultSet)
  233. };
  234. static char *GenericStatusEnumTypeStr[] = {
  235. MACROSTR(Accepted),
  236. MACROSTR(Rejected)
  237. };
  238. static char *GetCertificateIdUseEnumTypeStr[] = {
  239. MACROSTR(V2GRootCertificate),
  240. MACROSTR(MORootCertificate),
  241. MACROSTR(CSMSRootCertificate),
  242. MACROSTR(V2GCertificateChain),
  243. MACROSTR(ManufacturerRootCertificate)
  244. };
  245. static char *GetCertificateStatusEnumTypeStr[] = {
  246. MACROSTR(Accepted),
  247. MACROSTR(Failed)
  248. };
  249. static char *GetChargingProfileStatusEnumTypeStr[] = {
  250. MACROSTR(Accepted),
  251. MACROSTR(NoProfiles)
  252. };
  253. static char *GetDisplayMessagesStatusEnumTypeStr[] = {
  254. MACROSTR(Accepted),
  255. MACROSTR(Unknown)
  256. };
  257. static char *GetInstalledCertificateStatusEnumTypeStr[] = {
  258. MACROSTR(Accepted),
  259. MACROSTR(NotFound)
  260. };
  261. static char *GetVariableStatusEnumTypeStr[] = {
  262. MACROSTR(Accepted),
  263. MACROSTR(Rejected),
  264. MACROSTR(UnknownComponent),
  265. MACROSTR(UnknownVariable),
  266. MACROSTR(NotSupportedAttributeType)
  267. };
  268. static char *HashAlgorithmEnumTypeStr[] = {
  269. MACROSTR(SHA256),
  270. MACROSTR(SHA384),
  271. MACROSTR(SHA512)
  272. };
  273. static char *IdTokenEnumTypeStr[] = {
  274. MACROSTR(Central),
  275. MACROSTR(eMAID),
  276. MACROSTR(ISO14443),
  277. MACROSTR(KeyCode),
  278. MACROSTR(Local),
  279. MACROSTR(NoAuthorization),
  280. MACROSTR(ISO15693)
  281. };
  282. static char *InstallCertificateUseEnumTypeStr[] = {
  283. MACROSTR(V2GRootCertificate),
  284. MACROSTR(MORootCertificate),
  285. MACROSTR(CSMSRootCertificate),
  286. MACROSTR(ManufacturerRootCertificate)
  287. };
  288. static char *InstallCertificateStatusEnumTypeStr[]={
  289. MACROSTR(Accepted),
  290. MACROSTR(Failed),
  291. MACROSTR(Rejected)
  292. };
  293. static char *Iso15118EVCertificateStatusEnumTypeStr[] = {
  294. MACROSTR(Accepted),
  295. MACROSTR(Failed)
  296. };
  297. static char *LocationEnumTypeStr[] = {
  298. MACROSTR(Body),
  299. MACROSTR(Cable),
  300. MACROSTR(EV),
  301. MACROSTR(Inlet),
  302. MACROSTR(Outlet)
  303. };
  304. static char *LogEnumTypeStr[] = {
  305. MACROSTR(DiagnosticsLog),
  306. MACROSTR(SecurityLog)
  307. };
  308. static char *LogStatusEnumTypeStr[] = {
  309. MACROSTR(Accepted),
  310. MACROSTR(Rejected),
  311. MACROSTR(AcceptedCanceled)
  312. };
  313. static char *MeasurandEnumTypeStr[] = {
  314. MACROSTR(Current.Export),
  315. MACROSTR(Current.Import),
  316. MACROSTR(Current.Offered),
  317. MACROSTR(Energy.Active.Export.Register),
  318. MACROSTR(Energy.Active.Import.Register),
  319. MACROSTR(Energy.Reactive.Export.Register),
  320. MACROSTR(Energy.Reactive.Import.Register),
  321. MACROSTR(Energy.Active.Export.Interval),
  322. MACROSTR(Energy.Active.Import.Interval),
  323. MACROSTR(Energy.Active.Net),
  324. MACROSTR(Energy.Reactive.Export.Interval),
  325. MACROSTR(Energy.Reactive.Import.Interval),
  326. MACROSTR(Energy.Reactive.Net),
  327. MACROSTR(Energy.Apparent.Net),
  328. MACROSTR(Energy.Apparent.Import),
  329. MACROSTR(Energy.Apparent.Export),
  330. MACROSTR(Frequency),
  331. MACROSTR(Power.Active.Export),
  332. MACROSTR(Power.Active.Import),
  333. MACROSTR(Power.Factor),
  334. MACROSTR(Power.Offered),
  335. MACROSTR(Power.Reactive.Export),
  336. MACROSTR(Power.Reactive.Import),
  337. MACROSTR(SoC),
  338. MACROSTR(Voltage)
  339. };
  340. static char *MessageFormatEnumTypeStr[] = {
  341. MACROSTR(ASCII),
  342. MACROSTR(HTML),
  343. MACROSTR(URI),
  344. MACROSTR(UTF8)
  345. };
  346. static char *MessagePriorityEnumTypeStr[] = {
  347. MACROSTR(AlwaysFront),
  348. MACROSTR(InFront),
  349. MACROSTR(NormalCycle)
  350. };
  351. static char *MessageStateEnumTypeStr[] = {
  352. MACROSTR(Charging),
  353. MACROSTR(Faulted),
  354. MACROSTR(Idle),
  355. MACROSTR(Unavailable)
  356. };
  357. static char *MessageTriggerEnumTypeStr[] = {
  358. MACROSTR(BootNotification),
  359. MACROSTR(LogStatusNotification),
  360. MACROSTR(FirmwareStatusNotification),
  361. MACROSTR(Heartbeat),
  362. MACROSTR(MeterValues),
  363. MACROSTR(SignChargingStationCertificate),
  364. MACROSTR(SignV2GCertificate),
  365. MACROSTR(StatusNotification),
  366. MACROSTR(TransactionEvent),
  367. MACROSTR(SignCombinedCertificate),
  368. MACROSTR(PublishFirmwareStatusNotification)
  369. };
  370. static char *MonitorEnumTypeStr[] = {
  371. MACROSTR(UpperThreshold),
  372. MACROSTR(LowerThreshold),
  373. MACROSTR(Delta),
  374. MACROSTR(Periodic),
  375. MACROSTR(PeriodicClockAligned)
  376. };
  377. static char *MonitoringBaseEnumTypeStr[] = {
  378. MACROSTR(All),
  379. MACROSTR(FactoryDefault),
  380. MACROSTR(HardWiredOnly)
  381. };
  382. static char *MonitoringCriterionEnumTypeStr[] = {
  383. MACROSTR(ThresholdMonitoring),
  384. MACROSTR(DeltaMonitoring),
  385. MACROSTR(PeriodicMonitoring)
  386. };
  387. static char *MutabilityEnumTypeStr[] = {
  388. MACROSTR(ReadOnly),
  389. MACROSTR(WriteOnly),
  390. MACROSTR(ReadWrite)
  391. };
  392. static char *NotifyEVChargingNeedsStatusEnumTypeStr[] = {
  393. MACROSTR(Accepted),
  394. MACROSTR(Rejected),
  395. MACROSTR(Processing)
  396. };
  397. static char *OCPPInterfaceEnumTypeStr[] = {
  398. MACROSTR(Wired0),
  399. MACROSTR(Wired1),
  400. MACROSTR(Wired2),
  401. MACROSTR(Wired3),
  402. MACROSTR(Wireless0),
  403. MACROSTR(Wireless1),
  404. MACROSTR(Wireless2),
  405. MACROSTR(Wireless3)
  406. };
  407. static char *OCPPTransportEnumTypeStr[] = {
  408. MACROSTR(JSON),
  409. MACROSTR(SOAP)
  410. };
  411. static char *OCPPVersionEnumTypeStr[] = {
  412. MACROSTR(OCPP12),
  413. MACROSTR(OCPP15),
  414. MACROSTR(OCPP16),
  415. MACROSTR(OCPP20)
  416. };
  417. static char *OperationalStatusEnumTypeStr[] = {
  418. MACROSTR(Inoperative),
  419. MACROSTR(Operative)
  420. };
  421. static char *PhaseEnumTypeStr[] = {
  422. MACROSTR(L1),
  423. MACROSTR(L2),
  424. MACROSTR(L3),
  425. MACROSTR(N),
  426. MACROSTR(L1-N),
  427. MACROSTR(L2-N),
  428. MACROSTR(L3-N),
  429. MACROSTR(L1-L2),
  430. MACROSTR(L2-L3),
  431. MACROSTR(L3-L1)
  432. };
  433. static char *PublishFirmwareStatusEnumTypeStr[] = {
  434. MACROSTR(Downloaded),
  435. MACROSTR(DownloadFailed),
  436. MACROSTR(Downloading),
  437. MACROSTR(DownloadScheduled),
  438. MACROSTR(DownloadPaused),
  439. MACROSTR(PublishFailed),
  440. MACROSTR(Published),
  441. MACROSTR(InvalidChecksum),
  442. MACROSTR(ChecksumVerified)
  443. };
  444. static char *ReadingContextEnumTypeStr[] = {
  445. MACROSTR(Interruption.Begin),
  446. MACROSTR(Interruption.End),
  447. MACROSTR(Other),
  448. MACROSTR(Sample.Clock),
  449. MACROSTR(Sample.Periodic),
  450. MACROSTR(Transaction.Begin),
  451. MACROSTR(Transaction.End),
  452. MACROSTR(Trigger)
  453. };
  454. #if 0
  455. static char *ReasonEnumTypeStr[] = {
  456. MACROSTR(DeAuthorized),
  457. MACROSTR(EmergencyStop),
  458. MACROSTR(EnergyLimitReached),
  459. MACROSTR(EVDisconnected),
  460. MACROSTR(GroundFault),
  461. MACROSTR(ImmediateReset),
  462. MACROSTR(Local),
  463. MACROSTR(LocalOutOfCredit),
  464. MACROSTR(MasterPass),
  465. MACROSTR(Other),
  466. MACROSTR(OvercurrentFault),
  467. MACROSTR(PowerLoss),
  468. MACROSTR(PowerQuality),
  469. MACROSTR(Reboot),
  470. MACROSTR(Remote),
  471. MACROSTR(SOCLimitReached),
  472. MACROSTR(StoppedByEV),
  473. MACROSTR(TimeLimitReached),
  474. MACROSTR(TimeLimitReached)
  475. };
  476. #endif
  477. static char *RecurrencyKindEnumTypeStr[] = {
  478. MACROSTR(Daily),
  479. MACROSTR(Weekly)
  480. };
  481. static char *RegistrationStatusEnumTypeStr[] = {
  482. MACROSTR(Accepted),
  483. MACROSTR(Pending),
  484. MACROSTR(Rejected)
  485. };
  486. static char *ReportBaseEnumTypeStr[] = {
  487. MACROSTR(ConfigurationInventory),
  488. MACROSTR(FullInventory),
  489. MACROSTR(SummaryInventory)
  490. };
  491. static char *RequestStartStopStatusEnumTypeStr[] = {
  492. MACROSTR(Accepted),
  493. MACROSTR(Rejected)
  494. };
  495. static char *ReservationUpdateStatusEnumTypeStr[] = {
  496. MACROSTR(Expired),
  497. MACROSTR(Removed)
  498. };
  499. static char *ReserveNowStatusEnumTypeStr[] = {
  500. MACROSTR(Accepted),
  501. MACROSTR(Faulted),
  502. MACROSTR(Occupied),
  503. MACROSTR(Rejected),
  504. MACROSTR(Unavailable)
  505. };
  506. static char *ResetEnumTypeStr[] = {
  507. MACROSTR(Immediate),
  508. MACROSTR(OnIdle)
  509. };
  510. static char *ResetStatusEnumTypeStr[] = {
  511. MACROSTR(Accepted),
  512. MACROSTR(Rejected),
  513. MACROSTR(Scheduled)
  514. };
  515. static char *SetMonitoringStatusEnumTypeStr[] = {
  516. MACROSTR(Accepted),
  517. MACROSTR(UnknownComponent),
  518. MACROSTR(UnknownVariable),
  519. MACROSTR(UnsupportedMonitorType),
  520. MACROSTR(Rejected),
  521. MACROSTR(OutOfRange),
  522. MACROSTR(Duplicate)
  523. };
  524. static char *SetNetworkProfileStatusEnumTypeStr[] = {
  525. MACROSTR(Accepted),
  526. MACROSTR(Rejected),
  527. MACROSTR(Failed)
  528. };
  529. static char *SetVariableStatusEnumTypeStr[] = {
  530. MACROSTR(Accepted),
  531. MACROSTR(Rejected),
  532. MACROSTR(InvalidValue),
  533. MACROSTR(UnknownComponent),
  534. MACROSTR(UnknownVariable),
  535. MACROSTR(NotSupportedAttributeType),
  536. MACROSTR(OutOfRange),
  537. MACROSTR(RebootRequired)
  538. };
  539. static char *TransactionEventEnumTypeStr[] = {
  540. MACROSTR(Ended),
  541. MACROSTR(Started),
  542. MACROSTR(Updated)
  543. };
  544. static char *TriggerMessageStatusEnumTypeStr[] = {
  545. MACROSTR(Accepted),
  546. MACROSTR(Rejected),
  547. MACROSTR(NotImplemented)
  548. };
  549. static char *TriggerReasonEnumTypeStr[] = {
  550. MACROSTR(Authorized),
  551. MACROSTR(CablePluggedIn),
  552. MACROSTR(ChargingRateChanged),
  553. MACROSTR(ChargingStateChanged),
  554. MACROSTR(Deauthorized),
  555. MACROSTR(EnergyLimitReached),
  556. MACROSTR(EVCommunicationLost),
  557. MACROSTR(EVConnectTimeout),
  558. MACROSTR(MeterValueClock),
  559. MACROSTR(MeterValuePeriodic),
  560. MACROSTR(TimeLimitReached),
  561. MACROSTR(Trigger),
  562. MACROSTR(UnlockCommand),
  563. MACROSTR(StopAuthorized),
  564. MACROSTR(EVDeparted),
  565. MACROSTR(EVDetected),
  566. MACROSTR(RemoteStop),
  567. MACROSTR(RemoteStart),
  568. MACROSTR(AbnormalCondition),
  569. MACROSTR(SignedDataReceived),
  570. MACROSTR(ResetCommand)
  571. };
  572. static char *UnlockStatusEnumTypeStr[] = {
  573. MACROSTR(Unlocked),
  574. MACROSTR(UnlockFailed),
  575. MACROSTR(OngoingAuthorizedTransaction),
  576. MACROSTR(UnknownConnector)
  577. };
  578. static char *UnpublishFirmwareStatusEnumTypeStr[] = {
  579. MACROSTR(DownloadOngoing),
  580. MACROSTR(NoFirmware),
  581. MACROSTR(Unpublished)
  582. };
  583. static char *UpdateEnumTypeStr[] = {
  584. MACROSTR(Differential),
  585. MACROSTR(Full)
  586. };
  587. static char *UpdateFirmwareStatusEnumTypeStr[] = {
  588. MACROSTR(Accepted),
  589. MACROSTR(Rejected),
  590. MACROSTR(AcceptedCanceled),
  591. MACROSTR(InvalidCertificate),
  592. MACROSTR(RevokedCertificate)
  593. };
  594. static char *UpdateStatusEnumTypeStr[] = {
  595. MACROSTR(Accepted),
  596. MACROSTR(Failed),
  597. MACROSTR(VersionMismatch)
  598. };
  599. static char *UploadLogStatusEnumTypeStr[] = {
  600. MACROSTR(BadMessage),
  601. MACROSTR(Idle),
  602. MACROSTR(NotSupportedOperation),
  603. MACROSTR(PermissionDenied),
  604. MACROSTR(Uploaded),
  605. MACROSTR(UploadFailure),
  606. MACROSTR(Uploading)
  607. };
  608. static char *VPNEnumTypeStr[] = {
  609. MACROSTR(IKEv2),
  610. MACROSTR(IPSec),
  611. MACROSTR(L2TP),
  612. MACROSTR(PPTP)
  613. };
  614. #if 0
  615. static char *ChargePointErrorCodeEnumTypeStr[] = {
  616. MACROSTR(ConnectorLockFailure),
  617. MACROSTR(EVCommunicationError),
  618. MACROSTR(GroundFailure),
  619. MACROSTR(HighTemperature),
  620. MACROSTR(InternalError),
  621. MACROSTR(LocalListConflict),
  622. MACROSTR(NoError),
  623. MACROSTR(OtherError),
  624. MACROSTR(OverCurrentFailure),
  625. MACROSTR(OverVoltage),
  626. MACROSTR(PowerMeterFailure),
  627. MACROSTR(PowerSwitchFailure),
  628. MACROSTR(ReaderFailure),
  629. MACROSTR(ResetFailure),
  630. MACROSTR(UnderVoltage),
  631. MACROSTR(WeakSignal)
  632. };
  633. #endif
  634. static char *GetCompositeScheduleStatusEnumTypeStr[] = {
  635. MACROSTR(Accepted),
  636. MACROSTR(Rejected)
  637. };
  638. static char *RemoteStartStopStatusEnumTypeStr[] = {
  639. MACROSTR(Accepted),
  640. MACROSTR(Rejected)
  641. };
  642. #if 0
  643. static char * StopTransactionReasonEnumTypeStr[] = {
  644. MACROSTR(EmergencyStop),
  645. MACROSTR(EVDisconnected),
  646. MACROSTR(HardReset),
  647. MACROSTR(Local),
  648. MACROSTR(Other),
  649. MACROSTR(PowerLoss),
  650. MACROSTR(Reboot),
  651. MACROSTR(Remote),
  652. MACROSTR(SoftReset),
  653. MACROSTR(UnlockCommand),
  654. MACROSTR(DeAuthorized)
  655. };
  656. #endif
  657. //ChargePointMaxProfile
  658. #define ChargePointMaxProfile_JSON "/Storage/OCPP/ChargePointMaxProfile_OCPP20.json"
  659. //TxDefaultProfile
  660. #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0_OCPP20.json"
  661. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  662. struct StatusCodeData *ShmStatusCodeData;
  663. struct PsuData *ShmPsuData ;
  664. struct OCPP20Data *ShmOCPP20Data;
  665. pthread_mutex_t lock_send = PTHREAD_MUTEX_INITIALIZER;
  666. char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
  667. //===============================
  668. // Gun Total Numbers
  669. //===============================
  670. static int gunTotalNumber = 0;
  671. static uint8_t gunType[4] = {0};
  672. //===============================
  673. // Local List Version
  674. //===============================
  675. static int localversion=0;
  676. //===============================
  677. // OCPP sign variable
  678. //===============================
  679. static int server_sign = FALSE;
  680. int server_pending = FALSE;
  681. static int BootNotificationInterval = 10;
  682. static int SystemInitial = 0;//= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; // System Boot UP
  683. //===============================
  684. // OCPP auth variable
  685. //===============================
  686. static int authorizeRetryTimes = 0; //number of Retry times
  687. //===============================
  688. // OCPP other variables
  689. //===============================
  690. static int HeartBeatWaitTime = 10;
  691. static int FirstHeartBeat = 0;
  692. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  693. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  694. static char CurrentChargingProfileScheduleStr[30] = {0};
  695. //========================================
  696. // OCPP status/previous related variables
  697. //========================================
  698. static int GunStatusInterval = 10;
  699. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  700. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  701. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  702. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  703. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  704. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  705. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  706. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  707. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  708. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  709. static int TransactionMessageAttemptsValue = 0;
  710. static int TransactionMessageRetryIntervalValue = 0;
  711. static int TempMeterValueInterval = 0;
  712. static struct AuthorizationData idTagQuery;
  713. //=============================================
  714. // OCPP HeartBeat Response Not Receive Counts
  715. //============================================
  716. static int HeartBeatWithNOResponse = 0;
  717. static int HeartBeatCountPerHour = 0;
  718. sqlite3 *db;
  719. int TransactionMessageAttemptsGet(void);
  720. int TransactionMessageRetryIntervalGet(void);
  721. int GetOcppConnStatus(void);
  722. void SetOcppConnStatus(uint8_t status);
  723. int setKeyValue(char *key, char *value);
  724. void OCPP_get_TableAuthlocalAllData(void);
  725. void processUnkownKey(void);
  726. struct StructOCPPMeterValue
  727. {
  728. unsigned char TimeStamp[28];
  729. struct StructSampledValue SampledValue[10];
  730. };
  731. struct ClientTime
  732. {
  733. unsigned int Heartbeat;
  734. unsigned int StatusNotification[CONNECTOR_QUANTITY];
  735. unsigned int StartTransaction;
  736. unsigned int StopTransaction;
  737. unsigned int MeterValues[CONNECTOR_QUANTITY];
  738. }clientTime;
  739. typedef union
  740. {
  741. //Operations Initiated by Central System
  742. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  743. struct
  744. {
  745. //CsMsgValue[0]
  746. unsigned char StatusNotificationReq:1; //bit 0,
  747. unsigned char StatusNotificationConf:1; //bit 1,
  748. unsigned char TriggerMeterValueReq:1; //bit 2,
  749. unsigned char TransactionEventReq:1; //bit 3,
  750. unsigned char SampleMeterReq:1; //bit 4,
  751. unsigned char ClockAlignMeterReq:1; //bit 5,
  752. unsigned char :2;
  753. }bits[CONNECTOR_QUANTITY];
  754. }CpinitiateMsg;
  755. CpinitiateMsg cpinitateMsg;
  756. //=========================================
  757. // Date time related function
  758. //=========================================
  759. void getNowDatetime(uint8_t *data)
  760. {
  761. time_t t = time(NULL);
  762. struct tm tm = *localtime(&t);
  763. 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);
  764. }
  765. //=========================================
  766. // Sqlite3 related function
  767. //=========================================
  768. int DB_Initial()
  769. {
  770. int result = PASS;
  771. char* errMsg = NULL;
  772. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  773. "idToken text UNIQUE,"
  774. "type text,"
  775. "status text,"
  776. "cacheExpiryDateTime text,"
  777. "chargingPriority integer,"
  778. "language1 text,"
  779. "evseId text,"
  780. "language2 text,"
  781. "groupIdToken_idToken text,"
  782. "groupIdToken_type text,"
  783. "personalMessage text);";
  784. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  785. "idToken text UNIQUE,"
  786. "type text,"
  787. "status text,"
  788. "cacheExpiryDateTime text,"
  789. "chargingPriority integer,"
  790. "language1 text,"
  791. "evseId text,"
  792. "language2 text,"
  793. "groupIdToken_idToken text,"
  794. "groupIdToken_type text,"
  795. "personalMessage text,"
  796. "version text);";
  797. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  798. "componentName text NOT NULL ,"
  799. "componentInstance text, "
  800. "variableName text NOT NULL, "
  801. "variableInstance text, "
  802. "variableCharacteristicsDataType integer, "
  803. "variableCharacteristicsUnit text, "
  804. "variableCharacteristicsMaxLimit real,"
  805. "variableAttributesType text, "
  806. "variableAttributesTypeMutability text, "
  807. "variableAttributesTypeValue text, "
  808. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  809. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  810. "type text);";
  811. char *sqlNetworkProfile = "create table if not exists ocpp20_networkprofile (idx integer primary key,"
  812. "slot integer UNIQUE, connectionData text);";
  813. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  814. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  815. {
  816. result = FAIL;
  817. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  818. sqlite3_close(db);
  819. }
  820. else
  821. {
  822. DEBUG_INFO( "OCPP local database open successfully.\n");
  823. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  824. {
  825. result = FAIL;
  826. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  827. }
  828. else
  829. {
  830. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  831. }
  832. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  833. {
  834. result = FAIL;
  835. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  836. }
  837. else
  838. {
  839. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  840. }
  841. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  842. {
  843. result = FAIL;
  844. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  845. }
  846. else
  847. {
  848. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  849. }
  850. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  851. {
  852. result = FAIL;
  853. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  854. }
  855. else
  856. {
  857. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  858. }
  859. if (sqlite3_exec(db, sqlNetworkProfile, 0, 0, &errMsg) != SQLITE_OK)
  860. {
  861. result = FAIL;
  862. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_networkprofile table error message: %s\n", errMsg);
  863. }
  864. else
  865. {
  866. DEBUG_INFO( "Create OCPP 2.0 ocpp20_networkprofile table successfully\n");
  867. }
  868. //sqlite3_close(db);
  869. }
  870. return result;
  871. }
  872. int DB_cbGetVersion(void *para, int columnCount, char **columnValue, char **columnName)
  873. {
  874. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  875. return 0;
  876. }
  877. void DB_getListVerion()
  878. {
  879. char sql[256];
  880. char* errMsg = NULL;
  881. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  882. /* Execute SQL statement */
  883. if( sqlite3_exec(db, sql, DB_cbGetVersion, 0, &errMsg) != SQLITE_OK )
  884. {
  885. DEBUG_INFO("SQL error: %s", errMsg);
  886. }
  887. }
  888. int DB_cbGetIdTag(void *para, int columnCount, char **columnValue, char **columnName)
  889. {
  890. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  891. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  892. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  893. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  894. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  895. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  896. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  897. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  898. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  899. return 0;
  900. }
  901. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  902. {
  903. char sql[256];
  904. char* errMsg = NULL;
  905. memset(&idTagQuery, 0, sizeof(idTagQuery));
  906. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  907. if(isQueryFromCache)
  908. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  909. else
  910. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  911. /* Execute SQL statement */
  912. if(sqlite3_exec(db, sql, DB_cbGetIdTag, 0, &errMsg) != SQLITE_OK )
  913. {
  914. DEBUG_INFO("SQL error: %s", errMsg);
  915. }
  916. }
  917. int DB_cbTableAuthlocalAllData(void *para, int columnCount, char **columnValue, char **columnName)
  918. {
  919. for (int i = 0; i < columnCount; i++)
  920. {
  921. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  922. }
  923. return 0;
  924. }
  925. void DB_get_TableAuthlocalAllData(void)
  926. {
  927. char sql[256];
  928. char* errMsg = NULL;
  929. sprintf(sql,"select * from ocpp20_auth_local;");
  930. /* Execute SQL statement */
  931. if(sqlite3_exec(db, sql, DB_cbTableAuthlocalAllData, 0,&errMsg) != SQLITE_OK)
  932. {
  933. DEBUG_INFO("SQL error: %s", errMsg);
  934. }
  935. }
  936. int DB_cbAddLocalListCache(void *para, int columnCount, char **columnValue, char **columnName)
  937. {
  938. for(int i = 0; i<columnCount; i++)
  939. {
  940. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  941. }
  942. return 0;
  943. }
  944. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  945. {
  946. int result = PASS;
  947. char sql[512];
  948. char* errMsg = NULL;
  949. 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;",
  950. data->idToken.idToken,
  951. data->idToken.type,
  952. data->idTokenInfo.status,
  953. data->idTokenInfo.cacheExpiryDateTime,
  954. data->idTokenInfo.chargingPriority,
  955. data->idTokenInfo.language1,
  956. data->idTokenInfo.language2,
  957. data->idTokenInfo.groupIdToken.idToken,
  958. data->idTokenInfo.groupIdToken.type,
  959. listVersion);
  960. //* Execute SQL statement */
  961. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  962. {
  963. DEBUG_INFO("SQL error: %s\n", errMsg);
  964. result = FAIL;
  965. }
  966. else
  967. {
  968. memset(sql, 0, ARRAY_SIZE(sql));
  969. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  970. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  971. {
  972. DEBUG_INFO("SQL error: %s\n", errMsg);
  973. result = FAIL;
  974. }
  975. }
  976. return result;
  977. }
  978. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  979. {
  980. int result = PASS;
  981. char sql[512];
  982. char* errMsg = NULL;
  983. 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;",
  984. idToken->idToken,
  985. idToken->type,
  986. idTokenInfo->status,
  987. idTokenInfo->cacheExpiryDateTime,
  988. idTokenInfo->chargingPriority,
  989. idTokenInfo->language1,
  990. idTokenInfo->language2,
  991. idTokenInfo->groupIdToken.idToken,
  992. idTokenInfo->groupIdToken.type);
  993. //* Execute SQL statement */
  994. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  995. {
  996. DEBUG_INFO("SQL error: %s\n", errMsg);
  997. result = FAIL;
  998. }
  999. return result;
  1000. }
  1001. int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  1002. {
  1003. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  1004. // printf("localversion=%d\n", localversion);
  1005. return 0;
  1006. }
  1007. void DB_deleteIdTag(char idTag[])
  1008. {
  1009. char sql[512];
  1010. char* errMsg = NULL;
  1011. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1012. //* Execute SQL statement */
  1013. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1014. {
  1015. DEBUG_INFO("SQL error: %s", errMsg);
  1016. }
  1017. }
  1018. int DB_cleanLocalList()
  1019. {
  1020. int result = PASS;
  1021. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1022. char *errMsg = 0;
  1023. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1024. {
  1025. DEBUG_INFO("%s\n", errMsg);
  1026. result = FAIL;
  1027. }
  1028. return result;
  1029. }
  1030. int DB_cleanLocalCache()
  1031. {
  1032. int result = PASS;
  1033. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1034. char *errMsg = 0;
  1035. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1036. {
  1037. DEBUG_INFO("%s\n", errMsg);
  1038. result = FAIL;
  1039. }
  1040. return result;
  1041. }
  1042. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1043. {
  1044. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1045. return 0;
  1046. }
  1047. void DB_getBooType()
  1048. {
  1049. char sql[256];
  1050. char* errMsg = NULL;
  1051. sprintf(sql,"select * from ocpp20_boot_type;");
  1052. /* Execute SQL statement */
  1053. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1054. {
  1055. DEBUG_INFO("SQL error: %s\n", errMsg);
  1056. }
  1057. }
  1058. int DB_cbUpdateBootType(void *para, int columnCount, char **columnValue, char **columnName)
  1059. {
  1060. for(int i = 0; i<columnCount; i++)
  1061. {
  1062. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1063. }
  1064. return 0;
  1065. }
  1066. int DB_updateBootType(BootReasonEnumType reason)
  1067. {
  1068. int result = PASS;
  1069. char sql[512];
  1070. char* errMsg = NULL;
  1071. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1072. //* Execute SQL statement */
  1073. if(sqlite3_exec(db, sql, DB_cbUpdateBootType, 0, &errMsg) != SQLITE_OK)
  1074. {
  1075. DEBUG_INFO("SQL error: %s\n", errMsg);
  1076. result = FAIL;
  1077. }
  1078. return result;
  1079. }
  1080. int DB_cbVariableSaveToDb(void *para, int columnCount, char **columnValue, char **columnName)
  1081. {
  1082. for(int i = 0; i<columnCount; i++)
  1083. {
  1084. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1085. }
  1086. return 0;
  1087. }
  1088. int DB_variableSaveToDb(struct ReportDataType *variable)
  1089. {
  1090. int result = FAIL;
  1091. char sql[4096];
  1092. char* errMsg = NULL;
  1093. 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;",
  1094. variable->component.name,
  1095. variable->component.instance,
  1096. variable->variable.name,
  1097. variable->variable.instance,
  1098. variable->variableCharacteristics.dataType,
  1099. variable->variableCharacteristics.unit,
  1100. variable->variableCharacteristics.maxLimit,
  1101. variable->variableAttribute[0].type,
  1102. variable->variableAttribute[0].mutability,
  1103. variable->variableAttribute[0].value);
  1104. //* Execute SQL statement */
  1105. if(sqlite3_exec(db, sql, DB_cbVariableSaveToDb, 0, &errMsg) != SQLITE_OK)
  1106. {
  1107. DEBUG_INFO("SQL error: %s\n", errMsg);
  1108. result = FAIL;
  1109. }
  1110. return result;
  1111. }
  1112. int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1113. {
  1114. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1115. if(atoi(columnValue[0]) == 0)
  1116. {
  1117. DB_updateBootType(BootReasonEnumType_PowerUp);
  1118. // Create variable table content
  1119. /* AlignedDataCtrlr Required item */
  1120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1126. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1133. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1139. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1141. else
  1142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1143. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1148. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.minLimit = 10;
  1149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1152. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1159. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1166. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1172. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1174. else
  1175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1176. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1184. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1185. /* AuthCtrlrVariable Required item */
  1186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1192. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1199. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1206. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1213. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1220. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1227. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1231. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1235. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1236. /* AuthCacheCtrlr Variable Required item*/
  1237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1243. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1250. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1258. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1262. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*100);
  1263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1266. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1273. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1274. /* ClockCtrlr Variable Required item */
  1275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1280. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1281. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1288. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1296. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1303. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1310. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1318. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1325. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1332. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1333. /* ChargingStation Required item */
  1334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1340. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1347. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1354. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1355. /* Connector Required item */
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1362. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1369. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1376. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1377. /* CustomizationCtrlr Required item */
  1378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1384. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1385. /* DeviceDataCtrlr Required item */
  1386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1393. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1401. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1409. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1416. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1417. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1420. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1425. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1428. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1433. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1440. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1441. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1449. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1450. /* DisplayMessageCtrlr Required item */
  1451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1457. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1464. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "0");
  1471. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1478. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1485. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1486. /* EVSE Required item */
  1487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1493. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1498. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1500. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1507. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1514. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1515. /* LocalAuthListCtrlr Required item */
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1522. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1529. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1535. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1536. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1543. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "50");
  1544. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1551. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "2048");
  1552. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1556. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = 1024*1024;
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1559. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "5000");
  1560. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1561. /* MonitoringCtrlr Required item */
  1562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1567. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1568. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1575. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1580. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1583. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1590. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1591. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1598. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1599. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1606. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1607. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1613. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1614. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1615. /* OCPPCommCtrlr Required item */
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1621. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1622. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1631. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1635. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1638. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1643. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1645. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1646. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1651. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "[0]");
  1653. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1654. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1655. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1657. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1658. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1659. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1660. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1661. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1666. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1667. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1668. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1673. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1674. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1675. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1676. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1682. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1683. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1684. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1688. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1690. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1691. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1692. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "3");
  1693. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1695. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1696. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1697. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1698. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1699. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1700. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1702. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1704. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1705. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1706. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1707. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1708. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1710. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1712. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1713. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1714. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1715. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1716. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1717. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1719. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1720. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1721. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1722. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1723. /* ReservationCtrlr Required item */
  1724. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1725. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1727. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1728. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1729. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1730. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1732. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1734. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1735. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1737. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1739. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1741. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1742. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1743. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1744. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1745. /* SampledDataCtrlr Required item */
  1746. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1749. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1750. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1751. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1752. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  1753. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  1754. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1757. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1758. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1759. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  1761. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1764. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1765. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1766. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  1767. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  1768. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1772. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, " ");
  1773. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  1774. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  1775. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1776. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1779. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1780. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1781. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  1782. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  1783. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  1784. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1787. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  1788. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  1789. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  1791. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1792. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1793. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, " ");
  1795. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  1796. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1800. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.minLimit = 10;
  1801. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1802. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1803. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "30");
  1804. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  1805. /* SecurityCtrlr Required item */
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  1807. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  1808. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1809. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  1810. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1811. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1812. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, " ");
  1813. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  1814. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  1815. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  1816. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1817. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1819. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1820. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "Phihong Technology");
  1821. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  1822. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  1823. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  1824. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1825. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "Phihong");
  1828. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  1829. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  1831. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1833. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  1835. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  1836. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1839. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "0");
  1842. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  1843. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  1844. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  1845. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1847. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1848. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  1849. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  1850. /* SmartChargingCtrlr Required item */
  1851. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1854. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1855. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1857. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  1858. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  1859. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1862. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  1864. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  1865. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  1866. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1869. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1870. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  1871. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  1872. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  1873. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  1874. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1876. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1877. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "0");
  1878. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  1879. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  1880. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1882. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1884. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  1885. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  1886. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  1887. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  1888. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1891. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  1892. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  1893. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  1894. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  1895. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1897. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1898. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  1899. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  1900. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  1901. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  1902. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1903. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1904. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  1906. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  1907. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  1908. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  1909. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1911. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1912. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  1913. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  1914. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  1916. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1918. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1919. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "3");
  1920. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  1921. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  1922. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  1923. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1925. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1926. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  1927. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  1928. /* TariffCostCtrlr Required item */
  1929. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1933. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1934. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1935. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  1936. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  1937. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  1940. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1941. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1942. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1943. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  1944. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  1945. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  1946. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  1947. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1948. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  1949. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1950. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1951. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  1952. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  1954. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  1955. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  1956. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1957. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1958. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1959. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  1960. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  1961. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  1962. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  1963. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  1964. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1965. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1966. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1967. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  1968. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  1969. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  1970. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  1971. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1972. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  1973. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1974. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1975. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  1976. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  1977. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  1978. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  1979. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1980. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  1981. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1982. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1983. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  1984. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  1985. /* TxCtrlr Required item */
  1986. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  1987. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  1988. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1990. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1991. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  1992. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  1993. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  1994. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  1995. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  1996. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1997. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1998. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1999. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  2000. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  2001. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2002. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2003. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2005. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  2007. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  2008. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2009. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2010. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2012. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2014. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  2015. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2016. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2017. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2018. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2019. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2020. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "PowerPathClosed");
  2021. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  2022. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2023. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2024. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2026. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2027. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "PowerPathClosed");
  2028. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2029. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2030. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2031. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2032. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2034. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2035. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "60000");
  2036. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2037. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2038. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2039. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2040. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2041. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2042. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2043. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2044. }
  2045. else
  2046. {
  2047. // Variable name init
  2048. /* AlignedDataCtrlr Required item */
  2049. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2050. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2051. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2052. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2053. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2054. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2055. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2056. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2059. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2062. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2063. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2064. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2065. /* AuthCtrlrVariable Required item */
  2066. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2067. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2068. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2069. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2070. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2071. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2073. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2074. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2076. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2077. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2078. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2080. /* AuthCacheCtrlr Variable Required item */
  2081. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2082. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2083. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2085. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2086. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2087. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2088. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2089. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2090. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2091. /* ClockCtrlr Variable Required item */
  2092. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2095. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2110. /* ChargingStation Required item */
  2111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2117. /* Connector Required item */
  2118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2124. /* CustomizationCtrlr Required item */
  2125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  2127. /* DeviceDataCtrlr Required item */
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2150. /* DisplayMessageCtrlr Required item */
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2161. /* EVSE Required item */
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2170. /* LocalAuthListCtrlr Required item */
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2185. /* MonitoringCtrlr Required item */
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2204. /* OCPPCommCtrlr Required item */
  2205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2236. /* ReservationCtrlr Required item */
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2243. /* SampledDataCtrlr Required item */
  2244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2260. /* SecurityCtrlr Required item */
  2261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2273. /* SmartChargingCtrlr Required item */
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2296. /* TariffCostCtrlr Required item */
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2315. /* TxCtrlr Required item */
  2316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2332. }
  2333. return 0;
  2334. }
  2335. void DB_variableIsCreate()
  2336. {
  2337. char sql[512];
  2338. char* errMsg = NULL;
  2339. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2340. /* Execute SQL statement */
  2341. if(sqlite3_exec(db, sql, DB_cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2342. {
  2343. DEBUG_INFO("SQL error: %s\n", errMsg);
  2344. }
  2345. }
  2346. int DB_cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2347. {
  2348. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2349. {
  2350. if((strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) == 0) &&
  2351. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) == 0) &&
  2352. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) == 0) &&
  2353. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) == 0))
  2354. {
  2355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2357. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2361. }
  2362. }
  2363. return 0;
  2364. }
  2365. void DB_variableLoadFromDb()
  2366. {
  2367. char sql[512];
  2368. char* errMsg = NULL;
  2369. sprintf(sql,"select * from ocpp20_variable order by idx;");
  2370. /* Execute SQL statement */
  2371. if(sqlite3_exec(db, sql, DB_cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2372. {
  2373. DEBUG_INFO("SQL error: %s\n", errMsg);
  2374. }
  2375. }
  2376. int DB_cbGetNetworkProfileFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2377. {
  2378. memset(&ShmOCPP20Data->NetworkConnectionProfile[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile));
  2379. if(columnCount > 0)
  2380. {
  2381. for(int idx=0;idx<columnCount;idx++)
  2382. {
  2383. json_object *SetNetworkProfile;
  2384. SetNetworkProfile = json_tokener_parse(columnValue[2]);
  2385. if(!is_error(SetNetworkProfile))
  2386. {
  2387. // Required data
  2388. if(json_object_object_get(SetNetworkProfile, "ocppVersion") != NULL)
  2389. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppVersion")));
  2390. if(json_object_object_get(SetNetworkProfile, "ocppTransport") != NULL)
  2391. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppTransport")));
  2392. if(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl") != NULL)
  2393. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl")));
  2394. if(json_object_object_get(SetNetworkProfile, "messageTimeout") != NULL)
  2395. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.messageTimeout = json_object_get_int(json_object_object_get(SetNetworkProfile, "messageTimeout"));
  2396. if(json_object_object_get(SetNetworkProfile, "ocppInterface") != NULL)
  2397. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppInterface")));
  2398. if(json_object_object_get(SetNetworkProfile, "vpn") != NULL)
  2399. {
  2400. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server") != NULL)
  2401. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server")));
  2402. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user") != NULL)
  2403. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user")));
  2404. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group") != NULL)
  2405. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group")));
  2406. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password") != NULL)
  2407. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password")));
  2408. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key") != NULL)
  2409. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key")));
  2410. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type") != NULL)
  2411. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type")));
  2412. }
  2413. if(json_object_object_get(SetNetworkProfile, "apn") != NULL)
  2414. {
  2415. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn") != NULL)
  2416. {
  2417. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn));
  2418. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn")));
  2419. }
  2420. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName") != NULL)
  2421. {
  2422. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName));
  2423. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName")));
  2424. }
  2425. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword") != NULL)
  2426. {
  2427. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword));
  2428. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword")));
  2429. }
  2430. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin") != NULL)
  2431. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin"));
  2432. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork") != NULL)
  2433. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork")));
  2434. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork") != NULL)
  2435. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork"));
  2436. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication") != NULL)
  2437. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication")));
  2438. }
  2439. }
  2440. json_object_put(SetNetworkProfile);
  2441. ShmOCPP20Data->NetworkConnectionProfile[idx].slot = atoi(columnValue[1]);
  2442. }
  2443. }
  2444. return 0;
  2445. }
  2446. void DB_getNetworkProfileFromDb()
  2447. {
  2448. char sql[512];
  2449. char* errMsg = NULL;
  2450. sprintf(sql,"select * from ocpp20_networkprofile order by slot;");
  2451. /* Execute SQL statement */
  2452. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2453. {
  2454. DEBUG_INFO("SQL error: %s\n", errMsg);
  2455. }
  2456. }
  2457. int DB_addNetworkProfile(int slot, char *data)
  2458. {
  2459. int result = PASS;
  2460. char sql[512];
  2461. char* errMsg = NULL;
  2462. sprintf(sql,"insert or replace into ocpp20_networkprofile (slot, connectionData) VALUES('%d', '%s'); SELECT * from ocpp20_networkprofile order by slot;",
  2463. slot,
  2464. data);
  2465. //* Execute SQL statement */
  2466. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK)
  2467. {
  2468. DEBUG_INFO("SQL error: %s\n", errMsg);
  2469. result = FAIL;
  2470. }
  2471. return result;
  2472. }
  2473. int DB_deleteNetworkProfile(int slot)
  2474. {
  2475. int result = PASS;
  2476. char sql[512];
  2477. char* errMsg = NULL;
  2478. sprintf(sql,"DELETE from ocpp20_networkprofile where slot=%d; SELECT * from ocpp20_networkprofile order by slot;", slot);
  2479. //* Execute SQL statement */
  2480. if( sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2481. {
  2482. DEBUG_INFO("SQL error: %s", errMsg);
  2483. result = FAIL;
  2484. }
  2485. return result;
  2486. }
  2487. //==========================================
  2488. // Check time passed since today
  2489. //==========================================
  2490. long long DiffTimebWithNow(struct timeb ST)
  2491. {
  2492. //return milli-second
  2493. struct timeb ET;
  2494. long long StartTime,StopTime;
  2495. ftime(&ET);
  2496. StartTime=(long long)ST.time;
  2497. StopTime=(long long)ET.time;
  2498. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2499. }
  2500. int getTimePassSinceToday()
  2501. {
  2502. int result = -1;
  2503. time_t t;
  2504. struct tm *tmStartToday;
  2505. struct timeb tbStartToday;
  2506. t=time(NULL);
  2507. tmStartToday=localtime(&t);
  2508. tmStartToday->tm_hour = 0;
  2509. tmStartToday->tm_min = 0;
  2510. tmStartToday->tm_sec = 0;
  2511. tbStartToday.time = mktime(tmStartToday);
  2512. tbStartToday.millitm = 0;
  2513. result = DiffTimebWithNow(tbStartToday)/1000;
  2514. return result;
  2515. }
  2516. //==========================================
  2517. // GetCompositeSchedule logic related function
  2518. //==========================================
  2519. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2520. {
  2521. //return milli-second
  2522. unsigned int StartTime,StopTime;
  2523. StartTime=(unsigned int)ST.time;
  2524. StopTime=(unsigned int)ET.time;
  2525. return (StopTime-StartTime);
  2526. }
  2527. int DiffTimebWithNowSec(struct timeb ST)
  2528. {
  2529. //return milli-second
  2530. struct timeb ET;
  2531. unsigned int StartTime,StopTime;
  2532. ftime(&ET);
  2533. StartTime=(unsigned int)ST.time;
  2534. StopTime=(unsigned int)ET.time;
  2535. return (StopTime-StartTime);
  2536. }
  2537. int getStartStop(uint8_t *start, uint8_t *stop)
  2538. {
  2539. int result = -1;
  2540. struct tm tmStart;
  2541. struct timeb tbStart;
  2542. struct tm tmStop;
  2543. struct timeb tbStop;
  2544. 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) &&
  2545. (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))
  2546. {
  2547. //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);
  2548. //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);
  2549. tmStart.tm_year -= 1900;
  2550. tmStart.tm_mon -= 1;
  2551. tbStart.time = mktime(&tmStart);
  2552. tbStart.millitm = 0;
  2553. tmStop.tm_year -= 1900;
  2554. tmStop.tm_mon -= 1;
  2555. tbStop.time = mktime(&tmStop);
  2556. tbStop.millitm = 0;
  2557. result = DiffTimebSec(tbStart, tbStop);
  2558. //DEBUG_INFO("getStartStop(): %d\n", result);
  2559. }
  2560. else
  2561. {
  2562. DEBUG_WARN("Start or stop date parsing error.\r\n");
  2563. }
  2564. return result;
  2565. }
  2566. int isOvertNow(uint8_t *start)
  2567. {
  2568. int result = YES;
  2569. struct tm tmStart;
  2570. struct timeb tbStart;
  2571. 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))
  2572. {
  2573. //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);
  2574. tmStart.tm_year -= 1900;
  2575. tmStart.tm_mon -= 1;
  2576. tbStart.time = mktime(&tmStart);
  2577. tbStart.millitm = 0;
  2578. if(DiffTimebWithNowSec(tbStart) <= 0)
  2579. result = NO;
  2580. }
  2581. else
  2582. {
  2583. DEBUG_WARN("Start date parsing error.\r\n");
  2584. }
  2585. return result;
  2586. }
  2587. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  2588. {
  2589. int result = -1;
  2590. struct tm tmStart;
  2591. struct timeb tbStart;
  2592. struct tm tmStop;
  2593. struct timeb tbStop;
  2594. 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) &&
  2595. (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))
  2596. {
  2597. tmStart.tm_year -= 1900;
  2598. tmStart.tm_mon -= 1;
  2599. tbStart.time = mktime(&tmStart);
  2600. tbStart.millitm = 0;
  2601. tmStop.tm_year -= 1900;
  2602. tmStop.tm_mon -= 1;
  2603. tbStop.time = mktime(&tmStop);
  2604. tbStop.millitm = 0;
  2605. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  2606. }
  2607. return result;
  2608. }
  2609. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *compositeProfile)
  2610. {
  2611. FILE *fp;
  2612. char profileFileName[128];
  2613. char *line = NULL;
  2614. size_t len = 0;
  2615. time_t CurrentTime;
  2616. struct tm *tmComposite;
  2617. struct ChargingProfileType maxProfile;
  2618. struct ChargingProfileType defaultTxProfile;
  2619. struct ChargingProfileType txProfile;
  2620. struct ChargingSchedulePeriodType tmpPeriod;
  2621. uint8_t limitMax=0;
  2622. uint8_t limitDef=0;
  2623. uint8_t limitTx=0;
  2624. int compositePeriodIdx = 0;
  2625. CurrentTime = time(NULL);
  2626. tmComposite=localtime(&CurrentTime);
  2627. 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);
  2628. sprintf((char*)compositeProfile->chargingSchedule[0].chargingRateUnit, "A");
  2629. compositeProfile->chargingSchedule[0].duration = durationReq;
  2630. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2631. {
  2632. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2633. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2634. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2635. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  2636. }
  2637. compositeProfile->id = 0;
  2638. compositeProfile->stackLevel = 99 ;
  2639. sprintf((char*)compositeProfile->chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  2640. maxProfile.id = -1;
  2641. defaultTxProfile.id = -1;
  2642. txProfile.id = -1;
  2643. maxProfile.chargingSchedule[0].duration = -1;
  2644. defaultTxProfile.chargingSchedule[0].duration = -1;
  2645. txProfile.chargingSchedule[0].duration = -1;
  2646. system("yes|rm /tmp/*.json");
  2647. system("cp /Storage/OCPP/*.json /tmp");
  2648. /*
  2649. * Search valid charging profile
  2650. */
  2651. //DEBUG_INFO("====================================\n");
  2652. // Search tx profile
  2653. sprintf(profileFileName, "/tmp/TxProfile_%d.json", connectorId);
  2654. if((access(profileFileName, F_OK))!=-1)
  2655. {
  2656. fp = fopen(profileFileName, "r");
  2657. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2658. {
  2659. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2660. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2661. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2662. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2663. }
  2664. txProfile.id = -1;
  2665. txProfile.stackLevel = -1;
  2666. while(getline(&line, &len, fp) != -1)
  2667. {
  2668. json_object *obj = NULL;
  2669. obj = json_tokener_parse(line);
  2670. if(is_error(obj))
  2671. {
  2672. DEBUG_ERROR("Parse txProfile from file error.\n");
  2673. }
  2674. else
  2675. {
  2676. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != txProfile.id) &&
  2677. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= txProfile.stackLevel)
  2678. )
  2679. {
  2680. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2681. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2682. )
  2683. {
  2684. struct tm tmFrom, tmTo;
  2685. struct timeb tbFrom, tbTo;
  2686. 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) &&
  2687. (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))
  2688. {
  2689. tmFrom.tm_year -= 1900;
  2690. tmFrom.tm_mon -= 1;
  2691. tbFrom.time = mktime(&tmFrom);
  2692. tmTo.tm_year -= 1900;
  2693. tmTo.tm_mon -= 1;
  2694. tbTo.time = mktime(&tmTo);
  2695. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2696. {
  2697. if(txProfile.id == -1)
  2698. DEBUG_INFO("TxProfile found.\n");
  2699. else
  2700. DEBUG_INFO("TxProfile updated.\n");
  2701. // Required item
  2702. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2703. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2704. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2705. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2706. 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++)
  2707. {
  2708. 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"));
  2709. 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")));
  2710. 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?
  2711. 3:
  2712. 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")));
  2713. }
  2714. // Optional item
  2715. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2716. {
  2717. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2718. }
  2719. else
  2720. {
  2721. sprintf((char*)txProfile.validFrom, " ");
  2722. }
  2723. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2724. {
  2725. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2726. }
  2727. else
  2728. {
  2729. sprintf((char*)txProfile.validTo, " ");
  2730. }
  2731. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2732. {
  2733. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2734. }
  2735. else
  2736. {
  2737. sprintf((char*)txProfile.recurrencyKind, " ");
  2738. }
  2739. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2740. {
  2741. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2742. }
  2743. else
  2744. {
  2745. sprintf((char*)txProfile.transactionId, " ");
  2746. }
  2747. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2748. {
  2749. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2750. }
  2751. else
  2752. {
  2753. txProfile.chargingSchedule[0].duration = 86400;
  2754. }
  2755. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2756. {
  2757. 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")));
  2758. }
  2759. else
  2760. {
  2761. 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));
  2762. }
  2763. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2764. {
  2765. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2766. }
  2767. else
  2768. {
  2769. txProfile.chargingSchedule[0].minChargingRate = -1;
  2770. }
  2771. }
  2772. }
  2773. }
  2774. else
  2775. {
  2776. if(txProfile.id == -1)
  2777. DEBUG_INFO("TxProfile found.\n");
  2778. else
  2779. DEBUG_INFO("TxProfile updated.\n");
  2780. // Required item
  2781. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2782. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2783. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2784. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2785. 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++)
  2786. {
  2787. 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"));
  2788. 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")));
  2789. 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?
  2790. 3:
  2791. 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")));
  2792. }
  2793. // Optional item
  2794. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2795. {
  2796. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2797. }
  2798. else
  2799. {
  2800. sprintf((char*)txProfile.validFrom, " ");
  2801. }
  2802. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2803. {
  2804. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2805. }
  2806. else
  2807. {
  2808. sprintf((char*)txProfile.validTo, " ");
  2809. }
  2810. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2811. {
  2812. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2813. }
  2814. else
  2815. {
  2816. sprintf((char*)txProfile.recurrencyKind, " ");
  2817. }
  2818. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2819. {
  2820. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2821. }
  2822. else
  2823. {
  2824. sprintf((char*)txProfile.transactionId, " ");
  2825. }
  2826. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2827. {
  2828. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2829. }
  2830. else
  2831. {
  2832. txProfile.chargingSchedule[0].duration = 86400;
  2833. }
  2834. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2835. {
  2836. 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")));
  2837. }
  2838. else
  2839. {
  2840. 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));
  2841. }
  2842. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2843. {
  2844. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2845. }
  2846. else
  2847. {
  2848. txProfile.chargingSchedule[0].minChargingRate = -1;
  2849. }
  2850. }
  2851. }
  2852. }
  2853. json_object_put(obj);
  2854. }
  2855. fclose(fp);
  2856. /*
  2857. if(txProfile.ChargingProfileId != -1)
  2858. {
  2859. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  2860. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  2861. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  2862. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  2863. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  2864. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  2865. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  2866. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[0].StartSchedule);
  2867. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  2868. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  2869. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  2870. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  2871. {
  2872. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  2873. {
  2874. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  2875. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  2876. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  2877. }
  2878. }
  2879. }
  2880. else
  2881. DEBUG_INFO("TxProfile not found.\n");*/
  2882. }
  2883. // Search default tx profile
  2884. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d.json", connectorId);
  2885. if((access(profileFileName, F_OK))==-1)
  2886. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  2887. if((access(profileFileName, F_OK))!=-1)
  2888. {
  2889. fp = fopen(profileFileName, "r");
  2890. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2891. {
  2892. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2893. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2894. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2895. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2896. }
  2897. defaultTxProfile.id = -1;
  2898. defaultTxProfile.stackLevel = -1;
  2899. while(getline(&line, &len, fp) != -1)
  2900. {
  2901. json_object *obj = NULL;
  2902. obj = json_tokener_parse(line);
  2903. if(is_error(obj))
  2904. {
  2905. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  2906. }
  2907. else
  2908. {
  2909. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != defaultTxProfile.id) &&
  2910. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= defaultTxProfile.stackLevel)
  2911. )
  2912. {
  2913. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2914. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2915. )
  2916. {
  2917. struct tm tmFrom, tmTo;
  2918. struct timeb tbFrom, tbTo;
  2919. 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) &&
  2920. (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))
  2921. {
  2922. tmFrom.tm_year -= 1900;
  2923. tmFrom.tm_mon -= 1;
  2924. tbFrom.time = mktime(&tmFrom);
  2925. tmTo.tm_year -= 1900;
  2926. tmTo.tm_mon -= 1;
  2927. tbTo.time = mktime(&tmTo);
  2928. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2929. {
  2930. if(defaultTxProfile.id == -1)
  2931. DEBUG_INFO("TxDefaultProfile found.\n");
  2932. else
  2933. DEBUG_INFO("TxDefaultProfile updated.\n");
  2934. // Required item
  2935. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2936. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2937. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2938. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  2939. 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++)
  2940. {
  2941. 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"));
  2942. 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")));
  2943. 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?
  2944. 3:
  2945. 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")));
  2946. }
  2947. // Optional item
  2948. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2949. {
  2950. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2951. }
  2952. else
  2953. {
  2954. sprintf((char*)defaultTxProfile.validFrom, " ");
  2955. }
  2956. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2957. {
  2958. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2959. }
  2960. else
  2961. {
  2962. sprintf((char*)defaultTxProfile.validTo, " ");
  2963. }
  2964. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2965. {
  2966. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2967. }
  2968. else
  2969. {
  2970. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  2971. }
  2972. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2973. {
  2974. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2975. }
  2976. else
  2977. {
  2978. sprintf((char*)defaultTxProfile.transactionId, " ");
  2979. }
  2980. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2981. {
  2982. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2983. }
  2984. else
  2985. {
  2986. defaultTxProfile.chargingSchedule[0].duration = 86400;
  2987. }
  2988. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2989. {
  2990. 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")));
  2991. }
  2992. else
  2993. {
  2994. 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));
  2995. }
  2996. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2997. {
  2998. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2999. }
  3000. else
  3001. {
  3002. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  3003. }
  3004. }
  3005. }
  3006. }
  3007. else
  3008. {
  3009. if(defaultTxProfile.id == -1)
  3010. DEBUG_INFO("TxDefaultProfile found.\n");
  3011. else
  3012. DEBUG_INFO("TxDefaultProfile updated.\n");
  3013. // Required item
  3014. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3015. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3016. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3017. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3018. 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++)
  3019. {
  3020. 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"));
  3021. 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")));
  3022. 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?
  3023. 3:
  3024. 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")));
  3025. }
  3026. // Optional item
  3027. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3028. {
  3029. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3030. }
  3031. else
  3032. {
  3033. sprintf((char*)defaultTxProfile.validFrom, " ");
  3034. }
  3035. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3036. {
  3037. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3038. }
  3039. else
  3040. {
  3041. sprintf((char*)defaultTxProfile.validTo, " ");
  3042. }
  3043. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3044. {
  3045. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3046. }
  3047. else
  3048. {
  3049. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  3050. }
  3051. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3052. {
  3053. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3054. }
  3055. else
  3056. {
  3057. sprintf((char*)defaultTxProfile.transactionId, " ");
  3058. }
  3059. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3060. {
  3061. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3062. }
  3063. else
  3064. {
  3065. defaultTxProfile.chargingSchedule[0].duration = 86400;
  3066. }
  3067. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3068. {
  3069. 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")));
  3070. }
  3071. else
  3072. {
  3073. 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));
  3074. }
  3075. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3076. {
  3077. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3078. }
  3079. else
  3080. {
  3081. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  3082. }
  3083. }
  3084. }
  3085. }
  3086. json_object_put(obj);
  3087. }
  3088. fclose(fp);
  3089. /*
  3090. if(defaultTxProfile.ChargingProfileId != -1)
  3091. {
  3092. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3093. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3094. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3095. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3096. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3097. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3098. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3099. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[0].StartSchedule);
  3100. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3101. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3102. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3103. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3104. {
  3105. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3106. {
  3107. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3108. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3109. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3110. }
  3111. }
  3112. }
  3113. else
  3114. DEBUG_INFO("TxDefaultProfile not found.\n");
  3115. DEBUG_INFO("------------------------------------\n");*/
  3116. }
  3117. // Search max profile
  3118. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  3119. if((access(profileFileName, F_OK))!=-1)
  3120. {
  3121. fp = fopen(profileFileName, "r");
  3122. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3123. {
  3124. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3125. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  3126. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3127. }
  3128. maxProfile.id = -1;
  3129. maxProfile.stackLevel = -1;
  3130. while(getline(&line, &len, fp) != -1)
  3131. {
  3132. json_object *obj = NULL;
  3133. obj = json_tokener_parse(line);
  3134. if(is_error(obj))
  3135. {
  3136. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  3137. }
  3138. else
  3139. {
  3140. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != maxProfile.id) &&
  3141. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= maxProfile.stackLevel)
  3142. )
  3143. {
  3144. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3145. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3146. )
  3147. {
  3148. struct tm tmFrom, tmTo;
  3149. struct timeb tbFrom, tbTo;
  3150. 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) &&
  3151. (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))
  3152. {
  3153. tmFrom.tm_year -= 1900;
  3154. tmFrom.tm_mon -= 1;
  3155. tbFrom.time = mktime(&tmFrom);
  3156. tmTo.tm_year -= 1900;
  3157. tmTo.tm_mon -= 1;
  3158. tbTo.time = mktime(&tmTo);
  3159. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3160. {
  3161. if(maxProfile.id == -1)
  3162. DEBUG_INFO("MaxProfile found.\n");
  3163. else
  3164. DEBUG_INFO("MaxProfile updated.\n");
  3165. // Required item
  3166. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3167. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3168. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3169. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3170. 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++)
  3171. {
  3172. 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"));
  3173. 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")));
  3174. 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?
  3175. 3:
  3176. 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")));
  3177. }
  3178. // Optional item
  3179. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3180. {
  3181. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3182. }
  3183. else
  3184. {
  3185. sprintf((char*)maxProfile.validFrom, " ");
  3186. }
  3187. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3188. {
  3189. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3190. }
  3191. else
  3192. {
  3193. sprintf((char*)maxProfile.validTo, " ");
  3194. }
  3195. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3196. {
  3197. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3198. }
  3199. else
  3200. {
  3201. sprintf((char*)maxProfile.recurrencyKind, " ");
  3202. }
  3203. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3204. {
  3205. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3206. }
  3207. else
  3208. {
  3209. sprintf((char*)maxProfile.transactionId, " ");
  3210. }
  3211. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3212. {
  3213. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3214. }
  3215. else
  3216. {
  3217. maxProfile.chargingSchedule[0].duration = 86400;
  3218. }
  3219. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3220. {
  3221. 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")));
  3222. }
  3223. else
  3224. {
  3225. 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));
  3226. }
  3227. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3228. {
  3229. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3230. }
  3231. else
  3232. {
  3233. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3234. }
  3235. }
  3236. }
  3237. }
  3238. else
  3239. {
  3240. if(maxProfile.id == -1)
  3241. DEBUG_INFO("MaxProfile found.\n");
  3242. else
  3243. DEBUG_INFO("MaxProfile updated.\n");
  3244. // Required item
  3245. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3246. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3247. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3248. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3249. 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++)
  3250. {
  3251. 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"));
  3252. 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")));
  3253. 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?
  3254. 3:
  3255. 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")));
  3256. }
  3257. // Optional item
  3258. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3259. {
  3260. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3261. }
  3262. else
  3263. {
  3264. sprintf((char*)maxProfile.validFrom, " ");
  3265. }
  3266. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3267. {
  3268. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3269. }
  3270. else
  3271. {
  3272. sprintf((char*)maxProfile.validTo, " ");
  3273. }
  3274. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3275. {
  3276. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3277. }
  3278. else
  3279. {
  3280. sprintf((char*)maxProfile.recurrencyKind, " ");
  3281. }
  3282. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3283. {
  3284. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3285. }
  3286. else
  3287. {
  3288. sprintf((char*)maxProfile.transactionId, " ");
  3289. }
  3290. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3291. {
  3292. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3293. }
  3294. else
  3295. {
  3296. maxProfile.chargingSchedule[0].duration = 86400;
  3297. }
  3298. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3299. {
  3300. 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")));
  3301. }
  3302. else
  3303. {
  3304. 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));
  3305. }
  3306. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3307. {
  3308. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3309. }
  3310. else
  3311. {
  3312. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3313. }
  3314. }
  3315. }
  3316. }
  3317. json_object_put(obj);
  3318. }
  3319. fclose(fp);
  3320. /*
  3321. if(maxProfile.ChargingProfileId !=-1)
  3322. {
  3323. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3324. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3325. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3326. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3327. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3328. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3329. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3330. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[0].StartSchedule);
  3331. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3332. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3333. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3334. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3335. {
  3336. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3337. {
  3338. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3339. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3340. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3341. }
  3342. }
  3343. }
  3344. else
  3345. DEBUG_INFO("MaxProfile not found.\n");
  3346. DEBUG_INFO("------------------------------------\n");*/
  3347. }
  3348. /*
  3349. * Align found profile start schedule & periods
  3350. */
  3351. //DEBUG_INFO("====================================\n");
  3352. /*
  3353. // For local test usage, force modify found profile start schedule info
  3354. 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);
  3355. 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);
  3356. 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);
  3357. */
  3358. if(txProfile.id != -1)
  3359. {
  3360. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3361. {
  3362. if(txProfile.chargingSchedule[0].duration != -1)
  3363. {
  3364. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3365. 0:
  3366. (txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3367. }
  3368. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3369. {
  3370. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3371. {
  3372. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3373. 0:
  3374. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3375. if(idxPeriod > 0)
  3376. {
  3377. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3378. {
  3379. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3380. }
  3381. }
  3382. }
  3383. }
  3384. }
  3385. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3386. {
  3387. if(txProfile.chargingSchedule[0].duration != -1)
  3388. {
  3389. 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?
  3390. 0:
  3391. (txProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3392. }
  3393. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3394. {
  3395. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3396. {
  3397. 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?
  3398. 0:
  3399. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3400. if(idxPeriod > 0)
  3401. {
  3402. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3403. {
  3404. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3405. }
  3406. }
  3407. }
  3408. }
  3409. }
  3410. else
  3411. {
  3412. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3413. {
  3414. if(txProfile.chargingSchedule[0].duration != -1)
  3415. {
  3416. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3417. 0:
  3418. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3419. }
  3420. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3421. {
  3422. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3423. {
  3424. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3425. 0:
  3426. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3427. if(idxPeriod > 0)
  3428. {
  3429. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3430. {
  3431. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3432. }
  3433. }
  3434. }
  3435. }
  3436. }
  3437. else
  3438. {
  3439. if(txProfile.chargingSchedule[0].duration != -1)
  3440. {
  3441. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3442. 0:
  3443. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3444. }
  3445. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3446. {
  3447. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3448. {
  3449. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3450. 0:
  3451. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3452. if(idxPeriod > 0)
  3453. {
  3454. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3455. {
  3456. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3457. }
  3458. }
  3459. }
  3460. }
  3461. }
  3462. }
  3463. /*
  3464. DEBUG_INFO("txProfile after align.\n");
  3465. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  3466. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3467. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3468. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3469. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3470. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3471. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  3472. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3473. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  3474. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  3475. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  3476. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3477. {
  3478. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3479. {
  3480. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3481. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3482. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3483. }
  3484. }*/
  3485. }
  3486. if(defaultTxProfile.id != -1)
  3487. {
  3488. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3489. {
  3490. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3491. {
  3492. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3493. 0:
  3494. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3495. }
  3496. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3497. {
  3498. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3499. {
  3500. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3501. 0:
  3502. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3503. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3504. {
  3505. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3506. }
  3507. if(idxPeriod > 0)
  3508. {
  3509. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3510. {
  3511. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3512. }
  3513. }
  3514. }
  3515. }
  3516. }
  3517. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3518. {
  3519. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3520. {
  3521. 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?
  3522. 0:
  3523. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3524. }
  3525. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3526. {
  3527. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3528. {
  3529. 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?
  3530. 0:
  3531. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3532. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3533. {
  3534. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3535. }
  3536. if(idxPeriod > 0)
  3537. {
  3538. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3539. {
  3540. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3541. }
  3542. }
  3543. }
  3544. }
  3545. }
  3546. else
  3547. {
  3548. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3549. {
  3550. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3551. {
  3552. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3553. 0:
  3554. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3555. }
  3556. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3557. {
  3558. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3559. {
  3560. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3561. 0:
  3562. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3563. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3564. {
  3565. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3566. }
  3567. if(idxPeriod > 0)
  3568. {
  3569. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3570. {
  3571. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3572. }
  3573. }
  3574. }
  3575. }
  3576. }
  3577. else
  3578. {
  3579. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3580. {
  3581. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3582. 0:
  3583. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3584. }
  3585. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3586. {
  3587. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3588. {
  3589. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3590. 0:
  3591. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3592. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3593. {
  3594. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3595. }
  3596. if(idxPeriod > 0)
  3597. {
  3598. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3599. {
  3600. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3601. }
  3602. }
  3603. }
  3604. }
  3605. }
  3606. }
  3607. /*
  3608. DEBUG_INFO("defaultTxProfile after align.\n");
  3609. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3610. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3611. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3612. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3613. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3614. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3615. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3616. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3617. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3618. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3619. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3620. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3621. {
  3622. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3623. {
  3624. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3625. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3626. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3627. }
  3628. }
  3629. DEBUG_INFO("------------------------------------\n");*/
  3630. }
  3631. if(maxProfile.id != -1)
  3632. {
  3633. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3634. {
  3635. if(maxProfile.chargingSchedule[0].duration != -1)
  3636. {
  3637. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3638. 0:
  3639. (maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3640. }
  3641. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3642. {
  3643. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3644. {
  3645. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3646. 0:
  3647. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3648. if(idxPeriod > 0)
  3649. {
  3650. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3651. {
  3652. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3653. }
  3654. }
  3655. }
  3656. }
  3657. }
  3658. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3659. {
  3660. if(maxProfile.chargingSchedule[0].duration != -1)
  3661. {
  3662. 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?
  3663. 0:
  3664. (maxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[9].startSchedule)));
  3665. }
  3666. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3667. {
  3668. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3669. {
  3670. 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?
  3671. 0:
  3672. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3673. if(idxPeriod > 0)
  3674. {
  3675. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3676. {
  3677. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3678. }
  3679. }
  3680. }
  3681. }
  3682. }
  3683. else
  3684. {
  3685. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3686. {
  3687. if(maxProfile.chargingSchedule[0].duration != -1)
  3688. {
  3689. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3690. 0:
  3691. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3692. }
  3693. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3694. {
  3695. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3696. {
  3697. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3698. 0:
  3699. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3700. if(idxPeriod > 0)
  3701. {
  3702. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3703. {
  3704. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3705. }
  3706. }
  3707. }
  3708. }
  3709. }
  3710. else
  3711. {
  3712. if(maxProfile.chargingSchedule[0].duration != -1)
  3713. {
  3714. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3715. 0:
  3716. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3717. }
  3718. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3719. {
  3720. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3721. {
  3722. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3723. 0:
  3724. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3725. if(idxPeriod > 0)
  3726. {
  3727. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3728. {
  3729. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3730. }
  3731. }
  3732. }
  3733. }
  3734. }
  3735. }
  3736. /*
  3737. DEBUG_INFO("MaxProfile after align.\n");
  3738. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3739. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3740. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3741. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3742. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3743. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3744. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3745. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3746. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3747. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3748. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3749. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3750. {
  3751. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3752. {
  3753. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3754. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3755. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3756. }
  3757. }
  3758. DEBUG_INFO("------------------------------------\n");*/
  3759. }
  3760. /*
  3761. * Merge to conposite schedule
  3762. */
  3763. //DEBUG_INFO("====================================\n");
  3764. // Find each profile period quantity
  3765. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3766. {
  3767. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3768. limitMax = idx+1;
  3769. }
  3770. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3771. {
  3772. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3773. limitDef = idx+1;
  3774. }
  3775. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3776. {
  3777. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3778. limitTx = idx+1;
  3779. }
  3780. // TxProfile found, composite schedule based on it
  3781. if(txProfile.id != -1)
  3782. {
  3783. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  3784. {
  3785. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  3786. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  3787. (txProfile.chargingSchedule[0].duration > 0))
  3788. {
  3789. if(maxProfile.id != -1)
  3790. {
  3791. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3792. {
  3793. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  3794. {
  3795. if((maxProfile.chargingSchedule[0].duration > 0))
  3796. {
  3797. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3798. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3799. 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);
  3800. }
  3801. else
  3802. {
  3803. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3804. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3805. tmpPeriod.limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit;
  3806. }
  3807. }
  3808. if(idxMaxPeriod == (limitMax-1))
  3809. {
  3810. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3811. {
  3812. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3813. {
  3814. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3815. compositePeriodIdx++;
  3816. }
  3817. else
  3818. {
  3819. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3820. }
  3821. }
  3822. }
  3823. }
  3824. }
  3825. else
  3826. {
  3827. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3828. {
  3829. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3830. compositePeriodIdx++;
  3831. }
  3832. else
  3833. {
  3834. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3835. }
  3836. }
  3837. }
  3838. if(idxTxPeriod == (limitTx-1))
  3839. {
  3840. if(defaultTxProfile.id != -1)
  3841. {
  3842. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3843. {
  3844. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  3845. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3846. (defaultTxProfile.chargingSchedule[0].duration>0))
  3847. {
  3848. if(maxProfile.id != -1)
  3849. {
  3850. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3851. {
  3852. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3853. {
  3854. if((maxProfile.chargingSchedule[0].duration > 0))
  3855. {
  3856. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3857. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3858. 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);
  3859. }
  3860. else
  3861. {
  3862. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3863. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3864. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3865. }
  3866. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3867. {
  3868. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3869. {
  3870. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3871. compositePeriodIdx++;
  3872. }
  3873. else
  3874. {
  3875. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3876. }
  3877. }
  3878. break;
  3879. }
  3880. }
  3881. }
  3882. else
  3883. {
  3884. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3885. {
  3886. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3887. compositePeriodIdx++;
  3888. }
  3889. else
  3890. {
  3891. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3892. }
  3893. }
  3894. }
  3895. }
  3896. }
  3897. }
  3898. }
  3899. }
  3900. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  3901. else if(defaultTxProfile.id != -1)
  3902. {
  3903. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3904. {
  3905. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  3906. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3907. (defaultTxProfile.chargingSchedule[0].duration > 0))
  3908. {
  3909. if(maxProfile.id != -1)
  3910. {
  3911. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3912. {
  3913. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3914. {
  3915. if((maxProfile.chargingSchedule[0].duration > 0))
  3916. {
  3917. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3918. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3919. 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);
  3920. }
  3921. else
  3922. {
  3923. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3924. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3925. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3926. }
  3927. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3928. {
  3929. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3930. {
  3931. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3932. compositePeriodIdx++;
  3933. }
  3934. else
  3935. {
  3936. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3937. }
  3938. }
  3939. break;
  3940. }
  3941. }
  3942. }
  3943. else
  3944. {
  3945. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3946. {
  3947. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3948. compositePeriodIdx++;
  3949. }
  3950. else
  3951. {
  3952. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3953. }
  3954. }
  3955. }
  3956. }
  3957. }
  3958. // Fill other period by MaxProfile
  3959. if(maxProfile.id != -1)
  3960. {
  3961. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3962. {
  3963. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3964. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3965. (maxProfile.chargingSchedule[0].duration > 0))
  3966. {
  3967. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod >= compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod) &&
  3968. (maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3969. {
  3970. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod;
  3971. tmpPeriod.numberPhases = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].numberPhases;
  3972. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3973. }
  3974. if((maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3975. {
  3976. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].duration;
  3977. tmpPeriod.numberPhases = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  3978. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3979. }
  3980. if(tmpPeriod.limit != -1)
  3981. {
  3982. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3983. {
  3984. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3985. {
  3986. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3987. compositePeriodIdx++;
  3988. }
  3989. else
  3990. {
  3991. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3992. }
  3993. }
  3994. }
  3995. }
  3996. }
  3997. }
  3998. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  3999. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[0].startSchedule);
  4000. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[0].duration);
  4001. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[0].chargingRateUnit);
  4002. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  4003. {
  4004. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  4005. {
  4006. compositeProfile->id = 1;
  4007. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  4008. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit);
  4009. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases);
  4010. }
  4011. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit == -1)
  4012. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit =0;
  4013. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  4014. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  4015. }
  4016. if(line)
  4017. free(line);
  4018. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  4019. }
  4020. //==========================================
  4021. // Init all share memory
  4022. //==========================================
  4023. int InitShareMemory()
  4024. {
  4025. int result = PASS;
  4026. int MeterSMId;
  4027. //creat ShmSysConfigAndInfo
  4028. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  4029. {
  4030. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  4031. result = FAIL;
  4032. }
  4033. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4034. {
  4035. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  4036. result = FAIL;
  4037. }
  4038. else
  4039. {}
  4040. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  4041. {
  4042. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  4043. result = FAIL;
  4044. }
  4045. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4046. {
  4047. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  4048. result = FAIL;
  4049. }
  4050. else
  4051. {}
  4052. //creat ShmPsuData
  4053. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  4054. {
  4055. DEBUG_ERROR("shmget ShmPsuData NG\n");
  4056. result = FAIL;
  4057. }
  4058. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4059. {
  4060. DEBUG_ERROR("shmat ShmPsuData NG\n");
  4061. result = FAIL;
  4062. }
  4063. else
  4064. {}
  4065. //creat ShmOCPP20Data
  4066. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  4067. {
  4068. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  4069. result = FAIL;
  4070. }
  4071. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4072. {
  4073. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  4074. result = FAIL;
  4075. }
  4076. else
  4077. {}
  4078. /****************************** For Initial Settings************************************************/
  4079. //offline MeterValue Interval
  4080. TempMeterValueInterval = 0;
  4081. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  4082. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  4083. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  4084. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  4085. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  4086. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  4087. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  4088. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  4089. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  4090. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  4091. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  4092. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  4093. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  4094. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  4095. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  4096. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  4097. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  4098. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  4099. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  4100. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  4101. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  4102. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  4103. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  4104. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  4105. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  4106. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  4107. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  4108. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  4109. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  4110. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  4111. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  4112. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  4113. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  4114. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  4115. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  4116. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  4117. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  4118. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  4119. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  4120. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  4121. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  4122. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  4123. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  4124. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  4125. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  4126. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  4127. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  4128. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  4129. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  4130. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  4131. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  4132. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  4133. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  4134. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  4135. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  4136. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  4137. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  4138. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  4139. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  4140. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  4141. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  4142. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  4143. return result;
  4144. }
  4145. int ProcessShareMemory()
  4146. {
  4147. if(InitShareMemory() == FAIL)
  4148. {
  4149. DEBUG_ERROR("InitShareMemory NG\n");
  4150. if(ShmStatusCodeData!=NULL)
  4151. {
  4152. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  4153. }
  4154. sleep(5);
  4155. return FAIL;
  4156. }
  4157. return PASS;
  4158. }
  4159. //---------------------common routine---------------------------//
  4160. void checkNetworkProfile(void)
  4161. {
  4162. uint8_t isGetProfile = FALSE;
  4163. json_object *priority;
  4164. priority = json_tokener_parse((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value);
  4165. if(!is_error(priority))
  4166. {
  4167. for(uint8_t idxPriority=0;idxPriority<json_object_array_length(priority);idxPriority++)
  4168. {
  4169. for(uint8_t idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile);idx++)
  4170. {
  4171. if((ShmOCPP20Data->NetworkConnectionProfile[idx].slot == json_object_get_int(json_object_array_get_idx(priority, idxPriority))) &&
  4172. (strlen((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl) > 0) &&
  4173. (ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount < 3))
  4174. {
  4175. memcpy(ShmOCPP20Data->OcppServerURL, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  4176. memcpy(ShmSysConfigAndInfo->SysConfig.OcppServerURL, ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl));
  4177. isGetProfile = TRUE;
  4178. ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount++;
  4179. break;
  4180. }
  4181. }
  4182. }
  4183. }
  4184. json_object_put(priority);
  4185. if(!isGetProfile && (strlen((char*)ShmOCPP20Data->OcppServerURL) > 0))
  4186. {
  4187. memcpy(ShmSysConfigAndInfo->SysConfig.OcppServerURL, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  4188. }
  4189. DEBUG_INFO("Get network profile URL: %s\n", ShmSysConfigAndInfo->SysConfig.OcppServerURL);
  4190. }
  4191. void CheckSystemValue(void)
  4192. {
  4193. char filenmae[100]={0};
  4194. char str[100]={0};
  4195. int tempIndex = 0;
  4196. //===============================
  4197. // EVSE operation check
  4198. //===============================
  4199. //===============================
  4200. // Heartbeat check
  4201. //===============================
  4202. if((difftime(time((time_t*)NULL), clientTime.Heartbeat) < 0) || (HeartBeatWaitTime <= 0))
  4203. {
  4204. clientTime.Heartbeat = time((time_t*)NULL);
  4205. if(server_sign == TRUE)
  4206. {
  4207. HeartBeatWaitTime = ShmOCPP20Data->BootNotification.Response_interval;
  4208. }
  4209. else
  4210. {
  4211. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);
  4212. }
  4213. }
  4214. if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  4215. {
  4216. //parameter for test
  4217. sendHeartbeatRequest(0);
  4218. //==============================================
  4219. // Reset Waiting Time
  4220. //==============================================
  4221. HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
  4222. }
  4223. //===============================
  4224. // CSU Trigger Reset Conf
  4225. //===============================
  4226. if(isWebsocketSendable && (ShmOCPP20Data->MsMsg.bits.ResetConf == ON))
  4227. {
  4228. sendResetConfirmation((char *)ShmOCPP20Data->Reset.guid);
  4229. }
  4230. //===============================
  4231. // CSU Trigger Authorize Request
  4232. //===============================
  4233. if(isWebsocketSendable &&
  4234. (server_sign == TRUE) &&
  4235. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4236. (authorizeRetryTimes < 3))
  4237. {
  4238. sendAuthorizeRequest(0);
  4239. authorizeRetryTimes = authorizeRetryTimes + 1;
  4240. if(authorizeRetryTimes < 3)
  4241. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4242. }
  4243. else if((server_sign == TRUE) &&
  4244. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4245. (authorizeRetryTimes >= 3))
  4246. {
  4247. authorizeRetryTimes = 0;
  4248. SetOcppConnStatus(FALSE);
  4249. server_sign = FALSE;
  4250. }
  4251. else if((server_sign == FALSE) &&
  4252. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  4253. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  4254. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  4255. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  4256. {
  4257. sendAuthorizeRequest(0);
  4258. }
  4259. if(isWebsocketSendable &&
  4260. (server_sign == TRUE) &&
  4261. (ShmOCPP20Data->GetBaseReport.requestId > 0))
  4262. {
  4263. uint8_t reportIdx = 0;
  4264. ShmOCPP20Data->NotifyReport.requestId = ShmOCPP20Data->GetBaseReport.requestId;
  4265. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_ConfigurationInventory]) == 0)
  4266. {
  4267. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  4268. {
  4269. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  4270. {
  4271. 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))
  4272. {
  4273. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  4274. reportIdx++;
  4275. }
  4276. }
  4277. else
  4278. {
  4279. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  4280. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  4281. ShmOCPP20Data->NotifyReport.seqNo += 1;
  4282. else
  4283. ShmOCPP20Data->NotifyReport.seqNo = 0;
  4284. sendNotifyReportRequest();
  4285. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  4286. reportIdx = 0;
  4287. }
  4288. }
  4289. }
  4290. else if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_FullInventory]) == 0)
  4291. {
  4292. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  4293. {
  4294. if(reportIdx < ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData))
  4295. {
  4296. memcpy(&ShmOCPP20Data->NotifyReport.reportData[reportIdx], &ShmOCPP20Data->ControllerComponentVariable[idx_var], sizeof(struct ReportDataType));
  4297. reportIdx++;
  4298. }
  4299. else
  4300. {
  4301. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  4302. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  4303. ShmOCPP20Data->NotifyReport.seqNo += 1;
  4304. else
  4305. ShmOCPP20Data->NotifyReport.seqNo = 0;
  4306. sendNotifyReportRequest();
  4307. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  4308. reportIdx = 0;
  4309. }
  4310. }
  4311. }
  4312. else
  4313. {
  4314. /*
  4315. * TODO:
  4316. * 1. Fill out summary inventory to response message, currently not support
  4317. */
  4318. }
  4319. if(reportIdx > 0)
  4320. {
  4321. getNowDatetime(ShmOCPP20Data->NotifyReport.generatedAt);
  4322. if(ShmOCPP20Data->NotifyReport.seqNo < INT_MAX)
  4323. ShmOCPP20Data->NotifyReport.seqNo += 1;
  4324. else
  4325. ShmOCPP20Data->NotifyReport.seqNo = 0;
  4326. sendNotifyReportRequest();
  4327. memset(&ShmOCPP20Data->NotifyReport.reportData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData)*sizeof(struct ReportDataType));
  4328. reportIdx = 0;
  4329. }
  4330. ShmOCPP20Data->GetBaseReport.requestId = 0;
  4331. }
  4332. if(isWebsocketSendable &&
  4333. (server_sign == TRUE) &&
  4334. ShmOCPP20Data->SpMsg.bits.NotifyEventReq)
  4335. {
  4336. getNowDatetime(ShmOCPP20Data->NotifyEvent.generatedAt);
  4337. ShmOCPP20Data->NotifyEvent.tbc = FALSE;
  4338. if(ShmOCPP20Data->NotifyEvent.seqNo < INT_MAX)
  4339. ShmOCPP20Data->NotifyEvent.seqNo += 1;
  4340. else
  4341. ShmOCPP20Data->NotifyEvent.seqNo = 0;
  4342. sendNotifyEventRequest();
  4343. memset(&ShmOCPP20Data->NotifyEvent.eventData[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData)* sizeof(struct EventDataType ));
  4344. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  4345. }
  4346. //===============================
  4347. // Each connector operation check
  4348. //===============================
  4349. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  4350. {
  4351. //==========================================
  4352. // csu trigger DataTransferReq
  4353. //==========================================
  4354. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  4355. {
  4356. sendDataTransferRequest(gun_index);
  4357. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  4358. }
  4359. //===============================
  4360. // CSU Trigger Smart Charging Profilw
  4361. //===============================
  4362. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  4363. {
  4364. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index]);
  4365. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  4366. }
  4367. //==============================================
  4368. // Charger start transaction
  4369. //==============================================
  4370. /*
  4371. if((ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq == ON))
  4372. {
  4373. ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq = OFF;
  4374. sendStartTransactionRequest(gun_index);
  4375. clientTime.StartTransaction = time((time_t*)NULL);
  4376. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4377. }*/
  4378. //==============================================
  4379. // Charger stop transaction
  4380. //==============================================
  4381. /*
  4382. if(((ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq == ON)))
  4383. {
  4384. ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq =OFF;
  4385. sendStopTransactionRequest(gun_index);
  4386. clientTime.StopTransaction = time((time_t*)NULL);
  4387. }*/
  4388. //==============================================
  4389. // Charger status notification & Transaction event report
  4390. //==============================================
  4391. //--- Check Mode Change ---//
  4392. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  4393. if(gunType[gun_index] == 'J')
  4394. {
  4395. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4396. {
  4397. tempIndex = ((gun_index==2) ? 1: 0);
  4398. }
  4399. else
  4400. {
  4401. tempIndex = gun_index;
  4402. }
  4403. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4404. {
  4405. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4406. {
  4407. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  4408. {
  4409. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  4410. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  4411. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4412. if((SystemInitial == 0) &&
  4413. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4414. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4415. {
  4416. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4417. }
  4418. }
  4419. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4420. {
  4421. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4422. if((access(filenmae,F_OK))!=-1)
  4423. {
  4424. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4425. sprintf(str,"rm -f %s",filenmae);
  4426. system(str);
  4427. }
  4428. }
  4429. #if 1 // for TempStopTransaction
  4430. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4431. {
  4432. checkTempStopTransaction(gun_index);
  4433. }
  4434. #endif
  4435. }
  4436. }
  4437. }
  4438. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4439. {
  4440. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4441. {
  4442. tempIndex = ((gun_index==2) ? 1: 0);
  4443. }
  4444. else
  4445. {
  4446. tempIndex = gun_index;
  4447. }
  4448. for (int index = 0; index < CCS_QUANTITY; index++)
  4449. {
  4450. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4451. {
  4452. 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]*/ )
  4453. {
  4454. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  4455. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  4456. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4457. if((SystemInitial == 0) &&
  4458. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4459. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4460. {
  4461. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4462. }
  4463. }
  4464. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4465. {
  4466. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4467. if((access(filenmae,F_OK))!=-1)
  4468. {
  4469. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4470. sprintf(str,"rm -f %s",filenmae);
  4471. system(str);
  4472. }
  4473. }
  4474. #if 1 // for TempStopTransaction
  4475. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4476. {
  4477. checkTempStopTransaction(gun_index);
  4478. }
  4479. #endif
  4480. }
  4481. }
  4482. }
  4483. else if(gunType[gun_index] == 'G')
  4484. {
  4485. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4486. {
  4487. tempIndex = ((gun_index==2) ? 1: 0);
  4488. }
  4489. else
  4490. {
  4491. tempIndex = gun_index;
  4492. }
  4493. for (int index = 0; index < GB_QUANTITY; index++)
  4494. {
  4495. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4496. {
  4497. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  4498. {
  4499. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  4500. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  4501. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4502. if((SystemInitial == 0) &&
  4503. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4504. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4505. {
  4506. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4507. }
  4508. }
  4509. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4510. {
  4511. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4512. if((access(filenmae,F_OK))!=-1)
  4513. {
  4514. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4515. sprintf(str,"rm -f %s",filenmae);
  4516. system(str);
  4517. }
  4518. }
  4519. #if 1 // for TempStopTransaction
  4520. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4521. {
  4522. checkTempStopTransaction(gun_index);
  4523. }
  4524. #endif
  4525. }
  4526. }
  4527. }
  4528. else if(gunType[gun_index] == 'O')
  4529. {
  4530. tempIndex = gun_index;
  4531. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4532. {
  4533. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4534. {
  4535. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  4536. {
  4537. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  4538. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  4539. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4540. if((SystemInitial == 0) &&
  4541. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING) &&
  4542. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_COMPLETE))
  4543. {
  4544. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4545. }
  4546. }
  4547. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // complete
  4548. {
  4549. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4550. if((access(filenmae,F_OK))!=-1)
  4551. {
  4552. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4553. sprintf(str,"rm -f %s",filenmae);
  4554. system(str);
  4555. }
  4556. }
  4557. #if 1 // for TempStopTransaction
  4558. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4559. {
  4560. checkTempStopTransaction(gun_index);
  4561. }
  4562. #endif
  4563. }
  4564. }
  4565. }
  4566. else
  4567. {
  4568. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4569. {
  4570. tempIndex = 2;
  4571. }
  4572. else
  4573. {
  4574. tempIndex = gun_index;
  4575. }
  4576. for (int index = 0; index < AC_QUANTITY; index++)
  4577. {
  4578. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4579. {
  4580. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  4581. {
  4582. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  4583. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  4584. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4585. if((SystemInitial == 0) &&
  4586. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4587. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4588. {
  4589. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4590. }
  4591. }
  4592. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4593. {
  4594. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4595. if((access(filenmae,F_OK))!=-1)
  4596. {
  4597. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4598. sprintf(str,"rm -f %s",filenmae);
  4599. system(str);
  4600. }
  4601. }
  4602. #if 1 // for TempStopTransaction
  4603. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4604. {
  4605. checkTempStopTransaction(gun_index);
  4606. }
  4607. #endif
  4608. }
  4609. }// END
  4610. }
  4611. if(isWebsocketSendable &&
  4612. (cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) &&
  4613. ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 5) )
  4614. {
  4615. if(SystemInitial > 0)
  4616. SystemInitial -= 1;
  4617. sendStatusNotificationRequest(gun_index);
  4618. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  4619. }
  4620. if(isWebsocketSendable && (server_sign == TRUE) && (cpinitateMsg.bits[gun_index].TransactionEventReq == ON))
  4621. {
  4622. sendTransactionEventRequest(gun_index);
  4623. cpinitateMsg.bits[gun_index].TransactionEventReq = OFF;
  4624. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], 0x00, sizeof(struct MeterValueType));
  4625. }
  4626. //==============================================
  4627. // Meter report
  4628. //==============================================
  4629. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  4630. {
  4631. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  4632. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  4633. }
  4634. // ClockAlign MeterValue
  4635. 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))
  4636. {
  4637. //check Transaction active
  4638. if(gunType[gun_index] == 'J')
  4639. {
  4640. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4641. {
  4642. tempIndex = ((gun_index==2) ? 1: 0);
  4643. }
  4644. else
  4645. {
  4646. tempIndex = gun_index;
  4647. }
  4648. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4649. {
  4650. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4651. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4652. {
  4653. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4654. {
  4655. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4656. }
  4657. }
  4658. }// End for CHAdeMO
  4659. }
  4660. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4661. {
  4662. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4663. {
  4664. tempIndex = ((gun_index==2) ? 1: 0);
  4665. }
  4666. else
  4667. {
  4668. tempIndex = gun_index;
  4669. }
  4670. for (int index = 0; index < CCS_QUANTITY; index++)
  4671. {
  4672. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4673. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4674. {
  4675. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4676. {
  4677. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4678. }
  4679. }
  4680. } // End for CCS
  4681. }
  4682. else if(gunType[gun_index] == 'G')
  4683. {
  4684. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4685. {
  4686. tempIndex = ((gun_index==2) ? 1: 0);
  4687. }
  4688. else
  4689. {
  4690. tempIndex = gun_index;
  4691. }
  4692. for (int index = 0; index < GB_QUANTITY; index++)
  4693. {
  4694. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4695. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4696. {
  4697. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4698. {
  4699. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4700. }
  4701. }
  4702. }// End for GB
  4703. }
  4704. else if(gunType[gun_index] == 'O')
  4705. {
  4706. tempIndex = gun_index;
  4707. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4708. {
  4709. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4710. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4711. {
  4712. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_CHARGING)
  4713. {
  4714. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4715. }
  4716. }
  4717. }
  4718. }
  4719. else
  4720. {
  4721. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4722. {
  4723. tempIndex = 2;
  4724. }
  4725. else
  4726. {
  4727. tempIndex = gun_index;
  4728. }
  4729. for (int index = 0; index < AC_QUANTITY; index++)
  4730. {
  4731. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4732. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4733. {
  4734. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4735. {
  4736. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4737. }
  4738. }
  4739. }//End for AC
  4740. }
  4741. if(cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON)
  4742. {
  4743. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  4744. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  4745. }
  4746. }
  4747. // Sample period MeterValue
  4748. if(((time((time_t*)NULL) - clientTime.MeterValues[gun_index]) > (atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1)))
  4749. {
  4750. //check Transaction active
  4751. if(gunType[gun_index] == 'J')
  4752. {
  4753. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4754. {
  4755. tempIndex = ((gun_index==2) ? 1: 0);
  4756. }
  4757. else
  4758. {
  4759. tempIndex = gun_index;
  4760. }
  4761. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4762. {
  4763. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4764. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4765. {
  4766. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4767. {
  4768. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4769. }
  4770. }
  4771. }// End for CHAdeMO
  4772. }
  4773. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4774. {
  4775. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4776. {
  4777. tempIndex = ((gun_index==2) ? 1: 0);
  4778. }
  4779. else
  4780. {
  4781. tempIndex = gun_index;
  4782. }
  4783. for (int index = 0; index < CCS_QUANTITY; index++)
  4784. {
  4785. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4786. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4787. {
  4788. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4789. {
  4790. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4791. }
  4792. }
  4793. } // End for CCS
  4794. }
  4795. else if(gunType[gun_index] == 'G')
  4796. {
  4797. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4798. {
  4799. tempIndex = ((gun_index==2) ? 1: 0);
  4800. }
  4801. else
  4802. {
  4803. tempIndex = gun_index;
  4804. }
  4805. for (int index = 0; index < GB_QUANTITY; index++)
  4806. {
  4807. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4808. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4809. {
  4810. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4811. {
  4812. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4813. }
  4814. }
  4815. }// End for GB
  4816. }
  4817. else if(gunType[gun_index] == 'O')
  4818. {
  4819. tempIndex = gun_index;
  4820. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4821. {
  4822. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4823. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4824. {
  4825. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  4826. {
  4827. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4828. }
  4829. }
  4830. }
  4831. }
  4832. else
  4833. {
  4834. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4835. {
  4836. tempIndex = 2;
  4837. }
  4838. else
  4839. {
  4840. tempIndex = gun_index;
  4841. }
  4842. for (int index = 0; index < AC_QUANTITY; index++)
  4843. {
  4844. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4845. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4846. {
  4847. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4848. {
  4849. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4850. }
  4851. }
  4852. }//End for AC
  4853. }
  4854. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  4855. {
  4856. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  4857. storeTempStopTransaction(gun_index);
  4858. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  4859. }
  4860. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4861. }
  4862. //==============================================
  4863. // Check Connector reserved
  4864. //==============================================
  4865. //===============================
  4866. // Check if Reserve is expired
  4867. //===============================
  4868. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0) )
  4869. {
  4870. double diff_t;
  4871. struct tm tp;
  4872. // current time
  4873. time_t t = time(NULL);
  4874. strptime((char *)ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime, "%Y-%m-%dT%H:%M:%S", &tp);
  4875. tp.tm_isdst = -1;
  4876. time_t utc = mktime(&tp);
  4877. diff_t = difftime(utc, t);
  4878. if(diff_t <= 0)
  4879. {
  4880. DEBUG_INFO("reserve expired.\n");
  4881. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  4882. }
  4883. }//END OF Check if Reserve is expired
  4884. //==========================================
  4885. // csu trigger FirmwareStatusNotificationReq
  4886. //==========================================
  4887. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  4888. {
  4889. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  4890. }
  4891. //==========================================
  4892. // csu trigger CancelReservationConf
  4893. //==========================================
  4894. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  4895. {
  4896. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  4897. }
  4898. //==========================================
  4899. // csu trigger ChangeAvailabilityConf
  4900. //==========================================
  4901. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  4902. {
  4903. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  4904. }
  4905. //==========================================
  4906. // csu trigger UnlockConnectorConf
  4907. //==========================================
  4908. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  4909. {
  4910. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  4911. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  4912. }
  4913. //==========================================
  4914. // csu trigger ReserveNowConf
  4915. //==========================================
  4916. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  4917. {
  4918. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  4919. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  4920. }
  4921. }
  4922. }
  4923. //==========================================
  4924. // send request routine
  4925. //==========================================
  4926. int sendAuthorizeRequest(int gun_index)
  4927. {
  4928. mtrace();
  4929. int result = FAIL;
  4930. char message[4096]={0};
  4931. char guid[37];
  4932. char tempdata[128]={0};
  4933. json_object *Authorize = json_object_new_object();
  4934. json_object *idToken = json_object_new_object();
  4935. DEBUG_INFO("sendAuthorizeRequest...\n");
  4936. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  4937. //Local Authorize
  4938. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) && (ShmOCPP20Data->OcppConnStatus == 0))
  4939. {
  4940. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  4941. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4942. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  4943. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  4944. result = PASS;
  4945. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4946. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4947. authorizeRetryTimes = 0;
  4948. return result;
  4949. }
  4950. 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)) ||
  4951. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  4952. {
  4953. // Query idtag from cache
  4954. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  4955. // Query idtag from list
  4956. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4957. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  4958. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4959. {
  4960. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  4961. {
  4962. DEBUG_INFO("Card %s does not find in list or cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  4963. }
  4964. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  4965. {
  4966. DEBUG_INFO("Card %s does not accepted in list and cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  4967. }
  4968. // Return authorize result if does not connect to server
  4969. if(!ShmOCPP20Data->OcppConnStatus)
  4970. {
  4971. DEBUG_INFO("Local Authorization Fail.\n");
  4972. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4973. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4974. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  4975. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4976. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4977. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4978. authorizeRetryTimes = 0;
  4979. return result;
  4980. }
  4981. }
  4982. else
  4983. {
  4984. DEBUG_INFO("Local Authorization get result.\n");
  4985. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  4986. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4987. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  4988. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  4989. else
  4990. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  4991. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4992. result = PASS;
  4993. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4994. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4995. authorizeRetryTimes = 0;
  4996. return result;
  4997. }
  4998. }
  4999. //initialize struct Authorize
  5000. memset(&(ShmOCPP20Data->Authorize), 0 , sizeof(struct StructAuthorize));
  5001. //get data from shared memory
  5002. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  5003. strcpy((char *)ShmOCPP20Data->Authorize.idToken.type, IdTokenEnumTypeStr[IdTokenEnumType_ISO14443]);
  5004. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  5005. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  5006. json_object_object_add(Authorize, "idToken", idToken);
  5007. random_uuid(guid);
  5008. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  5009. json_object_put(Authorize);
  5010. LWS_Send(message);
  5011. sprintf(tempdata, "Authorize,%d", gun_index);
  5012. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5013. {
  5014. result = PASS;
  5015. }
  5016. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  5017. return result;
  5018. }
  5019. int sendBootNotificationRequest()
  5020. {
  5021. mtrace();
  5022. int result = FAIL;
  5023. char message[4096]={0};
  5024. char guid[37]={0};
  5025. char tempdata[128]={0};
  5026. json_object *BootNotification = json_object_new_object();
  5027. json_object *chargingStation = json_object_new_object();
  5028. json_object *modem = json_object_new_object();
  5029. DEBUG_INFO("sendBootNotificationRequest...\n");
  5030. // Fill BootNotification fields
  5031. DB_getBooType();
  5032. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  5033. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  5034. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  5035. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  5036. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  5037. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  5038. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  5039. {
  5040. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  5041. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  5042. json_object_object_add(chargingStation, "modem", modem);
  5043. }
  5044. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  5045. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  5046. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  5047. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  5048. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  5049. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  5050. random_uuid(guid);
  5051. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  5052. json_object_put(BootNotification);
  5053. LWS_Send(message);
  5054. sprintf(tempdata, "BootNotification,0");
  5055. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5056. {
  5057. result = PASS;
  5058. }
  5059. return result;
  5060. }
  5061. int sendClearedChargingLimitRequest(int gun_index)
  5062. {
  5063. mtrace();
  5064. int result = FAIL;
  5065. char message[4096]={0};
  5066. char guid[37]={0};
  5067. char tempdata[128]={0};
  5068. json_object *ClearedChargingLimit = json_object_new_object();
  5069. DEBUG_INFO("sendClearedChargingLimitRequest...\n");
  5070. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  5071. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  5072. random_uuid(guid);
  5073. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  5074. json_object_put(ClearedChargingLimit);
  5075. LWS_Send(message);
  5076. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  5077. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5078. {
  5079. result = PASS;
  5080. }
  5081. return result;
  5082. }
  5083. int sendDataTransferRequest(int gun_index)
  5084. {
  5085. mtrace();
  5086. char message[1000]={0};
  5087. char guid[37]={0};
  5088. char tempdata[65]={0};
  5089. int result = FAIL;
  5090. DEBUG_INFO("sendDataTransferRequest...\n");
  5091. random_uuid(guid);
  5092. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  5093. MESSAGE_TYPE_CALL,
  5094. guid,
  5095. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  5096. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  5097. ShmOCPP20Data->DataTransfer[gun_index].data);
  5098. LWS_Send(message);
  5099. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  5100. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5101. {
  5102. result = PASS;
  5103. }
  5104. return result;
  5105. }
  5106. int sendFirmwareStatusNotificationRequest(char *status)
  5107. {
  5108. mtrace();
  5109. int result = FAIL;
  5110. char message[110]={0};
  5111. char guid[37]={0};
  5112. char tempdata[65]={0};
  5113. json_object *FirmwareStatusNotification = json_object_new_object();
  5114. DEBUG_INFO("sendFirmwareStatusNotificationRequest...\n");
  5115. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  5116. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  5117. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  5118. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  5119. random_uuid(guid);
  5120. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  5121. json_object_put(FirmwareStatusNotification);
  5122. LWS_SendNow(message);
  5123. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  5124. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5125. {
  5126. result = PASS;
  5127. }
  5128. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  5129. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  5130. //record status
  5131. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  5132. {
  5133. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  5134. }
  5135. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  5136. {
  5137. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  5138. }
  5139. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  5140. {
  5141. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  5142. }
  5143. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  5144. {
  5145. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  5146. }
  5147. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  5148. {
  5149. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  5150. }
  5151. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  5152. {
  5153. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  5154. }
  5155. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  5156. {
  5157. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  5158. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5159. }
  5160. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  5161. {
  5162. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  5163. }
  5164. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  5165. {
  5166. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  5167. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5168. }
  5169. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  5170. {
  5171. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  5172. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5173. }
  5174. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  5175. {
  5176. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  5177. }
  5178. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  5179. {
  5180. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  5181. }
  5182. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  5183. {
  5184. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  5185. }
  5186. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  5187. {
  5188. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  5189. }
  5190. return result;
  5191. }
  5192. int sendGet15118EVCertificateRequest()
  5193. {
  5194. mtrace();
  5195. int result = FAIL;
  5196. char message[4096]={0};
  5197. char guid[37]={0};
  5198. char tempdata[128]={0};
  5199. json_object *Get15118EVCertificate = json_object_new_object();
  5200. DEBUG_INFO("sendGet15118EVCertificateRequest...\n");
  5201. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  5202. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  5203. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  5204. random_uuid(guid);
  5205. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  5206. json_object_put(Get15118EVCertificate);
  5207. LWS_Send(message);
  5208. sprintf(tempdata, "Get15118EVCertificate,0");
  5209. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5210. {
  5211. result = PASS;
  5212. }
  5213. return result;
  5214. }
  5215. int sendGetCertificateStatusRequest()
  5216. {
  5217. mtrace();
  5218. int result = FAIL;
  5219. char message[4096]={0};
  5220. char guid[37]={0};
  5221. char tempdata[128]={0};
  5222. json_object *GetCertificateStatus = json_object_new_object();
  5223. json_object *ocspRequestData = json_object_new_object();
  5224. DEBUG_INFO("sendGetCertificateStatusRequest...\n");
  5225. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  5226. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  5227. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  5228. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  5229. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  5230. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  5231. random_uuid(guid);
  5232. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  5233. json_object_put(GetCertificateStatus);
  5234. LWS_Send(message);
  5235. sprintf(tempdata, "GetCertificateStatus,0");
  5236. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5237. {
  5238. result = PASS;
  5239. }
  5240. return result;
  5241. }
  5242. int sendHeartbeatRequest()
  5243. {
  5244. mtrace();
  5245. int result = FAIL;
  5246. char message[40096]={0};
  5247. char guid[37]={0};
  5248. char tempdata[128]={0};
  5249. DEBUG_INFO("sendHeartbeatRequest...\n");
  5250. random_uuid(guid);
  5251. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  5252. , MESSAGE_TYPE_CALL
  5253. , guid );
  5254. LWS_Send(message);
  5255. sprintf(tempdata, "Heartbeat,%d", 0);
  5256. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5257. {
  5258. result = PASS;
  5259. }
  5260. return result;
  5261. }
  5262. int sendLogStatusNotificationRequest(char *status)
  5263. {
  5264. mtrace();
  5265. int result = FAIL;
  5266. char message[4096]={0};
  5267. char guid[37]={0};
  5268. char tempdata[128]={0};
  5269. json_object *LogStatusNotification = json_object_new_object();
  5270. DEBUG_INFO("sendLogStatusNotificationRequest...\n");
  5271. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  5272. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  5273. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  5274. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  5275. random_uuid(guid);
  5276. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  5277. json_object_put(LogStatusNotification);
  5278. LWS_SendNow(message);
  5279. sprintf(tempdata, "LogStatusNotification,%d", 0);
  5280. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5281. {
  5282. result = PASS;
  5283. }
  5284. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  5285. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  5286. //record status
  5287. if(strcmp(status,"BadMessage")==0)
  5288. {
  5289. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  5290. }
  5291. else if(strcmp(status,"Idle")==0)
  5292. {
  5293. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  5294. }
  5295. else if(strcmp(status,"NotSupportedOperation")==0)
  5296. {
  5297. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  5298. }
  5299. else if(strcmp(status,"PermissionDenied")==0)
  5300. {
  5301. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  5302. }
  5303. else if(strcmp(status,"Uploaded")==0)
  5304. {
  5305. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  5306. }
  5307. else if(strcmp(status,"UploadFailure")==0)
  5308. {
  5309. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  5310. }
  5311. else if(strcmp(status,"Uploading")==0)
  5312. {
  5313. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  5314. }
  5315. return result;
  5316. }
  5317. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  5318. {
  5319. mtrace();
  5320. int result = FAIL;
  5321. char guid[37]={0};
  5322. char tempdata[65]={0};
  5323. int tempIndex = 0;
  5324. json_object *MeterValueReq = json_object_new_object();
  5325. json_object *meterValues = json_object_new_array();
  5326. json_object *sampledValues = json_object_new_array();
  5327. DEBUG_INFO("sendMeterValuesRequest...\n");
  5328. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  5329. //set value
  5330. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  5331. //UTC Date time
  5332. struct timeval tmnow;
  5333. struct tm *tm;
  5334. char buf[28];//, usec_buf[6];
  5335. gettimeofday(&tmnow, NULL);
  5336. time_t t;
  5337. t = time(NULL);
  5338. /*UTC time and date*/
  5339. tm = gmtime(&t);
  5340. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  5341. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  5342. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  5343. //idx_sample=0;
  5344. //********************************(1)Current.Import L1************************************************/
  5345. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5346. if(gunType[gun_index] == 'J')
  5347. {
  5348. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5349. {
  5350. tempIndex = ((gun_index==2) ? 1: 0);
  5351. }
  5352. else
  5353. {
  5354. tempIndex = gun_index;
  5355. }
  5356. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5357. {
  5358. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5359. {
  5360. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent;
  5361. }
  5362. }
  5363. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5364. }
  5365. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5366. {
  5367. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5368. {
  5369. tempIndex = ((gun_index==2) ? 1: 0);
  5370. }
  5371. else
  5372. {
  5373. tempIndex = gun_index;
  5374. }
  5375. for (int index = 0; index < CCS_QUANTITY; index++)
  5376. {
  5377. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5378. {
  5379. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent;
  5380. }
  5381. }
  5382. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5383. }
  5384. else if(gunType[gun_index] == 'G')
  5385. {
  5386. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5387. {
  5388. tempIndex = ((gun_index==2) ? 1: 0);
  5389. }
  5390. else
  5391. {
  5392. tempIndex = gun_index;
  5393. }
  5394. for (int index = 0; index < GB_QUANTITY; index++)
  5395. {
  5396. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5397. {
  5398. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent;
  5399. }
  5400. }
  5401. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5402. }
  5403. else if(gunType[gun_index] == 'O')
  5404. {
  5405. tempIndex = gun_index;
  5406. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5407. {
  5408. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5409. {
  5410. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent;
  5411. }
  5412. }
  5413. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5414. }
  5415. else
  5416. {
  5417. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5418. {
  5419. tempIndex = 2;
  5420. }
  5421. else
  5422. {
  5423. tempIndex = gun_index;
  5424. }
  5425. for (int index = 0; index < AC_QUANTITY; index++)
  5426. {
  5427. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5428. {
  5429. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent;
  5430. }
  5431. }
  5432. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5433. }
  5434. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  5435. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5436. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5437. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  5438. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  5439. //idx_sample=1;
  5440. //********************************(2)Energy.Active.Import.Register ************************************************/
  5441. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5442. if(gunType[gun_index] == 'J')
  5443. {
  5444. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5445. {
  5446. tempIndex = ((gun_index==2) ? 1: 0);
  5447. }
  5448. else
  5449. {
  5450. tempIndex = gun_index;
  5451. }
  5452. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5453. {
  5454. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5455. {
  5456. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  5457. }
  5458. }
  5459. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5460. }
  5461. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5462. {
  5463. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5464. {
  5465. tempIndex = ((gun_index==2) ? 1: 0);
  5466. }
  5467. else
  5468. {
  5469. tempIndex = gun_index;
  5470. }
  5471. for (int index = 0; index < CCS_QUANTITY; index++)
  5472. {
  5473. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5474. {
  5475. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  5476. }
  5477. }
  5478. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5479. }
  5480. else if(gunType[gun_index] == 'G')
  5481. {
  5482. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5483. {
  5484. tempIndex = ((gun_index==2) ? 1: 0);
  5485. }
  5486. else
  5487. {
  5488. tempIndex = gun_index;
  5489. }
  5490. for (int index = 0; index < GB_QUANTITY; index++)
  5491. {
  5492. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5493. {
  5494. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  5495. }
  5496. }
  5497. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5498. }
  5499. else if(gunType[gun_index] == 'O')
  5500. {
  5501. tempIndex = gun_index;
  5502. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5503. {
  5504. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5505. {
  5506. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  5507. }
  5508. }
  5509. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5510. }
  5511. else
  5512. {
  5513. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5514. {
  5515. tempIndex = 2;
  5516. }
  5517. else
  5518. {
  5519. tempIndex = gun_index;
  5520. }
  5521. for (int index = 0; index < AC_QUANTITY; index++)
  5522. {
  5523. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5524. {
  5525. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  5526. }
  5527. }
  5528. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5529. }
  5530. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  5531. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  5532. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5533. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  5534. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5535. //idx_sample=2;
  5536. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  5537. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5538. if(gunType[gun_index] == 'J')
  5539. {
  5540. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5541. {
  5542. tempIndex = ((gun_index==2) ? 1: 0);
  5543. }
  5544. else
  5545. {
  5546. tempIndex = gun_index;
  5547. }
  5548. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5549. {
  5550. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5551. {
  5552. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
  5553. }
  5554. } // END OF FOR CHAdeMO_QUANTITY
  5555. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5556. }
  5557. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5558. {
  5559. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5560. {
  5561. tempIndex = ((gun_index==2) ? 1: 0);
  5562. }
  5563. else
  5564. {
  5565. tempIndex = gun_index;
  5566. }
  5567. for (int index = 0; index < CCS_QUANTITY; index++)
  5568. {
  5569. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5570. {
  5571. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
  5572. }
  5573. } // END OF CCS_QUANTITY
  5574. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5575. }
  5576. else if(gunType[gun_index] == 'G')
  5577. {
  5578. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5579. {
  5580. tempIndex = ((gun_index==2) ? 1: 0);
  5581. }
  5582. else
  5583. {
  5584. tempIndex = gun_index;
  5585. }
  5586. for (int index = 0; index < GB_QUANTITY; index++)
  5587. {
  5588. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5589. {
  5590. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
  5591. }
  5592. } // END OF GB_QUANTITY
  5593. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5594. }
  5595. else if(gunType[gun_index] == 'O')
  5596. {
  5597. tempIndex = gun_index;
  5598. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5599. {
  5600. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5601. {
  5602. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy;
  5603. }
  5604. }
  5605. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5606. }
  5607. else
  5608. {
  5609. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5610. {
  5611. tempIndex = 2;
  5612. }
  5613. else
  5614. {
  5615. tempIndex = gun_index;
  5616. }
  5617. for (int index = 0; index < AC_QUANTITY; index++)
  5618. {
  5619. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5620. {
  5621. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
  5622. }
  5623. }
  5624. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5625. }
  5626. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  5627. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  5628. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5629. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  5630. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5631. //idx_sample=3;
  5632. //********************************(4)Power.Active.Import************************************************/
  5633. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5634. if(gunType[gun_index] == 'J')
  5635. {
  5636. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5637. {
  5638. tempIndex = ((gun_index==2) ? 1: 0);
  5639. }
  5640. else
  5641. {
  5642. tempIndex = gun_index;
  5643. }
  5644. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5645. {
  5646. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5647. {
  5648. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower;
  5649. }
  5650. } // END OF FOR
  5651. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5652. }
  5653. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5654. {
  5655. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5656. {
  5657. tempIndex = ((gun_index==2) ? 1: 0);
  5658. }
  5659. else
  5660. {
  5661. tempIndex = gun_index;
  5662. }
  5663. for (int index = 0; index < CCS_QUANTITY; index++)
  5664. {
  5665. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5666. {
  5667. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower;
  5668. }
  5669. }
  5670. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5671. }
  5672. else if(gunType[gun_index] == 'G')
  5673. {
  5674. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5675. {
  5676. tempIndex = ((gun_index==2) ? 1: 0);
  5677. }
  5678. else
  5679. {
  5680. tempIndex = gun_index;
  5681. }
  5682. for (int index = 0; index < GB_QUANTITY; index++)
  5683. {
  5684. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5685. {
  5686. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5687. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower;
  5688. }
  5689. }
  5690. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5691. }
  5692. else if(gunType[gun_index] == 'O')
  5693. {
  5694. tempIndex = gun_index;
  5695. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5696. {
  5697. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5698. {
  5699. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5700. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower;
  5701. }
  5702. }
  5703. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5704. }
  5705. else
  5706. {
  5707. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5708. {
  5709. tempIndex = 2;
  5710. }
  5711. else
  5712. {
  5713. tempIndex = gun_index;
  5714. }
  5715. for (int index = 0; index < AC_QUANTITY; index++)
  5716. {
  5717. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5718. {
  5719. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower;
  5720. }
  5721. }
  5722. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5723. }
  5724. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  5725. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  5726. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5727. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  5728. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  5729. //idx_sample=4;
  5730. //***********************************************(5)VOLTAGE L1******************************************************/
  5731. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5732. if(gunType[gun_index] == 'J')
  5733. {
  5734. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5735. {
  5736. tempIndex = ((gun_index==2) ? 1: 0);
  5737. }
  5738. else
  5739. {
  5740. tempIndex = gun_index;
  5741. }
  5742. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5743. {
  5744. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5745. {
  5746. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage;
  5747. }
  5748. }
  5749. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5750. }
  5751. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5752. {
  5753. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5754. {
  5755. tempIndex = ((gun_index==2) ? 1: 0);
  5756. }
  5757. else
  5758. {
  5759. tempIndex = gun_index;
  5760. }
  5761. for (int index = 0; index < CCS_QUANTITY; index++)
  5762. {
  5763. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5764. {
  5765. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage;
  5766. }
  5767. }
  5768. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5769. }
  5770. else if(gunType[gun_index] == 'G')
  5771. {
  5772. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5773. {
  5774. tempIndex = ((gun_index==2) ? 1: 0);
  5775. }
  5776. else
  5777. {
  5778. tempIndex = gun_index;
  5779. }
  5780. for (int index = 0; index < GB_QUANTITY; index++)
  5781. {
  5782. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5783. {
  5784. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage;
  5785. }
  5786. }
  5787. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5788. }
  5789. else if(gunType[gun_index] == 'O')
  5790. {
  5791. tempIndex = gun_index;
  5792. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5793. {
  5794. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5795. {
  5796. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage;
  5797. }
  5798. }
  5799. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5800. }
  5801. else
  5802. {
  5803. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5804. {
  5805. tempIndex = 2;
  5806. }
  5807. else
  5808. {
  5809. tempIndex = gun_index;
  5810. }
  5811. for (int index = 0; index < AC_QUANTITY; index++)
  5812. {
  5813. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5814. {
  5815. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage;
  5816. }
  5817. }
  5818. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5819. }
  5820. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  5821. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5822. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5823. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  5824. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  5825. //***********************************************(6)SOC******************************************************/
  5826. if((gunType[gun_index] == 'J')||(gunType[gun_index] == 'U')||(gunType[gun_index] == 'E')||(gunType[gun_index] == 'G'))
  5827. {
  5828. //idx_sample=5;
  5829. //sampledValue = NULL;
  5830. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5831. {
  5832. tempIndex = ((gun_index==2) ? 1: 0);
  5833. }
  5834. else
  5835. {
  5836. tempIndex = gun_index;
  5837. }
  5838. if(gunType[gun_index] == 'J')
  5839. {
  5840. //tempIndex = ((gun_index==2) ? 1: 0);
  5841. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5842. {
  5843. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5844. {
  5845. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  5846. }
  5847. }
  5848. }
  5849. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5850. {
  5851. //tempIndex = ((gun_index==2) ? 1: 0);
  5852. for (int index = 0; index < CCS_QUANTITY; index++)
  5853. {
  5854. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5855. {
  5856. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  5857. }
  5858. }
  5859. }
  5860. else if(gunType[gun_index] == 'G')
  5861. {
  5862. //tempIndex = ((gun_index==2) ? 1: 0);
  5863. for (int index = 0; index < GB_QUANTITY; index++)
  5864. {
  5865. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5866. {
  5867. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  5868. }
  5869. }
  5870. }
  5871. else if(gunType[gun_index] == 'O')
  5872. {
  5873. //tempIndex = ((gun_index==2) ? 1: 0);
  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[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  5879. }
  5880. }
  5881. }
  5882. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  5883. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  5884. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5885. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  5886. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  5887. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  5888. }
  5889. //********************************(7)Current.Import L2************************************************/
  5890. // Only for AC 3 phase
  5891. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5892. {
  5893. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5894. {
  5895. tempIndex = 2;
  5896. }
  5897. else
  5898. {
  5899. tempIndex = gun_index;
  5900. }
  5901. for (int index = 0; index < AC_QUANTITY; index++)
  5902. {
  5903. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5904. {
  5905. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2;
  5906. }
  5907. }
  5908. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5909. }
  5910. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  5911. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5912. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5913. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  5914. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  5915. //********************************(8)Current.Import L3************************************************/
  5916. // Only for AC 3 phase
  5917. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5918. {
  5919. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5920. {
  5921. tempIndex = 2;
  5922. }
  5923. else
  5924. {
  5925. tempIndex = gun_index;
  5926. }
  5927. for (int index = 0; index < AC_QUANTITY; index++)
  5928. {
  5929. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5930. {
  5931. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3;
  5932. }
  5933. }
  5934. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5935. }
  5936. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  5937. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5938. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5939. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  5940. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  5941. //***********************************************(9)VOLTAGE L2******************************************************/
  5942. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5943. {
  5944. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5945. {
  5946. tempIndex = 2;
  5947. }
  5948. else
  5949. {
  5950. tempIndex = gun_index;
  5951. }
  5952. for (int index = 0; index < AC_QUANTITY; index++)
  5953. {
  5954. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5955. {
  5956. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2;
  5957. }
  5958. }
  5959. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5960. }
  5961. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  5962. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5963. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5964. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  5965. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  5966. //***********************************************(10)VOLTAGE L3******************************************************/
  5967. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5968. {
  5969. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5970. {
  5971. tempIndex = 2;
  5972. }
  5973. else
  5974. {
  5975. tempIndex = gun_index;
  5976. }
  5977. for (int index = 0; index < AC_QUANTITY; index++)
  5978. {
  5979. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5980. {
  5981. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3;
  5982. }
  5983. }
  5984. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5985. }
  5986. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  5987. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5988. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5989. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  5990. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  5991. // Message create ====================================================================================================
  5992. random_uuid(guid);
  5993. for(uint8_t idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue);idxMeter++)
  5994. {
  5995. json_object *meterValue = json_object_new_object();
  5996. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  5997. {
  5998. if(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value > 0)
  5999. {
  6000. json_object *sampledValue = json_object_new_object();
  6001. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  6002. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  6003. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  6004. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  6005. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  6006. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  6007. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  6008. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  6009. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  6010. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  6011. {
  6012. json_object *unitOfMeasure = json_object_new_object();
  6013. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  6014. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  6015. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  6016. }
  6017. json_object_array_add(sampledValues, sampledValue);
  6018. }
  6019. }
  6020. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  6021. json_object_object_add(meterValue, "sampledValue", sampledValues);
  6022. json_object_array_add(meterValues, meterValue);
  6023. idxMeter++;
  6024. }
  6025. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  6026. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  6027. sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",%s]"
  6028. ,gun_index + 1
  6029. ,MESSAGE_TYPE_CALL
  6030. ,guid
  6031. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  6032. json_object_put(MeterValueReq);
  6033. if((strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]) == 0) ||
  6034. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]) == 0) ||
  6035. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]) == 0))
  6036. {
  6037. // Transaction meter value send by TransactionEvent message
  6038. memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
  6039. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  6040. result = PASS;
  6041. }
  6042. else
  6043. {
  6044. // Put request guid to hash map
  6045. sprintf(tempdata, "MeterValues,%d", (gun_index));
  6046. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6047. {
  6048. result = PASS;
  6049. }
  6050. if((dataType != ReadingContextEnumType_Trigger) &&
  6051. (dataType != ReadingContextEnumType_Sample_Clock))
  6052. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  6053. else
  6054. {
  6055. if(FirstHeartBeat)
  6056. LWS_Send(queuedata +2);
  6057. }
  6058. }
  6059. return result;
  6060. }
  6061. int sendNotifyChargingLimitRequest(int gun_index)
  6062. {
  6063. mtrace();
  6064. int result = FAIL;
  6065. char message[4096]={0};
  6066. char guid[37]={0};
  6067. char tempdata[128]={0};
  6068. json_object *NotifyChargingLimit = json_object_new_object();
  6069. json_object *chargingLimit = json_object_new_object();
  6070. DEBUG_INFO("sendNotifyChargingLimitRequest...\n");
  6071. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  6072. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  6073. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  6074. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  6075. random_uuid(guid);
  6076. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  6077. json_object_put(NotifyChargingLimit);
  6078. LWS_Send(message);
  6079. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  6080. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6081. {
  6082. result = PASS;
  6083. }
  6084. return result;
  6085. }
  6086. int sendNotifyCustomerInformationRequest()
  6087. {
  6088. mtrace();
  6089. int result = FAIL;
  6090. char message[4096]={0};
  6091. char guid[37]={0};
  6092. char tempdata[128]={0};
  6093. json_object *NotifyCustomerInformation = json_object_new_object();
  6094. DEBUG_INFO("sendNotifyCustomerInformationRequest...\n");
  6095. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  6096. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  6097. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  6098. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  6099. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  6100. random_uuid(guid);
  6101. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  6102. json_object_put(NotifyCustomerInformation);
  6103. LWS_Send(message);
  6104. sprintf(tempdata, "NotifyCustomerInformation,0");
  6105. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6106. {
  6107. result = PASS;
  6108. }
  6109. return result;
  6110. }
  6111. int sendNotifyDisplayMessagesRequest()
  6112. {
  6113. mtrace();
  6114. int result = FAIL;
  6115. char message[4096]={0};
  6116. char guid[37]={0};
  6117. char tempdata[128]={0};
  6118. json_object *NotifyDisplayMessages = json_object_new_object();
  6119. json_object *messageInfos = json_object_new_array();
  6120. DEBUG_INFO("sendNotifyDisplayMessagesRequest...\n");
  6121. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  6122. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  6123. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  6124. {
  6125. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  6126. {
  6127. json_object *messageInfo = json_object_new_object();
  6128. json_object *message = json_object_new_object();
  6129. json_object *display = json_object_new_object();
  6130. json_object *evse = json_object_new_object();
  6131. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  6132. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  6133. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  6134. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  6135. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  6136. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  6137. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  6138. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  6139. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  6140. json_object_object_add(messageInfo, "message", message);
  6141. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  6142. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  6143. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  6144. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  6145. json_object_object_add(display, "evse",evse);
  6146. json_object_object_add(messageInfo, "evse", display);
  6147. json_object_array_add(messageInfos, messageInfo);
  6148. }
  6149. }
  6150. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  6151. random_uuid(guid);
  6152. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  6153. json_object_put(NotifyDisplayMessages);
  6154. LWS_Send(message);
  6155. sprintf(tempdata, "NotifyDisplayMessages,0");
  6156. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6157. {
  6158. result = PASS;
  6159. }
  6160. return result;
  6161. }
  6162. int sendNotifyEVChargingNeedsRequest(int gun_index)
  6163. {
  6164. mtrace();
  6165. int result = FAIL;
  6166. char message[4096]={0};
  6167. char guid[37]={0};
  6168. char tempdata[128]={0};
  6169. json_object *NotifyEVChargingNeeds = json_object_new_object();
  6170. json_object *chargingNeeds = json_object_new_object();
  6171. json_object *acChargingParameters = json_object_new_object();
  6172. json_object *dcChargingParameters = json_object_new_object();
  6173. DEBUG_INFO("sendNotifyEVChargingNeedsRequest...\n");
  6174. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  6175. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  6176. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  6177. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  6178. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  6179. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  6180. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  6181. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  6182. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  6183. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  6184. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  6185. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  6186. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  6187. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  6188. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  6189. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  6190. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  6191. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  6192. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  6193. random_uuid(guid);
  6194. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  6195. json_object_put(NotifyEVChargingNeeds);
  6196. LWS_Send(message);
  6197. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  6198. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6199. {
  6200. result = PASS;
  6201. }
  6202. return result;
  6203. }
  6204. int sendNotifyEVChargingScheduleRequest(int gun_index)
  6205. {
  6206. mtrace();
  6207. int result = FAIL;
  6208. char message[4096]={0};
  6209. char guid[37]={0};
  6210. char tempdata[128]={0};
  6211. json_object *NotifyEVChargingSchedule = json_object_new_object();
  6212. json_object *chargingSchedule = json_object_new_object();
  6213. json_object *periods = json_object_new_array();
  6214. DEBUG_INFO("sendNotifyEVChargingScheduleRequest...\n");
  6215. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  6216. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  6217. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  6218. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  6219. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  6220. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  6221. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  6222. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  6223. {
  6224. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  6225. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  6226. {
  6227. json_object *Period = json_object_new_object();
  6228. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  6229. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  6230. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  6231. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  6232. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  6233. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  6234. json_object_array_add(periods, Period);
  6235. }
  6236. }
  6237. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  6238. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  6239. random_uuid(guid);
  6240. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  6241. json_object_put(NotifyEVChargingSchedule);
  6242. LWS_Send(message);
  6243. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  6244. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6245. {
  6246. result = PASS;
  6247. }
  6248. return result;
  6249. }
  6250. int sendNotifyEventRequest()
  6251. {
  6252. mtrace();
  6253. int result = FAIL;
  6254. char message[4096]={0};
  6255. char guid[37]={0};
  6256. char tempdata[128]={0};
  6257. json_object *NotifyEvent = json_object_new_object();
  6258. json_object *eventDatas = json_object_new_array();
  6259. DEBUG_INFO("sendNotifyEventRequest...\n");
  6260. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  6261. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  6262. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  6263. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  6264. {
  6265. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  6266. {
  6267. json_object *eventData = json_object_new_object();
  6268. json_object *component = json_object_new_object();
  6269. json_object *evse = json_object_new_object();
  6270. json_object *variable = json_object_new_object();
  6271. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  6272. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  6273. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  6274. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  6275. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  6276. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  6277. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  6278. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  6279. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  6280. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  6281. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  6282. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  6283. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  6284. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  6285. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  6286. json_object_object_add(component, "evse",evse);
  6287. json_object_object_add(eventData, "component", component);
  6288. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  6289. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  6290. json_object_object_add(eventData, "variable", variable);
  6291. json_object_array_add(eventDatas, eventData);
  6292. }
  6293. }
  6294. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  6295. random_uuid(guid);
  6296. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  6297. json_object_put(NotifyEvent);
  6298. LWS_Send(message);
  6299. sprintf(tempdata, "NotifyEvent,0");
  6300. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6301. {
  6302. result = PASS;
  6303. }
  6304. return result;
  6305. }
  6306. int sendNotifyMonitoringReportRequest()
  6307. {
  6308. mtrace();
  6309. int result = FAIL;
  6310. char message[4096]={0};
  6311. char guid[37]={0};
  6312. char tempdata[128]={0};
  6313. json_object *NotifyMonitoringReport = json_object_new_object();
  6314. json_object *monitors = json_object_new_array();
  6315. DEBUG_INFO("sendNotifyMonitoringReportRequest...\n");
  6316. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  6317. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  6318. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  6319. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  6320. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  6321. {
  6322. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  6323. {
  6324. json_object *monitor = json_object_new_object();
  6325. json_object *component = json_object_new_object();
  6326. json_object *evse = json_object_new_object();
  6327. json_object *variable = json_object_new_object();
  6328. json_object *variableMonitorings = json_object_new_array();
  6329. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  6330. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  6331. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  6332. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  6333. json_object_object_add(component, "evse",evse);
  6334. json_object_object_add(monitor, "component", component);
  6335. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  6336. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  6337. json_object_object_add(monitor, "variable", variable);
  6338. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  6339. {
  6340. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  6341. {
  6342. json_object *variableMonitoring = json_object_new_object();
  6343. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  6344. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  6345. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  6346. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  6347. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  6348. json_object_array_add(variableMonitorings, variableMonitoring);
  6349. }
  6350. }
  6351. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  6352. json_object_array_add(monitors, monitor);
  6353. }
  6354. }
  6355. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  6356. random_uuid(guid);
  6357. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  6358. json_object_put(NotifyMonitoringReport);
  6359. LWS_Send(message);
  6360. sprintf(tempdata, "NotifyMonitoringReport,0");
  6361. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6362. {
  6363. result = PASS;
  6364. }
  6365. return result;
  6366. }
  6367. int sendNotifyReportRequest()
  6368. {
  6369. mtrace();
  6370. int result = FAIL;
  6371. char message[4096]={0};
  6372. char guid[37]={0};
  6373. char tempdata[128]={0};
  6374. json_object *NotifyReport = json_object_new_object();
  6375. json_object *reportDatas = json_object_new_array();
  6376. DEBUG_INFO("sendNotifyReportRequest...\n");
  6377. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  6378. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  6379. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  6380. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  6381. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  6382. {
  6383. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  6384. {
  6385. json_object *reportData = json_object_new_object();
  6386. json_object *component = json_object_new_object();
  6387. json_object *evse = json_object_new_object();
  6388. json_object *variable = json_object_new_object();
  6389. json_object *variableAttributes = json_object_new_array();
  6390. json_object *variableCharacteristics = json_object_new_object();
  6391. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  6392. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  6393. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  6394. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  6395. json_object_object_add(component, "evse",evse);
  6396. json_object_object_add(reportData, "component", component);
  6397. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  6398. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  6399. json_object_object_add(reportData, "variable",variable);
  6400. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  6401. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  6402. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  6403. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  6404. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  6405. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  6406. {
  6407. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  6408. {
  6409. json_object *variableAttribute = json_object_new_object();
  6410. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  6411. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  6412. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  6413. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  6414. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  6415. json_object_array_add(variableAttributes, variableAttribute);
  6416. }
  6417. }
  6418. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  6419. json_object_array_add(reportDatas, reportData);
  6420. }
  6421. }
  6422. json_object_object_add(NotifyReport, "reportData", reportDatas);
  6423. random_uuid(guid);
  6424. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  6425. json_object_put(NotifyReport);
  6426. LWS_SendNow(message);
  6427. sprintf(tempdata, "NotifyReport,0");
  6428. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6429. {
  6430. result = PASS;
  6431. }
  6432. return result;
  6433. }
  6434. int sendPublishFirmwareStatusNotificationRequest()
  6435. {
  6436. mtrace();
  6437. int result = FAIL;
  6438. char message[4096]={0};
  6439. char guid[37]={0};
  6440. char tempdata[128]={0};
  6441. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  6442. json_object *locations = json_object_new_array();
  6443. DEBUG_INFO("sendPublishFirmwareStatusNotificationRequest...\n");
  6444. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  6445. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  6446. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  6447. {
  6448. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  6449. }
  6450. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  6451. random_uuid(guid);
  6452. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  6453. json_object_put(PublishFirmwareStatusNotification);
  6454. LWS_Send(message);
  6455. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  6456. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6457. {
  6458. result = PASS;
  6459. }
  6460. return result;
  6461. }
  6462. int sendReportChargingProfilesRequest(int gun_index)
  6463. {
  6464. mtrace();
  6465. int result = FAIL;
  6466. char message[4096]={0};
  6467. char guid[37]={0};
  6468. char tempdata[128]={0};
  6469. json_object *ReportChargingProfiles = json_object_new_object();
  6470. json_object *chargingProfiles = json_object_new_array();
  6471. DEBUG_INFO("sendReportChargingProfilesRequest...\n");
  6472. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  6473. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  6474. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  6475. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  6476. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  6477. {
  6478. json_object *chargingProfile = json_object_new_object();
  6479. json_object *chargingSchedules = json_object_new_array();
  6480. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  6481. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  6482. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  6483. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  6484. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  6485. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  6486. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  6487. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  6488. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  6489. {
  6490. json_object *chargingSchedule = json_object_new_object();
  6491. json_object *chargingSchedulePeriods = json_object_new_array();
  6492. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  6493. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  6494. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  6495. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  6496. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  6497. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  6498. {
  6499. json_object *chargingSchedulePeriod = json_object_new_object();
  6500. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  6501. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  6502. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  6503. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  6504. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  6505. }
  6506. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  6507. json_object_array_add(chargingSchedules, chargingSchedule);
  6508. }
  6509. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  6510. json_object_array_add(chargingProfiles, chargingProfile);
  6511. }
  6512. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  6513. random_uuid(guid);
  6514. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  6515. json_object_put(ReportChargingProfiles);
  6516. LWS_Send(message);
  6517. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  6518. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6519. {
  6520. result = PASS;
  6521. }
  6522. return result;
  6523. }
  6524. int sendReservationStatusUpdateRequest(int gun_index)
  6525. {
  6526. mtrace();
  6527. int result = FAIL;
  6528. char message[4096]={0};
  6529. char guid[37]={0};
  6530. char tempdata[128]={0};
  6531. json_object *ReservationStatusUpdate = json_object_new_object();
  6532. DEBUG_INFO("sendReservationStatusUpdateRequest...\n");
  6533. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  6534. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  6535. random_uuid(guid);
  6536. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  6537. json_object_put(ReservationStatusUpdate);
  6538. LWS_Send(message);
  6539. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  6540. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6541. {
  6542. result = PASS;
  6543. }
  6544. return result;
  6545. }
  6546. int sendSecurityEventNotificationRequest()
  6547. {
  6548. mtrace();
  6549. int result = FAIL;
  6550. char message[4096]={0};
  6551. char guid[37]={0};
  6552. char tempdata[128]={0};
  6553. json_object *SecurityEventNotification = json_object_new_object();
  6554. DEBUG_INFO("sendSecurityEventNotificationRequest...\n");
  6555. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  6556. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  6557. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techinfo));
  6558. random_uuid(guid);
  6559. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  6560. json_object_put(SecurityEventNotification);
  6561. LWS_Send(message);
  6562. sprintf(tempdata, "SecurityEventNotification,0");
  6563. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6564. {
  6565. result = PASS;
  6566. }
  6567. return result;
  6568. }
  6569. int sendSignCertificateRequest()
  6570. {
  6571. mtrace();
  6572. int result = FAIL;
  6573. char message[4096]={0};
  6574. char guid[37]={0};
  6575. char tempdata[128]={0};
  6576. json_object *SignCertificate = json_object_new_object();
  6577. DEBUG_INFO("sendSignCertificateRequest...\n");
  6578. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  6579. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  6580. random_uuid(guid);
  6581. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  6582. json_object_put(SignCertificate);
  6583. LWS_Send(message);
  6584. sprintf(tempdata, "SignCertificate,0");
  6585. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6586. {
  6587. result = PASS;
  6588. }
  6589. return result;
  6590. }
  6591. int sendStatusNotificationRequest(int gun_index)
  6592. {
  6593. mtrace();
  6594. int result = FAIL;
  6595. char message[600]={0};
  6596. char guid[37];
  6597. int currentStatus = 0;
  6598. struct timeval tmnow;
  6599. struct tm *tm;
  6600. char buf[28];//, usec_buf[6];
  6601. char tempdata[65]={0};
  6602. int tempIndex = 0;
  6603. DEBUG_INFO("sendStatusNotificationRequest...\n");
  6604. gettimeofday(&tmnow, NULL);
  6605. time_t t;
  6606. t = time(NULL);
  6607. /*UTC time and date*/
  6608. tm = gmtime(&t);
  6609. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  6610. #if 0 // remove temporally
  6611. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  6612. strcat(buf,".");
  6613. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  6614. strcat(buf,usec_buf);
  6615. #endif
  6616. printf("%s",buf);
  6617. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  6618. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  6619. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  6620. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  6621. /*
  6622. enum _SYSTEM_STATUS
  6623. {
  6624. S_BOOTING = 0,
  6625. S_IDLE, = 1
  6626. S_AUTHORIZING, =2
  6627. S_REASSIGN_CHECK, =3
  6628. S_REASSIGN, =4
  6629. S_PRECHARGE, =5
  6630. S_PREPARING_FOR_EV, =6
  6631. S_PREPARING_FOR_EVSE, =7
  6632. S_CHARGING, =8
  6633. S_TERMINATING, =9
  6634. S_COMPLETE, =10
  6635. S_ALARM, =11
  6636. S_FAULT =12
  6637. }
  6638. */
  6639. //check Transaction active
  6640. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  6641. if(gunType[gun_index] == 'J')
  6642. {
  6643. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6644. {
  6645. tempIndex = ((gun_index==2) ? 1: 0);
  6646. }
  6647. else
  6648. {
  6649. tempIndex = gun_index;
  6650. }
  6651. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6652. {
  6653. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6654. {
  6655. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6656. {
  6657. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6658. {
  6659. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6660. }
  6661. else
  6662. {
  6663. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6664. }
  6665. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6666. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6667. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6668. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6669. }
  6670. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6671. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6672. ) //S_PRECHARGE
  6673. {
  6674. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6675. }
  6676. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6677. {
  6678. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6679. }
  6680. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6681. {
  6682. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6683. }
  6684. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6685. {
  6686. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6687. }
  6688. 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
  6689. {
  6690. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6691. }
  6692. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6693. {
  6694. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6695. }
  6696. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6697. {
  6698. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6699. }
  6700. } //end of the same index
  6701. }//end of for CHAdeMO_QUANTITY
  6702. }
  6703. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  6704. {
  6705. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6706. {
  6707. tempIndex = ((gun_index==2) ? 1: 0);
  6708. }
  6709. else
  6710. {
  6711. tempIndex = gun_index;
  6712. }
  6713. for (int index = 0; index < CCS_QUANTITY; index++)
  6714. {
  6715. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6716. {
  6717. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6718. {
  6719. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  6720. {
  6721. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6722. }
  6723. else
  6724. {
  6725. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6726. }
  6727. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6728. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6729. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6730. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6731. }
  6732. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6733. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6734. ) //S_PRECHARGE
  6735. {
  6736. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6737. }
  6738. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6739. {
  6740. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6741. }
  6742. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6743. {
  6744. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6745. }
  6746. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  6747. {
  6748. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6749. }
  6750. 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
  6751. {
  6752. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  6753. }
  6754. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6755. {
  6756. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6757. }
  6758. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6759. {
  6760. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6761. }
  6762. } //end of the same index
  6763. } // end of for CCS_QUANTITY
  6764. }
  6765. else if(gunType[gun_index] == 'G')
  6766. {
  6767. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6768. {
  6769. tempIndex = ((gun_index==2) ? 1: 0);
  6770. }
  6771. else
  6772. {
  6773. tempIndex = gun_index;
  6774. }
  6775. for (int index = 0; index < GB_QUANTITY; index++)
  6776. {
  6777. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6778. {
  6779. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6780. {
  6781. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6782. {
  6783. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6784. }
  6785. else
  6786. {
  6787. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6788. }
  6789. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6790. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6791. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6792. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6793. }
  6794. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6795. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6796. ) //S_PRECHARGE
  6797. {
  6798. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6799. }
  6800. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6801. {
  6802. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6803. }
  6804. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6805. {
  6806. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6807. }
  6808. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6809. {
  6810. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6811. }
  6812. 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
  6813. {
  6814. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6815. }
  6816. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6817. {
  6818. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6819. }
  6820. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6821. {
  6822. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6823. }
  6824. } //end of the same index
  6825. } // end of for GB_QUANTITY
  6826. }
  6827. else if(gunType[gun_index] == 'O')
  6828. {
  6829. tempIndex = gun_index;
  6830. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6831. {
  6832. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6833. {
  6834. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6835. {
  6836. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6837. {
  6838. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6839. }
  6840. else
  6841. {
  6842. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6843. }
  6844. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6845. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6846. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6847. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6848. }
  6849. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6850. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6851. ) //S_PRECHARGE
  6852. {
  6853. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6854. }
  6855. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6856. {
  6857. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6858. }
  6859. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6860. {
  6861. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6862. }
  6863. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6864. {
  6865. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6866. }
  6867. 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
  6868. {
  6869. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6870. }
  6871. 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
  6872. {
  6873. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6874. }
  6875. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6876. {
  6877. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6878. }
  6879. } //end of the same index
  6880. }
  6881. }
  6882. else
  6883. {
  6884. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6885. {
  6886. tempIndex = 2;
  6887. }
  6888. else
  6889. {
  6890. tempIndex = gun_index;
  6891. }
  6892. for (int index = 0; index < AC_QUANTITY; index++)
  6893. {
  6894. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6895. {
  6896. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  6897. {
  6898. 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))
  6899. {
  6900. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6901. }
  6902. else
  6903. {
  6904. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6905. }
  6906. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6907. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6908. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6909. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6910. }
  6911. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  6912. {
  6913. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6914. }
  6915. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  6916. {
  6917. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6918. }
  6919. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  6920. {
  6921. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6922. }
  6923. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6924. {
  6925. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6926. }
  6927. 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
  6928. {
  6929. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6930. }
  6931. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6932. {
  6933. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6934. }
  6935. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6936. {
  6937. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6938. }
  6939. }//end of the same index
  6940. }//end of for AC_QUANTITY
  6941. }
  6942. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  6943. random_uuid(guid);
  6944. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  6945. , MESSAGE_TYPE_CALL
  6946. , guid
  6947. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  6948. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  6949. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  6950. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  6951. if((server_sign == TRUE))
  6952. {
  6953. LWS_Send(message);
  6954. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  6955. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6956. {
  6957. result = PASS;
  6958. }
  6959. }
  6960. else
  6961. {
  6962. result = PASS;
  6963. }
  6964. return result;
  6965. }
  6966. int sendTransactionEventRequest(int gun_index)
  6967. {
  6968. mtrace();
  6969. int result = FAIL;
  6970. char message[1024*20]={0};
  6971. char guid[37]={0};
  6972. char tempdata[128]={0};
  6973. uint8_t tempIndex;
  6974. json_object *TransactionEvent = json_object_new_object();
  6975. json_object *transactionInfo = json_object_new_object();
  6976. json_object *idToken = json_object_new_object();
  6977. json_object *evse = json_object_new_object();
  6978. json_object *meterValues = json_object_new_array();
  6979. DEBUG_INFO("sendTransactionEventRequest...\n");
  6980. if(gunType[gun_index] == 'J')
  6981. {
  6982. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6983. {
  6984. tempIndex = ((gun_index==2) ? 1: 0);
  6985. }
  6986. else
  6987. {
  6988. tempIndex = gun_index;
  6989. }
  6990. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6991. {
  6992. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6993. {
  6994. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  6995. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  6996. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  6997. else
  6998. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  6999. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7000. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7001. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7002. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  7003. {
  7004. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7005. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7006. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7007. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7008. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7009. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7010. {
  7011. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7012. }
  7013. else
  7014. {
  7015. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7016. }
  7017. }
  7018. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7019. {
  7020. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7021. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7022. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7023. }
  7024. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7025. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7026. ) //S_PRECHARGE
  7027. {
  7028. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7029. {
  7030. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7031. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  7032. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7033. }
  7034. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7035. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7036. else
  7037. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7038. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7039. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7040. }
  7041. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7042. {
  7043. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7044. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7045. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7046. }
  7047. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7048. {
  7049. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7050. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7051. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7052. }
  7053. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7054. {
  7055. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7056. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7057. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7058. }
  7059. 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
  7060. {
  7061. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7062. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7063. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7064. }
  7065. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7066. {
  7067. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7068. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7069. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7070. }
  7071. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7072. {
  7073. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7074. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7075. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7076. }
  7077. } //end of the same index
  7078. }//end of for CHAdeMO_QUANTITY
  7079. }
  7080. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  7081. {
  7082. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7083. {
  7084. tempIndex = ((gun_index==2) ? 1: 0);
  7085. }
  7086. else
  7087. {
  7088. tempIndex = gun_index;
  7089. }
  7090. for (int index = 0; index < CCS_QUANTITY; index++)
  7091. {
  7092. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7093. {
  7094. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7095. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7096. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7097. else
  7098. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7099. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7100. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7101. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7102. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7103. {
  7104. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7105. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7106. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7107. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7108. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7109. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7110. {
  7111. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7112. }
  7113. else
  7114. {
  7115. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7116. }
  7117. }
  7118. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7119. {
  7120. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7121. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7122. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7123. }
  7124. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7125. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7126. ) //S_PRECHARGE
  7127. {
  7128. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7129. {
  7130. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7131. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  7132. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7133. }
  7134. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7135. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7136. else
  7137. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7138. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7139. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7140. }
  7141. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7142. {
  7143. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7144. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7145. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7146. }
  7147. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7148. {
  7149. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7150. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7151. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7152. }
  7153. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7154. {
  7155. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7156. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7157. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7158. }
  7159. 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
  7160. {
  7161. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7162. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7163. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7164. }
  7165. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7166. {
  7167. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7168. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7169. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7170. }
  7171. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7172. {
  7173. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7174. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7175. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7176. }
  7177. } //end of the same index
  7178. } // end of for CCS_QUANTITY
  7179. }
  7180. else if(gunType[gun_index] == 'G')
  7181. {
  7182. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7183. {
  7184. tempIndex = ((gun_index==2) ? 1: 0);
  7185. }
  7186. else
  7187. {
  7188. tempIndex = gun_index;
  7189. }
  7190. for (int index = 0; index < GB_QUANTITY; index++)
  7191. {
  7192. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7193. {
  7194. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7195. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7196. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7197. else
  7198. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7199. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7200. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7201. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7202. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7203. {
  7204. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7205. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7206. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7207. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7208. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7209. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7210. {
  7211. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7212. }
  7213. else
  7214. {
  7215. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7216. }
  7217. }
  7218. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7219. {
  7220. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7221. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7222. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7223. }
  7224. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7225. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7226. ) //S_PRECHARGE
  7227. {
  7228. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7229. {
  7230. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7231. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  7232. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7233. }
  7234. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7235. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7236. else
  7237. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7238. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7239. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7240. }
  7241. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7242. {
  7243. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7244. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7245. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7246. }
  7247. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7248. {
  7249. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7250. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7251. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7252. }
  7253. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7254. {
  7255. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7256. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7257. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7258. }
  7259. 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
  7260. {
  7261. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7262. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7263. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7264. }
  7265. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7266. {
  7267. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7268. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7269. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7270. }
  7271. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7272. {
  7273. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7274. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7275. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7276. }
  7277. } //end of the same index
  7278. } // end of for GB_QUANTITY
  7279. }
  7280. else if(gunType[gun_index] == 'O')
  7281. {
  7282. tempIndex = gun_index;
  7283. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7284. {
  7285. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7286. {
  7287. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7288. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7289. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7290. else
  7291. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7292. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7293. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7294. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7295. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7296. {
  7297. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7298. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7299. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7300. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7301. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7302. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7303. {
  7304. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7305. }
  7306. else
  7307. {
  7308. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7309. }
  7310. }
  7311. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7312. {
  7313. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7314. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7315. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7316. }
  7317. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7318. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7319. ) //S_PRECHARGE
  7320. {
  7321. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7322. {
  7323. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7324. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  7325. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7326. }
  7327. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7328. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7329. else
  7330. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7331. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7332. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7333. }
  7334. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7335. {
  7336. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7337. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7338. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7339. }
  7340. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7341. {
  7342. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7343. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7344. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7345. }
  7346. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7347. {
  7348. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7349. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7350. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7351. }
  7352. 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
  7353. {
  7354. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7355. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7356. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7357. }
  7358. 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
  7359. {
  7360. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7361. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7362. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7363. }
  7364. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7365. {
  7366. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7367. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7368. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7369. }
  7370. } //end of the same index
  7371. }
  7372. }
  7373. else
  7374. {
  7375. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7376. {
  7377. tempIndex = 2;
  7378. }
  7379. else
  7380. {
  7381. tempIndex = gun_index;
  7382. }
  7383. for (int index = 0; index < AC_QUANTITY; index++)
  7384. {
  7385. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7386. {
  7387. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7388. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7389. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7390. else
  7391. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7392. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7393. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7394. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7395. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  7396. {
  7397. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7398. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7399. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7400. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7401. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7402. 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))
  7403. {
  7404. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7405. }
  7406. else
  7407. {
  7408. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7409. }
  7410. }
  7411. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7412. {
  7413. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7414. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7415. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7416. }
  7417. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7418. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7419. ) //S_PRECHARGE
  7420. {
  7421. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7422. {
  7423. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7424. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  7425. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7426. }
  7427. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7428. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7429. else
  7430. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7431. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7432. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7433. }
  7434. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7435. {
  7436. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7437. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7438. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7439. }
  7440. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7441. {
  7442. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7443. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7444. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7445. }
  7446. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7447. {
  7448. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7449. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7450. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7451. }
  7452. 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
  7453. {
  7454. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7455. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7456. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7457. }
  7458. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7459. {
  7460. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7461. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7462. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7463. }
  7464. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7465. {
  7466. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7467. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7468. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7469. }
  7470. }//end of the same index
  7471. }//end of for AC_QUANTITY
  7472. }
  7473. // Message
  7474. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7475. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  7476. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  7477. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  7478. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  7479. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  7480. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  7481. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  7482. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  7483. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  7484. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  7485. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  7486. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  7487. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  7488. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  7489. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  7490. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  7491. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  7492. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  7493. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  7494. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  7495. {
  7496. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  7497. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  7498. json_object_object_add(TransactionEvent, "idToken", idToken);
  7499. }
  7500. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  7501. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  7502. json_object_object_add(TransactionEvent, "evse", evse);
  7503. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  7504. {
  7505. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  7506. {
  7507. json_object *meterValue = json_object_new_object();
  7508. json_object *sampledValues = json_object_new_array();
  7509. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  7510. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  7511. {
  7512. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  7513. ((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)))
  7514. {
  7515. json_object *sampledValue = json_object_new_object();
  7516. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  7517. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7518. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  7519. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  7520. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  7521. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  7522. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  7523. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  7524. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  7525. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  7526. {
  7527. json_object *unitOfMeasure = json_object_new_object();
  7528. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  7529. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  7530. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  7531. }
  7532. json_object_array_add(sampledValues, sampledValue);
  7533. }
  7534. }
  7535. json_object_object_add(meterValue, "sampledValue", sampledValues);
  7536. json_object_array_add(meterValues, meterValue);
  7537. }
  7538. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  7539. }
  7540. random_uuid(guid);
  7541. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  7542. json_object_put(TransactionEvent);
  7543. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  7544. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7545. {
  7546. result = PASS;
  7547. }
  7548. queue_operation(QUEUE_OPERATION_ADD, guid, message);
  7549. return result;
  7550. }
  7551. //==========================================
  7552. // send confirm routine
  7553. //==========================================
  7554. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  7555. {
  7556. mtrace();
  7557. int result = FAIL;
  7558. char message[4096]={0};
  7559. json_object *CancelReservation = json_object_new_object();
  7560. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  7561. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  7562. sprintf(message,"[%d,\"%s\",%s]"
  7563. ,MESSAGE_TYPE_CALLRESULT
  7564. ,uuid
  7565. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  7566. json_object_put(CancelReservation);
  7567. ShmOCPP20Data->CsMsg.bits[0].CancelReservationConf = OFF;
  7568. LWS_Send(message);
  7569. result = TRUE;
  7570. return result;
  7571. }
  7572. int sendCertificateSignedConfirmation(char *uuid)
  7573. {
  7574. mtrace();
  7575. int result = FAIL;
  7576. char message[4096]={0};
  7577. json_object *CertificateSigned = json_object_new_object();
  7578. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  7579. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  7580. sprintf(message,"[%d,\"%s\",%s]"
  7581. ,MESSAGE_TYPE_CALLRESULT
  7582. ,uuid
  7583. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  7584. json_object_put(CertificateSigned);
  7585. LWS_Send(message);
  7586. result = TRUE;
  7587. return result;
  7588. }
  7589. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  7590. {
  7591. mtrace();
  7592. int result = FAIL;
  7593. char message[4096]={0};
  7594. json_object *ChangeAvailability = json_object_new_object();
  7595. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  7596. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  7597. sprintf(message,"[%d,\"%s\",%s]"
  7598. ,MESSAGE_TYPE_CALLRESULT
  7599. ,uuid
  7600. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  7601. json_object_put(ChangeAvailability);
  7602. LWS_Send(message);
  7603. result = TRUE;
  7604. return result;
  7605. }
  7606. int sendClearCacheConfirmation(char *uuid)
  7607. {
  7608. mtrace();
  7609. int result = FAIL;
  7610. char message[4096]={0};
  7611. json_object *ClearCache = json_object_new_object();
  7612. DEBUG_INFO("sendClearCacheConfirmation...\n");
  7613. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  7614. sprintf(message,"[%d,\"%s\",%s]"
  7615. ,MESSAGE_TYPE_CALLRESULT
  7616. ,uuid
  7617. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  7618. json_object_put(ClearCache);
  7619. LWS_Send(message);
  7620. result = TRUE;
  7621. return result;
  7622. }
  7623. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  7624. {
  7625. mtrace();
  7626. int result = FAIL;
  7627. char message[500]={0};
  7628. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  7629. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  7630. LWS_Send(message);
  7631. return result;
  7632. }
  7633. int sendClearDisplayMessageConfirmation(char *uuid)
  7634. {
  7635. mtrace();
  7636. int result = FAIL;
  7637. char message[4096]={0};
  7638. json_object *ClearDisplayMessage = json_object_new_object();
  7639. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  7640. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  7641. sprintf(message,"[%d,\"%s\",%s]"
  7642. ,MESSAGE_TYPE_CALLRESULT
  7643. ,uuid
  7644. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  7645. json_object_put(ClearDisplayMessage);
  7646. LWS_Send(message);
  7647. result = TRUE;
  7648. return result;
  7649. }
  7650. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  7651. {
  7652. mtrace();
  7653. int result = FAIL;
  7654. char message[4096]={0};
  7655. json_object *ClearVariableMonitoring = json_object_new_object();
  7656. json_object *clearMonitoringResults = json_object_new_array();
  7657. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  7658. for(int idx=0;idx<variableQuantity;idx++)
  7659. {
  7660. json_object *clearMonitoringResult = json_object_new_object();
  7661. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  7662. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  7663. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  7664. }
  7665. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  7666. sprintf(message,"[%d,\"%s\",%s]"
  7667. ,MESSAGE_TYPE_CALLRESULT
  7668. ,uuid
  7669. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  7670. json_object_put(ClearVariableMonitoring);
  7671. LWS_Send(message);
  7672. result = TRUE;
  7673. return result;
  7674. }
  7675. int sendCostUpdatedConfirmation(char *uuid)
  7676. {
  7677. mtrace();
  7678. int result = FAIL;
  7679. char message[4096]={0};
  7680. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  7681. sprintf(message,"[%d,\"%s\",{}]"
  7682. ,MESSAGE_TYPE_CALLRESULT
  7683. ,uuid);
  7684. LWS_Send(message);
  7685. result = TRUE;
  7686. return result;
  7687. }
  7688. int sendCustomerInformationConfirmation(char *uuid)
  7689. {
  7690. mtrace();
  7691. int result = FAIL;
  7692. char message[4096]={0};
  7693. json_object *CustomerInformation = json_object_new_object();
  7694. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  7695. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  7696. sprintf(message,"[%d,\"%s\",%s]"
  7697. ,MESSAGE_TYPE_CALLRESULT
  7698. ,uuid
  7699. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  7700. json_object_put(CustomerInformation);
  7701. LWS_Send(message);
  7702. result = TRUE;
  7703. return result;
  7704. }
  7705. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  7706. {
  7707. mtrace();
  7708. int result = FAIL;
  7709. char message[4096]={0};
  7710. json_object *DataTransfer = json_object_new_object();
  7711. DEBUG_INFO("sendDataTransferConfirmation...\n");
  7712. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  7713. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  7714. sprintf(message,"[%d,\"%s\",%s]"
  7715. ,MESSAGE_TYPE_CALLRESULT
  7716. ,uuid
  7717. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  7718. json_object_put(DataTransfer);
  7719. LWS_Send(message);
  7720. result = TRUE;
  7721. return result;
  7722. }
  7723. int sendDeleteCertificateConfirmation(char *uuid)
  7724. {
  7725. mtrace();
  7726. int result = FAIL;
  7727. char message[4096]={0};
  7728. json_object *DeleteCertificate = json_object_new_object();
  7729. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  7730. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  7731. sprintf(message,"[%d,\"%s\",%s]"
  7732. ,MESSAGE_TYPE_CALLRESULT
  7733. ,uuid
  7734. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  7735. json_object_put(DeleteCertificate);
  7736. LWS_Send(message);
  7737. result = TRUE;
  7738. return result;
  7739. }
  7740. int sendGetBaseReportConfirmation(char *uuid)
  7741. {
  7742. mtrace();
  7743. int result = FAIL;
  7744. char message[4096]={0};
  7745. json_object *GetBaseReport = json_object_new_object();
  7746. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  7747. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  7748. sprintf(message,"[%d,\"%s\",%s]"
  7749. ,MESSAGE_TYPE_CALLRESULT
  7750. ,uuid
  7751. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  7752. json_object_put(GetBaseReport);
  7753. LWS_Send(message);
  7754. result = TRUE;
  7755. return result;
  7756. }
  7757. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  7758. {
  7759. mtrace();
  7760. int result = FAIL;
  7761. char message[4096]={0};
  7762. json_object *GetChargingProfiles = json_object_new_object();
  7763. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  7764. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  7765. sprintf(message,"[%d,\"%s\",%s]"
  7766. ,MESSAGE_TYPE_CALLRESULT
  7767. ,uuid
  7768. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  7769. json_object_put(GetChargingProfiles);
  7770. LWS_Send(message);
  7771. result = TRUE;
  7772. return result;
  7773. }
  7774. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  7775. {
  7776. mtrace();
  7777. int result = FAIL;
  7778. char message[4096]={0};
  7779. int CompositeScheduleIndex = 0;
  7780. json_object *GetCompositeSchedule = json_object_new_object();
  7781. json_object *schedule = json_object_new_object();
  7782. json_object *chargingSchedule = json_object_new_object();
  7783. json_object *chargingSchedulePeriod = json_object_new_array();
  7784. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  7785. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  7786. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  7787. if(nPeriod == 0)
  7788. {
  7789. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  7790. {
  7791. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7792. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7793. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7794. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7795. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7796. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7797. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7798. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7799. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7800. {
  7801. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7802. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7803. {
  7804. json_object *Period = json_object_new_object();
  7805. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7806. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7807. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7808. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7809. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7810. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7811. json_object_array_add(chargingSchedulePeriod, Period);
  7812. }
  7813. }
  7814. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7815. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7816. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7817. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7818. }
  7819. }
  7820. else
  7821. {
  7822. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7823. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7824. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7825. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7826. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7827. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7828. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7829. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7830. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7831. {
  7832. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7833. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7834. {
  7835. json_object *Period = json_object_new_object();
  7836. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7837. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7838. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7839. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7840. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7841. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7842. json_object_array_add(chargingSchedulePeriod, Period);
  7843. }
  7844. }
  7845. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7846. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7847. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7848. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7849. }
  7850. sprintf(message,"[%d,\"%s\",%s]"
  7851. ,MESSAGE_TYPE_CALLRESULT
  7852. ,uuid
  7853. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  7854. json_object_put(GetCompositeSchedule);
  7855. LWS_Send(message);
  7856. result = TRUE;
  7857. return result;
  7858. }
  7859. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  7860. {
  7861. mtrace();
  7862. int result = FAIL;
  7863. char message[4096]={0};
  7864. json_object *GetGetDisplayMessages = json_object_new_object();
  7865. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  7866. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  7867. sprintf(message,"[%d,\"%s\",%s]"
  7868. ,MESSAGE_TYPE_CALLRESULT
  7869. ,uuid
  7870. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  7871. json_object_put(GetGetDisplayMessages);
  7872. LWS_Send(message);
  7873. result = TRUE;
  7874. return result;
  7875. }
  7876. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  7877. {
  7878. mtrace();
  7879. int result = FAIL;
  7880. char message[4096]={0};
  7881. json_object *GetInstalledCertificateIds = json_object_new_object();
  7882. json_object *certificateHashDataChains = json_object_new_array();
  7883. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  7884. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  7885. for(int idx=0;idx<certQuantity;idx++)
  7886. {
  7887. json_object *cert = json_object_new_object();
  7888. json_object *certificateHashData = json_object_new_object();
  7889. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  7890. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  7891. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  7892. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  7893. json_object_object_add(cert, "certificateHashData", certificateHashData);
  7894. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  7895. json_object_array_add(certificateHashDataChains, cert);
  7896. }
  7897. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  7898. sprintf(message,"[%d,\"%s\",%s]"
  7899. ,MESSAGE_TYPE_CALLRESULT
  7900. ,uuid
  7901. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  7902. json_object_put(GetInstalledCertificateIds);
  7903. LWS_Send(message);
  7904. result = TRUE;
  7905. return result;
  7906. }
  7907. int sendGetLocalListVersionConfirmation(char *uuid)
  7908. {
  7909. mtrace();
  7910. int result = FAIL;
  7911. char message[4096]={0};
  7912. json_object *GetLocalListVersion = json_object_new_object();
  7913. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  7914. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  7915. sprintf(message,"[%d,\"%s\",%s]"
  7916. ,MESSAGE_TYPE_CALLRESULT
  7917. ,uuid
  7918. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  7919. json_object_put(GetLocalListVersion);
  7920. LWS_Send(message);
  7921. result = TRUE;
  7922. return result;
  7923. }
  7924. int sendGetLogConfirmation(char *uuid)
  7925. {
  7926. mtrace();
  7927. int result = FAIL;
  7928. char message[4096]={0};
  7929. json_object *GetLog = json_object_new_object();
  7930. DEBUG_INFO("sendGetLogConfirmation...\n");
  7931. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  7932. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  7933. sprintf(message,"[%d,\"%s\",%s]"
  7934. ,MESSAGE_TYPE_CALLRESULT
  7935. ,uuid
  7936. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  7937. json_object_put(GetLog);
  7938. LWS_Send(message);
  7939. result = TRUE;
  7940. return result;
  7941. }
  7942. int sendGetMonitoringReportConfirmation(char *uuid)
  7943. {
  7944. mtrace();
  7945. int result = FAIL;
  7946. char message[4096]={0};
  7947. json_object *GetMonitoringReport = json_object_new_object();
  7948. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  7949. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  7950. sprintf(message,"[%d,\"%s\",%s]"
  7951. ,MESSAGE_TYPE_CALLRESULT
  7952. ,uuid
  7953. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  7954. json_object_put(GetMonitoringReport);
  7955. LWS_Send(message);
  7956. result = TRUE;
  7957. return result;
  7958. }
  7959. int sendGetReportConfirmation(char *uuid)
  7960. {
  7961. mtrace();
  7962. int result = FAIL;
  7963. char message[4096]={0};
  7964. json_object *GetReport = json_object_new_object();
  7965. DEBUG_INFO("sendGetReportConfirmation...\n");
  7966. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  7967. sprintf(message,"[%d,\"%s\",%s]"
  7968. ,MESSAGE_TYPE_CALLRESULT
  7969. ,uuid
  7970. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  7971. json_object_put(GetReport);
  7972. LWS_Send(message);
  7973. result = TRUE;
  7974. return result;
  7975. }
  7976. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  7977. {
  7978. mtrace();
  7979. int result = FAIL;
  7980. char message[4096]={0};
  7981. json_object *GetTransactionStatus = json_object_new_object();
  7982. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  7983. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  7984. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  7985. sprintf(message,"[%d,\"%s\",%s]"
  7986. ,MESSAGE_TYPE_CALLRESULT
  7987. ,uuid
  7988. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  7989. json_object_put(GetTransactionStatus);
  7990. LWS_Send(message);
  7991. result = TRUE;
  7992. return result;
  7993. }
  7994. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  7995. {
  7996. mtrace();
  7997. int result = FAIL;
  7998. char message[4096]={0};
  7999. json_object *GetVariables = json_object_new_object();
  8000. json_object *getVariableResults = json_object_new_array();
  8001. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  8002. for(int idx=0;idx<variableQuantity;idx++)
  8003. {
  8004. json_object *variableResult = json_object_new_object();
  8005. json_object *component = json_object_new_object();
  8006. json_object *variable = json_object_new_object();
  8007. json_object *evse = json_object_new_object();
  8008. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  8009. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  8010. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  8011. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  8012. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  8013. json_object_object_add(component, "evse", evse);
  8014. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  8015. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  8016. json_object_object_add(variableResult, "component", component);
  8017. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  8018. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  8019. json_object_object_add(variableResult, "variable", variable);
  8020. json_object_array_add(getVariableResults, variableResult);
  8021. }
  8022. json_object_object_add(GetVariables , "getVariableResult", getVariableResults);
  8023. sprintf(message,"[%d,\"%s\",%s]"
  8024. ,MESSAGE_TYPE_CALLRESULT
  8025. ,uuid
  8026. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  8027. json_object_put(GetVariables);
  8028. LWS_Send(message);
  8029. result = TRUE;
  8030. return result;
  8031. }
  8032. int sendInstallCertificateConfirmation(char *uuid)
  8033. {
  8034. mtrace();
  8035. int result = FAIL;
  8036. char message[4096]={0};
  8037. json_object *InstallCertificate = json_object_new_object();
  8038. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  8039. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  8040. sprintf(message,"[%d,\"%s\",%s]"
  8041. ,MESSAGE_TYPE_CALLRESULT
  8042. ,uuid
  8043. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  8044. json_object_put(InstallCertificate);
  8045. LWS_Send(message);
  8046. result = TRUE;
  8047. return result;
  8048. }
  8049. int sendPublishFirmwareConfirmation(char *uuid)
  8050. {
  8051. mtrace();
  8052. int result = FAIL;
  8053. char message[4096]={0};
  8054. json_object *PublishFirmware = json_object_new_object();
  8055. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  8056. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  8057. sprintf(message,"[%d,\"%s\",%s]"
  8058. ,MESSAGE_TYPE_CALLRESULT
  8059. ,uuid
  8060. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  8061. json_object_put(PublishFirmware);
  8062. LWS_Send(message);
  8063. result = TRUE;
  8064. return result;
  8065. }
  8066. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  8067. {
  8068. mtrace();
  8069. int result = FAIL;
  8070. char message[4096]={0};
  8071. json_object *RemoteStartTransaction = json_object_new_object();
  8072. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  8073. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  8074. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  8075. sprintf(message,"[%d,\"%s\",%s]"
  8076. ,MESSAGE_TYPE_CALLRESULT
  8077. ,uuid
  8078. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  8079. json_object_put(RemoteStartTransaction);
  8080. LWS_Send(message);
  8081. result = TRUE;
  8082. return result;
  8083. }
  8084. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  8085. {
  8086. mtrace();
  8087. int result = FAIL;
  8088. char message[4096]={0};
  8089. json_object *RemoteStopTransaction = json_object_new_object();
  8090. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  8091. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  8092. sprintf(message,"[%d,\"%s\",%s]"
  8093. ,MESSAGE_TYPE_CALLRESULT
  8094. ,uuid
  8095. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  8096. json_object_put(RemoteStopTransaction);
  8097. LWS_Send(message);
  8098. result = TRUE;
  8099. return result;
  8100. }
  8101. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  8102. {
  8103. mtrace();
  8104. int result = FAIL;
  8105. char message[4096]={0};
  8106. json_object *ReserveNow = json_object_new_object();
  8107. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  8108. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  8109. sprintf(message,"[%d,\"%s\",%s]"
  8110. ,MESSAGE_TYPE_CALLRESULT
  8111. ,uuid
  8112. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  8113. json_object_put(ReserveNow);
  8114. LWS_Send(message);
  8115. result = TRUE;
  8116. return result;
  8117. }
  8118. int sendResetConfirmation(char *uuid)
  8119. {
  8120. mtrace();
  8121. int result = FAIL;
  8122. char message[4096]={0};
  8123. json_object *Reset = json_object_new_object();
  8124. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  8125. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  8126. sprintf(message,"[%d,\"%s\",%s]"
  8127. ,MESSAGE_TYPE_CALLRESULT
  8128. ,uuid
  8129. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  8130. json_object_put(Reset);
  8131. LWS_Send(message);
  8132. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  8133. {
  8134. DB_updateBootType(BootReasonEnumType_RemoteReset);
  8135. }
  8136. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  8137. {
  8138. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  8139. }
  8140. result = TRUE;
  8141. return result;
  8142. }
  8143. int sendSendLocalListConfirmation(char *uuid)
  8144. {
  8145. mtrace();
  8146. int result = FAIL;
  8147. char message[4096]={0};
  8148. json_object *SendLocalList = json_object_new_object();
  8149. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  8150. sprintf(message,"[%d,\"%s\",%s]"
  8151. ,MESSAGE_TYPE_CALLRESULT
  8152. ,uuid
  8153. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  8154. json_object_put(SendLocalList);
  8155. LWS_Send(message);
  8156. result = TRUE;
  8157. return result;
  8158. }
  8159. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  8160. {
  8161. mtrace();
  8162. int result = FAIL;
  8163. char message[4096]={0};
  8164. json_object *SetChargingProfile = json_object_new_object();
  8165. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  8166. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  8167. sprintf(message,"[%d,\"%s\",%s]"
  8168. ,MESSAGE_TYPE_CALLRESULT
  8169. ,uuid
  8170. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  8171. json_object_put(SetChargingProfile);
  8172. LWS_Send(message);
  8173. result = TRUE;
  8174. return result;
  8175. }
  8176. int sendSetDisplayMessageConfirmation(char *uuid)
  8177. {
  8178. mtrace();
  8179. int result = FAIL;
  8180. char message[4096]={0};
  8181. json_object *SetDisplayMessage = json_object_new_object();
  8182. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  8183. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  8184. sprintf(message,"[%d,\"%s\",%s]"
  8185. ,MESSAGE_TYPE_CALLRESULT
  8186. ,uuid
  8187. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  8188. json_object_put(SetDisplayMessage);
  8189. LWS_Send(message);
  8190. result = TRUE;
  8191. return result;
  8192. }
  8193. int sendSetMonitoringBaseConfirmation(char *uuid)
  8194. {
  8195. mtrace();
  8196. int result = FAIL;
  8197. char message[4096]={0};
  8198. json_object *SetMonitoringBase = json_object_new_object();
  8199. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  8200. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  8201. sprintf(message,"[%d,\"%s\",%s]"
  8202. ,MESSAGE_TYPE_CALLRESULT
  8203. ,uuid
  8204. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  8205. json_object_put(SetMonitoringBase);
  8206. LWS_Send(message);
  8207. result = TRUE;
  8208. return result;
  8209. }
  8210. int sendSetMonitoringLevelConfirmation(char *uuid)
  8211. {
  8212. mtrace();
  8213. int result = FAIL;
  8214. char message[4096]={0};
  8215. json_object *SetMonitoringLevel = json_object_new_object();
  8216. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  8217. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  8218. sprintf(message,"[%d,\"%s\",%s]"
  8219. ,MESSAGE_TYPE_CALLRESULT
  8220. ,uuid
  8221. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  8222. json_object_put(SetMonitoringLevel);
  8223. LWS_Send(message);
  8224. result = TRUE;
  8225. return result;
  8226. }
  8227. int sendSetNetworkProfileConfirmation(char *uuid)
  8228. {
  8229. mtrace();
  8230. int result = FAIL;
  8231. char message[4096]={0};
  8232. json_object *SetNetworkProfile = json_object_new_object();
  8233. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  8234. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  8235. sprintf(message,"[%d,\"%s\",%s]"
  8236. ,MESSAGE_TYPE_CALLRESULT
  8237. ,uuid
  8238. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  8239. json_object_put(SetNetworkProfile);
  8240. LWS_Send(message);
  8241. result = TRUE;
  8242. return result;
  8243. }
  8244. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  8245. {
  8246. mtrace();
  8247. int result = FAIL;
  8248. char message[4096]={0};
  8249. json_object *SetVariableMonitoring = json_object_new_object();
  8250. json_object *setMonitoringResults = json_object_new_array();
  8251. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  8252. for(int idx=0;idx<variableQuantity;idx++)
  8253. {
  8254. json_object *variableMonitorResult = json_object_new_object();
  8255. json_object *component = json_object_new_object();
  8256. json_object *variable = json_object_new_object();
  8257. json_object *evse = json_object_new_object();
  8258. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  8259. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  8260. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  8261. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  8262. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  8263. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  8264. json_object_object_add(component, "component", evse);
  8265. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  8266. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  8267. json_object_object_add(variableMonitorResult, "component", component);
  8268. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  8269. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  8270. json_object_object_add(variableMonitorResult, "variable", variable);
  8271. json_object_array_add(setMonitoringResults, variableMonitorResult);
  8272. }
  8273. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  8274. sprintf(message,"[%d,\"%s\",%s]"
  8275. ,MESSAGE_TYPE_CALLRESULT
  8276. ,uuid
  8277. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  8278. json_object_put(SetVariableMonitoring);
  8279. LWS_Send(message);
  8280. result = TRUE;
  8281. return result;
  8282. }
  8283. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  8284. {
  8285. mtrace();
  8286. int result = FAIL;
  8287. char message[4096]={0};
  8288. json_object *SetVariable = json_object_new_object();
  8289. json_object *setVariableResults = json_object_new_array();
  8290. DEBUG_INFO("sendSetVariableConfirmation...\n");
  8291. for(int idx=0;idx<variableQuantity;idx++)
  8292. {
  8293. json_object *variableResult = json_object_new_object();
  8294. json_object *component = json_object_new_object();
  8295. json_object *variable = json_object_new_object();
  8296. json_object *evse = json_object_new_object();
  8297. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  8298. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  8299. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  8300. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  8301. json_object_object_add(component, "component", evse);
  8302. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  8303. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  8304. json_object_object_add(variableResult, "component", component);
  8305. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  8306. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  8307. json_object_object_add(variableResult, "variable", variable);
  8308. json_object_array_add(setVariableResults, variableResult);
  8309. }
  8310. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  8311. sprintf(message,"[%d,\"%s\",%s]"
  8312. ,MESSAGE_TYPE_CALLRESULT
  8313. ,uuid
  8314. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  8315. json_object_put(SetVariable);
  8316. LWS_Send(message);
  8317. result = TRUE;
  8318. return result;
  8319. }
  8320. int sendTriggerMessageConfirmation(char *uuid)
  8321. {
  8322. mtrace();
  8323. int result = FAIL;
  8324. char message[4096]={0};
  8325. json_object *TriggerMessage = json_object_new_object();
  8326. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  8327. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  8328. sprintf(message,"[%d,\"%s\",%s]",
  8329. MESSAGE_TYPE_CALLRESULT,
  8330. uuid,
  8331. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  8332. json_object_put(TriggerMessage);
  8333. LWS_Send(message);
  8334. result = TRUE;
  8335. return result;
  8336. }
  8337. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  8338. {
  8339. mtrace();
  8340. int result = FAIL;
  8341. char message[4096]={0};
  8342. json_object *UnlockConnector = json_object_new_object();
  8343. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  8344. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  8345. sprintf(message,"[%d,\"%s\",%s]",
  8346. MESSAGE_TYPE_CALLRESULT,
  8347. uuid,
  8348. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  8349. json_object_put(UnlockConnector);
  8350. LWS_Send(message);
  8351. result = TRUE;
  8352. return result;
  8353. }
  8354. int sendUnpublishFirmwareConfirmation(char *uuid)
  8355. {
  8356. mtrace();
  8357. int result = FAIL;
  8358. char message[4096]={0};
  8359. json_object *UnpublishFirmware = json_object_new_object();
  8360. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  8361. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  8362. sprintf(message,"[%d,\"%s\",%s]"
  8363. ,MESSAGE_TYPE_CALLRESULT
  8364. ,uuid
  8365. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  8366. json_object_put(UnpublishFirmware);
  8367. LWS_Send(message);
  8368. result = TRUE;
  8369. return result;
  8370. }
  8371. int sendUpdateFirmwareConfirmation(char *uuid)
  8372. {
  8373. mtrace();
  8374. int result = FAIL;
  8375. char message[4096]={0};
  8376. json_object *UpdateFirmware = json_object_new_object();
  8377. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  8378. sprintf((char*)ShmOCPP20Data->UpdateFirmware.Response_status, "%s", UpdateFirmwareStatusEnumTypeStr[UpdateFirmwareStatusEnumType_Accepted]);
  8379. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  8380. sprintf(message,"[%d,\"%s\",%s]"
  8381. ,MESSAGE_TYPE_CALLRESULT
  8382. ,uuid
  8383. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  8384. json_object_put(UpdateFirmware);
  8385. LWS_Send(message);
  8386. result = TRUE;
  8387. return result;
  8388. }
  8389. //==========================================
  8390. // send CallError routine
  8391. //==========================================
  8392. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  8393. {
  8394. mtrace();
  8395. char message[220]={0};
  8396. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  8397. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  8398. LWS_Send(message);
  8399. }
  8400. //==========================================
  8401. // Handle server request routine Start
  8402. //==========================================
  8403. int handleCancelReservationRequest(char *uuid, char *payload)
  8404. {
  8405. mtrace();
  8406. int result = FAIL;
  8407. int gunNO = 0;
  8408. int reservationIdInt = -1;
  8409. DEBUG_INFO("handleCancelReservationRequest...\n");
  8410. json_object *CancelReservation;
  8411. CancelReservation = json_tokener_parse(payload);
  8412. if(!is_error(CancelReservation))
  8413. {
  8414. // Required data
  8415. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  8416. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  8417. }
  8418. json_object_put(CancelReservation);
  8419. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  8420. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  8421. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  8422. if(reservationIdInt != -1)
  8423. {
  8424. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  8425. //check Transaction active
  8426. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  8427. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8428. {
  8429. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  8430. {
  8431. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8432. if(gunType[2] == 'J')
  8433. {
  8434. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  8435. }
  8436. else
  8437. {
  8438. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  8439. }
  8440. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8441. goto end;
  8442. }
  8443. }
  8444. for (int index = 0; index < CCS_QUANTITY; index++)
  8445. {
  8446. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  8447. {
  8448. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8449. if((gunType[2] == 'U') || (gunType[2] == 'E'))
  8450. {
  8451. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  8452. }
  8453. else
  8454. {
  8455. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  8456. }
  8457. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8458. goto end;
  8459. }
  8460. }
  8461. for (int index = 0; index < GB_QUANTITY; index++)
  8462. {
  8463. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  8464. {
  8465. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8466. if(gunType[2] == 'G')
  8467. {
  8468. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  8469. }
  8470. else
  8471. {
  8472. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  8473. }
  8474. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8475. goto end;
  8476. }
  8477. }
  8478. for (int index = 0; index < AC_QUANTITY; index++)
  8479. {
  8480. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  8481. {
  8482. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8483. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8484. {
  8485. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  8486. }
  8487. else
  8488. {
  8489. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  8490. }
  8491. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8492. goto end;
  8493. }
  8494. }
  8495. }
  8496. //The reservationId does NOT match the reservationId
  8497. sendCancelReservationConfirmation(uuid, gunNO);
  8498. end:
  8499. // Fill in ocpp packet uuid
  8500. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  8501. return result;
  8502. }
  8503. int handleCertificateSignedRequest(char *uuid, char *payload)
  8504. {
  8505. mtrace();
  8506. int result = FAIL;
  8507. json_object *CertificateSigned;
  8508. DEBUG_INFO("handleCertificateSignedRequest...\n");
  8509. CertificateSigned = json_tokener_parse(payload);
  8510. if(!is_error(CertificateSigned))
  8511. {
  8512. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  8513. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  8514. // Required data
  8515. if(json_object_array_length(json_object_object_get(CertificateSigned, "certificate")) <= ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.certificate))
  8516. {
  8517. for(int idx=0;idx<json_object_array_length(json_object_object_get(CertificateSigned, "certificate"));idx++)
  8518. {
  8519. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificate[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(CertificateSigned, "certificateType"), idx)));
  8520. /*
  8521. * TODO:
  8522. * 1. Certificate install response
  8523. */
  8524. }
  8525. }
  8526. // Optional data
  8527. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  8528. {
  8529. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  8530. }
  8531. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  8532. }
  8533. else
  8534. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  8535. json_object_put(CertificateSigned);
  8536. sendCertificateSignedConfirmation(uuid);
  8537. return result;
  8538. }
  8539. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  8540. {
  8541. mtrace();
  8542. int result = FAIL;
  8543. int evseId = 0, gunIndex = 0;
  8544. char operationalStatus[16]={0};
  8545. char comfirmstr[20];
  8546. int specificId = FALSE;
  8547. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  8548. json_object *ChangeAvailability;
  8549. ChangeAvailability = json_tokener_parse(payload);
  8550. if(!is_error(ChangeAvailability))
  8551. {
  8552. // Required data
  8553. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  8554. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  8555. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  8556. {
  8557. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  8558. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  8559. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  8560. }
  8561. }
  8562. json_object_put(ChangeAvailability);
  8563. if((evseId != 0) && (evseId <= gunTotalNumber))
  8564. {
  8565. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  8566. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  8567. }
  8568. else if(evseId == 0)
  8569. {
  8570. for(int i=0; i < gunTotalNumber; i++)
  8571. {
  8572. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  8573. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8574. }
  8575. }
  8576. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8577. {
  8578. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  8579. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  8580. }
  8581. else if(gunIndex == 0)
  8582. {
  8583. for(int i=0; i < gunTotalNumber; i++)
  8584. {
  8585. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  8586. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8587. }
  8588. }
  8589. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  8590. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8591. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  8592. {
  8593. specificId = TRUE;
  8594. }
  8595. if(specificId == FALSE)
  8596. goto end;
  8597. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  8598. {
  8599. //----------------------gunIndex is 0 ------------------------------------------------//
  8600. if(gunIndex == 0)
  8601. {
  8602. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8603. {
  8604. for(int i=0; i < gunTotalNumber; i++)
  8605. {
  8606. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8607. {
  8608. if ((gunType[i] == 'J')&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  8609. {
  8610. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8611. {
  8612. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8613. goto end;
  8614. }
  8615. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8616. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8617. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8618. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8619. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8620. {
  8621. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8622. goto end;
  8623. }
  8624. }
  8625. }//END FOR CHAdeMO_QUANTITY
  8626. for (int index = 0; index < CCS_QUANTITY; index++)
  8627. {
  8628. if (((gunType[i] == 'U')||(gunType[i] == 'E'))&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  8629. {
  8630. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  8631. {
  8632. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8633. goto end;
  8634. }
  8635. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8636. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8637. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8638. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8639. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8640. {
  8641. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8642. goto end;
  8643. }
  8644. }
  8645. }//END FOR CCS_QUANTITY
  8646. for (int index = 0; index < GB_QUANTITY; index++)
  8647. {
  8648. if ((gunType[i] == 'G')&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  8649. {
  8650. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8651. {
  8652. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8653. goto end;
  8654. }
  8655. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8656. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8657. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8658. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8659. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8660. {
  8661. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8662. goto end;
  8663. }
  8664. }
  8665. }// END FOR GB_QUANTITY
  8666. for (int index = 0; index < AC_QUANTITY; index++)
  8667. {
  8668. if (((gunType[i] > '0')&&(gunType[i] <= '9'))&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  8669. {
  8670. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8671. {
  8672. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8673. goto end;
  8674. }
  8675. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8676. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8677. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8678. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8679. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8680. {
  8681. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8682. goto end;
  8683. }
  8684. }
  8685. }//END FOR AC_QUANTITY
  8686. }// END FOR gunTotalNumber
  8687. }
  8688. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8689. {
  8690. for(int i=0; i < gunTotalNumber; i++)
  8691. {
  8692. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8693. {
  8694. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8695. goto end;
  8696. }
  8697. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8698. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  8699. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  8700. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  8701. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8702. {
  8703. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8704. goto end;
  8705. }
  8706. }
  8707. }
  8708. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8709. goto end;
  8710. }
  8711. //----------------------gunIndex is not 0 ------------------------------------------------//
  8712. //check Transaction active
  8713. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8714. {
  8715. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J'))
  8716. {
  8717. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  8718. {
  8719. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8720. goto end;
  8721. }
  8722. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8723. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8724. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8725. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8726. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8727. {
  8728. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8729. goto end;
  8730. }
  8731. else
  8732. {
  8733. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  8734. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8735. goto end;
  8736. }
  8737. }
  8738. }//END FOR CHAdeMO_QUANTITY
  8739. for (int index = 0; index < CCS_QUANTITY; index++)
  8740. {
  8741. if ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E')))
  8742. {
  8743. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  8744. {
  8745. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8746. goto end;
  8747. }
  8748. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8749. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8750. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8751. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8752. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8753. {
  8754. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8755. goto end;
  8756. }
  8757. else
  8758. {
  8759. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  8760. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8761. goto end;
  8762. }
  8763. }
  8764. }//END FOR CCS_QUANTITY
  8765. for (int index = 0; index < GB_QUANTITY; index++)
  8766. {
  8767. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))
  8768. {
  8769. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8770. {
  8771. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8772. goto end;
  8773. }
  8774. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8775. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8776. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8777. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8778. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8779. {
  8780. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8781. goto end;
  8782. }
  8783. else
  8784. {
  8785. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  8786. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8787. goto end;
  8788. }
  8789. }
  8790. }// END FOR GB_QUANTITY
  8791. for (int index = 0; index < AC_QUANTITY; index++)
  8792. {
  8793. if ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))
  8794. {
  8795. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8796. {
  8797. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8798. goto end;
  8799. }
  8800. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8801. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8802. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8803. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8804. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8805. {
  8806. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8807. goto end;
  8808. }
  8809. else
  8810. {
  8811. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  8812. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8813. goto end;
  8814. }
  8815. }
  8816. }//END FOR AC_QUANTITY
  8817. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  8818. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  8819. {
  8820. //----------------------gunIndex is 0 ------------------------------------------------//
  8821. if(gunIndex == 0)
  8822. {
  8823. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8824. {
  8825. for(int i=0; i < gunTotalNumber; i++)
  8826. {
  8827. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8828. {
  8829. 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
  8830. {
  8831. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8832. goto end;
  8833. }
  8834. }//END FOR CHAdeMO_QUANTITY
  8835. for (int index = 0; index < CCS_QUANTITY; index++)
  8836. {
  8837. 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
  8838. {
  8839. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8840. goto end;
  8841. }
  8842. }//END FOR CCS_QUANTITY
  8843. for (int index = 0; index < GB_QUANTITY; index++)
  8844. {
  8845. 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
  8846. {
  8847. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8848. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8849. goto end;
  8850. }
  8851. }// END FOR GB_QUANTITY
  8852. for (int index = 0; index < AC_QUANTITY; index++)
  8853. {
  8854. 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
  8855. {
  8856. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8857. goto end;
  8858. }
  8859. }//END FOR CHAdeMO_QUANTITY
  8860. }// END FOR gunTotalNumber
  8861. }
  8862. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8863. {
  8864. for(int i=0; i < gunTotalNumber; i++)
  8865. {
  8866. for (int index = 0; index < AC_QUANTITY; index++)
  8867. {
  8868. 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
  8869. {
  8870. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8871. goto end;
  8872. }
  8873. }//END FOR CHAdeMO_QUANTITY
  8874. } // END FOR gunTotalNumber
  8875. }
  8876. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8877. goto end;
  8878. }
  8879. //----------------------gunIndex is not 0 ------------------------------------------------//
  8880. //check Transaction active
  8881. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8882. {
  8883. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'J') ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8884. {
  8885. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8886. goto end;
  8887. }
  8888. }//END FOR CHAdeMO_QUANTITY
  8889. for (int index = 0; index < CCS_QUANTITY; index++)
  8890. {
  8891. if ((((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8892. {
  8893. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8894. goto end;
  8895. }
  8896. }//END FOR CCS_QUANTITY
  8897. for (int index = 0; index < GB_QUANTITY; index++)
  8898. {
  8899. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8900. {
  8901. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8902. goto end;
  8903. }
  8904. }// END FOR GB_QUANTITY
  8905. for (int index = 0; index < AC_QUANTITY; index++)
  8906. {
  8907. if (((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9'))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8908. {
  8909. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8910. goto end;
  8911. }
  8912. }//END FOR AC_QUANTITY
  8913. }//END FOR AvailabilityEnumTypeStr[Operative]
  8914. end:
  8915. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8916. {
  8917. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  8918. }
  8919. else
  8920. {
  8921. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  8922. }
  8923. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8924. {
  8925. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  8926. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8927. }
  8928. else if(gunIndex == 0)
  8929. {
  8930. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  8931. {
  8932. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  8933. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  8934. }
  8935. }
  8936. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  8937. return result;
  8938. }
  8939. int handleClearCacheRequest(char *uuid, char *payload)
  8940. {
  8941. mtrace();
  8942. int result = FAIL;
  8943. char rmFileCmd[100]={0};
  8944. struct stat stats;
  8945. DEBUG_INFO("handleClearCacheRequest...\n");
  8946. stat("/Storage/OCPP", &stats);
  8947. // Check for directory existence
  8948. if (S_ISDIR(stats.st_mode) == 1)
  8949. {}
  8950. else
  8951. {
  8952. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  8953. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  8954. system(rmFileCmd);
  8955. }
  8956. /*
  8957. * TODO:
  8958. * 1. Clear cache from sqlite db
  8959. */
  8960. if(1)
  8961. {
  8962. DEBUG_INFO("open AuthorizationCache file failed\n");
  8963. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  8964. }
  8965. else
  8966. {
  8967. DEBUG_INFO("open AuthorizationCache file successful\n");
  8968. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  8969. }
  8970. sendClearCacheConfirmation(uuid);
  8971. return result;
  8972. }
  8973. int handleClearChargingProfileRequest(char *uuid, char *payload)
  8974. {
  8975. mtrace();
  8976. int result = FAIL;
  8977. int resultRename;
  8978. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  8979. char chargingProfilePurposeStr[26]={0};
  8980. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  8981. char tempchargingProfilePurposeStr[26]={0};
  8982. char sstr[160]={0};
  8983. char str[100]={0};
  8984. int c = 0;
  8985. char *loc;
  8986. char fname[200]={0};
  8987. char comfirmstr[20]={0};
  8988. char word[1600]={0};
  8989. int clearflag = FALSE;
  8990. int chargingProfileIdIsNULL = FALSE;
  8991. int connectorIsNULL = FALSE;
  8992. int chargingProfilePurposeIsNULL = FALSE;
  8993. int stackLevelIsNULL = FALSE;
  8994. //int GotoEnd = FALSE;
  8995. FILE *fptr1, *fptr2;
  8996. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  8997. int n_chargingProfile=0;
  8998. int isEmptyFile = FALSE;
  8999. char sLineWord[1600]={0};
  9000. char chargingProfiles[10][100]={0};
  9001. int ChargeProfileCount = 0;
  9002. int ch;
  9003. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  9004. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  9005. json_object *ClearChargingProfile;
  9006. ClearChargingProfile = json_tokener_parse(payload);
  9007. if(!is_error(ClearChargingProfile))
  9008. {
  9009. // Optional data
  9010. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  9011. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  9012. else
  9013. chargingProfileIdIsNULL = TRUE;
  9014. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  9015. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  9016. else
  9017. connectorIsNULL = TRUE;
  9018. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  9019. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  9020. else
  9021. chargingProfilePurposeIsNULL = TRUE;
  9022. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  9023. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  9024. else
  9025. stackLevelIsNULL = TRUE;
  9026. }
  9027. json_object_put(ClearChargingProfile);
  9028. if(connectorIsNULL == FALSE)
  9029. {
  9030. switch(connectorIdInt)
  9031. {
  9032. case 0:
  9033. if(chargingProfilePurposeIsNULL == TRUE)
  9034. {
  9035. int l = 0;
  9036. strcpy(fname, ChargePointMaxProfile_JSON);
  9037. if((access(fname,F_OK))!=-1)
  9038. {
  9039. strcpy(chargingProfiles[l], fname);
  9040. l = l + 1;
  9041. }
  9042. strcpy(fname, TxDefaultProfile_0_JSON);
  9043. if((access(fname,F_OK))!=-1)
  9044. {
  9045. strcpy(chargingProfiles[l], fname);
  9046. l = l + 1;
  9047. }
  9048. ChargeProfileCount = l;
  9049. }
  9050. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  9051. {
  9052. strcpy(fname, ChargePointMaxProfile_JSON);
  9053. if((access(fname,F_OK))!=-1)
  9054. {
  9055. strcpy(chargingProfiles[0], fname);
  9056. ChargeProfileCount = 1;
  9057. }
  9058. }
  9059. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  9060. {
  9061. strcpy(fname, TxDefaultProfile_0_JSON);
  9062. if((access(fname,F_OK))!=-1)
  9063. {
  9064. strcpy(chargingProfiles[0], fname);
  9065. ChargeProfileCount = 1;
  9066. }
  9067. }
  9068. break;
  9069. default:
  9070. if(chargingProfilePurposeIsNULL == TRUE)
  9071. {
  9072. int m = 0;
  9073. memset(fname, 0, ARRAY_SIZE(fname));
  9074. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  9075. if((access(fname,F_OK))!=-1)
  9076. {
  9077. strcpy(chargingProfiles[m], fname);
  9078. m = m + 1;
  9079. }
  9080. memset(fname, 0, ARRAY_SIZE(fname));
  9081. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  9082. if((access(fname,F_OK))!=-1)
  9083. {
  9084. strcpy(chargingProfiles[m], fname);
  9085. m = m + 1;
  9086. }
  9087. ChargeProfileCount = m;
  9088. }
  9089. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  9090. {
  9091. //strcpy(fname, TxDefaultProfile_1_JSON);
  9092. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  9093. if((access(fname,F_OK))!=-1)
  9094. {
  9095. strcpy(chargingProfiles[0], fname);
  9096. ChargeProfileCount = 1;
  9097. }
  9098. }
  9099. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  9100. {
  9101. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  9102. if((access(fname,F_OK))!=-1)
  9103. {
  9104. strcpy(chargingProfiles[0], fname);
  9105. ChargeProfileCount = 1;
  9106. }
  9107. }
  9108. //strcpy(fname, ChargePointMaxProfile_JSON );
  9109. break;
  9110. }
  9111. }
  9112. else // Check all Charging Profiles
  9113. {
  9114. int i = 0;
  9115. char fnametemp[200]={0};
  9116. ChargeProfileCount = 0;
  9117. //Check ChargePointMaxProfile.json exit
  9118. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  9119. {
  9120. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  9121. i = i + 1;
  9122. }
  9123. //Check TxDefaultProfile_0.json exit
  9124. if((access("/Storage/OCPP/TxDefaultProfile_0.json",F_OK))!=-1)
  9125. {
  9126. strcpy(chargingProfiles[i], "/Storage/OCPP/TxDefaultProfile_0.json");
  9127. i = i + 1;
  9128. }
  9129. //Check TxDefaultProfile_%d.json
  9130. for(int j=1; j <= gunTotalNumber; j++)
  9131. {
  9132. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  9133. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d.json", j);
  9134. if((access(fnametemp,F_OK))!=-1)
  9135. {
  9136. strcpy(chargingProfiles[i], fnametemp);
  9137. i = i + 1;
  9138. }
  9139. }
  9140. //Check TxProfile_%d.json
  9141. for(int j=1; j <= gunTotalNumber; j++)
  9142. {
  9143. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  9144. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d.json", j);
  9145. if((access(fnametemp,F_OK))!=-1)
  9146. {
  9147. strcpy(chargingProfiles[i], fnametemp);
  9148. i = i + 1;
  9149. }
  9150. }
  9151. ChargeProfileCount = i;
  9152. }// End connectorIsNULL is TRUE
  9153. if(ChargeProfileCount == 0)
  9154. {
  9155. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9156. goto end;
  9157. }
  9158. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  9159. {
  9160. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9161. goto end;
  9162. }
  9163. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  9164. {
  9165. memset(str, 0, ARRAY_SIZE(str));
  9166. // clear temp file
  9167. sprintf(str,"rm -f %s",temp);
  9168. system(str);
  9169. for(int k=0; k < ChargeProfileCount; k++)
  9170. {
  9171. memset(str, 0, ARRAY_SIZE(str));
  9172. //clear file in C
  9173. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9174. system(str);
  9175. }
  9176. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9177. goto end;
  9178. }
  9179. else if(connectorIsNULL == TRUE)
  9180. {
  9181. for(int k=0; k < ChargeProfileCount; k++)
  9182. {
  9183. fptr1 = fopen(chargingProfiles[k], "r");
  9184. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  9185. //Check Charging Profile Count
  9186. while(fscanf(fptr1, "%s", word) != EOF)
  9187. {
  9188. //DEBUG_INFO("word=%s\n",word);
  9189. if(strstr(word, "chargingProfileId")!= NULL)
  9190. {
  9191. //DEBUG_INFO("test chargingProfileId \n");
  9192. n_chargingProfile = n_chargingProfile + 1;
  9193. //DEBUG_INFO("chargingProfileId Found\n");
  9194. }
  9195. }
  9196. rewind(fptr1);
  9197. //search Charging Profile Element
  9198. //int i= 0;
  9199. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9200. {
  9201. //------------------------tempconnectorIdInt------------------------//
  9202. loc = strstr(sLineWord, "connectorId");
  9203. c = 0;
  9204. memset(sstr ,0, sizeof(sstr) );
  9205. while (loc[strlen("connectorId")+2+c] != ',')
  9206. {
  9207. sstr[c] = loc[strlen("connectorId")+2+c];
  9208. c++;
  9209. }
  9210. sstr[c] = '\0';
  9211. tempconnectorIdInt = atoi(sstr);
  9212. printf("file's gun number is %d\n", tempconnectorIdInt);
  9213. //--------------------------chargingProfileId--------------------//
  9214. c = 0;
  9215. loc = strstr(sLineWord, "chargingProfileId");
  9216. memset(sstr ,0, ARRAY_SIZE(sstr));
  9217. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9218. {
  9219. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9220. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9221. c++;
  9222. }
  9223. sstr[c] = '\0';
  9224. tempchargingProfileIdInt = atoi(sstr);
  9225. //stackLevel
  9226. c = 0;
  9227. loc = strstr(sLineWord, "stackLevel");
  9228. memset(sstr ,0, ARRAY_SIZE(sstr));
  9229. while (loc[strlen("stackLevel")+2+c] != ',')
  9230. {
  9231. sstr[c] = loc[strlen("stackLevel")+2+c];
  9232. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9233. c++;
  9234. }
  9235. sstr[c] = '\0';
  9236. tempstackLevelInt = atoi(sstr);
  9237. c = 0;
  9238. loc = strstr(sLineWord, "chargingProfilePurpose");
  9239. memset(sstr ,0, ARRAY_SIZE(sstr));
  9240. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9241. {
  9242. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9243. c++;
  9244. }
  9245. sstr[c] = '\0';
  9246. strcpy(tempchargingProfilePurposeStr, sstr);
  9247. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9248. {
  9249. //------- not write to fptr2-------//
  9250. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9251. //clearflag = TRUE;
  9252. }
  9253. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  9254. {
  9255. //------- not write to fptr2-------//
  9256. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9257. }
  9258. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9259. {
  9260. //------- not write to fptr2-------//
  9261. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9262. }
  9263. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  9264. {
  9265. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9266. }
  9267. else
  9268. {
  9269. fprintf(fptr2, sLineWord);//writing data into file
  9270. }
  9271. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9272. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9273. if(clearflag == TRUE)
  9274. {
  9275. fclose(fptr1);
  9276. fclose(fptr2);
  9277. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9278. system(str);
  9279. // clear temp file
  9280. sprintf(str,"rm -f %s",temp);
  9281. system(str);
  9282. }
  9283. else
  9284. {
  9285. fclose(fptr1);
  9286. fclose(fptr2);
  9287. memset(str, 0, ARRAY_SIZE(str));
  9288. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9289. system(str);
  9290. resultRename = rename(temp, chargingProfiles[k]);
  9291. if(resultRename == 0)
  9292. {
  9293. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  9294. }
  9295. else
  9296. {
  9297. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  9298. }
  9299. if(comfirmstr[0]== 0)
  9300. {
  9301. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9302. }
  9303. //Check chargingProfile is empty file
  9304. /*------ Read the file ----------------*/
  9305. fptr1=fopen(chargingProfiles[k],"r");
  9306. ch=fgetc(fptr1);
  9307. rewind(fptr1);
  9308. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9309. if(ch!=EOF)
  9310. {
  9311. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9312. {
  9313. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9314. if(sLineWord[0]=='\0')
  9315. {
  9316. isEmptyFile = TRUE;
  9317. break;
  9318. }
  9319. else
  9320. {
  9321. isEmptyFile = FALSE;
  9322. break;
  9323. }
  9324. }
  9325. }
  9326. else
  9327. isEmptyFile = TRUE;
  9328. fclose(fptr1);
  9329. if(isEmptyFile == TRUE)
  9330. {
  9331. memset(str, 0, ARRAY_SIZE(str));
  9332. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9333. system(str);
  9334. }
  9335. }
  9336. }// End of while(int k=0; k < ChargePointCount; k++)
  9337. }
  9338. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  9339. {
  9340. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  9341. for(int k=0; k < ChargeProfileCount; k++)
  9342. {
  9343. fptr1 = fopen(chargingProfiles[k], "r");
  9344. fptr2 = fopen(temp, "w+");
  9345. //Check Charging Profile Count
  9346. while(fscanf(fptr1, "%s", word) != EOF)
  9347. {
  9348. //DEBUG_INFO("word=%s\n",word);
  9349. if(strstr(word, "chargingProfileId")!= NULL)
  9350. {
  9351. n_chargingProfile = n_chargingProfile + 1;
  9352. }
  9353. }
  9354. rewind(fptr1);
  9355. //search Charging Profile Element
  9356. //int i= 0;
  9357. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9358. {
  9359. //*************************tempconnectorIdInt*********************************/
  9360. loc = strstr(sLineWord, "connectorId");
  9361. c = 0;
  9362. memset(sstr ,0, ARRAY_SIZE(sstr));
  9363. while (loc[strlen("connectorId")+2+c] != ',')
  9364. {
  9365. sstr[c] = loc[strlen("connectorId")+2+c];
  9366. c++;
  9367. }
  9368. sstr[c] = '\0';
  9369. tempconnectorIdInt = atoi(sstr);
  9370. //chargingProfileId
  9371. c = 0;
  9372. loc = strstr(sLineWord, "chargingProfileId");
  9373. memset(sstr ,0, ARRAY_SIZE(sstr));
  9374. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9375. {
  9376. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9377. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9378. c++;
  9379. }
  9380. sstr[c] = '\0';
  9381. tempchargingProfileIdInt = atoi(sstr);
  9382. //stackLevel
  9383. c = 0;
  9384. loc = strstr(sLineWord, "stackLevel");
  9385. memset(sstr ,0, ARRAY_SIZE(sstr));
  9386. while (loc[strlen("stackLevel")+2+c] != ',')
  9387. {
  9388. sstr[c] = loc[strlen("stackLevel")+2+c];
  9389. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9390. c++;
  9391. }
  9392. sstr[c] = '\0';
  9393. tempstackLevelInt = atoi(sstr);
  9394. c = 0;
  9395. loc = strstr(sLineWord, "chargingProfilePurpose");
  9396. memset(sstr ,0, ARRAY_SIZE(sstr));
  9397. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9398. {
  9399. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9400. c++;
  9401. }
  9402. sstr[c] = '\0';
  9403. strcpy(tempchargingProfilePurposeStr, sstr);
  9404. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9405. {
  9406. //------- not write to fptr2-------//
  9407. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9408. //clearflag = TRUE;
  9409. }
  9410. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9411. {
  9412. //------- not write to fptr2-------//
  9413. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9414. }
  9415. else if(stackLevelIsNULL == TRUE)
  9416. {
  9417. //Clear Whole File
  9418. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9419. clearflag = TRUE;
  9420. break;
  9421. }
  9422. else
  9423. {
  9424. fprintf(fptr2, sLineWord);//writing data into file
  9425. }
  9426. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9427. }
  9428. if(clearflag == TRUE)
  9429. {
  9430. fclose(fptr1);
  9431. fclose(fptr2);
  9432. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9433. system(str);
  9434. // clear temp file
  9435. sprintf(str,"rm -f %s",temp);
  9436. system(str);
  9437. }
  9438. else
  9439. {
  9440. fclose(fptr1);
  9441. fclose(fptr2);
  9442. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9443. system(str);
  9444. resultRename = rename(temp, chargingProfiles[k]);
  9445. if(resultRename == 0)
  9446. {
  9447. DEBUG_INFO("File ChargingProfile renamed successfully");
  9448. }
  9449. else
  9450. {
  9451. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  9452. }
  9453. if(comfirmstr[0]== 0)
  9454. {
  9455. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9456. }
  9457. //Check chargingProfile is empty file
  9458. /*------ Read the file ----------------*/
  9459. fptr1=fopen(chargingProfiles[k],"r");
  9460. ch=fgetc(fptr1);
  9461. rewind(fptr1);
  9462. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9463. if(ch!=EOF)
  9464. {
  9465. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9466. {
  9467. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9468. if(sLineWord[0]=='\0')
  9469. {
  9470. isEmptyFile = TRUE;
  9471. break;
  9472. }
  9473. else
  9474. {
  9475. isEmptyFile = FALSE;
  9476. break;
  9477. }
  9478. }
  9479. }
  9480. else
  9481. isEmptyFile = TRUE;
  9482. fclose(fptr1);
  9483. if(isEmptyFile == TRUE)
  9484. {
  9485. memset(str, 0, ARRAY_SIZE(str));
  9486. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9487. system(str);
  9488. }
  9489. /*------- End of reading ---------------*/
  9490. }
  9491. } // while(int k=0; k < ChargeProfileCount; k++)
  9492. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  9493. end:
  9494. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  9495. {
  9496. if(connectorIdInt == 0)
  9497. {
  9498. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  9499. {
  9500. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  9501. }
  9502. }
  9503. else
  9504. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1]);
  9505. }
  9506. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  9507. return result;
  9508. }
  9509. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  9510. {
  9511. mtrace();
  9512. int result = FAIL;
  9513. json_object *ClearDisplayMessage;
  9514. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  9515. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  9516. ClearDisplayMessage = json_tokener_parse(payload);
  9517. if(!is_error(ClearDisplayMessage))
  9518. {
  9519. // Required data
  9520. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  9521. {
  9522. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  9523. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  9524. }
  9525. }
  9526. json_object_put(ClearDisplayMessage);
  9527. sendCostUpdatedConfirmation(uuid);
  9528. return result;
  9529. }
  9530. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  9531. {
  9532. mtrace();
  9533. int result = FAIL;
  9534. json_object *ClearVariableMonitorin;
  9535. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  9536. ClearVariableMonitorin = json_tokener_parse(payload);
  9537. if(!is_error(ClearVariableMonitorin))
  9538. {
  9539. // Required data
  9540. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  9541. {
  9542. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  9543. {
  9544. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  9545. /*
  9546. * TODO:
  9547. * 1. Check response
  9548. */
  9549. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  9550. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  9551. }
  9552. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  9553. }
  9554. }
  9555. json_object_put(ClearVariableMonitorin);
  9556. return result;
  9557. }
  9558. int handleCostUpdatedRequest(char *uuid, char *payload)
  9559. {
  9560. mtrace();
  9561. int result = FAIL;
  9562. json_object *CostUpdate;
  9563. DEBUG_INFO("handleCostUpdatedRequest...\n");
  9564. CostUpdate = json_tokener_parse(payload);
  9565. if(!is_error(CostUpdate))
  9566. {
  9567. // Required data
  9568. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  9569. {
  9570. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  9571. }
  9572. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  9573. {
  9574. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  9575. }
  9576. }
  9577. json_object_put(CostUpdate);
  9578. sendCostUpdatedConfirmation(uuid);
  9579. return result;
  9580. }
  9581. int handleCustomerInformationRequest(char *uuid, char *payload)
  9582. {
  9583. mtrace();
  9584. int result = FAIL;
  9585. json_object *CustomerInformation;
  9586. DEBUG_INFO("handleCustomerInformationRequest...\n");
  9587. CustomerInformation = json_tokener_parse(payload);
  9588. if(!is_error(CustomerInformation))
  9589. {
  9590. // Required data
  9591. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  9592. {
  9593. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  9594. }
  9595. if(json_object_object_get(CustomerInformation, "report") != NULL)
  9596. {
  9597. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  9598. }
  9599. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  9600. {
  9601. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  9602. }
  9603. // Optional data
  9604. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  9605. {
  9606. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  9607. {
  9608. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  9609. }
  9610. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  9611. {
  9612. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  9613. }
  9614. }
  9615. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  9616. {
  9617. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  9618. {
  9619. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  9620. }
  9621. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  9622. {
  9623. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  9624. }
  9625. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  9626. {
  9627. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  9628. }
  9629. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  9630. {
  9631. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  9632. }
  9633. }
  9634. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  9635. }
  9636. else
  9637. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  9638. json_object_put(CustomerInformation);
  9639. sendCustomerInformationConfirmation(uuid);
  9640. return result;
  9641. }
  9642. void createFirmwareVersionByDataTransfer(void)
  9643. {
  9644. json_object *FirmwareDataTransfer = json_object_new_object();
  9645. // AC & DC model
  9646. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  9647. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  9648. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  9649. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  9650. // DC model
  9651. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]!='O')
  9652. {
  9653. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  9654. {
  9655. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  9656. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  9657. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  9658. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  9659. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  9660. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  9661. }
  9662. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
  9663. ((gunType[1] != '0') || (gunType[2] != '0') || (gunType[3] != '0')))
  9664. {
  9665. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  9666. }
  9667. }
  9668. else
  9669. {
  9670. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  9671. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  9672. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  9673. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  9674. json_object_object_add(FirmwareDataTransfer, "DD0_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuBootLoadFwRev));
  9675. json_object_object_add(FirmwareDataTransfer, "DD0_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuKernelFwRev));
  9676. json_object_object_add(FirmwareDataTransfer, "DD0_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuRootFsFwRev));
  9677. json_object_object_add(FirmwareDataTransfer, "DD0_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuPrimFwRev));
  9678. json_object_object_add(FirmwareDataTransfer, "DD0_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].FanModuleFwRev));
  9679. json_object_object_add(FirmwareDataTransfer, "DD0_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].RelayModuleFwRev));
  9680. json_object_object_add(FirmwareDataTransfer, "DD0_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].LedModuleFwRev));
  9681. json_object_object_add(FirmwareDataTransfer, "DD0_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector1FwRev));
  9682. json_object_object_add(FirmwareDataTransfer, "DD0_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector2FwRev));
  9683. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev) > 0)
  9684. json_object_object_add(FirmwareDataTransfer, "DD1_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev));
  9685. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev) > 0)
  9686. json_object_object_add(FirmwareDataTransfer, "DD1_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev));
  9687. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev) > 0)
  9688. json_object_object_add(FirmwareDataTransfer, "DD1_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev));
  9689. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev) > 0)
  9690. json_object_object_add(FirmwareDataTransfer, "DD1_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev));
  9691. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev) > 0)
  9692. json_object_object_add(FirmwareDataTransfer, "DD1_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev));
  9693. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev) > 0)
  9694. json_object_object_add(FirmwareDataTransfer, "DD1_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev));
  9695. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev) > 0)
  9696. json_object_object_add(FirmwareDataTransfer, "DD1_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev));
  9697. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev) > 0)
  9698. json_object_object_add(FirmwareDataTransfer, "DD1_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev));
  9699. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev) > 0)
  9700. json_object_object_add(FirmwareDataTransfer, "DD1_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev));
  9701. }
  9702. // 4G model
  9703. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  9704. {
  9705. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  9706. }
  9707. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "Phihong Technology");
  9708. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion");
  9709. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, json_object_to_json_string(FirmwareDataTransfer));
  9710. }
  9711. int handleDataTransferRequest(char *uuid, char *payload)
  9712. {
  9713. mtrace();
  9714. int result = PASS;
  9715. DEBUG_INFO("handleDataTransferRequest...\n");
  9716. if((uuid != NULL) && (payload != NULL))
  9717. {
  9718. json_object *DataTransfer;
  9719. DataTransfer = json_tokener_parse(payload);
  9720. if(!is_error(DataTransfer))
  9721. {
  9722. // Required data
  9723. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  9724. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  9725. // Optional data
  9726. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  9727. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  9728. if(json_object_object_get(DataTransfer, "data") != NULL)
  9729. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  9730. result = PASS;
  9731. }
  9732. json_object_put(DataTransfer);
  9733. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  9734. {
  9735. // Send all moudle firmware version on EVSE
  9736. createFirmwareVersionByDataTransfer();
  9737. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9738. }
  9739. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_Tmate") != NULL)
  9740. {
  9741. system("/usr/bin/run_tmate_restart.sh &");
  9742. }
  9743. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  9744. {
  9745. json_object *data;
  9746. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  9747. if(!is_error(data))
  9748. {
  9749. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  9750. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  9751. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  9752. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  9753. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  9754. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  9755. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  9756. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  9757. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  9758. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  9759. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9760. }
  9761. else
  9762. {
  9763. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  9764. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  9765. }
  9766. json_object_put(data);
  9767. }
  9768. else
  9769. {
  9770. // Can not find valid message id
  9771. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9772. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  9773. ,ShmOCPP20Data->DataTransfer[0].vendorId
  9774. ,ShmOCPP20Data->DataTransfer[0].messageId
  9775. ,ShmOCPP20Data->DataTransfer[0].data);
  9776. }
  9777. }
  9778. else
  9779. {
  9780. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9781. result = FAIL;
  9782. }
  9783. sendDataTransferConfirmation(uuid, 0);
  9784. return result;
  9785. }
  9786. int handleDeleteCertificateRequest(char *uuid, char *payload)
  9787. {
  9788. mtrace();
  9789. int result = FAIL;
  9790. json_object *DeleteCertificate;
  9791. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  9792. DeleteCertificate = json_tokener_parse(payload);
  9793. if(!is_error(DeleteCertificate))
  9794. {
  9795. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  9796. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  9797. // Required data
  9798. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  9799. {
  9800. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  9801. {
  9802. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  9803. }
  9804. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  9805. {
  9806. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  9807. }
  9808. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  9809. {
  9810. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  9811. }
  9812. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  9813. {
  9814. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  9815. }
  9816. /*
  9817. * TODO:
  9818. * 1. Delete certification and response
  9819. */
  9820. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  9821. }
  9822. }
  9823. else
  9824. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  9825. json_object_put(DeleteCertificate);
  9826. sendDeleteCertificateConfirmation(uuid);
  9827. return result;
  9828. }
  9829. int handleGetBaseReportRequest(char *uuid, char *payload)
  9830. {
  9831. mtrace();
  9832. int result = FAIL;
  9833. json_object *GetBaseRepor;
  9834. DEBUG_INFO("handleGetBaseReportRequest...\n");
  9835. GetBaseRepor = json_tokener_parse(payload);
  9836. if(!is_error(GetBaseRepor))
  9837. {
  9838. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  9839. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  9840. // Required data
  9841. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  9842. {
  9843. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  9844. }
  9845. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  9846. {
  9847. sprintf((char*)ShmOCPP20Data->GetBaseReport.reportBase, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  9848. }
  9849. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_SummaryInventory]) == 0)
  9850. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  9851. else
  9852. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  9853. }
  9854. else
  9855. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  9856. json_object_put(GetBaseRepor);
  9857. sendGetBaseReportConfirmation(uuid);
  9858. return result;
  9859. }
  9860. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  9861. {
  9862. mtrace();
  9863. int result = FAIL;
  9864. int gun_index = -1;
  9865. json_object *GetChargingProfiles;
  9866. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  9867. GetChargingProfiles = json_tokener_parse(payload);
  9868. if(!is_error(GetChargingProfiles))
  9869. {
  9870. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  9871. {
  9872. 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;
  9873. }
  9874. if(gun_index >-1)
  9875. {
  9876. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  9877. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  9878. // Required data
  9879. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  9880. {
  9881. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  9882. }
  9883. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  9884. {
  9885. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  9886. {
  9887. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  9888. }
  9889. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  9890. {
  9891. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  9892. }
  9893. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  9894. {
  9895. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  9896. {
  9897. 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)));
  9898. }
  9899. }
  9900. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  9901. {
  9902. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  9903. {
  9904. 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));
  9905. }
  9906. }
  9907. }
  9908. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  9909. }
  9910. else
  9911. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  9912. }
  9913. json_object_put(GetChargingProfiles);
  9914. sendGetChargingProfilesConfirmation(uuid, gun_index);
  9915. return result;
  9916. }
  9917. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  9918. {
  9919. mtrace();
  9920. int result = FAIL;
  9921. int connectorIdInt, durationInt;
  9922. char chargingRateUnitStr[4]={0};
  9923. char comfirmstr[20];
  9924. int confirmPeriods = 0;
  9925. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  9926. json_object *GetCompositeSchedule;
  9927. GetCompositeSchedule = json_tokener_parse(payload);
  9928. if(!is_error(GetCompositeSchedule))
  9929. {
  9930. // Required data
  9931. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  9932. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  9933. else
  9934. connectorIdInt = -1;
  9935. if(json_object_object_get(GetCompositeSchedule, "duration"))
  9936. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  9937. else
  9938. durationInt = 86400;
  9939. // Optional data
  9940. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  9941. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  9942. }
  9943. json_object_put(GetCompositeSchedule);
  9944. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  9945. if((connectorIdInt == 0) ||
  9946. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  9947. {
  9948. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  9949. struct ChargingProfileType tmpProfile[1];
  9950. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  9951. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  9952. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0]);
  9953. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  9954. {
  9955. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  9956. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  9957. }
  9958. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  9959. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  9960. {
  9961. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  9962. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  9963. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  9964. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0))
  9965. {
  9966. confirmPeriods = idx;
  9967. break;
  9968. }
  9969. }
  9970. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  9971. }
  9972. else
  9973. {
  9974. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  9975. }
  9976. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  9977. return result;
  9978. }
  9979. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  9980. {
  9981. mtrace();
  9982. int result = FAIL;
  9983. json_object *GetDisplayMessages;
  9984. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  9985. GetDisplayMessages = json_tokener_parse(payload);
  9986. if(!is_error(GetDisplayMessages))
  9987. {
  9988. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  9989. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  9990. // Required data
  9991. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  9992. {
  9993. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  9994. }
  9995. // Optional data
  9996. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  9997. {
  9998. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  9999. }
  10000. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  10001. {
  10002. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  10003. }
  10004. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  10005. {
  10006. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  10007. {
  10008. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  10009. }
  10010. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  10011. }
  10012. else
  10013. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  10014. }
  10015. json_object_put(GetDisplayMessages);
  10016. return result;
  10017. }
  10018. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  10019. {
  10020. mtrace();
  10021. int result = FAIL;
  10022. json_object *GetInstalledCertificateIds;
  10023. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  10024. GetInstalledCertificateIds = json_tokener_parse(payload);
  10025. if(!is_error(GetInstalledCertificateIds))
  10026. {
  10027. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  10028. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  10029. // Optional data
  10030. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  10031. {
  10032. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  10033. {
  10034. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  10035. /*
  10036. * TODO:
  10037. * 1. Get installed certificate info for response
  10038. */
  10039. }
  10040. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  10041. }
  10042. else
  10043. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  10044. }
  10045. json_object_put(GetInstalledCertificateIds);
  10046. sendInstallCertificateConfirmation(uuid);
  10047. return result;
  10048. }
  10049. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  10050. {
  10051. mtrace();
  10052. int result = FAIL;
  10053. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  10054. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  10055. {
  10056. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  10057. localversion = -1;
  10058. }
  10059. else
  10060. {
  10061. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  10062. DB_getListVerion();
  10063. }
  10064. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  10065. sendGetLocalListVersionConfirmation(uuid);
  10066. return result;
  10067. }
  10068. static char fnamePlusPath[100]={0};
  10069. static char fnamePWithNoPath[60]={0};
  10070. void checkUploadLog(void)
  10071. {
  10072. FILE *fp;
  10073. /* Open the command for reading. */
  10074. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  10075. if (fp == NULL) {
  10076. printf("Failed to run command\n" );
  10077. exit(1);
  10078. }
  10079. int ftppathlen = 0;
  10080. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  10081. int i = 0;
  10082. /* Read the output a line at a time - output it. */
  10083. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  10084. if(i==0)
  10085. {
  10086. ftppathlen = strlen(fnamePlusPath);
  10087. printf("%s\n", fnamePlusPath);
  10088. fnamePlusPath[ftppathlen]='\0';
  10089. break;
  10090. }
  10091. i= i+1;
  10092. }
  10093. /* close */
  10094. pclose(fp);
  10095. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  10096. {
  10097. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  10098. {
  10099. fnamePlusPath[k]='\0';
  10100. }
  10101. }
  10102. i=1;
  10103. //char fname[60]={0};
  10104. while(i < ftppathlen)
  10105. {
  10106. int len=ftppathlen-i;
  10107. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  10108. {
  10109. printf("compare '/' all right\n");
  10110. break;
  10111. }
  10112. i=i+1;
  10113. }
  10114. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  10115. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  10116. fnamePWithNoPath[i+1] = '\0';
  10117. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  10118. {
  10119. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  10120. {
  10121. fnamePWithNoPath[j]='\0';
  10122. }
  10123. }
  10124. FILE* fp1 = fopen(fnamePlusPath, "r");
  10125. if (fp1)
  10126. {
  10127. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  10128. // file exists
  10129. fclose(fp1);
  10130. }
  10131. else
  10132. {
  10133. // file doesn't exist
  10134. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  10135. }
  10136. }
  10137. void* GetLogProcess(void* data)
  10138. {
  10139. pthread_detach(pthread_self());
  10140. mtrace();
  10141. int requestId, retriesInt=0, retryIntervalInt=0;
  10142. char logType[32], remoteLocation[512]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  10143. 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};
  10144. int port=0;
  10145. int isSuccess = FALSE;
  10146. char ftpbuf[200]={0};
  10147. json_object *GetLog;
  10148. DEBUG_INFO("GetGetProcess...\n");
  10149. GetLog = json_tokener_parse(data);
  10150. if(!is_error(GetLog))
  10151. {
  10152. // Required data
  10153. if(json_object_object_get(GetLog, "requestId") != NULL)
  10154. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  10155. if(json_object_object_get(GetLog, "logType") != NULL)
  10156. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  10157. if(json_object_object_get(GetLog, "log") != NULL)
  10158. {
  10159. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  10160. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  10161. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  10162. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  10163. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  10164. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  10165. }
  10166. // Optional data
  10167. if(json_object_object_get(GetLog, "retries") != NULL)
  10168. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  10169. else
  10170. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  10171. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  10172. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  10173. else
  10174. retryIntervalInt = 30;
  10175. }
  10176. json_object_put(GetLog);
  10177. ShmOCPP20Data->GetLog.requestId = requestId;
  10178. //****************location*******************/
  10179. if(strcmp(remoteLocation,"")==0)
  10180. {
  10181. DEBUG_INFO("remoteLocation is <Empty>!\n");
  10182. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10183. goto end;
  10184. }
  10185. memset(protocol, 0, ARRAY_SIZE(protocol));
  10186. memset(user, 0, ARRAY_SIZE(user) );
  10187. memset(password, 0, ARRAY_SIZE(password));
  10188. memset(host, 0, ARRAY_SIZE(host));
  10189. memset(path, 0, ARRAY_SIZE(path));
  10190. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  10191. memset(host1, 0, ARRAY_SIZE(host1));
  10192. memset(path1, 0, ARRAY_SIZE(path1));
  10193. /*location: ftp://user:password@host:port/path*/
  10194. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  10195. if((access(fnamePlusPath,F_OK))!=-1)
  10196. {
  10197. DEBUG_INFO("fnamePlusPath exist.\n");
  10198. }
  10199. else
  10200. {
  10201. DEBUG_INFO("fnamePlusPath not exist!\n");
  10202. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10203. goto end;
  10204. }
  10205. if(strchr(remoteLocation,'@')==NULL)
  10206. {
  10207. sscanf(remoteLocation,
  10208. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  10209. protocol, host, &port, path);
  10210. strcpy(user,"anonymous");
  10211. strcpy(password,"");
  10212. }
  10213. else
  10214. {
  10215. //DEBUG_INFO("pch=%s\n", pch);
  10216. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  10217. protocol, user, password, host, &port, path);
  10218. }
  10219. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
  10220. {
  10221. DEBUG_INFO("protocol is not ftp/http ! \n");
  10222. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10223. goto end;
  10224. }
  10225. if(strncmp(remoteLocation,"http", 4) == 0)
  10226. {
  10227. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  10228. sprintf(ftppath,"/%s", path);
  10229. do
  10230. {
  10231. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  10232. sleep(3);
  10233. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  10234. if(!isSuccess)
  10235. {
  10236. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  10237. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10238. sleep(retryIntervalInt);
  10239. }
  10240. else
  10241. {
  10242. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  10243. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  10244. }
  10245. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt--));
  10246. }
  10247. else
  10248. {
  10249. sscanf(host,"%[^/]%s",host1, path1);
  10250. sprintf(ftppath,"%s", path1);
  10251. int ftppathlen=strlen(ftppath);
  10252. int i=1;
  10253. char filenametemp[50];
  10254. while(i < ftppathlen)
  10255. {
  10256. int len=ftppathlen-i;
  10257. if(ftppath[len]== 47) // '/' ascll code: 47
  10258. {
  10259. DEBUG_INFO("find '/' all right\n");
  10260. break;
  10261. }
  10262. i=i+1;
  10263. }
  10264. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  10265. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  10266. filenametemp[i+1] = 0;
  10267. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  10268. if(port == 0)
  10269. port = 21;
  10270. do
  10271. {
  10272. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  10273. sleep(3);
  10274. isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  10275. if(!isSuccess)
  10276. {
  10277. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  10278. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10279. sleep(retryIntervalInt);
  10280. }
  10281. else
  10282. {
  10283. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  10284. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  10285. }
  10286. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  10287. }
  10288. end:
  10289. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  10290. pthread_exit(NULL);
  10291. }
  10292. int handleGetLogRequest(char *uuid, char *payload)
  10293. {
  10294. mtrace();
  10295. int result = FAIL;
  10296. char cmdBuf[512];
  10297. char fName[258];
  10298. time_t CurrentTime;
  10299. struct tm *tm;
  10300. pthread_t th_Status;
  10301. CurrentTime = time(NULL);
  10302. tm = localtime(&CurrentTime);
  10303. 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);
  10304. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  10305. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  10306. sendGetLogConfirmation(uuid);
  10307. system("exec /root/logPackTools 'log' 6");
  10308. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", fName);
  10309. system(cmdBuf);
  10310. checkUploadLog();
  10311. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  10312. return result;
  10313. }
  10314. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  10315. {
  10316. mtrace();
  10317. int result = FAIL;
  10318. json_object *GetMonitoringReport;
  10319. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  10320. GetMonitoringReport = json_tokener_parse(payload);
  10321. if(!is_error(GetMonitoringReport))
  10322. {
  10323. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  10324. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  10325. // Required data
  10326. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  10327. {
  10328. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  10329. }
  10330. // Optional data
  10331. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  10332. {
  10333. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  10334. }
  10335. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  10336. {
  10337. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  10338. {
  10339. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  10340. {
  10341. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  10342. {
  10343. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  10344. {
  10345. 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")));
  10346. }
  10347. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10348. {
  10349. 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")));
  10350. }
  10351. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10352. {
  10353. 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)
  10354. {
  10355. 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"));
  10356. }
  10357. 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)
  10358. {
  10359. 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"));
  10360. }
  10361. }
  10362. }
  10363. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  10364. {
  10365. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10366. {
  10367. 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")));
  10368. }
  10369. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10370. {
  10371. 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")));
  10372. }
  10373. }
  10374. }
  10375. }
  10376. }
  10377. }
  10378. json_object_put(GetMonitoringReport);
  10379. /*
  10380. * TODO:
  10381. * 1. Response result
  10382. */
  10383. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10384. sendGetMonitoringReportConfirmation(uuid);
  10385. return result;
  10386. }
  10387. int handleGetReportRequest(char *uuid, char *payload)
  10388. {
  10389. mtrace();
  10390. int result = FAIL;
  10391. json_object *GetReport;
  10392. DEBUG_INFO("handleGetReportRequest...\n");
  10393. GetReport = json_tokener_parse(payload);
  10394. if(!is_error(GetReport))
  10395. {
  10396. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  10397. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  10398. // Required data
  10399. if(json_object_object_get(GetReport, "requestId") != NULL)
  10400. {
  10401. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  10402. }
  10403. // Optional data
  10404. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  10405. {
  10406. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  10407. }
  10408. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  10409. {
  10410. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  10411. {
  10412. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  10413. {
  10414. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  10415. {
  10416. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  10417. {
  10418. 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")));
  10419. }
  10420. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10421. {
  10422. 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")));
  10423. }
  10424. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10425. {
  10426. 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)
  10427. {
  10428. 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"));
  10429. }
  10430. 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)
  10431. {
  10432. 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"));
  10433. }
  10434. }
  10435. }
  10436. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  10437. {
  10438. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10439. {
  10440. 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")));
  10441. }
  10442. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10443. {
  10444. 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")));
  10445. }
  10446. }
  10447. }
  10448. }
  10449. }
  10450. }
  10451. json_object_put(GetReport);
  10452. /*
  10453. * TODO:
  10454. * 1. Response result
  10455. */
  10456. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10457. sendGetReportConfirmation(uuid);
  10458. return result;
  10459. }
  10460. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  10461. {
  10462. mtrace();
  10463. int result = FAIL;
  10464. int8_t gun_index = -1;
  10465. json_object *GetTransactionStatus;
  10466. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  10467. GetTransactionStatus = json_tokener_parse(payload);
  10468. if(!is_error(GetTransactionStatus))
  10469. {
  10470. /*
  10471. * TODO:
  10472. * 1. Check transaction locate which connector
  10473. */
  10474. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  10475. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  10476. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  10477. {
  10478. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  10479. }
  10480. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  10481. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  10482. }
  10483. json_object_put(GetTransactionStatus);
  10484. sendGetTransactionStatusConfirmation(uuid, gun_index);
  10485. return result;
  10486. }
  10487. int handleGetVariablesRequest(char *uuid, char *payload)
  10488. {
  10489. mtrace();
  10490. int result = FAIL;
  10491. json_object *GetVariables;
  10492. DEBUG_INFO("handleGetVariablesRequest...\n");
  10493. GetVariables = json_tokener_parse(payload);
  10494. if(!is_error(GetVariables))
  10495. {
  10496. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  10497. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  10498. // Required data
  10499. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  10500. {
  10501. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  10502. {
  10503. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  10504. {
  10505. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  10506. {
  10507. 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")));
  10508. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  10509. }
  10510. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  10511. {
  10512. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  10513. {
  10514. 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")));
  10515. }
  10516. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  10517. {
  10518. 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")));
  10519. }
  10520. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  10521. {
  10522. 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)
  10523. {
  10524. 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"));
  10525. }
  10526. 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)
  10527. {
  10528. 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"));
  10529. }
  10530. }
  10531. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  10532. }
  10533. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  10534. {
  10535. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  10536. {
  10537. 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")));
  10538. }
  10539. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  10540. {
  10541. 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")));
  10542. }
  10543. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  10544. }
  10545. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  10546. {
  10547. if((strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) == 0) &&
  10548. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance) == 0) &&
  10549. (strcmp((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) == 0) &&
  10550. (strcmp((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance) == 0))
  10551. {
  10552. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  10553. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  10554. break;
  10555. }
  10556. else
  10557. {
  10558. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  10559. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  10560. }
  10561. }
  10562. }
  10563. }
  10564. }
  10565. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  10566. }
  10567. json_object_put(GetVariables);
  10568. return result;
  10569. }
  10570. int handleInstallCertificateRequest(char *uuid, char *payload)
  10571. {
  10572. mtrace();
  10573. int result = FAIL;
  10574. json_object *InstallCertificate;
  10575. DEBUG_INFO("handleInstallCertificateRequest...\n");
  10576. InstallCertificate = json_tokener_parse(payload);
  10577. if(!is_error(InstallCertificate))
  10578. {
  10579. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  10580. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  10581. // Required data
  10582. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  10583. {
  10584. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  10585. }
  10586. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  10587. {
  10588. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  10589. }
  10590. }
  10591. json_object_put(InstallCertificate);
  10592. /*
  10593. * TODO:
  10594. * 1. Install certification preocess and response
  10595. */
  10596. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10597. sendInstallCertificateConfirmation(uuid);
  10598. return result;
  10599. }
  10600. int handlePublishFirmwareRequest(char *uuid, char *payload)
  10601. {
  10602. mtrace();
  10603. int result = FAIL;
  10604. json_object *PublishFirmware;
  10605. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  10606. PublishFirmware = json_tokener_parse(payload);
  10607. if(!is_error(PublishFirmware))
  10608. {
  10609. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  10610. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  10611. // Required data
  10612. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  10613. {
  10614. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  10615. }
  10616. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  10617. {
  10618. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  10619. }
  10620. // Optional data
  10621. if(json_object_object_get(PublishFirmware, "location") != NULL)
  10622. {
  10623. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  10624. }
  10625. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  10626. {
  10627. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  10628. }
  10629. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  10630. {
  10631. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  10632. }
  10633. }
  10634. json_object_put(PublishFirmware);
  10635. /*
  10636. * TODO:
  10637. * 1. Publish firmware preocess and response
  10638. */
  10639. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10640. sendPublishFirmwareConfirmation(uuid);
  10641. return result;
  10642. }
  10643. int handleRemoteStartTransactionRequest(char *uuid, char *payload)
  10644. {
  10645. mtrace();
  10646. int result = FAIL;
  10647. int8_t gun_index = -1;
  10648. uint8_t isPeriodOverMax = FALSE;
  10649. uint8_t isProfileOverMax = FALSE;
  10650. uint8_t isConnectorMismatch = FALSE;
  10651. uint8_t isTxProfile = FALSE;
  10652. uint8_t existProfileQuantity = 0;
  10653. uint8_t filename[128]={0};
  10654. uint8_t word[2048]={0};
  10655. FILE *filePtr;
  10656. json_object *RemoteStartTransaction;
  10657. DEBUG_INFO("handleRemoteStartTransactionRequest...\n");
  10658. RemoteStartTransaction = json_tokener_parse(payload);
  10659. if(!is_error(RemoteStartTransaction))
  10660. {
  10661. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  10662. {
  10663. gun_index = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
  10664. }
  10665. else
  10666. {
  10667. /*
  10668. * TODO:
  10669. * 1. Selected connector process
  10670. */
  10671. gun_index = 0;
  10672. }
  10673. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  10674. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  10675. // Required data
  10676. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  10677. {
  10678. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  10679. }
  10680. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  10681. {
  10682. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  10683. {
  10684. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  10685. }
  10686. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  10687. {
  10688. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  10689. }
  10690. }
  10691. // Optional data
  10692. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  10693. {
  10694. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  10695. {
  10696. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  10697. }
  10698. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  10699. {
  10700. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  10701. }
  10702. }
  10703. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  10704. {
  10705. // Check periods is over max configuration
  10706. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  10707. {
  10708. isPeriodOverMax = TRUE;
  10709. }
  10710. // Check periods is over max configuration
  10711. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  10712. {
  10713. if(gun_index > 0)
  10714. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  10715. else
  10716. isConnectorMismatch = TRUE;
  10717. if(!isConnectorMismatch)
  10718. {
  10719. filePtr = fopen((char*)filename, "r");
  10720. if (!filePtr)
  10721. {
  10722. DEBUG_INFO("%s not exist, create it.\n", filename);
  10723. filePtr = fopen((char*)filename, "w+");
  10724. }
  10725. else
  10726. {
  10727. //Check Charging Profile Count
  10728. while(fscanf(filePtr, "%s", word) != EOF)
  10729. {
  10730. //DEBUG_INFO("word=%s\n",word);
  10731. if(strstr((char*)word, "chargingProfileId")!= NULL)
  10732. {
  10733. existProfileQuantity += 1;
  10734. }
  10735. }
  10736. }
  10737. fclose(filePtr);
  10738. }
  10739. }
  10740. else
  10741. {
  10742. }
  10743. if(existProfileQuantity > 3)
  10744. isProfileOverMax = TRUE;
  10745. }
  10746. // Profile replace or add info
  10747. if((gun_index > 0) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTxProfile)
  10748. {
  10749. FILE *infile;
  10750. FILE *outfile;
  10751. char tmpProfileName[32];
  10752. char rmFileCmd[128];
  10753. char tempchargingProfilePurposeStr[30]={0};
  10754. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  10755. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfileRemote");
  10756. infile = fopen ((char*)filename, "r");
  10757. outfile = fopen ((char*)tmpProfileName, "w");
  10758. int d = fgetc(infile);
  10759. rewind(infile);
  10760. if(d == EOF)
  10761. {
  10762. // Profile is empty
  10763. fprintf(outfile,"%s\n", payload);
  10764. fclose(infile);
  10765. fclose(outfile);
  10766. sprintf(rmFileCmd,"rm -f %s",filename);
  10767. system(rmFileCmd);
  10768. rename((char*)tmpProfileName, (char*)filename);
  10769. }
  10770. else
  10771. {
  10772. // Profile is not empty
  10773. char buf[2048]={0};
  10774. int ChargingProfileAdded = FALSE;
  10775. while (fgets(buf, sizeof(buf), infile) != NULL)
  10776. {
  10777. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  10778. json_object *tmpChargingProfile;
  10779. tmpChargingProfile = json_tokener_parse(buf);
  10780. if(!is_error(tmpChargingProfile))
  10781. {
  10782. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  10783. {
  10784. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  10785. }
  10786. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  10787. {
  10788. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  10789. {
  10790. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  10791. }
  10792. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  10793. {
  10794. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  10795. }
  10796. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  10797. {
  10798. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  10799. }
  10800. }
  10801. }
  10802. json_object_put(tmpChargingProfile);
  10803. if((tempconnectorIdInt == gun_index) &&
  10804. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId"))))
  10805. {
  10806. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel"))) &&
  10807. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  10808. {
  10809. if(ChargingProfileAdded == FALSE)
  10810. {
  10811. fprintf(outfile,"%s\n",payload);
  10812. ChargingProfileAdded = TRUE;
  10813. }
  10814. }
  10815. else
  10816. {
  10817. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10818. {
  10819. if(ChargingProfileAdded == FALSE)
  10820. {
  10821. fprintf(outfile,"%s\n",buf);
  10822. fprintf(outfile,"%s\n",payload);
  10823. ChargingProfileAdded = TRUE;
  10824. }
  10825. else
  10826. {
  10827. fprintf(outfile,"%s\n",buf);
  10828. }
  10829. }
  10830. else
  10831. {
  10832. if(ChargingProfileAdded == FALSE)
  10833. {
  10834. fprintf(outfile,"%s\n",buf);
  10835. fprintf(outfile,"%s\n",payload);
  10836. ChargingProfileAdded = TRUE;
  10837. }
  10838. else
  10839. {
  10840. fprintf(outfile,"%s\n",buf);
  10841. }
  10842. }
  10843. }
  10844. }
  10845. else
  10846. {
  10847. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId")))
  10848. {
  10849. if(ChargingProfileAdded == FALSE)
  10850. {
  10851. fprintf(outfile,"%s\n",buf);
  10852. fprintf(outfile,"%s\n",payload);
  10853. ChargingProfileAdded = TRUE;
  10854. }
  10855. else
  10856. {
  10857. fprintf(outfile,"%s\n",buf);
  10858. }
  10859. }
  10860. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10861. {
  10862. if(ChargingProfileAdded == FALSE)
  10863. {
  10864. fprintf(outfile,"%s\n",buf);
  10865. fprintf(outfile,"%s\n",payload);
  10866. ChargingProfileAdded = TRUE;
  10867. }
  10868. else
  10869. {
  10870. fprintf(outfile,"%s\n",buf);
  10871. }
  10872. }
  10873. else
  10874. {
  10875. if(ChargingProfileAdded == FALSE)
  10876. {
  10877. fprintf(outfile,"%s\n",buf);
  10878. fprintf(outfile,"%s\n",payload);
  10879. ChargingProfileAdded = TRUE;
  10880. }
  10881. else
  10882. {
  10883. fprintf(outfile,"%s\n",buf);
  10884. }
  10885. }
  10886. }
  10887. } // end of while loop
  10888. fclose(infile);
  10889. fclose(outfile);
  10890. sprintf(rmFileCmd,"rm -f %s",filename);
  10891. system(rmFileCmd);
  10892. rename((char*)tmpProfileName, (char*)filename);
  10893. }
  10894. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted] );
  10895. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_transactionId);
  10896. result = PASS;
  10897. }
  10898. else
  10899. {
  10900. if(gun_index <= 0)
  10901. DEBUG_WARN("Connector id is wrong.\n");
  10902. if(isConnectorMismatch)
  10903. DEBUG_WARN("Connector id is mismatch.\n");
  10904. if(isPeriodOverMax)
  10905. DEBUG_WARN("Profile periods quantity is over spec.\n");
  10906. if(isProfileOverMax)
  10907. DEBUG_WARN("Profile quantity is over spec.\n");
  10908. if(!isTxProfile)
  10909. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  10910. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  10911. }
  10912. }
  10913. json_object_put(RemoteStartTransaction);
  10914. sendRemoteStartTransactionConfirmation(uuid, gun_index);
  10915. return result;
  10916. }
  10917. int handleRemoteStopTransactionRequest(char *uuid, char *payload)
  10918. {
  10919. mtrace();
  10920. int result = FAIL;
  10921. int match = FALSE;
  10922. int GunNO = 0;
  10923. int tempIndex = 0;
  10924. char transactionIdStr[37];
  10925. int transactionIdIsNULL= TRUE;
  10926. json_object *RemoteStopTransaction;
  10927. DEBUG_INFO("handleRemoteStopTransactionRequest...\n");
  10928. if(server_pending == TRUE)
  10929. {
  10930. return 0;
  10931. }
  10932. RemoteStopTransaction = json_tokener_parse(payload);
  10933. if(!is_error(RemoteStopTransaction))
  10934. {
  10935. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  10936. {
  10937. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  10938. transactionIdIsNULL = FALSE;
  10939. }
  10940. }
  10941. json_object_put(RemoteStopTransaction);
  10942. if(transactionIdIsNULL == FALSE)
  10943. {
  10944. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  10945. {
  10946. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  10947. {
  10948. //check Transaction active
  10949. if(gunType[gun_index] == 'J')
  10950. {
  10951. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10952. {
  10953. tempIndex = ((gun_index==2) ? 1: 0);
  10954. }
  10955. else
  10956. {
  10957. tempIndex = gun_index;
  10958. }
  10959. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10960. {
  10961. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  10962. {
  10963. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10964. {
  10965. match = TRUE;
  10966. GunNO = gun_index;
  10967. }
  10968. }
  10969. }// END FOR CHAdeMO_QUANTITY
  10970. }
  10971. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  10972. {
  10973. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10974. {
  10975. tempIndex = ((gun_index==2) ? 1: 0);
  10976. }
  10977. else
  10978. {
  10979. tempIndex = gun_index;
  10980. }
  10981. for (int index = 0; index < CCS_QUANTITY; index++)
  10982. {
  10983. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  10984. {
  10985. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10986. {
  10987. match = TRUE;
  10988. GunNO = gun_index;
  10989. }
  10990. }
  10991. }// END FOR CCS_QUANTITY
  10992. }
  10993. else if(gunType[gun_index] == 'G')
  10994. {
  10995. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10996. {
  10997. tempIndex = ((gun_index==2) ? 1: 0);
  10998. }
  10999. else
  11000. {
  11001. tempIndex = gun_index;
  11002. }
  11003. for (int index = 0; index < GB_QUANTITY; index++)
  11004. {
  11005. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  11006. {
  11007. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11008. {
  11009. match = TRUE;
  11010. GunNO = gun_index;
  11011. }
  11012. }
  11013. }// END FOR GB_QUANTITY
  11014. }
  11015. else if(gunType[gun_index] == 'O')
  11016. {
  11017. tempIndex = gun_index;
  11018. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  11019. {
  11020. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  11021. {
  11022. 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
  11023. {
  11024. match = TRUE;
  11025. GunNO = gun_index;
  11026. }
  11027. }
  11028. }// END FOR GB_QUANTITY
  11029. }
  11030. else
  11031. {
  11032. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11033. {
  11034. tempIndex = 2;
  11035. }
  11036. else
  11037. {
  11038. tempIndex = gun_index;
  11039. }
  11040. for (int index = 0; index < AC_QUANTITY; index++)
  11041. {
  11042. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  11043. {
  11044. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  11045. {
  11046. match = TRUE;
  11047. GunNO = gun_index;
  11048. }
  11049. }
  11050. }// END FOR CHAdeMO_QUANTITY
  11051. } // END FOR AC ELSE
  11052. }// CHECK IF ResponseTransactionId == transactionIdInt
  11053. }//END FOR
  11054. if( match == TRUE)
  11055. {
  11056. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  11057. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  11058. }
  11059. else
  11060. {
  11061. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  11062. }
  11063. }
  11064. else
  11065. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  11066. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  11067. return result;
  11068. }
  11069. int handleReserveNowRequest(char *uuid, char *payload)
  11070. {
  11071. mtrace();
  11072. int result = FAIL;
  11073. int connectorIdInt=0, reservationIdInt=0;
  11074. int tempIndex = 0;
  11075. json_object *ReserveNow;
  11076. DEBUG_INFO("handleReserveNowRequest ...\n");
  11077. ReserveNow = json_tokener_parse(payload);
  11078. if(!is_error(ReserveNow))
  11079. {
  11080. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  11081. {
  11082. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  11083. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  11084. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  11085. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  11086. }
  11087. // Required data
  11088. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  11089. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  11090. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  11091. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  11092. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  11093. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  11094. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  11095. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  11096. // Optional data
  11097. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  11098. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  11099. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  11100. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  11101. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  11102. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  11103. result = PASS;
  11104. }
  11105. json_object_put(ReserveNow);
  11106. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11107. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  11108. {
  11109. //check Transaction active
  11110. if(gunType[connectorIdInt -1] == 'J')
  11111. {
  11112. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11113. {
  11114. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11115. }
  11116. else
  11117. {
  11118. tempIndex = connectorIdInt -1;
  11119. }
  11120. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11121. {
  11122. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  11123. {
  11124. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  11125. {
  11126. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  11127. {
  11128. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11129. {
  11130. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11131. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11132. }
  11133. 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'))
  11134. {
  11135. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11136. }
  11137. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11138. {
  11139. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11140. }
  11141. else
  11142. {
  11143. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11144. }
  11145. }
  11146. 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
  11147. {
  11148. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11149. }
  11150. }
  11151. else
  11152. {
  11153. //replace reservation
  11154. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11155. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11156. }
  11157. }
  11158. } // END FOR CHAdeMO_QUANTITY
  11159. }
  11160. else if((gunType[connectorIdInt -1] == 'U')||(gunType[connectorIdInt -1] == 'E'))
  11161. {
  11162. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11163. {
  11164. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11165. }
  11166. else
  11167. {
  11168. tempIndex = connectorIdInt -1;
  11169. }
  11170. for (int index = 0; index < CCS_QUANTITY; index++)
  11171. {
  11172. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  11173. {
  11174. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  11175. {
  11176. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11177. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  11178. {
  11179. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11180. {
  11181. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11182. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11183. }
  11184. 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'))
  11185. {
  11186. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11187. }
  11188. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  11189. {
  11190. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11191. }
  11192. else
  11193. {
  11194. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11195. }
  11196. }
  11197. 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
  11198. {
  11199. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11200. }
  11201. }
  11202. else
  11203. {
  11204. //replace reservation
  11205. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11206. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11207. }
  11208. }
  11209. } // END FOR CCS_QUANTITY
  11210. }
  11211. else if(gunType[connectorIdInt -1] == 'G')
  11212. {
  11213. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11214. {
  11215. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11216. }
  11217. else
  11218. {
  11219. tempIndex = connectorIdInt -1;
  11220. }
  11221. for (int index = 0; index < GB_QUANTITY; index++)
  11222. {
  11223. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  11224. {
  11225. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  11226. {
  11227. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11228. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11229. {
  11230. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11231. {
  11232. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11233. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11234. }
  11235. 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'))
  11236. {
  11237. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11238. }
  11239. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11240. {
  11241. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11242. }
  11243. else
  11244. {
  11245. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11246. }
  11247. }
  11248. 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
  11249. {
  11250. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11251. }
  11252. }
  11253. else
  11254. {
  11255. //replace reservation
  11256. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11257. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11258. }
  11259. }
  11260. }// END FOR GB_QUANTITY
  11261. }
  11262. else
  11263. {
  11264. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11265. {
  11266. tempIndex = 2;
  11267. }
  11268. else
  11269. {
  11270. tempIndex = (connectorIdInt -1);
  11271. }
  11272. for (int index = 0; index < AC_QUANTITY; index++)
  11273. {
  11274. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  11275. {
  11276. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11277. {
  11278. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11279. {
  11280. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11281. {
  11282. 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))
  11283. {
  11284. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11285. }
  11286. else
  11287. {
  11288. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11289. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11290. }
  11291. }
  11292. 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'))
  11293. {
  11294. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11295. }
  11296. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11297. {
  11298. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11299. }
  11300. else
  11301. {
  11302. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11303. }
  11304. }
  11305. 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
  11306. {
  11307. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11308. }
  11309. }
  11310. else
  11311. {
  11312. //replace reservation
  11313. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11314. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11315. }
  11316. }
  11317. } // END FOR AC_QUANTITY
  11318. }
  11319. }
  11320. else if(connectorIdInt == 0)
  11321. {
  11322. //check Transaction active
  11323. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11324. {
  11325. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  11326. {
  11327. 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'))
  11328. {
  11329. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11330. goto end;
  11331. }
  11332. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11333. {
  11334. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11335. goto end;
  11336. }
  11337. 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
  11338. {
  11339. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11340. goto end;
  11341. }
  11342. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11343. {
  11344. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11345. goto end;
  11346. }
  11347. }
  11348. }// END FOR CHAdeMO_QUANTITY
  11349. for (int index = 0; index < CCS_QUANTITY; index++)
  11350. {
  11351. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  11352. {
  11353. 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'))
  11354. {
  11355. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11356. goto end;
  11357. }
  11358. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  11359. {
  11360. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11361. goto end;
  11362. }
  11363. 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
  11364. {
  11365. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11366. goto end;
  11367. }
  11368. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11369. {
  11370. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11371. goto end;
  11372. }
  11373. }
  11374. } // END FOR CCS_QUANTITY
  11375. for (int index = 0; index < GB_QUANTITY; index++)
  11376. {
  11377. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  11378. {
  11379. 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'))
  11380. {
  11381. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11382. goto end;
  11383. }
  11384. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11385. {
  11386. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11387. goto end;
  11388. }
  11389. 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
  11390. {
  11391. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11392. goto end;
  11393. }
  11394. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11395. {
  11396. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11397. goto end;
  11398. }
  11399. }
  11400. } // END FOR GB_QUANTITY
  11401. for (int index = 0; index < AC_QUANTITY; index++)
  11402. {
  11403. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11404. {
  11405. 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'))
  11406. {
  11407. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11408. goto end;
  11409. }
  11410. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11411. {
  11412. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11413. goto end;
  11414. }
  11415. 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
  11416. {
  11417. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11418. goto end;
  11419. }
  11420. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11421. {
  11422. 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))
  11423. {
  11424. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11425. goto end;
  11426. }
  11427. }
  11428. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11429. {
  11430. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11431. goto end;
  11432. }
  11433. }
  11434. }// END FOR AC_QUANTITY
  11435. //The connectorId is 0
  11436. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  11437. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11438. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  11439. result = TRUE;
  11440. return result;
  11441. }
  11442. else
  11443. {
  11444. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11445. }
  11446. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  11447. {
  11448. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  11449. result = TRUE;
  11450. return result;
  11451. }
  11452. end:
  11453. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  11454. return result;
  11455. }
  11456. int handleResetRequest(char *uuid, char *payload)
  11457. {
  11458. mtrace();
  11459. int result = FAIL;
  11460. json_object *Reset = json_object_new_object();
  11461. DEBUG_INFO("handleResetRequest...\n");
  11462. Reset = json_tokener_parse(payload);
  11463. if(!is_error(Reset))
  11464. {
  11465. // Required data
  11466. if(json_object_object_get(Reset, "type") != NULL)
  11467. {
  11468. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  11469. }
  11470. if(json_object_object_get(Reset, "evseId") != NULL)
  11471. {
  11472. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  11473. }
  11474. }
  11475. json_object_put(Reset);
  11476. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  11477. {
  11478. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  11479. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  11480. result = TRUE;
  11481. return result;
  11482. }
  11483. else
  11484. {
  11485. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  11486. goto errorend;
  11487. }
  11488. errorend:
  11489. sendResetConfirmation(uuid);
  11490. return result;
  11491. }
  11492. int handleSendLocalListRequest(char *uuid, char *payload)
  11493. {
  11494. mtrace();
  11495. int result = FAIL;
  11496. char updateTypestr[15]={0};
  11497. int checkState_Faulted = FALSE;
  11498. json_object *SendLocalList;
  11499. DEBUG_INFO("handleSendLocalListRequest...\n");
  11500. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  11501. {
  11502. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11503. goto end;
  11504. }
  11505. SendLocalList = json_tokener_parse(payload);
  11506. if(!is_error(SendLocalList))
  11507. {
  11508. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  11509. // Required data
  11510. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  11511. {
  11512. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  11513. }
  11514. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  11515. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  11516. // Optional data
  11517. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  11518. {
  11519. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  11520. {
  11521. // Required data
  11522. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  11523. {
  11524. 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")));
  11525. 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")));
  11526. }
  11527. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  11528. {
  11529. 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")));
  11530. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  11531. 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")));
  11532. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  11533. 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"));
  11534. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  11535. {
  11536. 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")));
  11537. 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")));
  11538. }
  11539. }
  11540. }
  11541. }
  11542. }
  11543. json_object_put(SendLocalList);
  11544. //check Charge Point state
  11545. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11546. {
  11547. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11548. {
  11549. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11550. }
  11551. }
  11552. for (int index = 0; index < CCS_QUANTITY; index++)
  11553. {
  11554. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11555. {
  11556. checkState_Faulted = TRUE; //OCPP Status
  11557. }
  11558. }
  11559. for (int index = 0; index < GB_QUANTITY; index++)
  11560. {
  11561. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11562. {
  11563. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11564. }
  11565. }
  11566. for (int index = 0; index < AC_QUANTITY; index++)
  11567. {
  11568. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11569. {
  11570. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11571. }
  11572. }
  11573. if(checkState_Faulted == TRUE)
  11574. {
  11575. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11576. goto end;
  11577. }
  11578. // Check update type
  11579. if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  11580. {
  11581. //Local list full update
  11582. DEBUG_INFO("Local list full update.\n");
  11583. DB_getListVerion();
  11584. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11585. {
  11586. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11587. goto end;
  11588. }
  11589. DB_cleanLocalList();
  11590. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11591. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11592. }
  11593. else if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  11594. {
  11595. //Local list different update
  11596. DEBUG_INFO("Local list different update.\n");
  11597. DB_getListVerion();
  11598. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11599. {
  11600. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  11601. goto end;
  11602. }
  11603. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11604. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11605. }
  11606. else
  11607. {
  11608. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11609. goto end;
  11610. }
  11611. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  11612. end:
  11613. sendSendLocalListConfirmation(uuid);
  11614. return result;
  11615. }
  11616. int handleSetChargingProfileRequest(char *uuid, char *payload)
  11617. {
  11618. mtrace();
  11619. int result = FAIL;
  11620. int8_t gun_index = -1;
  11621. uint8_t isPeriodOverMax = FALSE;
  11622. uint8_t isProfileOverMax = FALSE;
  11623. uint8_t isConnectorMismatch = FALSE;
  11624. uint8_t existProfileQuantity = 0;
  11625. uint8_t filename[128]={0};
  11626. uint8_t word[2048]={0};
  11627. FILE *filePtr;
  11628. json_object *SetChargingProfile;
  11629. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  11630. SetChargingProfile = json_tokener_parse(payload);
  11631. if(!is_error(SetChargingProfile))
  11632. {
  11633. // Required data
  11634. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  11635. {
  11636. gun_index = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  11637. }
  11638. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  11639. {
  11640. // Check periods is over max configuration
  11641. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  11642. {
  11643. isPeriodOverMax = TRUE;
  11644. }
  11645. // Check periods is over max configuration
  11646. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  11647. {
  11648. if(gun_index == 0)
  11649. {
  11650. sprintf((char*)filename, ChargePointMaxProfile_JSON);
  11651. filePtr = fopen((char*)filename, "r");
  11652. if (!filePtr)
  11653. {
  11654. DEBUG_INFO("%s not exist, create it.\n", ChargePointMaxProfile_JSON);
  11655. filePtr = fopen((char*)filename, "w+");
  11656. }
  11657. else
  11658. {
  11659. //Check Charging Profile Count
  11660. while(fscanf(filePtr, "%s", word) != EOF)
  11661. {
  11662. //DEBUG_INFO("word=%s\n",word);
  11663. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11664. {
  11665. existProfileQuantity += 1;
  11666. }
  11667. }
  11668. }
  11669. fclose(filePtr);
  11670. }
  11671. else
  11672. isConnectorMismatch = TRUE;
  11673. }
  11674. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  11675. {
  11676. if(gun_index < 5)
  11677. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", gun_index);
  11678. else
  11679. isConnectorMismatch = TRUE;
  11680. if(!isConnectorMismatch)
  11681. {
  11682. filePtr = fopen((char*)filename, "r");
  11683. if (!filePtr)
  11684. {
  11685. DEBUG_INFO("%s not exist, create it.\n", filename);
  11686. filePtr = fopen((char*)filename, "w+");
  11687. }
  11688. else
  11689. {
  11690. //Check Charging Profile Count
  11691. while(fscanf(filePtr, "%s", word) != EOF)
  11692. {
  11693. //DEBUG_INFO("word=%s\n",word);
  11694. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11695. {
  11696. existProfileQuantity += 1;
  11697. }
  11698. }
  11699. }
  11700. fclose(filePtr);
  11701. }
  11702. }
  11703. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  11704. {
  11705. if(gun_index>0)
  11706. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  11707. else
  11708. isConnectorMismatch = TRUE;
  11709. if(!isConnectorMismatch)
  11710. {
  11711. filePtr = fopen((char*)filename, "r");
  11712. if (!filePtr)
  11713. {
  11714. DEBUG_INFO("%s not exist, create it.\n", filename);
  11715. filePtr = fopen((char*)filename, "w+");
  11716. }
  11717. else
  11718. {
  11719. //Check Charging Profile Count
  11720. while(fscanf(filePtr, "%s", word) != EOF)
  11721. {
  11722. //DEBUG_INFO("word=%s\n",word);
  11723. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11724. {
  11725. existProfileQuantity += 1;
  11726. }
  11727. }
  11728. }
  11729. fclose(filePtr);
  11730. }
  11731. }
  11732. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  11733. {
  11734. }
  11735. else
  11736. {
  11737. }
  11738. if(existProfileQuantity > 3)
  11739. isProfileOverMax = TRUE;
  11740. }
  11741. // Profile replace or add info
  11742. if((gun_index > -1) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch)
  11743. {
  11744. FILE *infile;
  11745. FILE *outfile;
  11746. char tmpProfileName[32];
  11747. char rmFileCmd[128];
  11748. char tempchargingProfilePurposeStr[30]={0};
  11749. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  11750. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfile");
  11751. infile = fopen ((char*)filename, "r");
  11752. outfile = fopen ((char*)tmpProfileName, "w");
  11753. int d = fgetc(infile);
  11754. rewind(infile);
  11755. if(d == EOF)
  11756. {
  11757. // Profile is empty
  11758. fprintf(outfile,"%s\n", payload);
  11759. fclose(infile);
  11760. fclose(outfile);
  11761. sprintf(rmFileCmd,"rm -f %s",filename);
  11762. system(rmFileCmd);
  11763. rename((char*)tmpProfileName, (char*)filename);
  11764. }
  11765. else
  11766. {
  11767. // Profile is not empty
  11768. char buf[2048]={0};
  11769. int ChargingProfileAdded = FALSE;
  11770. while (fgets(buf, sizeof(buf), infile) != NULL)
  11771. {
  11772. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  11773. json_object *tmpChargingProfile;
  11774. tmpChargingProfile = json_tokener_parse(buf);
  11775. if(!is_error(tmpChargingProfile))
  11776. {
  11777. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  11778. {
  11779. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  11780. }
  11781. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  11782. {
  11783. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  11784. {
  11785. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  11786. }
  11787. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  11788. {
  11789. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  11790. }
  11791. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  11792. {
  11793. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  11794. }
  11795. }
  11796. }
  11797. json_object_put(tmpChargingProfile);
  11798. if((tempconnectorIdInt == gun_index) &&
  11799. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId"))))
  11800. {
  11801. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel"))) &&
  11802. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  11803. {
  11804. //DEBUG_INFO("update set chargingProfile to file -0\n");
  11805. if(ChargingProfileAdded == FALSE)
  11806. {
  11807. fprintf(outfile,"%s\n",payload);
  11808. ChargingProfileAdded = TRUE;
  11809. }
  11810. }
  11811. else
  11812. {
  11813. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11814. {
  11815. if(ChargingProfileAdded == FALSE)
  11816. {
  11817. fprintf(outfile,"%s\n",buf);
  11818. fprintf(outfile,"%s\n",payload);
  11819. ChargingProfileAdded = TRUE;
  11820. }
  11821. else
  11822. {
  11823. fprintf(outfile,"%s\n",buf);
  11824. }
  11825. }
  11826. else
  11827. {
  11828. if(ChargingProfileAdded == FALSE)
  11829. {
  11830. fprintf(outfile,"%s\n",buf);
  11831. fprintf(outfile,"%s\n",payload);
  11832. ChargingProfileAdded = TRUE;
  11833. }
  11834. else
  11835. {
  11836. fprintf(outfile,"%s\n",buf);
  11837. }
  11838. }
  11839. }
  11840. }
  11841. else
  11842. {
  11843. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId")))
  11844. {
  11845. if(ChargingProfileAdded == FALSE)
  11846. {
  11847. fprintf(outfile,"%s\n",buf);
  11848. fprintf(outfile,"%s\n",payload);
  11849. ChargingProfileAdded = TRUE;
  11850. }
  11851. else
  11852. {
  11853. fprintf(outfile,"%s\n",buf);
  11854. }
  11855. }
  11856. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11857. {
  11858. if(ChargingProfileAdded == FALSE)
  11859. {
  11860. fprintf(outfile,"%s\n",buf);
  11861. fprintf(outfile,"%s\n",payload);
  11862. ChargingProfileAdded = TRUE;
  11863. }
  11864. else
  11865. {
  11866. fprintf(outfile,"%s\n",buf);
  11867. }
  11868. }
  11869. else
  11870. {
  11871. if(ChargingProfileAdded == FALSE)
  11872. {
  11873. fprintf(outfile,"%s\n",buf);
  11874. fprintf(outfile,"%s\n",payload);
  11875. ChargingProfileAdded = TRUE;
  11876. }
  11877. else
  11878. {
  11879. fprintf(outfile,"%s\n",buf);
  11880. }
  11881. }
  11882. }
  11883. } // end of while loop
  11884. fclose(infile);
  11885. fclose(outfile);
  11886. sprintf(rmFileCmd,"rm -f %s",filename);
  11887. system(rmFileCmd);
  11888. rename((char*)tmpProfileName, (char*)filename);
  11889. }
  11890. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  11891. result = PASS;
  11892. }
  11893. else
  11894. {
  11895. if(gun_index == -1)
  11896. DEBUG_WARN("Connector id is wrong.\n");
  11897. if(isConnectorMismatch)
  11898. DEBUG_WARN("Connector id is mismatch.\n");
  11899. if(isPeriodOverMax)
  11900. DEBUG_WARN("Profile periods quantity is over spec.\n");
  11901. if(isProfileOverMax)
  11902. DEBUG_WARN("Profile quantity is over spec.\n");
  11903. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  11904. }
  11905. }
  11906. json_object_put(SetChargingProfile);
  11907. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  11908. {
  11909. if(gun_index == 0)
  11910. {
  11911. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  11912. {
  11913. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  11914. }
  11915. }
  11916. else
  11917. checkCompositeSchedule(gun_index, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index-1]);
  11918. }
  11919. sendSetChargingProfileConfirmation(uuid, (gun_index==0?gun_index:gun_index-1));
  11920. return result;
  11921. }
  11922. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  11923. {
  11924. mtrace();
  11925. int result = FAIL;
  11926. json_object *SetDisplayMessage;
  11927. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  11928. SetDisplayMessage = json_tokener_parse(payload);
  11929. if(!is_error(SetDisplayMessage))
  11930. {
  11931. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  11932. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  11933. // Required data
  11934. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  11935. {
  11936. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  11937. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  11938. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  11939. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  11940. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  11941. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  11942. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  11943. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  11944. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  11945. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  11946. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  11947. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  11948. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  11949. {
  11950. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  11951. 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")));
  11952. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  11953. 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")));
  11954. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  11955. 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")));
  11956. }
  11957. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  11958. {
  11959. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  11960. 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")));
  11961. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  11962. 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")));
  11963. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  11964. {
  11965. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  11966. 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"));
  11967. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  11968. 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"));
  11969. }
  11970. }
  11971. }
  11972. }
  11973. json_object_put(SetDisplayMessage);
  11974. /*
  11975. * TODO:
  11976. * 1. Configure display message and response
  11977. */
  11978. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  11979. sendSetMonitoringBaseConfirmation(uuid);
  11980. return result;
  11981. }
  11982. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  11983. {
  11984. mtrace();
  11985. int result = FAIL;
  11986. json_object *SetMonitoringBase;
  11987. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  11988. SetMonitoringBase = json_tokener_parse(payload);
  11989. if(!is_error(SetMonitoringBase))
  11990. {
  11991. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  11992. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  11993. // Required data
  11994. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  11995. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  11996. }
  11997. json_object_put(SetMonitoringBase);
  11998. /*
  11999. * TODO:
  12000. * 1. Configure monitor base and response
  12001. */
  12002. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  12003. sendSetMonitoringBaseConfirmation(uuid);
  12004. return result;
  12005. }
  12006. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  12007. {
  12008. mtrace();
  12009. int result = FAIL;
  12010. json_object *SetMonitoringLevel;
  12011. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  12012. SetMonitoringLevel = json_tokener_parse(payload);
  12013. if(!is_error(SetMonitoringLevel))
  12014. {
  12015. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  12016. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  12017. // Required data
  12018. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  12019. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  12020. }
  12021. json_object_put(SetMonitoringLevel);
  12022. /*
  12023. * TODO:
  12024. * Configure monitor status and response
  12025. */
  12026. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  12027. sendSetMonitoringLevelConfirmation(uuid);
  12028. return result;
  12029. }
  12030. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  12031. {
  12032. mtrace();
  12033. int result = FAIL;
  12034. json_object *SetNetworkProfile;
  12035. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  12036. SetNetworkProfile = json_tokener_parse(payload);
  12037. if(!is_error(SetNetworkProfile))
  12038. {
  12039. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  12040. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  12041. // Required data
  12042. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  12043. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  12044. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  12045. {
  12046. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  12047. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  12048. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  12049. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  12050. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  12051. {
  12052. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  12053. memcpy((char*)ShmSysConfigAndInfo->SysConfig.OcppServerURL, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl));
  12054. }
  12055. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  12056. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  12057. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  12058. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  12059. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  12060. {
  12061. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  12062. 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")));
  12063. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  12064. 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")));
  12065. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  12066. 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")));
  12067. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  12068. 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")));
  12069. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  12070. 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")));
  12071. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  12072. 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")));
  12073. }
  12074. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  12075. {
  12076. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  12077. {
  12078. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  12079. 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")));
  12080. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  12081. }
  12082. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  12083. {
  12084. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  12085. 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")));
  12086. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  12087. }
  12088. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  12089. {
  12090. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  12091. 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")));
  12092. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  12093. }
  12094. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  12095. 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"));
  12096. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  12097. 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")));
  12098. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  12099. 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"));
  12100. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  12101. 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")));
  12102. }
  12103. DB_addNetworkProfile(ShmOCPP20Data->SetNetworkProfile.configurationSlot, (char*)json_object_get_string(json_object_object_get(SetNetworkProfile, "connectionData")));
  12104. }
  12105. }
  12106. json_object_put(SetNetworkProfile);
  12107. /*
  12108. * TODO:
  12109. * 1. Process network configuration and response
  12110. */
  12111. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  12112. {
  12113. }
  12114. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  12115. {
  12116. }
  12117. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  12118. {
  12119. }
  12120. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  12121. {
  12122. }
  12123. else
  12124. {
  12125. }
  12126. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  12127. {
  12128. }
  12129. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  12130. {
  12131. }
  12132. else
  12133. {
  12134. }
  12135. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  12136. {
  12137. }
  12138. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  12139. {
  12140. }
  12141. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  12142. {
  12143. }
  12144. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  12145. {
  12146. }
  12147. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  12148. {
  12149. }
  12150. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  12151. {
  12152. }
  12153. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  12154. {
  12155. }
  12156. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  12157. {
  12158. }
  12159. else
  12160. {
  12161. }
  12162. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  12163. {
  12164. }
  12165. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  12166. {
  12167. }
  12168. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  12169. {
  12170. }
  12171. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  12172. {
  12173. }
  12174. else
  12175. {
  12176. }
  12177. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  12178. {
  12179. }
  12180. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  12181. {
  12182. }
  12183. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  12184. {
  12185. }
  12186. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  12187. {
  12188. }
  12189. else
  12190. {
  12191. }
  12192. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  12193. sendSetNetworkProfileConfirmation(uuid);
  12194. return result;
  12195. }
  12196. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  12197. {
  12198. mtrace();
  12199. int result = FAIL;
  12200. json_object *SetVariableMonitoring;
  12201. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  12202. SetVariableMonitoring = json_tokener_parse(payload);
  12203. if(!is_error(SetVariableMonitoring))
  12204. {
  12205. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  12206. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  12207. // Required data
  12208. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  12209. {
  12210. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  12211. {
  12212. 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"));
  12213. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  12214. }
  12215. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  12216. {
  12217. 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"));
  12218. /*
  12219. * TODO:
  12220. * 1. Check monitor value status
  12221. */
  12222. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, MonitorEnumTypeStr[MonitorEnumType_Delta]);
  12223. }
  12224. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  12225. {
  12226. 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")));
  12227. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  12228. }
  12229. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  12230. {
  12231. 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"));
  12232. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  12233. }
  12234. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  12235. {
  12236. 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"));
  12237. }
  12238. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component") != NULL)
  12239. {
  12240. 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)
  12241. {
  12242. 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")));
  12243. }
  12244. 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)
  12245. {
  12246. 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")));
  12247. }
  12248. 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)
  12249. {
  12250. 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)
  12251. {
  12252. 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"));
  12253. }
  12254. 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)
  12255. {
  12256. 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"));
  12257. }
  12258. }
  12259. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  12260. }
  12261. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable") != NULL)
  12262. {
  12263. 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)
  12264. {
  12265. 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")));
  12266. }
  12267. 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)
  12268. {
  12269. 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")));
  12270. }
  12271. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  12272. }
  12273. }
  12274. }
  12275. json_object_put(SetVariableMonitoring);
  12276. return result;
  12277. }
  12278. int handleSetVariablesRequest(char *uuid, char *payload)
  12279. {
  12280. mtrace();
  12281. int result = FAIL;
  12282. json_object *SetVariables;
  12283. DEBUG_INFO("handleSetVariablesRequest...\n");
  12284. SetVariables = json_tokener_parse(payload);
  12285. if(!is_error(SetVariables))
  12286. {
  12287. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  12288. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  12289. // Required data
  12290. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  12291. {
  12292. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  12293. {
  12294. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  12295. {
  12296. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  12297. {
  12298. 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")));
  12299. }
  12300. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  12301. {
  12302. 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")));
  12303. }
  12304. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  12305. {
  12306. 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)
  12307. {
  12308. 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"));
  12309. }
  12310. 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)
  12311. {
  12312. 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"));
  12313. }
  12314. }
  12315. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  12316. }
  12317. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  12318. {
  12319. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  12320. {
  12321. 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")));
  12322. }
  12323. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  12324. {
  12325. 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")));
  12326. }
  12327. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  12328. }
  12329. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  12330. {
  12331. 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")));
  12332. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  12333. }
  12334. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  12335. {
  12336. 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")));
  12337. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  12338. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  12339. {
  12340. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL) &&
  12341. (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) &&
  12342. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name) != NULL) &&
  12343. (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))
  12344. {
  12345. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  12346. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  12347. if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "NetworkConfigurationPriority") != NULL))
  12348. {
  12349. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]);
  12350. }
  12351. else
  12352. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  12353. }
  12354. }
  12355. }
  12356. }
  12357. }
  12358. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  12359. }
  12360. json_object_put(SetVariables);
  12361. return result;
  12362. }
  12363. int handleTriggerMessageRequest(char *uuid, char *payload)
  12364. {
  12365. mtrace();
  12366. int result = FAIL;
  12367. int connectorIdIsNULL = FALSE;
  12368. int connectorIdInt =0;
  12369. char requestedMessagestr[40]={0};
  12370. json_object *TriggerMessage;
  12371. DEBUG_INFO("handleTriggerMessageRequest\n");
  12372. TriggerMessage = json_tokener_parse(payload);
  12373. if(!is_error(TriggerMessage))
  12374. {
  12375. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  12376. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  12377. // Required data
  12378. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  12379. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  12380. // Optional data
  12381. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  12382. {
  12383. // Required data
  12384. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  12385. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  12386. // Optional data
  12387. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  12388. {
  12389. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  12390. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  12391. }
  12392. else
  12393. connectorIdIsNULL = TRUE;
  12394. }
  12395. }
  12396. json_object_put(TriggerMessage);
  12397. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  12398. {
  12399. if((strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  12400. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  12401. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  12402. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  12403. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  12404. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  12405. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  12406. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  12407. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  12408. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  12409. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  12410. {
  12411. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  12412. sendTriggerMessageConfirmation(uuid);
  12413. return TRUE;
  12414. }
  12415. else
  12416. {
  12417. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  12418. sendTriggerMessageConfirmation(uuid);
  12419. }
  12420. }
  12421. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  12422. {
  12423. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  12424. sendTriggerMessageConfirmation(uuid);
  12425. return TRUE;
  12426. }
  12427. //==========================
  12428. // Trigger message
  12429. //==========================
  12430. if( strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  12431. {
  12432. if((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) &&
  12433. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) &&
  12434. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) &&
  12435. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing) )
  12436. {
  12437. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  12438. }
  12439. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusNotificationStatus]);
  12440. }
  12441. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  12442. {
  12443. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[LogStatusNotificationStatus]);
  12444. }
  12445. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  12446. {
  12447. if(DB_updateBootType(BootReasonEnumType_Triggered))
  12448. server_sign = FALSE;
  12449. }
  12450. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  12451. {
  12452. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval);
  12453. }
  12454. else if (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  12455. {
  12456. if(connectorIdIsNULL == FALSE)
  12457. {
  12458. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12459. {
  12460. //sendMeterValuesRequest((connectorIdInt -1), ReadingContext_Trigger);
  12461. cpinitateMsg.bits[connectorIdInt -1].TriggerMeterValueReq = ON;
  12462. }
  12463. }
  12464. else
  12465. {
  12466. for(int idx=0;idx< gunTotalNumber;idx++)
  12467. {
  12468. //sendMeterValuesRequest(idx, ReadingContext_Trigger);
  12469. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  12470. }
  12471. }
  12472. }
  12473. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  12474. {
  12475. if(connectorIdIsNULL == FALSE)
  12476. {
  12477. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12478. {
  12479. cpinitateMsg.bits[connectorIdInt -1].StatusNotificationReq = ON;
  12480. }
  12481. }
  12482. else
  12483. {
  12484. for(int idx=0;idx< gunTotalNumber;idx++)
  12485. cpinitateMsg.bits[idx].StatusNotificationReq = ON;
  12486. }
  12487. }
  12488. return result;
  12489. }
  12490. int handleUnlockConnectorRequest(char *uuid, char *payload)
  12491. {
  12492. mtrace();
  12493. int result = FAIL;
  12494. int connectorIdInt =0;
  12495. int tempIndex = 0;
  12496. json_object *UnlockConnector;
  12497. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  12498. UnlockConnector = json_tokener_parse(payload);
  12499. if(!is_error(UnlockConnector))
  12500. {
  12501. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  12502. {
  12503. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  12504. }
  12505. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  12506. {
  12507. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  12508. }
  12509. }
  12510. json_object_put(UnlockConnector);
  12511. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  12512. if(gunTotalNumber == 0)
  12513. {
  12514. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12515. goto end;
  12516. }
  12517. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  12518. {
  12519. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12520. goto end;
  12521. }
  12522. else
  12523. {
  12524. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  12525. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  12526. //check Transaction active
  12527. if(gunType[connectorIdInt-1] == 'J')
  12528. {
  12529. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12530. {
  12531. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12532. }
  12533. else
  12534. {
  12535. tempIndex = connectorIdInt -1;
  12536. }
  12537. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12538. {
  12539. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12540. {
  12541. //stop Transaction
  12542. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12543. }
  12544. }
  12545. }
  12546. else if((gunType[connectorIdInt-1] == 'U')||(gunType[connectorIdInt-1] == 'E'))
  12547. {
  12548. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12549. {
  12550. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12551. }
  12552. else
  12553. {
  12554. tempIndex = connectorIdInt -1;
  12555. }
  12556. for (int index = 0; index < CCS_QUANTITY; index++)
  12557. {
  12558. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12559. {
  12560. //stop Transaction
  12561. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12562. }
  12563. }
  12564. }
  12565. else if(gunType[connectorIdInt-1] == 'G')
  12566. {
  12567. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12568. {
  12569. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12570. }
  12571. else
  12572. {
  12573. tempIndex = connectorIdInt -1;
  12574. }
  12575. for (int index = 0; index < GB_QUANTITY; index++)
  12576. {
  12577. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)))
  12578. {
  12579. //stop Transaction
  12580. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12581. }
  12582. }
  12583. }
  12584. else
  12585. {
  12586. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  12587. {
  12588. tempIndex = 2;
  12589. }
  12590. else
  12591. {
  12592. tempIndex = connectorIdInt-1;
  12593. }
  12594. for (int index = 0; index < AC_QUANTITY; index++)
  12595. {
  12596. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12597. {
  12598. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12599. }
  12600. }
  12601. }
  12602. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  12603. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  12604. result = TRUE;
  12605. return result;
  12606. }
  12607. end:
  12608. //json_object_put(obj); --- remove temporally
  12609. sendUnlockConnectorConfirmation(uuid, connectorIdInt-1);
  12610. return result;
  12611. }
  12612. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  12613. {
  12614. mtrace();
  12615. int result = FAIL;
  12616. json_object *UnpublishFirmware;
  12617. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  12618. UnpublishFirmware = json_tokener_parse(payload);
  12619. if(!is_error(UnpublishFirmware))
  12620. {
  12621. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  12622. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  12623. // Required data
  12624. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  12625. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  12626. }
  12627. json_object_put(UnpublishFirmware);
  12628. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  12629. /*
  12630. * TODO:
  12631. * 1. Check unpublished status
  12632. */
  12633. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  12634. sendUnpublishFirmwareConfirmation(uuid);
  12635. return result;
  12636. }
  12637. static char UpdateFirmwarepayloadData[512]={0};
  12638. void *UpdateFirmwareProcess(void *data)
  12639. {
  12640. pthread_detach(pthread_self());
  12641. mtrace();
  12642. int retriesInt =0, retryIntervalInt=0;
  12643. char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
  12644. int port=0;
  12645. char locationstr[160]={0}, retrieveDatestr[30]={0};
  12646. int isSuccess = 0;
  12647. char ftpbuf[200];
  12648. char temp[100];
  12649. char * pch;
  12650. DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
  12651. json_object *UpdateFirmware;
  12652. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  12653. if(!is_error(UpdateFirmware))
  12654. {
  12655. // Required data
  12656. if(json_object_object_get(UpdateFirmware, "location") != NULL)
  12657. sprintf((char*)locationstr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "location")));
  12658. if(json_object_object_get(UpdateFirmware, "retrieveDate") != NULL)
  12659. sprintf((char*)retrieveDatestr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "retrieveDate")));
  12660. // Optional data
  12661. if(json_object_object_get(UpdateFirmware, "retries"))
  12662. {
  12663. retriesInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  12664. }
  12665. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  12666. {
  12667. retryIntervalInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  12668. }
  12669. }
  12670. json_object_put(UpdateFirmware);
  12671. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  12672. memset(path, 0, ARRAY_SIZE(path));
  12673. system("rm -f /mnt/*");
  12674. if(strncmp(locationstr,"http", 4) == 0)
  12675. {
  12676. sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  12677. //sscanf(locationstr,"%[^:]:%*2[/]%[^:]:%[^@]@%[^/]%199[^\n]",
  12678. // protocol, user, password, host, path);
  12679. sprintf(ftppath,"/%s", path);
  12680. DEBUG_INFO("locationstr: %s\n", locationstr);
  12681. DEBUG_INFO("protocol: %s\n",protocol);
  12682. DEBUG_INFO("host: %s\n",host);
  12683. DEBUG_INFO("path: %s\n",path);
  12684. DEBUG_INFO("ftppath: %s\n",ftppath);
  12685. int ftppathlen=strlen(ftppath);
  12686. int i=1;
  12687. char filenametemp[50];
  12688. while(i < ftppathlen)
  12689. {
  12690. int len=ftppathlen-i;
  12691. if(ftppath[len]== 47) // '/' ascll code: 47
  12692. {
  12693. DEBUG_INFO("compare '/' all right\n");
  12694. break;
  12695. }
  12696. i=i+1;
  12697. }
  12698. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12699. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  12700. filenametemp[i+1] = 0;
  12701. do
  12702. {
  12703. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12704. sleep(3);
  12705. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
  12706. if(!isSuccess)
  12707. {
  12708. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12709. sleep(retryIntervalInt);
  12710. }
  12711. else
  12712. {
  12713. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12714. }
  12715. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
  12716. }
  12717. else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
  12718. {
  12719. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12720. memset(temp, 0, ARRAY_SIZE(temp));
  12721. //DEBUG_INFO("locationstr=%s\n",locationstr);
  12722. strcpy(ftpbuf, locationstr/*"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/DemoDC1_2018-07-13_185011_PSULog.zip"*/ );
  12723. int ftppathlen=strlen(ftpbuf);
  12724. int i=1;
  12725. char filenametemp[50];
  12726. while(i < ftppathlen)
  12727. {
  12728. int len=ftppathlen-i;
  12729. if(ftpbuf[len]== 47) // '/' ascll code: 47
  12730. {
  12731. DEBUG_INFO(" compare '/' all right\n");
  12732. break;
  12733. }
  12734. i=i+1;
  12735. }
  12736. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12737. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  12738. filenametemp[i+1] = 0;
  12739. strncpy(temp, ftpbuf, ftppathlen-i+1);
  12740. pch=strchr(temp,'@');
  12741. if(pch==NULL)
  12742. {
  12743. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  12744. protocol, host, &port, path);
  12745. strcpy(user,"anonymous");
  12746. strcpy(password,"");
  12747. }
  12748. else
  12749. {
  12750. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  12751. protocol, user, password, host, &port, path);
  12752. }
  12753. sscanf(host,"%[^/]%s",host1, path1);
  12754. sprintf(ftppath,"%s", path1);
  12755. //DEBUG_INFO("protocol =%s\n",protocol);
  12756. //DEBUG_INFO("user =%s\n",user);
  12757. //DEBUG_INFO("password =%s\n",password);
  12758. //DEBUG_INFO("host1 =%s\n",host1);
  12759. //DEBUG_INFO("port =%d\n",port);
  12760. //DEBUG_INFO("path1 =%s\n",path1);
  12761. //DEBUG_INFO("ftppath=%s\n",ftppath);
  12762. //ftpFile(host, user, password, port, ftppath, fname);
  12763. //download firmware pthred
  12764. if(port == 0)
  12765. {
  12766. port = 21;
  12767. }
  12768. do
  12769. {
  12770. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12771. sleep(3);
  12772. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
  12773. if(!isSuccess)
  12774. {
  12775. //BulldogUtil.sleepMs(interval*1000);
  12776. DEBUG_INFO("Update firmware request and download file fail.\n");
  12777. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12778. sleep(retryIntervalInt);
  12779. }
  12780. else
  12781. {
  12782. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12783. }
  12784. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  12785. }
  12786. else
  12787. {
  12788. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12789. }
  12790. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  12791. pthread_exit(NULL);
  12792. }
  12793. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  12794. {
  12795. mtrace();
  12796. int result = FAIL;
  12797. pthread_t t;
  12798. sendUpdateFirmwareConfirmation(uuid);
  12799. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  12800. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  12801. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  12802. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  12803. ////pthread_join(t, NULL); //
  12804. //pthread_detach(t);
  12805. //sendUpdateFirmwareConfirmation(uuid);
  12806. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  12807. return result;
  12808. }
  12809. //==========================================
  12810. // Handle server response routine
  12811. //==========================================
  12812. void handleAuthorizeResponse(char *payload, int gun_index)
  12813. {
  12814. mtrace();
  12815. DEBUG_INFO("handleAuthorizeResponse...\n");
  12816. json_object *Authorize;
  12817. Authorize = json_tokener_parse(payload);
  12818. if(!is_error(Authorize))
  12819. {
  12820. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  12821. {
  12822. // Required data
  12823. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  12824. // Optional data
  12825. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  12826. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  12827. else
  12828. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  12829. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  12830. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  12831. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  12832. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  12833. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  12834. {
  12835. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  12836. {
  12837. 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));
  12838. }
  12839. }
  12840. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  12841. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  12842. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  12843. {
  12844. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  12845. 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")));
  12846. else
  12847. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  12848. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  12849. 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")));
  12850. }
  12851. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  12852. {
  12853. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  12854. 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")));
  12855. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  12856. 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")));
  12857. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  12858. 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")));
  12859. }
  12860. }
  12861. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  12862. {
  12863. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  12864. }
  12865. }
  12866. json_object_put(Authorize);
  12867. //Update idTag information to authorization cache if supported
  12868. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  12869. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  12870. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  12871. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  12872. {
  12873. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  12874. }
  12875. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  12876. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  12877. authorizeRetryTimes = 0;
  12878. }
  12879. void handleBootNotificationResponse(char *payload, int gun_index)
  12880. {
  12881. mtrace();
  12882. char statusStr[12]={0};
  12883. char currentTimeStr[30]={0};
  12884. int intervalInt = 0;
  12885. struct tm tp;
  12886. char buf[28]={0};
  12887. char timebuf[50]={0};
  12888. DEBUG_INFO("handleBootNotificationResponse...\n");
  12889. json_object *BootNotification;
  12890. BootNotification = json_tokener_parse(payload);
  12891. if(!is_error(BootNotification))
  12892. {
  12893. // Required data
  12894. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  12895. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  12896. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  12897. }
  12898. json_object_put(BootNotification);
  12899. DEBUG_INFO("statusStr: %s\n", statusStr);
  12900. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  12901. BootNotificationInterval = intervalInt;
  12902. HeartBeatWaitTime = intervalInt;
  12903. //write back to ShmOCPP20Data->BootNotification
  12904. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  12905. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  12906. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  12907. {
  12908. server_sign = TRUE;
  12909. server_pending =FALSE;
  12910. DB_updateBootType(BootReasonEnumType_PowerUp);
  12911. }
  12912. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  12913. {
  12914. server_pending = TRUE;
  12915. }
  12916. strptime((const char *)ShmOCPP20Data->BootNotification.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  12917. tp.tm_isdst = -1;
  12918. //time_t utc = mktime(&tp);
  12919. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  12920. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  12921. sprintf(timebuf,"date -s '%s'",buf);
  12922. system(timebuf);
  12923. srand(time(NULL));
  12924. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  12925. //==============================================
  12926. // RTC sync
  12927. //==============================================
  12928. system("/sbin/hwclock -w --systohc");
  12929. SetOcppConnStatus(TRUE);
  12930. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  12931. }
  12932. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  12933. {
  12934. mtrace();
  12935. json_object *ClearedChargingLimit;
  12936. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  12937. ClearedChargingLimit = json_tokener_parse(payload);
  12938. if(!is_error(ClearedChargingLimit))
  12939. {
  12940. // Required data
  12941. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  12942. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  12943. }
  12944. json_object_put(ClearedChargingLimit);
  12945. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitReq = OFF;
  12946. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitConf = ON;
  12947. }
  12948. void handleDataTransferResponse(char *payload, int gun_index)
  12949. {
  12950. mtrace();
  12951. json_object *DataTrans;
  12952. DEBUG_INFO("handleDataTransferResponse...\n");
  12953. DataTrans = json_tokener_parse(payload);
  12954. if(!is_error(DataTrans))
  12955. {
  12956. // Required data
  12957. if(json_object_object_get(DataTrans,"status") != NULL)
  12958. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  12959. // Optional data
  12960. if(json_object_object_get(DataTrans,"data") != NULL)
  12961. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  12962. }
  12963. json_object_put(DataTrans);
  12964. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  12965. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  12966. }
  12967. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  12968. {
  12969. mtrace();
  12970. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  12971. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  12972. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  12973. }
  12974. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  12975. {
  12976. mtrace();
  12977. json_object *Get15118EVCertificate;
  12978. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  12979. Get15118EVCertificate = json_tokener_parse(payload);
  12980. if(!is_error(Get15118EVCertificate))
  12981. {
  12982. // Required data
  12983. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  12984. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  12985. // Optional data
  12986. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  12987. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  12988. }
  12989. json_object_put(Get15118EVCertificate);
  12990. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  12991. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  12992. }
  12993. void hanldeGetCertificateStatusResponse(char *payload, int gun_index)
  12994. {
  12995. mtrace();
  12996. json_object *GetCertificateStatus;
  12997. DEBUG_INFO("hanldeGetCertificateStatusResponse...\n");
  12998. GetCertificateStatus = json_tokener_parse(payload);
  12999. if(!is_error(GetCertificateStatus))
  13000. {
  13001. // Required data
  13002. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  13003. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  13004. // Optional data
  13005. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  13006. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  13007. }
  13008. json_object_put(GetCertificateStatus);
  13009. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  13010. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  13011. }
  13012. void handleHeartbeatResponse(char *payload, int gun_index)
  13013. {
  13014. mtrace();
  13015. struct tm tp;
  13016. char buf[28]={0};
  13017. char timebuf[128]={0};
  13018. DEBUG_INFO("handleHeartbeatResponse...\n");
  13019. json_object *Heartbeat;
  13020. Heartbeat = json_tokener_parse(payload);
  13021. if(!is_error(Heartbeat))
  13022. {
  13023. // Required data
  13024. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  13025. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  13026. }
  13027. json_object_put(Heartbeat);
  13028. if(FirstHeartBeat == OFF)
  13029. {
  13030. FirstHeartBeat = ON;
  13031. DEBUG_INFO("FirstHeartBeat \n");
  13032. }
  13033. HeartBeatWithNOResponse = 0;
  13034. clientTime.Heartbeat=time((time_t*)NULL);
  13035. strptime((const char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  13036. tp.tm_isdst = -1;
  13037. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  13038. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  13039. sprintf(timebuf,"date -s '%s'",buf);
  13040. system(timebuf);
  13041. //==============================================
  13042. // RTC sync
  13043. //==============================================
  13044. system("/sbin/hwclock -w --systohc");
  13045. }
  13046. void hanldeLogStatusNotificationResponse(char *payload, int gun_index)
  13047. {
  13048. mtrace();
  13049. DEBUG_INFO("hanldeLogStatusNotificationResponse...\n");
  13050. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  13051. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  13052. }
  13053. void handleMeterValuesResponse(char *payload, int gun_index)
  13054. {
  13055. mtrace();
  13056. DEBUG_INFO("handleMeterValuesResponse...\n");
  13057. }
  13058. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  13059. {
  13060. mtrace();
  13061. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  13062. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  13063. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  13064. }
  13065. void hanldeNotifyCustomerInformationResponse(char *payload, int gun_index)
  13066. {
  13067. mtrace();
  13068. DEBUG_INFO("hanldeNotifyCustomerInformationResponse...\n");
  13069. }
  13070. void hanldeNotifyDisplayMessagesResponse(char *payload, int gun_index)
  13071. {
  13072. mtrace();
  13073. DEBUG_INFO("hanldeNotifyDisplayMessagesResponse...\n");
  13074. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  13075. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  13076. }
  13077. void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  13078. {
  13079. mtrace();
  13080. json_object *NotifyEVChargingNeeds;
  13081. DEBUG_INFO("hanldeNotifyEVChargingNeedsResponse...\n");
  13082. NotifyEVChargingNeeds = json_tokener_parse(payload);
  13083. if(!is_error(NotifyEVChargingNeeds))
  13084. {
  13085. // Required data
  13086. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  13087. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  13088. }
  13089. json_object_put(NotifyEVChargingNeeds);
  13090. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  13091. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  13092. }
  13093. void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  13094. {
  13095. mtrace();
  13096. json_object *NotifyEVChargingSchedule;
  13097. DEBUG_INFO("hanldeNotifyEVChargingScheduleResponse...\n");
  13098. NotifyEVChargingSchedule = json_tokener_parse(payload);
  13099. if(!is_error(NotifyEVChargingSchedule))
  13100. {
  13101. // Required data
  13102. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  13103. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  13104. }
  13105. json_object_put(NotifyEVChargingSchedule);
  13106. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  13107. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  13108. }
  13109. void hanldeNotifyEventResponse(char *payload, int gun_index)
  13110. {
  13111. mtrace();
  13112. DEBUG_INFO("hanldeNotifyEventResponse...\n");
  13113. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  13114. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  13115. }
  13116. void hanldeNotifyMonitoringReportResponse(char *payload, int gun_index)
  13117. {
  13118. mtrace();
  13119. DEBUG_INFO("hanldeNotifyMonitoringReportResponse...\n");
  13120. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  13121. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  13122. }
  13123. void hanldeNotifyReportResponse(char *payload, int gun_index)
  13124. {
  13125. mtrace();
  13126. DEBUG_INFO("hanldeNotifyReportResponse...\n");
  13127. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  13128. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  13129. }
  13130. void hanldePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  13131. {
  13132. mtrace();
  13133. DEBUG_INFO("hanldePublishFirmwareStatusNotificationResponse...\n");
  13134. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  13135. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  13136. }
  13137. void hanldeReportChargingProfilesResponse(char *payload, int gun_index)
  13138. {
  13139. mtrace();
  13140. DEBUG_INFO("hanldeReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  13141. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  13142. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  13143. }
  13144. void hanldeReservationStatusUpdateResponse(char *payload, int gun_index)
  13145. {
  13146. mtrace();
  13147. DEBUG_INFO("hanldeReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  13148. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  13149. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  13150. }
  13151. void hanldeSecurityEventNotificationResponse(char *payload, int gun_index)
  13152. {
  13153. mtrace();
  13154. DEBUG_INFO("hanldeSecurityEventNotificationResponse...\n");
  13155. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  13156. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  13157. }
  13158. void hanldeSignCertificateResponse(char *payload, int gun_index)
  13159. {
  13160. mtrace();
  13161. json_object *SignCertificate;
  13162. DEBUG_INFO("hanldeSignCertificateResponse...\n");
  13163. SignCertificate = json_tokener_parse(payload);
  13164. if(!is_error(SignCertificate))
  13165. {
  13166. // Required data
  13167. if(json_object_object_get(SignCertificate,"status") != NULL)
  13168. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  13169. }
  13170. json_object_put(SignCertificate);
  13171. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  13172. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  13173. }
  13174. void handleStatusNotificationResponse(char *payload, int gun_index)
  13175. {
  13176. mtrace();
  13177. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  13178. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13179. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  13180. }
  13181. void hanldeTransactionEvenResponse(char *payload, int gun_index)
  13182. {
  13183. mtrace();
  13184. json_object *TransactionEven;
  13185. DEBUG_INFO("hanldeTransactionEvenResponse...\n");
  13186. TransactionEven = json_tokener_parse(payload);
  13187. if(!is_error(TransactionEven))
  13188. {
  13189. // Required data
  13190. // Optional data
  13191. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  13192. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  13193. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  13194. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  13195. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  13196. {
  13197. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  13198. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  13199. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  13200. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  13201. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  13202. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  13203. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  13204. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  13205. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  13206. {
  13207. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  13208. 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")));
  13209. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  13210. 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")));
  13211. }
  13212. }
  13213. }
  13214. json_object_put(TransactionEven);
  13215. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  13216. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  13217. }
  13218. //==========================================
  13219. // Handle Error routine
  13220. //==========================================
  13221. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  13222. {
  13223. mtrace();
  13224. #ifdef SystemLogMessage
  13225. DEBUG_INFO("errorCode: %s\n", errorCode);
  13226. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  13227. DEBUG_INFO("errorDetails: %s\n", payload);
  13228. #endif
  13229. }
  13230. //===============================================
  13231. // Common routine
  13232. //===============================================
  13233. int initialConfigurationTable(void)
  13234. {
  13235. DEBUG_INFO("initialConfigurationTable...\n");
  13236. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  13237. DB_variableIsCreate();
  13238. DB_variableLoadFromDb();
  13239. DB_getNetworkProfileFromDb();
  13240. return 0;
  13241. }
  13242. int TransactionMessageAttemptsGet(void)
  13243. {
  13244. return TransactionMessageAttemptsValue;
  13245. }
  13246. int FirstHeartBeatResponse(void)
  13247. {
  13248. return FirstHeartBeat;
  13249. }
  13250. int TransactionMessageRetryIntervalGet(void)
  13251. {
  13252. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  13253. }
  13254. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  13255. {
  13256. char rmFileCmd[100]={0};
  13257. char FilePath[100]={0};
  13258. char ftpbuf[200];
  13259. int systemresult;
  13260. //DEBUG_INFO("filename=%s\n",filename);
  13261. //DEBUG_INFO("url=%s\n",url);
  13262. sprintf(FilePath,"/mnt/%s",filename);
  13263. system("ping 8.8.8.8 &");
  13264. if((access(FilePath,F_OK))!=-1)
  13265. {
  13266. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13267. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13268. system(rmFileCmd);
  13269. }
  13270. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13271. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13272. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13273. systemresult = system(ftpbuf);
  13274. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13275. if(systemresult != 0)
  13276. {
  13277. DEBUG_INFO("http DownLoad error!\n");
  13278. return FALSE;
  13279. }
  13280. system("pkill ping");
  13281. return TRUE;
  13282. }
  13283. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  13284. {
  13285. char rmFileCmd[100]={0};
  13286. char FilePath[100]={0};
  13287. char ftpbuf[200];
  13288. int systemresult;
  13289. //char temp[100];
  13290. sprintf(FilePath,"/mnt/%s",filename);
  13291. system("ping 8.8.8.8 &");
  13292. if((access(FilePath,F_OK))!=-1)
  13293. {
  13294. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13295. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13296. system(rmFileCmd);
  13297. }
  13298. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13299. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13300. //sprintf(ftpbuf, "ftpget -u %s -p %s %s -P %d %s %s%s",user,password,IPbuffer,port/*21*/,filename,path,filename); --- remove temporally
  13301. //DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13302. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13303. systemresult = system(ftpbuf);
  13304. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13305. if(systemresult != 0)
  13306. {
  13307. printf("wget error!\n");
  13308. return FALSE;
  13309. }
  13310. system("pkill ping");
  13311. return TRUE;
  13312. }
  13313. int httpUploadFile(char *location, char *path, char *filename,char *url)
  13314. {
  13315. char rmFileCmd[100]={0};
  13316. char FilePath[100]={0};
  13317. char ftpbuf[200];
  13318. int systemresult;
  13319. //DEBUG_INFO("filename=%s\n",filename);
  13320. //DEBUG_INFO("url=%s\n",url);
  13321. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  13322. if((access(FilePath,F_OK))!=-1)
  13323. {
  13324. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13325. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13326. system(rmFileCmd);
  13327. }
  13328. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  13329. if(fp == NULL)
  13330. {
  13331. DEBUG_INFO("log is NULL\n");
  13332. return FALSE;
  13333. }
  13334. else
  13335. {
  13336. fprintf(fp, "%s\n", url);
  13337. fprintf(fp, "%s\n", filename);
  13338. fclose(fp);
  13339. }
  13340. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13341. sprintf(ftpbuf, "%s","/bin/php-cgi /var/www/ocpp_upload.php");
  13342. systemresult = system(ftpbuf);
  13343. DEBUG_INFO("systemresult = %d\n",systemresult);
  13344. if(systemresult != 0)
  13345. {
  13346. DEBUG_INFO("http upload error!\n");
  13347. return FALSE;
  13348. }
  13349. return TRUE;
  13350. }
  13351. int ftpUploadFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  13352. {
  13353. struct hostent* server;
  13354. char *IPbuffer;
  13355. char ftpbuf[200];
  13356. int systemresult;
  13357. // To retrieve host information
  13358. server = gethostbyname(location);
  13359. // To convert an Internet network
  13360. // address into ASCII string
  13361. IPbuffer = inet_ntoa(*((struct in_addr*)
  13362. server->h_addr_list[0]));
  13363. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13364. /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
  13365. /* format : ftpput -u username -p passwd IP target source*/
  13366. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
  13367. DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13368. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13369. systemresult = system(ftpbuf);
  13370. DEBUG_INFO("systemresult=%d\n",systemresult);
  13371. if(systemresult != 0)
  13372. {
  13373. DEBUG_INFO("ftpput error!\n");
  13374. return FALSE;
  13375. }
  13376. return TRUE;
  13377. }
  13378. //=========================================
  13379. // Routine
  13380. //=========================================
  13381. int GetOcppServerURL()
  13382. {
  13383. int result = FALSE;
  13384. struct yuarel url;
  13385. char urlStr[512];
  13386. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  13387. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  13388. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  13389. if((ShmSysConfigAndInfo->SysConfig.OcppServerURL != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0) )
  13390. {
  13391. memcpy(urlStr, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  13392. if(yuarel_parse(&url, urlStr) != -1)
  13393. {
  13394. sprintf(OcppProtocol, "%s", url.scheme);
  13395. sprintf(OcppHost, "%s", url.host);
  13396. if(url.path == NULL)
  13397. OcppTempPath[0] = '\0';
  13398. else
  13399. {
  13400. if((url.path[strlen(url.path)-1] != '/') && (strlen(url.path) > 0))
  13401. {
  13402. sprintf(OcppTempPath, "%s/", url.path);
  13403. }
  13404. else
  13405. {
  13406. sprintf(OcppTempPath, "%s", url.path);
  13407. }
  13408. }
  13409. if(url.port == 0)
  13410. {
  13411. if(strcmp(OcppProtocol, "wss") == 0)
  13412. OcppPort = 443;
  13413. else
  13414. OcppPort = 80;
  13415. }
  13416. else
  13417. OcppPort = url.port;
  13418. result = TRUE;
  13419. }
  13420. }
  13421. else if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  13422. {
  13423. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  13424. if(yuarel_parse(&url, urlStr) != -1)
  13425. {
  13426. sprintf(OcppProtocol, "%s", url.scheme);
  13427. sprintf(OcppHost, "%s", url.host);
  13428. if(url.path == NULL)
  13429. OcppTempPath[0] = '\0';
  13430. else
  13431. sprintf(OcppTempPath, "%s", url.path);
  13432. if(url.port == 0)
  13433. {
  13434. if(strcmp(OcppProtocol, "wss") == 0)
  13435. OcppPort = 443;
  13436. else
  13437. OcppPort = 80;
  13438. }
  13439. else
  13440. OcppPort = url.port;
  13441. result = TRUE;
  13442. }
  13443. }
  13444. else
  13445. {
  13446. strcpy(OcppHost,"");
  13447. }
  13448. return result;
  13449. }
  13450. int GetOcppPath()
  13451. {
  13452. int result = FALSE;
  13453. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  13454. {
  13455. if(OcppTempPath == NULL)
  13456. {
  13457. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13458. }
  13459. else
  13460. {
  13461. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13462. }
  13463. result = TRUE;
  13464. }
  13465. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  13466. {
  13467. if(OcppTempPath == NULL)
  13468. {
  13469. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  13470. }
  13471. else
  13472. {
  13473. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  13474. }
  13475. result = TRUE;
  13476. }
  13477. else
  13478. {
  13479. strcpy(OcppPath,"");
  13480. }
  13481. return result;
  13482. }
  13483. int GetOcppPort()
  13484. {
  13485. return OcppPort;
  13486. }
  13487. int GetOcppConnStatus(void)
  13488. {
  13489. return ShmOCPP20Data->OcppConnStatus;
  13490. }
  13491. void SetOcppConnStatus(uint8_t status)
  13492. {
  13493. ShmOCPP20Data->OcppConnStatus = status;
  13494. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  13495. }
  13496. int GetHeartBeatWithNOResponse(void)
  13497. {
  13498. return HeartBeatWithNOResponse;
  13499. }
  13500. void SetHeartBeatWithNOResponse(void)
  13501. {
  13502. HeartBeatWithNOResponse = 0;
  13503. }
  13504. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  13505. void storeTempStopTransaction(int gun_index)
  13506. {
  13507. }
  13508. void checkTempStopTransaction(int gun_index)
  13509. {
  13510. FILE *fptr1;
  13511. char ch;
  13512. char str[QUEUE_MESSAGE_LENGTH]={0};
  13513. char guid[37]={0};
  13514. char tempdata[65]={0};
  13515. char connectorStr[2]={0};
  13516. char TempStopTransaction[256];
  13517. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  13518. fptr1 = fopen(TempStopTransaction, "r");
  13519. if (!fptr1)
  13520. {
  13521. //DEBUG_INFO("TempStopTransaction_%d not found or unable to open the input file!\n", (gun_index+1));
  13522. return ;
  13523. }
  13524. ch=fgetc(fptr1);
  13525. rewind(fptr1);
  13526. if(ch!=EOF)
  13527. {
  13528. // copy all contents to the temporary file except the specific line
  13529. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  13530. {
  13531. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13532. if(str[0]=='\0')
  13533. {
  13534. break;
  13535. }
  13536. //TempStopTransaction格式: 槍號,StopTransaction封包
  13537. strncpy(connectorStr, str, 1);
  13538. if(atoi(connectorStr) != (gun_index+1))
  13539. {
  13540. DEBUG_INFO("atoi(connectorStr) = %d, gun_index = %d\n", atoi(connectorStr), gun_index);
  13541. fclose(fptr1);
  13542. return ;
  13543. }
  13544. //random_uuid(guid);
  13545. strncpy(guid, str+6, 36); //copy guid
  13546. sprintf(tempdata, "StopTransaction,%d", (gun_index));
  13547. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  13548. {
  13549. //DEBUG_INFO("StopTransaction mapitem pass\n");
  13550. }
  13551. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  13552. memset(str,0,ARRAY_SIZE(str));
  13553. }
  13554. }
  13555. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  13556. fclose(fptr1);
  13557. remove(TempStopTransaction); // remove the original file
  13558. }
  13559. int GetWebSocketPingInterval(void)
  13560. {
  13561. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  13562. }
  13563. int GetServerSign(void)
  13564. {
  13565. return server_sign;
  13566. }
  13567. uint8_t GetOcppSecurityProfile()
  13568. {
  13569. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  13570. }
  13571. void GetOcppChargerBoxId(uint8_t *data)
  13572. {
  13573. sprintf((char*)data, "%s", ShmOCPP20Data->ChargeBoxId);
  13574. }
  13575. void GetOcppSecurityPassword(uint8_t *data)
  13576. {
  13577. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  13578. }
  13579. void SetServerSign(int value)
  13580. {
  13581. server_sign = value;
  13582. }
  13583. int GetBootNotificationInterval(void)
  13584. {
  13585. return BootNotificationInterval;
  13586. }
  13587. int GetInternetConn(void)
  13588. {
  13589. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  13590. }
  13591. void InitialSystemValue(void)
  13592. {
  13593. int connectorIndex = 0;
  13594. gunTotalNumber=0;
  13595. SystemInitial = 0;
  13596. localversion=0;
  13597. BootNotificationInterval = 10;
  13598. authorizeRetryTimes = 0;
  13599. GunStatusInterval = 10;
  13600. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  13601. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  13602. //Hear Beat
  13603. HeartBeatWithNOResponse = 0;
  13604. HeartBeatCountPerHour = 0;
  13605. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  13606. FirstHeartBeat = 0;
  13607. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  13608. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  13609. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  13610. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  13611. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  13612. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  13613. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  13614. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  13615. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  13616. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  13617. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  13618. memset(gunType, 0, ARRAY_SIZE(gunType));
  13619. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13620. {
  13621. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O')
  13622. {
  13623. // DO series
  13624. for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
  13625. {
  13626. SystemInitial = SystemInitial + 1;
  13627. gunTotalNumber = gunTotalNumber + 1;
  13628. gunType[connectorIndex] = 'O';
  13629. connectorIndex = connectorIndex + 1;
  13630. }
  13631. }
  13632. else
  13633. {
  13634. // DM, DW, DS series
  13635. //check connector / socket type (index: 8, 9, 10)
  13636. for(int index=7; index <10 ; index++)
  13637. {
  13638. if(index != 8)
  13639. {
  13640. // DC Connector
  13641. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] >= 'A') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= 'Z'))
  13642. {
  13643. SystemInitial = SystemInitial + 1;
  13644. gunTotalNumber = gunTotalNumber + 1;
  13645. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13646. connectorIndex = connectorIndex + 1;
  13647. }
  13648. }
  13649. else
  13650. {
  13651. // AC Connector
  13652. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13653. {
  13654. SystemInitial = SystemInitial + 1;
  13655. gunTotalNumber = gunTotalNumber + 1;
  13656. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13657. connectorIndex = connectorIndex + 1;
  13658. }
  13659. }
  13660. }
  13661. }
  13662. //DEBUG_INFO("DC ...\n");
  13663. }
  13664. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  13665. {
  13666. //check connector / socket type (index: 8, 9, 10)
  13667. for(int index=7; index <10 ; index++)
  13668. {
  13669. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13670. {
  13671. SystemInitial = SystemInitial + 1;
  13672. gunTotalNumber = gunTotalNumber + 1;
  13673. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13674. connectorIndex = connectorIndex + 1;
  13675. //DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
  13676. }
  13677. }
  13678. }
  13679. //Status && ConnectorPlugIn Setting
  13680. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13681. {
  13682. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  13683. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  13684. }
  13685. for (int index = 0; index < CCS_QUANTITY; index++)
  13686. {
  13687. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  13688. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  13689. }
  13690. for (int index = 0; index < GB_QUANTITY; index++)
  13691. {
  13692. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  13693. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  13694. }
  13695. for (int index = 0; index < AC_QUANTITY; index++)
  13696. {
  13697. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  13698. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  13699. }
  13700. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13701. {
  13702. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  13703. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  13704. }
  13705. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  13706. {
  13707. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13708. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  13709. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  13710. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  13711. }
  13712. clientTime.Heartbeat=time((time_t*)NULL);
  13713. sleep(1);
  13714. }
  13715. void LWS_Send(char * str)
  13716. {
  13717. //=====================================================
  13718. // Check InternetConn 0: disconnected, 1: connected
  13719. //====================================================
  13720. if(GetOcppConnStatus() == 0)
  13721. {
  13722. DEBUG_INFO("offline now !!!\n");
  13723. return;
  13724. }
  13725. pthread_mutex_lock(&lock_send);
  13726. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13727. sprintf((char *)SendBuffer, "%s", str);
  13728. SendBufLen = strlen(str);
  13729. pthread_mutex_unlock(&lock_send);
  13730. lws_callback_on_writable(wsi_client);
  13731. //lws_service(context, 0);
  13732. //sleep(1);
  13733. }
  13734. void LWS_SendNow(char * str)
  13735. {
  13736. //=====================================================
  13737. // Check InternetConn 0: disconnected, 1: connected
  13738. //====================================================
  13739. if(GetOcppConnStatus() == 0)
  13740. {
  13741. DEBUG_INFO("offline now !!!\n");
  13742. return;
  13743. }
  13744. pthread_mutex_lock(&lock_send);
  13745. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13746. sprintf((char *)SendBuffer, "%s", str);
  13747. SendBufLen = strlen(str);
  13748. pthread_mutex_unlock(&lock_send);
  13749. lws_callback_on_writable(wsi_client);
  13750. lws_service(context, 0);
  13751. //sleep(1);
  13752. }