MessageHandler.c 797 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842
  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. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1151. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1158. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1165. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1171. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1173. else
  1174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1175. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1183. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1184. /* AuthCtrlrVariable Required item */
  1185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1191. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1198. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1205. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1212. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1219. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1226. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1230. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1234. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1235. /* AuthCacheCtrlr Variable Required item*/
  1236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1242. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1249. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1257. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1261. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*100);
  1262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1265. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1272. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1273. /* ClockCtrlr Variable Required item */
  1274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1279. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1280. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1287. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1295. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1302. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1309. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1317. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1324. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1331. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1332. /* ChargingStation Required item */
  1333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1339. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1340. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1346. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1353. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1354. /* Connector Required item */
  1355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1361. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1368. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1375. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1376. /* CustomizationCtrlr Required item */
  1377. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1383. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1384. /* DeviceDataCtrlr Required item */
  1385. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1392. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1393. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1400. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1401. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1408. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1416. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1419. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1424. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1425. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1427. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1432. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1440. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1448. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1449. /* DisplayMessageCtrlr Required item */
  1450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1456. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1463. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "0");
  1470. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1477. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1484. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1485. /* EVSE Required item */
  1486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1492. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1498. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1499. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1506. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1513. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1514. /* LocalAuthListCtrlr Required item */
  1515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1521. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1522. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1528. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1535. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1536. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "50");
  1543. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "2048");
  1551. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1555. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = 1024*1024;
  1556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "5000");
  1559. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1560. /* MonitoringCtrlr Required item */
  1561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1567. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1574. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1575. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1580. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1582. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1583. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1590. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1591. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1598. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1606. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1607. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1613. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1614. /* OCPPCommCtrlr Required item */
  1615. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1621. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1622. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1630. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1635. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1637. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1643. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1645. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1646. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1651. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "[0]");
  1652. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1653. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1654. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1655. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1657. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1658. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1659. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1660. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1661. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1666. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1667. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1668. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1673. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1674. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1675. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1676. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1682. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1683. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1684. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1688. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1690. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1691. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "3");
  1692. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1693. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1695. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1696. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1697. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1698. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1699. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1700. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1702. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1704. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1705. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1706. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1707. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1708. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1710. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1712. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1713. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1714. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1715. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1716. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1717. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1719. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1720. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1721. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1722. /* ReservationCtrlr Required item */
  1723. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1724. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1725. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1727. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1728. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1729. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1730. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1732. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1734. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1735. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1736. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1737. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1739. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1741. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1742. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1743. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1744. /* SampledDataCtrlr Required item */
  1745. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  1746. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1749. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1750. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1751. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  1752. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  1753. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  1754. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1757. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1758. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  1759. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  1761. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1764. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1765. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  1766. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  1767. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1768. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, " ");
  1772. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  1773. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  1774. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1775. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1776. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1779. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1780. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  1781. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  1782. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  1783. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1784. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  1787. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  1788. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  1789. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1791. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1792. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1793. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, " ");
  1794. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  1795. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  1796. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1800. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1801. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "0");
  1802. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  1803. /* SecurityCtrlr Required item */
  1804. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  1805. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1807. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  1808. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1809. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1810. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, " ");
  1811. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  1812. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  1813. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  1814. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1815. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  1816. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1817. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "Phihong Technology");
  1819. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  1820. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  1821. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  1822. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1823. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1824. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1825. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "Phihong");
  1826. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  1828. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  1829. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1831. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  1833. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  1835. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  1836. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1839. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "0");
  1840. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  1842. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  1843. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1844. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1845. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  1847. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  1848. /* SmartChargingCtrlr Required item */
  1849. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  1850. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  1851. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1854. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1855. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  1857. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  1858. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1859. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  1862. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  1864. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  1865. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1866. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  1869. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  1870. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  1871. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  1872. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1873. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1874. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "0");
  1876. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  1877. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  1878. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  1879. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1880. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1882. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  1883. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  1884. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  1885. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  1886. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1887. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1888. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  1890. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  1891. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  1892. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  1893. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1894. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1895. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  1897. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  1898. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  1899. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  1900. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1901. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1902. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1903. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  1904. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  1906. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  1907. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1908. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1909. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  1911. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  1912. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  1913. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  1914. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1916. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "3");
  1918. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  1919. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  1920. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  1921. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1922. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1923. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  1925. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  1926. /* TariffCostCtrlr Required item */
  1927. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  1928. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  1929. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1933. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  1934. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  1935. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  1936. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  1937. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1940. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1941. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  1942. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  1943. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  1944. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  1945. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1946. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  1947. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1948. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1949. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  1950. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  1951. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  1952. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  1954. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1955. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1956. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1957. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  1958. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  1959. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  1960. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  1961. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  1962. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1963. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1964. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1965. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  1966. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  1967. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  1968. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  1969. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1970. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  1971. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1972. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1973. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  1974. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  1975. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  1976. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  1977. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1978. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  1979. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1980. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1981. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  1982. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  1983. /* TxCtrlr Required item */
  1984. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  1985. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  1986. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1987. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1988. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  1990. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  1991. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  1992. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  1993. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  1994. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1995. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1996. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1997. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  1998. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  1999. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2000. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2001. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2002. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2003. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  2005. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2007. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2008. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2009. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2010. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2012. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2014. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2015. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2016. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2017. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2018. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "PowerPathClosed");
  2019. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  2020. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2021. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2022. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2023. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2024. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "PowerPathClosed");
  2026. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2027. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2028. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2029. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2030. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2031. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2032. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "60000");
  2034. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2035. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2036. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2037. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2038. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2039. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2040. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2041. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2042. }
  2043. else
  2044. {
  2045. // Variable name init
  2046. /* AlignedDataCtrlr Required item */
  2047. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2048. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2049. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2050. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2051. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2052. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2053. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2054. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2055. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2056. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2059. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2062. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2063. /* AuthCtrlrVariable Required item */
  2064. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2065. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2066. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2067. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2068. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2069. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2070. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2071. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2073. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2074. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2076. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2077. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2078. /* AuthCacheCtrlr Variable Required item */
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2080. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2081. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2082. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2083. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2085. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2086. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2087. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2088. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2089. /* ClockCtrlr Variable Required item */
  2090. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2091. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2092. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2095. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2108. /* ChargingStation Required item */
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2110. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2115. /* Connector Required item */
  2116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2117. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2122. /* DeviceDataCtrlr Required item */
  2123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2145. /* DisplayMessageCtrlr Required item */
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2156. /* EVSE Required item */
  2157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2165. /* LocalAuthListCtrlr Required item */
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2180. /* MonitoringCtrlr Required item */
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2199. /* OCPPCommCtrlr Required item */
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2231. /* ReservationCtrlr Required item */
  2232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2238. /* SampledDataCtrlr Required item */
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2255. /* SecurityCtrlr Required item */
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2268. /* SmartChargingCtrlr Required item */
  2269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2291. /* TariffCostCtrlr Required item */
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2310. /* TxCtrlr Required item */
  2311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2327. }
  2328. return 0;
  2329. }
  2330. void DB_variableIsCreate()
  2331. {
  2332. char sql[512];
  2333. char* errMsg = NULL;
  2334. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2335. /* Execute SQL statement */
  2336. if(sqlite3_exec(db, sql, DB_cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2337. {
  2338. DEBUG_INFO("SQL error: %s\n", errMsg);
  2339. }
  2340. }
  2341. int DB_cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2342. {
  2343. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2344. {
  2345. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) != NULL) &&
  2346. (strlen(columnValue[2])>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) != NULL):TRUE) &&
  2347. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) != NULL) &&
  2348. (strlen(columnValue[4])>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) != NULL):TRUE))
  2349. {
  2350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2352. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2356. }
  2357. }
  2358. return 0;
  2359. }
  2360. void DB_variableLoadFromDb()
  2361. {
  2362. char sql[512];
  2363. char* errMsg = NULL;
  2364. sprintf(sql,"select * from ocpp20_variable;");
  2365. /* Execute SQL statement */
  2366. if(sqlite3_exec(db, sql, DB_cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2367. {
  2368. DEBUG_INFO("SQL error: %s\n", errMsg);
  2369. }
  2370. }
  2371. int DB_cbGetNetworkProfileFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2372. {
  2373. memset(&ShmOCPP20Data->NetworkConnectionProfile[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile));
  2374. if(columnCount > 0)
  2375. {
  2376. for(int idx=0;idx<columnCount;idx++)
  2377. {
  2378. json_object *SetNetworkProfile;
  2379. SetNetworkProfile = json_tokener_parse(columnValue[2]);
  2380. if(!is_error(SetNetworkProfile))
  2381. {
  2382. // Required data
  2383. if(json_object_object_get(SetNetworkProfile, "ocppVersion") != NULL)
  2384. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppVersion")));
  2385. if(json_object_object_get(SetNetworkProfile, "ocppTransport") != NULL)
  2386. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppTransport")));
  2387. if(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl") != NULL)
  2388. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl")));
  2389. if(json_object_object_get(SetNetworkProfile, "messageTimeout") != NULL)
  2390. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.messageTimeout = json_object_get_int(json_object_object_get(SetNetworkProfile, "messageTimeout"));
  2391. if(json_object_object_get(SetNetworkProfile, "ocppInterface") != NULL)
  2392. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppInterface")));
  2393. if(json_object_object_get(SetNetworkProfile, "vpn") != NULL)
  2394. {
  2395. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server") != NULL)
  2396. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server")));
  2397. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user") != NULL)
  2398. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user")));
  2399. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group") != NULL)
  2400. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group")));
  2401. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password") != NULL)
  2402. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password")));
  2403. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key") != NULL)
  2404. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key")));
  2405. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type") != NULL)
  2406. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type")));
  2407. }
  2408. if(json_object_object_get(SetNetworkProfile, "apn") != NULL)
  2409. {
  2410. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn") != NULL)
  2411. {
  2412. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn));
  2413. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn")));
  2414. }
  2415. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName") != NULL)
  2416. {
  2417. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName));
  2418. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName")));
  2419. }
  2420. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword") != NULL)
  2421. {
  2422. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword));
  2423. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword")));
  2424. }
  2425. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin") != NULL)
  2426. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin"));
  2427. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork") != NULL)
  2428. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork")));
  2429. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork") != NULL)
  2430. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork"));
  2431. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication") != NULL)
  2432. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication")));
  2433. }
  2434. }
  2435. json_object_put(SetNetworkProfile);
  2436. ShmOCPP20Data->NetworkConnectionProfile[idx].slot = atoi(columnValue[1]);
  2437. }
  2438. }
  2439. return 0;
  2440. }
  2441. void DB_getNetworkProfileFromDb()
  2442. {
  2443. char sql[512];
  2444. char* errMsg = NULL;
  2445. sprintf(sql,"select * from ocpp20_networkprofile order by slot;");
  2446. /* Execute SQL statement */
  2447. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2448. {
  2449. DEBUG_INFO("SQL error: %s\n", errMsg);
  2450. }
  2451. }
  2452. int DB_addNetworkProfile(int slot, char *data)
  2453. {
  2454. int result = PASS;
  2455. char sql[512];
  2456. char* errMsg = NULL;
  2457. sprintf(sql,"insert or replace into ocpp20_networkprofile (slot, connectionData) VALUES('%d', '%s'); SELECT * from ocpp20_networkprofile order by slot;",
  2458. slot,
  2459. data);
  2460. //* Execute SQL statement */
  2461. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK)
  2462. {
  2463. DEBUG_INFO("SQL error: %s\n", errMsg);
  2464. result = FAIL;
  2465. }
  2466. return result;
  2467. }
  2468. int DB_deleteNetworkProfile(int slot)
  2469. {
  2470. int result = PASS;
  2471. char sql[512];
  2472. char* errMsg = NULL;
  2473. sprintf(sql,"DELETE from ocpp20_networkprofile where slot=%d; SELECT * from ocpp20_networkprofile order by slot;", slot);
  2474. //* Execute SQL statement */
  2475. if( sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2476. {
  2477. DEBUG_INFO("SQL error: %s", errMsg);
  2478. result = FAIL;
  2479. }
  2480. return result;
  2481. }
  2482. //==========================================
  2483. // Check time passed since today
  2484. //==========================================
  2485. long long DiffTimebWithNow(struct timeb ST)
  2486. {
  2487. //return milli-second
  2488. struct timeb ET;
  2489. long long StartTime,StopTime;
  2490. ftime(&ET);
  2491. StartTime=(long long)ST.time;
  2492. StopTime=(long long)ET.time;
  2493. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2494. }
  2495. int getTimePassSinceToday()
  2496. {
  2497. int result = -1;
  2498. time_t t;
  2499. struct tm *tmStartToday;
  2500. struct timeb tbStartToday;
  2501. t=time(NULL);
  2502. tmStartToday=localtime(&t);
  2503. tmStartToday->tm_hour = 0;
  2504. tmStartToday->tm_min = 0;
  2505. tmStartToday->tm_sec = 0;
  2506. tbStartToday.time = mktime(tmStartToday);
  2507. tbStartToday.millitm = 0;
  2508. result = DiffTimebWithNow(tbStartToday)/1000;
  2509. return result;
  2510. }
  2511. //==========================================
  2512. // GetCompositeSchedule logic related function
  2513. //==========================================
  2514. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2515. {
  2516. //return milli-second
  2517. unsigned int StartTime,StopTime;
  2518. StartTime=(unsigned int)ST.time;
  2519. StopTime=(unsigned int)ET.time;
  2520. return (StopTime-StartTime);
  2521. }
  2522. int DiffTimebWithNowSec(struct timeb ST)
  2523. {
  2524. //return milli-second
  2525. struct timeb ET;
  2526. unsigned int StartTime,StopTime;
  2527. ftime(&ET);
  2528. StartTime=(unsigned int)ST.time;
  2529. StopTime=(unsigned int)ET.time;
  2530. return (StopTime-StartTime);
  2531. }
  2532. int getStartStop(uint8_t *start, uint8_t *stop)
  2533. {
  2534. int result = -1;
  2535. struct tm tmStart;
  2536. struct timeb tbStart;
  2537. struct tm tmStop;
  2538. struct timeb tbStop;
  2539. 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) &&
  2540. (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))
  2541. {
  2542. //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);
  2543. //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);
  2544. tmStart.tm_year -= 1900;
  2545. tmStart.tm_mon -= 1;
  2546. tbStart.time = mktime(&tmStart);
  2547. tbStart.millitm = 0;
  2548. tmStop.tm_year -= 1900;
  2549. tmStop.tm_mon -= 1;
  2550. tbStop.time = mktime(&tmStop);
  2551. tbStop.millitm = 0;
  2552. result = DiffTimebSec(tbStart, tbStop);
  2553. //DEBUG_INFO("getStartStop(): %d\n", result);
  2554. }
  2555. else
  2556. {
  2557. DEBUG_WARN("Start or stop date parsing error.\r\n");
  2558. }
  2559. return result;
  2560. }
  2561. int isOvertNow(uint8_t *start)
  2562. {
  2563. int result = YES;
  2564. struct tm tmStart;
  2565. struct timeb tbStart;
  2566. 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))
  2567. {
  2568. //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);
  2569. tmStart.tm_year -= 1900;
  2570. tmStart.tm_mon -= 1;
  2571. tbStart.time = mktime(&tmStart);
  2572. tbStart.millitm = 0;
  2573. if(DiffTimebWithNowSec(tbStart) <= 0)
  2574. result = NO;
  2575. }
  2576. else
  2577. {
  2578. DEBUG_WARN("Start date parsing error.\r\n");
  2579. }
  2580. return result;
  2581. }
  2582. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  2583. {
  2584. int result = -1;
  2585. struct tm tmStart;
  2586. struct timeb tbStart;
  2587. struct tm tmStop;
  2588. struct timeb tbStop;
  2589. 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) &&
  2590. (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))
  2591. {
  2592. tmStart.tm_year -= 1900;
  2593. tmStart.tm_mon -= 1;
  2594. tbStart.time = mktime(&tmStart);
  2595. tbStart.millitm = 0;
  2596. tmStop.tm_year -= 1900;
  2597. tmStop.tm_mon -= 1;
  2598. tbStop.time = mktime(&tmStop);
  2599. tbStop.millitm = 0;
  2600. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  2601. }
  2602. return result;
  2603. }
  2604. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *compositeProfile)
  2605. {
  2606. FILE *fp;
  2607. char profileFileName[128];
  2608. char *line = NULL;
  2609. size_t len = 0;
  2610. time_t CurrentTime;
  2611. struct tm *tmComposite;
  2612. struct ChargingProfileType maxProfile;
  2613. struct ChargingProfileType defaultTxProfile;
  2614. struct ChargingProfileType txProfile;
  2615. struct ChargingSchedulePeriodType tmpPeriod;
  2616. uint8_t limitMax=0;
  2617. uint8_t limitDef=0;
  2618. uint8_t limitTx=0;
  2619. int compositePeriodIdx = 0;
  2620. CurrentTime = time(NULL);
  2621. tmComposite=localtime(&CurrentTime);
  2622. 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);
  2623. sprintf((char*)compositeProfile->chargingSchedule[0].chargingRateUnit, "A");
  2624. compositeProfile->chargingSchedule[0].duration = durationReq;
  2625. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2626. {
  2627. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2628. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2629. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2630. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  2631. }
  2632. compositeProfile->id = 0;
  2633. compositeProfile->stackLevel = 99 ;
  2634. sprintf((char*)compositeProfile->chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  2635. maxProfile.id = -1;
  2636. defaultTxProfile.id = -1;
  2637. txProfile.id = -1;
  2638. maxProfile.chargingSchedule[0].duration = -1;
  2639. defaultTxProfile.chargingSchedule[0].duration = -1;
  2640. txProfile.chargingSchedule[0].duration = -1;
  2641. system("yes|rm /tmp/*.json");
  2642. system("cp /Storage/OCPP/*.json /tmp");
  2643. /*
  2644. * Search valid charging profile
  2645. */
  2646. //DEBUG_INFO("====================================\n");
  2647. // Search tx profile
  2648. sprintf(profileFileName, "/tmp/TxProfile_%d.json", connectorId);
  2649. if((access(profileFileName, F_OK))!=-1)
  2650. {
  2651. fp = fopen(profileFileName, "r");
  2652. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2653. {
  2654. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2655. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2656. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2657. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2658. }
  2659. txProfile.id = -1;
  2660. txProfile.stackLevel = -1;
  2661. while(getline(&line, &len, fp) != -1)
  2662. {
  2663. json_object *obj = NULL;
  2664. obj = json_tokener_parse(line);
  2665. if(is_error(obj))
  2666. {
  2667. DEBUG_ERROR("Parse txProfile from file error.\n");
  2668. }
  2669. else
  2670. {
  2671. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != txProfile.id) &&
  2672. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= txProfile.stackLevel)
  2673. )
  2674. {
  2675. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2676. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2677. )
  2678. {
  2679. struct tm tmFrom, tmTo;
  2680. struct timeb tbFrom, tbTo;
  2681. 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) &&
  2682. (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))
  2683. {
  2684. tmFrom.tm_year -= 1900;
  2685. tmFrom.tm_mon -= 1;
  2686. tbFrom.time = mktime(&tmFrom);
  2687. tmTo.tm_year -= 1900;
  2688. tmTo.tm_mon -= 1;
  2689. tbTo.time = mktime(&tmTo);
  2690. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2691. {
  2692. if(txProfile.id == -1)
  2693. DEBUG_INFO("TxProfile found.\n");
  2694. else
  2695. DEBUG_INFO("TxProfile updated.\n");
  2696. // Required item
  2697. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2698. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2699. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2700. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2701. 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++)
  2702. {
  2703. 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"));
  2704. 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")));
  2705. 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?
  2706. 3:
  2707. 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")));
  2708. }
  2709. // Optional item
  2710. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2711. {
  2712. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2713. }
  2714. else
  2715. {
  2716. sprintf((char*)txProfile.validFrom, " ");
  2717. }
  2718. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2719. {
  2720. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2721. }
  2722. else
  2723. {
  2724. sprintf((char*)txProfile.validTo, " ");
  2725. }
  2726. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2727. {
  2728. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2729. }
  2730. else
  2731. {
  2732. sprintf((char*)txProfile.recurrencyKind, " ");
  2733. }
  2734. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2735. {
  2736. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2737. }
  2738. else
  2739. {
  2740. sprintf((char*)txProfile.transactionId, " ");
  2741. }
  2742. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2743. {
  2744. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2745. }
  2746. else
  2747. {
  2748. txProfile.chargingSchedule[0].duration = 86400;
  2749. }
  2750. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2751. {
  2752. 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")));
  2753. }
  2754. else
  2755. {
  2756. 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));
  2757. }
  2758. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2759. {
  2760. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2761. }
  2762. else
  2763. {
  2764. txProfile.chargingSchedule[0].minChargingRate = -1;
  2765. }
  2766. }
  2767. }
  2768. }
  2769. else
  2770. {
  2771. if(txProfile.id == -1)
  2772. DEBUG_INFO("TxProfile found.\n");
  2773. else
  2774. DEBUG_INFO("TxProfile updated.\n");
  2775. // Required item
  2776. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2777. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2778. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2779. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2780. 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++)
  2781. {
  2782. 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"));
  2783. 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")));
  2784. 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?
  2785. 3:
  2786. 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")));
  2787. }
  2788. // Optional item
  2789. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2790. {
  2791. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2792. }
  2793. else
  2794. {
  2795. sprintf((char*)txProfile.validFrom, " ");
  2796. }
  2797. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2798. {
  2799. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2800. }
  2801. else
  2802. {
  2803. sprintf((char*)txProfile.validTo, " ");
  2804. }
  2805. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2806. {
  2807. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2808. }
  2809. else
  2810. {
  2811. sprintf((char*)txProfile.recurrencyKind, " ");
  2812. }
  2813. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2814. {
  2815. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2816. }
  2817. else
  2818. {
  2819. sprintf((char*)txProfile.transactionId, " ");
  2820. }
  2821. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2822. {
  2823. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2824. }
  2825. else
  2826. {
  2827. txProfile.chargingSchedule[0].duration = 86400;
  2828. }
  2829. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2830. {
  2831. 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")));
  2832. }
  2833. else
  2834. {
  2835. 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));
  2836. }
  2837. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2838. {
  2839. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2840. }
  2841. else
  2842. {
  2843. txProfile.chargingSchedule[0].minChargingRate = -1;
  2844. }
  2845. }
  2846. }
  2847. }
  2848. json_object_put(obj);
  2849. }
  2850. fclose(fp);
  2851. /*
  2852. if(txProfile.ChargingProfileId != -1)
  2853. {
  2854. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  2855. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  2856. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  2857. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  2858. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  2859. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  2860. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  2861. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[0].StartSchedule);
  2862. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  2863. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  2864. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  2865. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  2866. {
  2867. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  2868. {
  2869. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  2870. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  2871. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  2872. }
  2873. }
  2874. }
  2875. else
  2876. DEBUG_INFO("TxProfile not found.\n");*/
  2877. }
  2878. // Search default tx profile
  2879. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d.json", connectorId);
  2880. if((access(profileFileName, F_OK))==-1)
  2881. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  2882. if((access(profileFileName, F_OK))!=-1)
  2883. {
  2884. fp = fopen(profileFileName, "r");
  2885. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2886. {
  2887. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2888. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2889. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2890. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2891. }
  2892. defaultTxProfile.id = -1;
  2893. defaultTxProfile.stackLevel = -1;
  2894. while(getline(&line, &len, fp) != -1)
  2895. {
  2896. json_object *obj = NULL;
  2897. obj = json_tokener_parse(line);
  2898. if(is_error(obj))
  2899. {
  2900. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  2901. }
  2902. else
  2903. {
  2904. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != defaultTxProfile.id) &&
  2905. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= defaultTxProfile.stackLevel)
  2906. )
  2907. {
  2908. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2909. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2910. )
  2911. {
  2912. struct tm tmFrom, tmTo;
  2913. struct timeb tbFrom, tbTo;
  2914. 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) &&
  2915. (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))
  2916. {
  2917. tmFrom.tm_year -= 1900;
  2918. tmFrom.tm_mon -= 1;
  2919. tbFrom.time = mktime(&tmFrom);
  2920. tmTo.tm_year -= 1900;
  2921. tmTo.tm_mon -= 1;
  2922. tbTo.time = mktime(&tmTo);
  2923. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2924. {
  2925. if(defaultTxProfile.id == -1)
  2926. DEBUG_INFO("TxDefaultProfile found.\n");
  2927. else
  2928. DEBUG_INFO("TxDefaultProfile updated.\n");
  2929. // Required item
  2930. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2931. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2932. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2933. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  2934. 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++)
  2935. {
  2936. 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"));
  2937. 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")));
  2938. 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?
  2939. 3:
  2940. 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")));
  2941. }
  2942. // Optional item
  2943. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2944. {
  2945. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2946. }
  2947. else
  2948. {
  2949. sprintf((char*)defaultTxProfile.validFrom, " ");
  2950. }
  2951. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2952. {
  2953. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2954. }
  2955. else
  2956. {
  2957. sprintf((char*)defaultTxProfile.validTo, " ");
  2958. }
  2959. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2960. {
  2961. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2962. }
  2963. else
  2964. {
  2965. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  2966. }
  2967. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2968. {
  2969. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2970. }
  2971. else
  2972. {
  2973. sprintf((char*)defaultTxProfile.transactionId, " ");
  2974. }
  2975. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2976. {
  2977. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2978. }
  2979. else
  2980. {
  2981. defaultTxProfile.chargingSchedule[0].duration = 86400;
  2982. }
  2983. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2984. {
  2985. 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")));
  2986. }
  2987. else
  2988. {
  2989. 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));
  2990. }
  2991. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2992. {
  2993. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2994. }
  2995. else
  2996. {
  2997. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  2998. }
  2999. }
  3000. }
  3001. }
  3002. else
  3003. {
  3004. if(defaultTxProfile.id == -1)
  3005. DEBUG_INFO("TxDefaultProfile found.\n");
  3006. else
  3007. DEBUG_INFO("TxDefaultProfile updated.\n");
  3008. // Required item
  3009. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3010. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3011. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3012. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3013. 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++)
  3014. {
  3015. 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"));
  3016. 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")));
  3017. 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?
  3018. 3:
  3019. 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")));
  3020. }
  3021. // Optional item
  3022. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3023. {
  3024. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3025. }
  3026. else
  3027. {
  3028. sprintf((char*)defaultTxProfile.validFrom, " ");
  3029. }
  3030. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3031. {
  3032. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3033. }
  3034. else
  3035. {
  3036. sprintf((char*)defaultTxProfile.validTo, " ");
  3037. }
  3038. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3039. {
  3040. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3041. }
  3042. else
  3043. {
  3044. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  3045. }
  3046. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3047. {
  3048. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3049. }
  3050. else
  3051. {
  3052. sprintf((char*)defaultTxProfile.transactionId, " ");
  3053. }
  3054. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3055. {
  3056. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3057. }
  3058. else
  3059. {
  3060. defaultTxProfile.chargingSchedule[0].duration = 86400;
  3061. }
  3062. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3063. {
  3064. 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")));
  3065. }
  3066. else
  3067. {
  3068. 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));
  3069. }
  3070. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3071. {
  3072. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3073. }
  3074. else
  3075. {
  3076. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  3077. }
  3078. }
  3079. }
  3080. }
  3081. json_object_put(obj);
  3082. }
  3083. fclose(fp);
  3084. /*
  3085. if(defaultTxProfile.ChargingProfileId != -1)
  3086. {
  3087. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3088. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3089. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3090. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3091. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3092. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3093. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3094. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[0].StartSchedule);
  3095. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3096. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3097. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3098. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3099. {
  3100. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3101. {
  3102. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3103. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3104. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3105. }
  3106. }
  3107. }
  3108. else
  3109. DEBUG_INFO("TxDefaultProfile not found.\n");
  3110. DEBUG_INFO("------------------------------------\n");*/
  3111. }
  3112. // Search max profile
  3113. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  3114. if((access(profileFileName, F_OK))!=-1)
  3115. {
  3116. fp = fopen(profileFileName, "r");
  3117. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3118. {
  3119. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3120. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  3121. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3122. }
  3123. maxProfile.id = -1;
  3124. maxProfile.stackLevel = -1;
  3125. while(getline(&line, &len, fp) != -1)
  3126. {
  3127. json_object *obj = NULL;
  3128. obj = json_tokener_parse(line);
  3129. if(is_error(obj))
  3130. {
  3131. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  3132. }
  3133. else
  3134. {
  3135. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != maxProfile.id) &&
  3136. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= maxProfile.stackLevel)
  3137. )
  3138. {
  3139. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3140. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3141. )
  3142. {
  3143. struct tm tmFrom, tmTo;
  3144. struct timeb tbFrom, tbTo;
  3145. 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) &&
  3146. (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))
  3147. {
  3148. tmFrom.tm_year -= 1900;
  3149. tmFrom.tm_mon -= 1;
  3150. tbFrom.time = mktime(&tmFrom);
  3151. tmTo.tm_year -= 1900;
  3152. tmTo.tm_mon -= 1;
  3153. tbTo.time = mktime(&tmTo);
  3154. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3155. {
  3156. if(maxProfile.id == -1)
  3157. DEBUG_INFO("MaxProfile found.\n");
  3158. else
  3159. DEBUG_INFO("MaxProfile updated.\n");
  3160. // Required item
  3161. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3162. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3163. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3164. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3165. 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++)
  3166. {
  3167. 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"));
  3168. 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")));
  3169. 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?
  3170. 3:
  3171. 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")));
  3172. }
  3173. // Optional item
  3174. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3175. {
  3176. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3177. }
  3178. else
  3179. {
  3180. sprintf((char*)maxProfile.validFrom, " ");
  3181. }
  3182. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3183. {
  3184. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3185. }
  3186. else
  3187. {
  3188. sprintf((char*)maxProfile.validTo, " ");
  3189. }
  3190. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3191. {
  3192. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3193. }
  3194. else
  3195. {
  3196. sprintf((char*)maxProfile.recurrencyKind, " ");
  3197. }
  3198. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3199. {
  3200. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3201. }
  3202. else
  3203. {
  3204. sprintf((char*)maxProfile.transactionId, " ");
  3205. }
  3206. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3207. {
  3208. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3209. }
  3210. else
  3211. {
  3212. maxProfile.chargingSchedule[0].duration = 86400;
  3213. }
  3214. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3215. {
  3216. 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")));
  3217. }
  3218. else
  3219. {
  3220. 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));
  3221. }
  3222. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3223. {
  3224. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3225. }
  3226. else
  3227. {
  3228. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3229. }
  3230. }
  3231. }
  3232. }
  3233. else
  3234. {
  3235. if(maxProfile.id == -1)
  3236. DEBUG_INFO("MaxProfile found.\n");
  3237. else
  3238. DEBUG_INFO("MaxProfile updated.\n");
  3239. // Required item
  3240. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3241. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3242. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3243. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3244. 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++)
  3245. {
  3246. 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"));
  3247. 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")));
  3248. 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?
  3249. 3:
  3250. 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")));
  3251. }
  3252. // Optional item
  3253. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3254. {
  3255. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3256. }
  3257. else
  3258. {
  3259. sprintf((char*)maxProfile.validFrom, " ");
  3260. }
  3261. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3262. {
  3263. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3264. }
  3265. else
  3266. {
  3267. sprintf((char*)maxProfile.validTo, " ");
  3268. }
  3269. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3270. {
  3271. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3272. }
  3273. else
  3274. {
  3275. sprintf((char*)maxProfile.recurrencyKind, " ");
  3276. }
  3277. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3278. {
  3279. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3280. }
  3281. else
  3282. {
  3283. sprintf((char*)maxProfile.transactionId, " ");
  3284. }
  3285. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3286. {
  3287. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3288. }
  3289. else
  3290. {
  3291. maxProfile.chargingSchedule[0].duration = 86400;
  3292. }
  3293. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3294. {
  3295. 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")));
  3296. }
  3297. else
  3298. {
  3299. 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));
  3300. }
  3301. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3302. {
  3303. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3304. }
  3305. else
  3306. {
  3307. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3308. }
  3309. }
  3310. }
  3311. }
  3312. json_object_put(obj);
  3313. }
  3314. fclose(fp);
  3315. /*
  3316. if(maxProfile.ChargingProfileId !=-1)
  3317. {
  3318. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3319. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3320. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3321. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3322. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3323. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3324. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3325. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[0].StartSchedule);
  3326. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3327. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3328. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3329. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3330. {
  3331. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3332. {
  3333. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3334. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3335. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3336. }
  3337. }
  3338. }
  3339. else
  3340. DEBUG_INFO("MaxProfile not found.\n");
  3341. DEBUG_INFO("------------------------------------\n");*/
  3342. }
  3343. /*
  3344. * Align found profile start schedule & periods
  3345. */
  3346. //DEBUG_INFO("====================================\n");
  3347. /*
  3348. // For local test usage, force modify found profile start schedule info
  3349. 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);
  3350. 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);
  3351. 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);
  3352. */
  3353. if(txProfile.id != -1)
  3354. {
  3355. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3356. {
  3357. if(txProfile.chargingSchedule[0].duration != -1)
  3358. {
  3359. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3360. 0:
  3361. (txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3362. }
  3363. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3364. {
  3365. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3366. {
  3367. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3368. 0:
  3369. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3370. if(idxPeriod > 0)
  3371. {
  3372. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3373. {
  3374. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3375. }
  3376. }
  3377. }
  3378. }
  3379. }
  3380. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3381. {
  3382. if(txProfile.chargingSchedule[0].duration != -1)
  3383. {
  3384. 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?
  3385. 0:
  3386. (txProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3387. }
  3388. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3389. {
  3390. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3391. {
  3392. 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?
  3393. 0:
  3394. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3395. if(idxPeriod > 0)
  3396. {
  3397. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3398. {
  3399. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3400. }
  3401. }
  3402. }
  3403. }
  3404. }
  3405. else
  3406. {
  3407. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3408. {
  3409. if(txProfile.chargingSchedule[0].duration != -1)
  3410. {
  3411. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3412. 0:
  3413. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3414. }
  3415. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3416. {
  3417. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3418. {
  3419. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3420. 0:
  3421. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3422. if(idxPeriod > 0)
  3423. {
  3424. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3425. {
  3426. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3427. }
  3428. }
  3429. }
  3430. }
  3431. }
  3432. else
  3433. {
  3434. if(txProfile.chargingSchedule[0].duration != -1)
  3435. {
  3436. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3437. 0:
  3438. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3439. }
  3440. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3441. {
  3442. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3443. {
  3444. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3445. 0:
  3446. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3447. if(idxPeriod > 0)
  3448. {
  3449. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3450. {
  3451. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3452. }
  3453. }
  3454. }
  3455. }
  3456. }
  3457. }
  3458. /*
  3459. DEBUG_INFO("txProfile after align.\n");
  3460. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  3461. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3462. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3463. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3464. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3465. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3466. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  3467. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3468. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  3469. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  3470. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  3471. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3472. {
  3473. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3474. {
  3475. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3476. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3477. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3478. }
  3479. }*/
  3480. }
  3481. if(defaultTxProfile.id != -1)
  3482. {
  3483. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3484. {
  3485. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3486. {
  3487. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3488. 0:
  3489. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3490. }
  3491. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3492. {
  3493. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3494. {
  3495. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3496. 0:
  3497. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3498. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3499. {
  3500. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3501. }
  3502. if(idxPeriod > 0)
  3503. {
  3504. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3505. {
  3506. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3507. }
  3508. }
  3509. }
  3510. }
  3511. }
  3512. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3513. {
  3514. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3515. {
  3516. 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?
  3517. 0:
  3518. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3519. }
  3520. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3521. {
  3522. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3523. {
  3524. 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?
  3525. 0:
  3526. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3527. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3528. {
  3529. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3530. }
  3531. if(idxPeriod > 0)
  3532. {
  3533. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3534. {
  3535. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3536. }
  3537. }
  3538. }
  3539. }
  3540. }
  3541. else
  3542. {
  3543. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3544. {
  3545. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3546. {
  3547. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3548. 0:
  3549. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3550. }
  3551. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3552. {
  3553. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3554. {
  3555. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3556. 0:
  3557. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3558. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3559. {
  3560. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3561. }
  3562. if(idxPeriod > 0)
  3563. {
  3564. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3565. {
  3566. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3567. }
  3568. }
  3569. }
  3570. }
  3571. }
  3572. else
  3573. {
  3574. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3575. {
  3576. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3577. 0:
  3578. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3579. }
  3580. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3581. {
  3582. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3583. {
  3584. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3585. 0:
  3586. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3587. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3588. {
  3589. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3590. }
  3591. if(idxPeriod > 0)
  3592. {
  3593. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3594. {
  3595. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3596. }
  3597. }
  3598. }
  3599. }
  3600. }
  3601. }
  3602. /*
  3603. DEBUG_INFO("defaultTxProfile after align.\n");
  3604. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3605. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3606. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3607. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3608. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3609. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3610. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3611. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3612. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3613. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3614. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3615. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3616. {
  3617. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3618. {
  3619. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3620. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3621. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3622. }
  3623. }
  3624. DEBUG_INFO("------------------------------------\n");*/
  3625. }
  3626. if(maxProfile.id != -1)
  3627. {
  3628. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3629. {
  3630. if(maxProfile.chargingSchedule[0].duration != -1)
  3631. {
  3632. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3633. 0:
  3634. (maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3635. }
  3636. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3637. {
  3638. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3639. {
  3640. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3641. 0:
  3642. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3643. if(idxPeriod > 0)
  3644. {
  3645. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3646. {
  3647. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3648. }
  3649. }
  3650. }
  3651. }
  3652. }
  3653. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3654. {
  3655. if(maxProfile.chargingSchedule[0].duration != -1)
  3656. {
  3657. 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?
  3658. 0:
  3659. (maxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[9].startSchedule)));
  3660. }
  3661. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3662. {
  3663. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3664. {
  3665. 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?
  3666. 0:
  3667. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3668. if(idxPeriod > 0)
  3669. {
  3670. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3671. {
  3672. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3673. }
  3674. }
  3675. }
  3676. }
  3677. }
  3678. else
  3679. {
  3680. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3681. {
  3682. if(maxProfile.chargingSchedule[0].duration != -1)
  3683. {
  3684. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3685. 0:
  3686. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3687. }
  3688. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3689. {
  3690. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3691. {
  3692. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3693. 0:
  3694. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3695. if(idxPeriod > 0)
  3696. {
  3697. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3698. {
  3699. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3700. }
  3701. }
  3702. }
  3703. }
  3704. }
  3705. else
  3706. {
  3707. if(maxProfile.chargingSchedule[0].duration != -1)
  3708. {
  3709. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3710. 0:
  3711. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3712. }
  3713. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3714. {
  3715. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3716. {
  3717. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3718. 0:
  3719. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3720. if(idxPeriod > 0)
  3721. {
  3722. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3723. {
  3724. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3725. }
  3726. }
  3727. }
  3728. }
  3729. }
  3730. }
  3731. /*
  3732. DEBUG_INFO("MaxProfile after align.\n");
  3733. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3734. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3735. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3736. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3737. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3738. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3739. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3740. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3741. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3742. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3743. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3744. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3745. {
  3746. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3747. {
  3748. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3749. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3750. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3751. }
  3752. }
  3753. DEBUG_INFO("------------------------------------\n");*/
  3754. }
  3755. /*
  3756. * Merge to conposite schedule
  3757. */
  3758. //DEBUG_INFO("====================================\n");
  3759. // Find each profile period quantity
  3760. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3761. {
  3762. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3763. limitMax = idx+1;
  3764. }
  3765. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3766. {
  3767. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3768. limitDef = idx+1;
  3769. }
  3770. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3771. {
  3772. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3773. limitTx = idx+1;
  3774. }
  3775. // TxProfile found, composite schedule based on it
  3776. if(txProfile.id != -1)
  3777. {
  3778. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  3779. {
  3780. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  3781. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  3782. (txProfile.chargingSchedule[0].duration > 0))
  3783. {
  3784. if(maxProfile.id != -1)
  3785. {
  3786. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3787. {
  3788. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  3789. {
  3790. if((maxProfile.chargingSchedule[0].duration > 0))
  3791. {
  3792. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3793. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3794. 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);
  3795. }
  3796. else
  3797. {
  3798. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3799. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3800. tmpPeriod.limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit;
  3801. }
  3802. }
  3803. if(idxMaxPeriod == (limitMax-1))
  3804. {
  3805. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3806. {
  3807. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3808. {
  3809. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3810. compositePeriodIdx++;
  3811. }
  3812. else
  3813. {
  3814. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3815. }
  3816. }
  3817. }
  3818. }
  3819. }
  3820. else
  3821. {
  3822. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3823. {
  3824. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3825. compositePeriodIdx++;
  3826. }
  3827. else
  3828. {
  3829. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3830. }
  3831. }
  3832. }
  3833. if(idxTxPeriod == (limitTx-1))
  3834. {
  3835. if(defaultTxProfile.id != -1)
  3836. {
  3837. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3838. {
  3839. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  3840. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3841. (defaultTxProfile.chargingSchedule[0].duration>0))
  3842. {
  3843. if(maxProfile.id != -1)
  3844. {
  3845. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3846. {
  3847. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3848. {
  3849. if((maxProfile.chargingSchedule[0].duration > 0))
  3850. {
  3851. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3852. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3853. 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);
  3854. }
  3855. else
  3856. {
  3857. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3858. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3859. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3860. }
  3861. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3862. {
  3863. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3864. {
  3865. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3866. compositePeriodIdx++;
  3867. }
  3868. else
  3869. {
  3870. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3871. }
  3872. }
  3873. break;
  3874. }
  3875. }
  3876. }
  3877. else
  3878. {
  3879. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3880. {
  3881. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3882. compositePeriodIdx++;
  3883. }
  3884. else
  3885. {
  3886. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3887. }
  3888. }
  3889. }
  3890. }
  3891. }
  3892. }
  3893. }
  3894. }
  3895. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  3896. else if(defaultTxProfile.id != -1)
  3897. {
  3898. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3899. {
  3900. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  3901. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3902. (defaultTxProfile.chargingSchedule[0].duration > 0))
  3903. {
  3904. if(maxProfile.id != -1)
  3905. {
  3906. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3907. {
  3908. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3909. {
  3910. if((maxProfile.chargingSchedule[0].duration > 0))
  3911. {
  3912. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3913. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3914. 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);
  3915. }
  3916. else
  3917. {
  3918. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3919. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3920. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3921. }
  3922. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3923. {
  3924. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3925. {
  3926. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3927. compositePeriodIdx++;
  3928. }
  3929. else
  3930. {
  3931. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3932. }
  3933. }
  3934. break;
  3935. }
  3936. }
  3937. }
  3938. else
  3939. {
  3940. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3941. {
  3942. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3943. compositePeriodIdx++;
  3944. }
  3945. else
  3946. {
  3947. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3948. }
  3949. }
  3950. }
  3951. }
  3952. }
  3953. // Fill other period by MaxProfile
  3954. if(maxProfile.id != -1)
  3955. {
  3956. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3957. {
  3958. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3959. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3960. (maxProfile.chargingSchedule[0].duration > 0))
  3961. {
  3962. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod >= compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod) &&
  3963. (maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3964. {
  3965. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod;
  3966. tmpPeriod.numberPhases = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].numberPhases;
  3967. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3968. }
  3969. if((maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3970. {
  3971. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].duration;
  3972. tmpPeriod.numberPhases = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  3973. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3974. }
  3975. if(tmpPeriod.limit != -1)
  3976. {
  3977. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3978. {
  3979. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3980. {
  3981. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3982. compositePeriodIdx++;
  3983. }
  3984. else
  3985. {
  3986. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3987. }
  3988. }
  3989. }
  3990. }
  3991. }
  3992. }
  3993. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  3994. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[0].startSchedule);
  3995. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[0].duration);
  3996. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[0].chargingRateUnit);
  3997. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3998. {
  3999. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  4000. {
  4001. compositeProfile->id = 1;
  4002. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  4003. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit);
  4004. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases);
  4005. }
  4006. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit == -1)
  4007. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit =0;
  4008. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  4009. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  4010. }
  4011. if(line)
  4012. free(line);
  4013. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  4014. }
  4015. //==========================================
  4016. // Init all share memory
  4017. //==========================================
  4018. int InitShareMemory()
  4019. {
  4020. int result = PASS;
  4021. int MeterSMId;
  4022. //creat ShmSysConfigAndInfo
  4023. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  4024. {
  4025. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  4026. result = FAIL;
  4027. }
  4028. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4029. {
  4030. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  4031. result = FAIL;
  4032. }
  4033. else
  4034. {}
  4035. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  4036. {
  4037. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  4038. result = FAIL;
  4039. }
  4040. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4041. {
  4042. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  4043. result = FAIL;
  4044. }
  4045. else
  4046. {}
  4047. //creat ShmPsuData
  4048. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  4049. {
  4050. DEBUG_ERROR("shmget ShmPsuData NG\n");
  4051. result = FAIL;
  4052. }
  4053. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4054. {
  4055. DEBUG_ERROR("shmat ShmPsuData NG\n");
  4056. result = FAIL;
  4057. }
  4058. else
  4059. {}
  4060. //creat ShmOCPP20Data
  4061. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  4062. {
  4063. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  4064. result = FAIL;
  4065. }
  4066. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4067. {
  4068. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  4069. result = FAIL;
  4070. }
  4071. else
  4072. {}
  4073. /****************************** For Initial Settings************************************************/
  4074. //offline MeterValue Interval
  4075. TempMeterValueInterval = 0;
  4076. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  4077. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  4078. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  4079. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  4080. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  4081. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  4082. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  4083. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  4084. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  4085. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  4086. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  4087. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  4088. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  4089. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  4090. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  4091. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  4092. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  4093. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  4094. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  4095. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  4096. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  4097. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  4098. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  4099. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  4100. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  4101. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  4102. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  4103. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  4104. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  4105. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  4106. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  4107. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  4108. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  4109. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  4110. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  4111. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  4112. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  4113. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  4114. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  4115. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  4116. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  4117. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  4118. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  4119. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  4120. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  4121. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  4122. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  4123. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  4124. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  4125. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  4126. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  4127. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  4128. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  4129. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  4130. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  4131. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  4132. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  4133. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  4134. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  4135. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  4136. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  4137. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  4138. return result;
  4139. }
  4140. int ProcessShareMemory()
  4141. {
  4142. if(InitShareMemory() == FAIL)
  4143. {
  4144. DEBUG_ERROR("InitShareMemory NG\n");
  4145. if(ShmStatusCodeData!=NULL)
  4146. {
  4147. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  4148. }
  4149. sleep(5);
  4150. return FAIL;
  4151. }
  4152. return PASS;
  4153. }
  4154. //---------------------common routine---------------------------//
  4155. void checkNetworkProfile(void)
  4156. {
  4157. uint8_t isGetProfile = FALSE;
  4158. json_object *priority;
  4159. priority = json_tokener_parse((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value);
  4160. if(!is_error(priority))
  4161. {
  4162. for(uint8_t idxPriority=0;idxPriority<json_object_array_length(priority);idxPriority++)
  4163. {
  4164. for(uint8_t idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile);idx++)
  4165. {
  4166. if((ShmOCPP20Data->NetworkConnectionProfile[idx].slot == json_object_get_int(json_object_array_get_idx(priority, idxPriority))) &&
  4167. (strlen((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl) > 0) &&
  4168. (ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount < 3))
  4169. {
  4170. memcpy(ShmOCPP20Data->OcppServerURL, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  4171. memcpy(ShmSysConfigAndInfo->SysConfig.OcppServerURL, ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl));
  4172. isGetProfile = TRUE;
  4173. ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount++;
  4174. break;
  4175. }
  4176. }
  4177. }
  4178. }
  4179. json_object_put(priority);
  4180. if(!isGetProfile && (strlen((char*)ShmOCPP20Data->OcppServerURL) > 0))
  4181. {
  4182. memcpy(ShmSysConfigAndInfo->SysConfig.OcppServerURL, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  4183. }
  4184. DEBUG_INFO("Get network profile URL: %s\n", ShmSysConfigAndInfo->SysConfig.OcppServerURL);
  4185. }
  4186. void CheckSystemValue(void)
  4187. {
  4188. char filenmae[100]={0};
  4189. char str[100]={0};
  4190. int tempIndex = 0;
  4191. //===============================
  4192. // EVSE operation check
  4193. //===============================
  4194. //===============================
  4195. // Heartbeat check
  4196. //===============================
  4197. if((difftime(time((time_t*)NULL), clientTime.Heartbeat) < 0) || (HeartBeatWaitTime <= 0))
  4198. {
  4199. clientTime.Heartbeat = time((time_t*)NULL);
  4200. if(server_sign == TRUE)
  4201. {
  4202. HeartBeatWaitTime = ShmOCPP20Data->BootNotification.Response_interval;
  4203. }
  4204. else
  4205. {
  4206. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);
  4207. }
  4208. }
  4209. if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  4210. {
  4211. //parameter for test
  4212. sendHeartbeatRequest(0);
  4213. //==============================================
  4214. // Reset Waiting Time
  4215. //==============================================
  4216. HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
  4217. }
  4218. //===============================
  4219. // CSU Trigger Reset Conf
  4220. //===============================
  4221. if(isWebsocketSendable && (ShmOCPP20Data->MsMsg.bits.ResetConf == ON))
  4222. {
  4223. sendResetConfirmation((char *)ShmOCPP20Data->Reset.guid);
  4224. }
  4225. //===============================
  4226. // CSU Trigger Authorize Request
  4227. //===============================
  4228. if(isWebsocketSendable &&
  4229. (server_sign == TRUE) &&
  4230. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4231. (authorizeRetryTimes < 3))
  4232. {
  4233. sendAuthorizeRequest(0);
  4234. authorizeRetryTimes = authorizeRetryTimes + 1;
  4235. if(authorizeRetryTimes < 3)
  4236. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4237. }
  4238. else if((server_sign == TRUE) &&
  4239. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4240. (authorizeRetryTimes >= 3))
  4241. {
  4242. authorizeRetryTimes = 0;
  4243. SetOcppConnStatus(FALSE);
  4244. server_sign = FALSE;
  4245. }
  4246. else if((server_sign == FALSE) &&
  4247. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  4248. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  4249. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  4250. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  4251. {
  4252. sendAuthorizeRequest(0);
  4253. }
  4254. if(isWebsocketSendable &&
  4255. (server_sign == TRUE) &&
  4256. (ShmOCPP20Data->GetBaseReport.requestId > 0))
  4257. {
  4258. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_ConfigurationInventory]) == 0)
  4259. {
  4260. /*
  4261. * TODO:
  4262. * 1. Fill out configuration to response message
  4263. */
  4264. }
  4265. else if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_FullInventory]) == 0)
  4266. {
  4267. /*
  4268. * TODO:
  4269. * 1. Fill out full inventory to response message
  4270. */
  4271. }
  4272. else
  4273. {
  4274. /*
  4275. * TODO:
  4276. * 1. Fill out summary inventory to response message
  4277. */
  4278. }
  4279. sendNotifyReportRequest();
  4280. ShmOCPP20Data->GetBaseReport.requestId = 0;
  4281. }
  4282. if(isWebsocketSendable &&
  4283. (server_sign == TRUE) &&
  4284. ShmOCPP20Data->SpMsg.bits.NotifyEventReq)
  4285. {
  4286. /*
  4287. * TODO:
  4288. * 1. Fill out NotifyEvent message data
  4289. */
  4290. getNowDatetime(ShmOCPP20Data->NotifyEvent.generatedAt);
  4291. ShmOCPP20Data->NotifyEvent.tbc = FALSE;
  4292. if(ShmOCPP20Data->NotifyEvent.seqNo < 2147483647)
  4293. ShmOCPP20Data->NotifyEvent.seqNo += 1;
  4294. else
  4295. ShmOCPP20Data->NotifyEvent.seqNo = 0;
  4296. sendNotifyEventRequest();
  4297. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  4298. }
  4299. //===============================
  4300. // Each connector operation check
  4301. //===============================
  4302. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  4303. {
  4304. //==========================================
  4305. // csu trigger DataTransferReq
  4306. //==========================================
  4307. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  4308. {
  4309. sendDataTransferRequest(gun_index);
  4310. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  4311. }
  4312. //===============================
  4313. // CSU Trigger Smart Charging Profilw
  4314. //===============================
  4315. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  4316. {
  4317. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index]);
  4318. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  4319. }
  4320. //==============================================
  4321. // Charger start transaction
  4322. //==============================================
  4323. /*
  4324. if((ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq == ON))
  4325. {
  4326. ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq = OFF;
  4327. sendStartTransactionRequest(gun_index);
  4328. clientTime.StartTransaction = time((time_t*)NULL);
  4329. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4330. }*/
  4331. //==============================================
  4332. // Charger stop transaction
  4333. //==============================================
  4334. /*
  4335. if(((ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq == ON)))
  4336. {
  4337. ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq =OFF;
  4338. sendStopTransactionRequest(gun_index);
  4339. clientTime.StopTransaction = time((time_t*)NULL);
  4340. }*/
  4341. //==============================================
  4342. // Charger status notification & Transaction event report
  4343. //==============================================
  4344. //--- Check Mode Change ---//
  4345. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  4346. if(gunType[gun_index] == 'J')
  4347. {
  4348. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4349. {
  4350. tempIndex = ((gun_index==2) ? 1: 0);
  4351. }
  4352. else
  4353. {
  4354. tempIndex = gun_index;
  4355. }
  4356. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4357. {
  4358. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4359. {
  4360. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  4361. {
  4362. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  4363. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  4364. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4365. if((SystemInitial == 0) &&
  4366. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4367. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4368. {
  4369. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4370. }
  4371. }
  4372. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4373. {
  4374. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4375. if((access(filenmae,F_OK))!=-1)
  4376. {
  4377. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4378. sprintf(str,"rm -f %s",filenmae);
  4379. system(str);
  4380. }
  4381. }
  4382. #if 1 // for TempStopTransaction
  4383. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4384. {
  4385. checkTempStopTransaction(gun_index);
  4386. }
  4387. #endif
  4388. }
  4389. }
  4390. }
  4391. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4392. {
  4393. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4394. {
  4395. tempIndex = ((gun_index==2) ? 1: 0);
  4396. }
  4397. else
  4398. {
  4399. tempIndex = gun_index;
  4400. }
  4401. for (int index = 0; index < CCS_QUANTITY; index++)
  4402. {
  4403. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4404. {
  4405. 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]*/ )
  4406. {
  4407. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  4408. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  4409. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4410. if((SystemInitial == 0) &&
  4411. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4412. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4413. {
  4414. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4415. }
  4416. }
  4417. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4418. {
  4419. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4420. if((access(filenmae,F_OK))!=-1)
  4421. {
  4422. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4423. sprintf(str,"rm -f %s",filenmae);
  4424. system(str);
  4425. }
  4426. }
  4427. #if 1 // for TempStopTransaction
  4428. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4429. {
  4430. checkTempStopTransaction(gun_index);
  4431. }
  4432. #endif
  4433. }
  4434. }
  4435. }
  4436. else if(gunType[gun_index] == 'G')
  4437. {
  4438. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4439. {
  4440. tempIndex = ((gun_index==2) ? 1: 0);
  4441. }
  4442. else
  4443. {
  4444. tempIndex = gun_index;
  4445. }
  4446. for (int index = 0; index < GB_QUANTITY; index++)
  4447. {
  4448. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4449. {
  4450. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  4451. {
  4452. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  4453. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  4454. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4455. if((SystemInitial == 0) &&
  4456. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4457. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4458. {
  4459. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4460. }
  4461. }
  4462. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4463. {
  4464. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4465. if((access(filenmae,F_OK))!=-1)
  4466. {
  4467. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4468. sprintf(str,"rm -f %s",filenmae);
  4469. system(str);
  4470. }
  4471. }
  4472. #if 1 // for TempStopTransaction
  4473. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4474. {
  4475. checkTempStopTransaction(gun_index);
  4476. }
  4477. #endif
  4478. }
  4479. }
  4480. }
  4481. else if(gunType[gun_index] == 'O')
  4482. {
  4483. tempIndex = gun_index;
  4484. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4485. {
  4486. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4487. {
  4488. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  4489. {
  4490. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  4491. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  4492. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4493. if((SystemInitial == 0) &&
  4494. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING) &&
  4495. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_COMPLETE))
  4496. {
  4497. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4498. }
  4499. }
  4500. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // complete
  4501. {
  4502. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4503. if((access(filenmae,F_OK))!=-1)
  4504. {
  4505. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4506. sprintf(str,"rm -f %s",filenmae);
  4507. system(str);
  4508. }
  4509. }
  4510. #if 1 // for TempStopTransaction
  4511. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4512. {
  4513. checkTempStopTransaction(gun_index);
  4514. }
  4515. #endif
  4516. }
  4517. }
  4518. }
  4519. else
  4520. {
  4521. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4522. {
  4523. tempIndex = 2;
  4524. }
  4525. else
  4526. {
  4527. tempIndex = gun_index;
  4528. }
  4529. for (int index = 0; index < AC_QUANTITY; index++)
  4530. {
  4531. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4532. {
  4533. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  4534. {
  4535. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  4536. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  4537. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4538. if((SystemInitial == 0) &&
  4539. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4540. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4541. {
  4542. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4543. }
  4544. }
  4545. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4546. {
  4547. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4548. if((access(filenmae,F_OK))!=-1)
  4549. {
  4550. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4551. sprintf(str,"rm -f %s",filenmae);
  4552. system(str);
  4553. }
  4554. }
  4555. #if 1 // for TempStopTransaction
  4556. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4557. {
  4558. checkTempStopTransaction(gun_index);
  4559. }
  4560. #endif
  4561. }
  4562. }// END
  4563. }
  4564. if(isWebsocketSendable &&
  4565. (cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) &&
  4566. ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 10) )
  4567. {
  4568. if(SystemInitial > 0)
  4569. SystemInitial -= 1;
  4570. sendStatusNotificationRequest(gun_index);
  4571. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  4572. }
  4573. if(isWebsocketSendable && (server_sign == TRUE) && (cpinitateMsg.bits[gun_index].TransactionEventReq == ON))
  4574. {
  4575. sendTransactionEventRequest(gun_index);
  4576. cpinitateMsg.bits[gun_index].TransactionEventReq = OFF;
  4577. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], 0x00, sizeof(struct MeterValueType));
  4578. }
  4579. //==============================================
  4580. // Meter report
  4581. //==============================================
  4582. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  4583. {
  4584. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  4585. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  4586. }
  4587. // ClockAlign MeterValue
  4588. 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))
  4589. {
  4590. //check Transaction active
  4591. if(gunType[gun_index] == 'J')
  4592. {
  4593. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4594. {
  4595. tempIndex = ((gun_index==2) ? 1: 0);
  4596. }
  4597. else
  4598. {
  4599. tempIndex = gun_index;
  4600. }
  4601. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4602. {
  4603. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4604. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4605. {
  4606. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4607. {
  4608. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4609. }
  4610. }
  4611. }// End for CHAdeMO
  4612. }
  4613. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4614. {
  4615. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4616. {
  4617. tempIndex = ((gun_index==2) ? 1: 0);
  4618. }
  4619. else
  4620. {
  4621. tempIndex = gun_index;
  4622. }
  4623. for (int index = 0; index < CCS_QUANTITY; index++)
  4624. {
  4625. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4626. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4627. {
  4628. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4629. {
  4630. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4631. }
  4632. }
  4633. } // End for CCS
  4634. }
  4635. else if(gunType[gun_index] == 'G')
  4636. {
  4637. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4638. {
  4639. tempIndex = ((gun_index==2) ? 1: 0);
  4640. }
  4641. else
  4642. {
  4643. tempIndex = gun_index;
  4644. }
  4645. for (int index = 0; index < GB_QUANTITY; index++)
  4646. {
  4647. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4648. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4649. {
  4650. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4651. {
  4652. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4653. }
  4654. }
  4655. }// End for GB
  4656. }
  4657. else if(gunType[gun_index] == 'O')
  4658. {
  4659. tempIndex = gun_index;
  4660. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4661. {
  4662. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4663. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4664. {
  4665. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_CHARGING)
  4666. {
  4667. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4668. }
  4669. }
  4670. }
  4671. }
  4672. else
  4673. {
  4674. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4675. {
  4676. tempIndex = 2;
  4677. }
  4678. else
  4679. {
  4680. tempIndex = gun_index;
  4681. }
  4682. for (int index = 0; index < AC_QUANTITY; index++)
  4683. {
  4684. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4685. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4686. {
  4687. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4688. {
  4689. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4690. }
  4691. }
  4692. }//End for AC
  4693. }
  4694. if(cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON)
  4695. {
  4696. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  4697. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  4698. }
  4699. }
  4700. // Sample period MeterValue
  4701. if(((time((time_t*)NULL) - clientTime.MeterValues[gun_index]) > (atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1)))
  4702. {
  4703. //check Transaction active
  4704. if(gunType[gun_index] == 'J')
  4705. {
  4706. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4707. {
  4708. tempIndex = ((gun_index==2) ? 1: 0);
  4709. }
  4710. else
  4711. {
  4712. tempIndex = gun_index;
  4713. }
  4714. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4715. {
  4716. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4717. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4718. {
  4719. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4720. {
  4721. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4722. }
  4723. }
  4724. }// End for CHAdeMO
  4725. }
  4726. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4727. {
  4728. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4729. {
  4730. tempIndex = ((gun_index==2) ? 1: 0);
  4731. }
  4732. else
  4733. {
  4734. tempIndex = gun_index;
  4735. }
  4736. for (int index = 0; index < CCS_QUANTITY; index++)
  4737. {
  4738. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4739. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4740. {
  4741. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4742. {
  4743. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4744. }
  4745. }
  4746. } // End for CCS
  4747. }
  4748. else if(gunType[gun_index] == 'G')
  4749. {
  4750. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4751. {
  4752. tempIndex = ((gun_index==2) ? 1: 0);
  4753. }
  4754. else
  4755. {
  4756. tempIndex = gun_index;
  4757. }
  4758. for (int index = 0; index < GB_QUANTITY; index++)
  4759. {
  4760. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4761. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4762. {
  4763. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4764. {
  4765. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4766. }
  4767. }
  4768. }// End for GB
  4769. }
  4770. else if(gunType[gun_index] == 'O')
  4771. {
  4772. tempIndex = gun_index;
  4773. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4774. {
  4775. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4776. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4777. {
  4778. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  4779. {
  4780. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4781. }
  4782. }
  4783. }
  4784. }
  4785. else
  4786. {
  4787. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4788. {
  4789. tempIndex = 2;
  4790. }
  4791. else
  4792. {
  4793. tempIndex = gun_index;
  4794. }
  4795. for (int index = 0; index < AC_QUANTITY; index++)
  4796. {
  4797. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4798. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4799. {
  4800. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4801. {
  4802. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4803. }
  4804. }
  4805. }//End for AC
  4806. }
  4807. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  4808. {
  4809. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  4810. storeTempStopTransaction(gun_index);
  4811. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  4812. }
  4813. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4814. }
  4815. //==============================================
  4816. // Check Connector reserved
  4817. //==============================================
  4818. //===============================
  4819. // Check if Reserve is expired
  4820. //===============================
  4821. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0) )
  4822. {
  4823. double diff_t;
  4824. struct tm tp;
  4825. // current time
  4826. time_t t = time(NULL);
  4827. strptime((char *)ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime, "%Y-%m-%dT%H:%M:%S", &tp);
  4828. tp.tm_isdst = -1;
  4829. time_t utc = mktime(&tp);
  4830. diff_t = difftime(utc, t);
  4831. if(diff_t <= 0)
  4832. {
  4833. DEBUG_INFO("reserve expired.\n");
  4834. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  4835. }
  4836. }//END OF Check if Reserve is expired
  4837. //==========================================
  4838. // csu trigger FirmwareStatusNotificationReq
  4839. //==========================================
  4840. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  4841. {
  4842. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  4843. }
  4844. //==========================================
  4845. // csu trigger CancelReservationConf
  4846. //==========================================
  4847. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  4848. {
  4849. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  4850. }
  4851. //==========================================
  4852. // csu trigger ChangeAvailabilityConf
  4853. //==========================================
  4854. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  4855. {
  4856. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  4857. }
  4858. //==========================================
  4859. // csu trigger UnlockConnectorConf
  4860. //==========================================
  4861. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  4862. {
  4863. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  4864. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  4865. }
  4866. //==========================================
  4867. // csu trigger ReserveNowConf
  4868. //==========================================
  4869. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  4870. {
  4871. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  4872. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  4873. }
  4874. }
  4875. }
  4876. //==========================================
  4877. // send request routine
  4878. //==========================================
  4879. int sendAuthorizeRequest(int gun_index)
  4880. {
  4881. mtrace();
  4882. int result = FAIL;
  4883. char message[4096]={0};
  4884. char guid[37];
  4885. char tempdata[128]={0};
  4886. json_object *Authorize = json_object_new_object();
  4887. json_object *idToken = json_object_new_object();
  4888. DEBUG_INFO("sendAuthorizeRequest...\n");
  4889. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  4890. //Local Authorize
  4891. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) && (ShmOCPP20Data->OcppConnStatus == 0))
  4892. {
  4893. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  4894. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4895. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  4896. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  4897. result = PASS;
  4898. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4899. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4900. authorizeRetryTimes = 0;
  4901. return result;
  4902. }
  4903. 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)) ||
  4904. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  4905. {
  4906. // Query idtag from cache
  4907. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  4908. // Query idtag from list
  4909. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4910. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  4911. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4912. {
  4913. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  4914. {
  4915. DEBUG_INFO("Card %s does not find in list or cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  4916. }
  4917. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  4918. {
  4919. DEBUG_INFO("Card %s does not accepted in list and cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  4920. }
  4921. // Return authorize result if does not connect to server
  4922. if(!ShmOCPP20Data->OcppConnStatus)
  4923. {
  4924. DEBUG_INFO("Local Authorization Fail.\n");
  4925. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4926. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4927. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  4928. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4929. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4930. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4931. authorizeRetryTimes = 0;
  4932. return result;
  4933. }
  4934. }
  4935. else
  4936. {
  4937. DEBUG_INFO("Local Authorization get result.\n");
  4938. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  4939. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4940. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  4941. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  4942. else
  4943. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  4944. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4945. result = PASS;
  4946. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4947. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4948. authorizeRetryTimes = 0;
  4949. return result;
  4950. }
  4951. }
  4952. //initialize struct Authorize
  4953. memset(&(ShmOCPP20Data->Authorize), 0 , sizeof(struct StructAuthorize));
  4954. //get data from shared memory
  4955. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4956. strcpy((char *)ShmOCPP20Data->Authorize.idToken.type, IdTokenEnumTypeStr[IdTokenEnumType_ISO14443]);
  4957. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  4958. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  4959. json_object_object_add(Authorize, "idToken", idToken);
  4960. random_uuid(guid);
  4961. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  4962. json_object_put(Authorize);
  4963. LWS_Send(message);
  4964. sprintf(tempdata, "Authorize,%d", gun_index);
  4965. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4966. {
  4967. result = PASS;
  4968. }
  4969. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4970. return result;
  4971. }
  4972. int sendBootNotificationRequest()
  4973. {
  4974. mtrace();
  4975. int result = FAIL;
  4976. char message[4096]={0};
  4977. char guid[37]={0};
  4978. char tempdata[128]={0};
  4979. json_object *BootNotification = json_object_new_object();
  4980. json_object *chargingStation = json_object_new_object();
  4981. json_object *modem = json_object_new_object();
  4982. // Fill BootNotification fields
  4983. DB_getBooType();
  4984. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  4985. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  4986. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  4987. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  4988. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  4989. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  4990. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  4991. {
  4992. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  4993. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  4994. json_object_object_add(chargingStation, "modem", modem);
  4995. }
  4996. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  4997. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  4998. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  4999. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  5000. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  5001. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  5002. random_uuid(guid);
  5003. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  5004. json_object_put(BootNotification);
  5005. LWS_Send(message);
  5006. sprintf(tempdata, "BootNotification,0");
  5007. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5008. {
  5009. result = PASS;
  5010. }
  5011. return result;
  5012. }
  5013. int sendClearedChargingLimitRequest(int gun_index)
  5014. {
  5015. mtrace();
  5016. int result = FAIL;
  5017. char message[4096]={0};
  5018. char guid[37]={0};
  5019. char tempdata[128]={0};
  5020. json_object *ClearedChargingLimit = json_object_new_object();
  5021. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  5022. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  5023. random_uuid(guid);
  5024. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  5025. json_object_put(ClearedChargingLimit);
  5026. LWS_Send(message);
  5027. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  5028. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5029. {
  5030. result = PASS;
  5031. }
  5032. return result;
  5033. }
  5034. int sendDataTransferRequest(int gun_index)
  5035. {
  5036. mtrace();
  5037. char message[1000]={0};
  5038. char guid[37]={0};
  5039. char tempdata[65]={0};
  5040. int result = FAIL;
  5041. random_uuid(guid);
  5042. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  5043. MESSAGE_TYPE_CALL,
  5044. guid,
  5045. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  5046. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  5047. ShmOCPP20Data->DataTransfer[gun_index].data);
  5048. LWS_Send(message);
  5049. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  5050. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5051. {
  5052. result = PASS;
  5053. }
  5054. return result;
  5055. }
  5056. int sendFirmwareStatusNotificationRequest(char *status)
  5057. {
  5058. mtrace();
  5059. int result = FAIL;
  5060. char message[110]={0};
  5061. char guid[37]={0};
  5062. char tempdata[65]={0};
  5063. json_object *FirmwareStatusNotification = json_object_new_object();
  5064. DEBUG_INFO("sendFirmwareStatusNotificationRequest \n");
  5065. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  5066. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  5067. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  5068. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  5069. random_uuid(guid);
  5070. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  5071. json_object_put(FirmwareStatusNotification);
  5072. LWS_SendNow(message);
  5073. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  5074. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5075. {
  5076. result = PASS;
  5077. }
  5078. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  5079. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  5080. //record status
  5081. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  5082. {
  5083. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  5084. }
  5085. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  5086. {
  5087. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  5088. }
  5089. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  5090. {
  5091. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  5092. }
  5093. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  5094. {
  5095. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  5096. }
  5097. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  5098. {
  5099. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  5100. }
  5101. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  5102. {
  5103. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  5104. }
  5105. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  5106. {
  5107. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  5108. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5109. }
  5110. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  5111. {
  5112. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  5113. }
  5114. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  5115. {
  5116. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  5117. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5118. }
  5119. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  5120. {
  5121. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  5122. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5123. }
  5124. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  5125. {
  5126. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  5127. }
  5128. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  5129. {
  5130. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  5131. }
  5132. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  5133. {
  5134. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  5135. }
  5136. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  5137. {
  5138. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  5139. }
  5140. return result;
  5141. }
  5142. int sendGet15118EVCertificateRequest()
  5143. {
  5144. mtrace();
  5145. int result = FAIL;
  5146. char message[4096]={0};
  5147. char guid[37]={0};
  5148. char tempdata[128]={0};
  5149. json_object *Get15118EVCertificate = json_object_new_object();
  5150. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  5151. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  5152. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  5153. random_uuid(guid);
  5154. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  5155. json_object_put(Get15118EVCertificate);
  5156. LWS_Send(message);
  5157. sprintf(tempdata, "Get15118EVCertificate,0");
  5158. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5159. {
  5160. result = PASS;
  5161. }
  5162. return result;
  5163. }
  5164. int sendGetCertificateStatusRequest()
  5165. {
  5166. mtrace();
  5167. int result = FAIL;
  5168. char message[4096]={0};
  5169. char guid[37]={0};
  5170. char tempdata[128]={0};
  5171. json_object *GetCertificateStatus = json_object_new_object();
  5172. json_object *ocspRequestData = json_object_new_object();
  5173. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  5174. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  5175. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  5176. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  5177. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  5178. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  5179. random_uuid(guid);
  5180. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  5181. json_object_put(GetCertificateStatus);
  5182. LWS_Send(message);
  5183. sprintf(tempdata, "GetCertificateStatus,0");
  5184. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5185. {
  5186. result = PASS;
  5187. }
  5188. return result;
  5189. }
  5190. int sendHeartbeatRequest()
  5191. {
  5192. mtrace();
  5193. int result = FAIL;
  5194. char message[40096]={0};
  5195. char guid[37]={0};
  5196. char tempdata[128]={0};
  5197. random_uuid(guid);
  5198. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  5199. , MESSAGE_TYPE_CALL
  5200. , guid );
  5201. LWS_Send(message);
  5202. sprintf(tempdata, "Heartbeat,%d", 0);
  5203. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5204. {
  5205. result = PASS;
  5206. }
  5207. return result;
  5208. }
  5209. int sendLogStatusNotificationRequest(char *status)
  5210. {
  5211. mtrace();
  5212. int result = FAIL;
  5213. char message[4096]={0};
  5214. char guid[37]={0};
  5215. char tempdata[128]={0};
  5216. json_object *LogStatusNotification = json_object_new_object();
  5217. DEBUG_INFO("sendLogStatusNotificationRequest \n");
  5218. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  5219. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  5220. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  5221. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  5222. random_uuid(guid);
  5223. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  5224. json_object_put(LogStatusNotification);
  5225. LWS_SendNow(message);
  5226. sprintf(tempdata, "LogStatusNotification,%d", 0);
  5227. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5228. {
  5229. result = PASS;
  5230. }
  5231. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  5232. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  5233. //record status
  5234. if(strcmp(status,"BadMessage")==0)
  5235. {
  5236. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  5237. }
  5238. else if(strcmp(status,"Idle")==0)
  5239. {
  5240. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  5241. }
  5242. else if(strcmp(status,"NotSupportedOperation")==0)
  5243. {
  5244. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  5245. }
  5246. else if(strcmp(status,"PermissionDenied")==0)
  5247. {
  5248. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  5249. }
  5250. else if(strcmp(status,"Uploaded")==0)
  5251. {
  5252. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  5253. }
  5254. else if(strcmp(status,"UploadFailure")==0)
  5255. {
  5256. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  5257. }
  5258. else if(strcmp(status,"Uploading")==0)
  5259. {
  5260. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  5261. }
  5262. return result;
  5263. }
  5264. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  5265. {
  5266. mtrace();
  5267. int result = FAIL;
  5268. char guid[37]={0};
  5269. char tempdata[65]={0};
  5270. int tempIndex = 0;
  5271. json_object *MeterValueReq = json_object_new_object();
  5272. json_object *meterValues = json_object_new_array();
  5273. json_object *meterValue = json_object_new_object();
  5274. json_object *sampledValues = json_object_new_array();
  5275. json_object *sampledValue = json_object_new_object();
  5276. json_object *unitOfMeasure = json_object_new_object();
  5277. DEBUG_INFO("sendMeterValuesRequest ...\n");
  5278. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  5279. //set value
  5280. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  5281. //UTC Date time
  5282. struct timeval tmnow;
  5283. struct tm *tm;
  5284. char buf[28];//, usec_buf[6];
  5285. gettimeofday(&tmnow, NULL);
  5286. time_t t;
  5287. t = time(NULL);
  5288. /*UTC time and date*/
  5289. tm = gmtime(&t);
  5290. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  5291. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  5292. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  5293. //idx_sample=0;
  5294. //********************************(1)Current.Import L1************************************************/
  5295. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5296. if(gunType[gun_index] == 'J')
  5297. {
  5298. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5299. {
  5300. tempIndex = ((gun_index==2) ? 1: 0);
  5301. }
  5302. else
  5303. {
  5304. tempIndex = gun_index;
  5305. }
  5306. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5307. {
  5308. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5309. {
  5310. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent;
  5311. }
  5312. }
  5313. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5314. }
  5315. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5316. {
  5317. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5318. {
  5319. tempIndex = ((gun_index==2) ? 1: 0);
  5320. }
  5321. else
  5322. {
  5323. tempIndex = gun_index;
  5324. }
  5325. for (int index = 0; index < CCS_QUANTITY; index++)
  5326. {
  5327. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5328. {
  5329. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent;
  5330. }
  5331. }
  5332. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5333. }
  5334. else if(gunType[gun_index] == 'G')
  5335. {
  5336. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5337. {
  5338. tempIndex = ((gun_index==2) ? 1: 0);
  5339. }
  5340. else
  5341. {
  5342. tempIndex = gun_index;
  5343. }
  5344. for (int index = 0; index < GB_QUANTITY; index++)
  5345. {
  5346. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5347. {
  5348. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent;
  5349. }
  5350. }
  5351. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5352. }
  5353. else if(gunType[gun_index] == 'O')
  5354. {
  5355. tempIndex = gun_index;
  5356. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5357. {
  5358. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5359. {
  5360. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent;
  5361. }
  5362. }
  5363. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5364. }
  5365. else
  5366. {
  5367. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5368. {
  5369. tempIndex = 2;
  5370. }
  5371. else
  5372. {
  5373. tempIndex = gun_index;
  5374. }
  5375. for (int index = 0; index < AC_QUANTITY; index++)
  5376. {
  5377. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5378. {
  5379. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent;
  5380. }
  5381. }
  5382. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5383. }
  5384. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  5385. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5386. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5387. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  5388. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  5389. //idx_sample=1;
  5390. //********************************(2)Energy.Active.Import.Register ************************************************/
  5391. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5392. if(gunType[gun_index] == 'J')
  5393. {
  5394. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5395. {
  5396. tempIndex = ((gun_index==2) ? 1: 0);
  5397. }
  5398. else
  5399. {
  5400. tempIndex = gun_index;
  5401. }
  5402. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5403. {
  5404. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5405. {
  5406. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  5407. }
  5408. }
  5409. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5410. }
  5411. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5412. {
  5413. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5414. {
  5415. tempIndex = ((gun_index==2) ? 1: 0);
  5416. }
  5417. else
  5418. {
  5419. tempIndex = gun_index;
  5420. }
  5421. for (int index = 0; index < CCS_QUANTITY; index++)
  5422. {
  5423. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5424. {
  5425. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  5426. }
  5427. }
  5428. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5429. }
  5430. else if(gunType[gun_index] == 'G')
  5431. {
  5432. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5433. {
  5434. tempIndex = ((gun_index==2) ? 1: 0);
  5435. }
  5436. else
  5437. {
  5438. tempIndex = gun_index;
  5439. }
  5440. for (int index = 0; index < GB_QUANTITY; index++)
  5441. {
  5442. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5443. {
  5444. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  5445. }
  5446. }
  5447. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5448. }
  5449. else if(gunType[gun_index] == 'O')
  5450. {
  5451. tempIndex = gun_index;
  5452. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5453. {
  5454. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5455. {
  5456. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  5457. }
  5458. }
  5459. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5460. }
  5461. else
  5462. {
  5463. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5464. {
  5465. tempIndex = 2;
  5466. }
  5467. else
  5468. {
  5469. tempIndex = gun_index;
  5470. }
  5471. for (int index = 0; index < AC_QUANTITY; index++)
  5472. {
  5473. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5474. {
  5475. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  5476. }
  5477. }
  5478. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5479. }
  5480. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  5481. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  5482. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5483. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  5484. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5485. //idx_sample=2;
  5486. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  5487. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5488. if(gunType[gun_index] == 'J')
  5489. {
  5490. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5491. {
  5492. tempIndex = ((gun_index==2) ? 1: 0);
  5493. }
  5494. else
  5495. {
  5496. tempIndex = gun_index;
  5497. }
  5498. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5499. {
  5500. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5501. {
  5502. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
  5503. }
  5504. } // END OF FOR CHAdeMO_QUANTITY
  5505. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5506. }
  5507. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5508. {
  5509. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5510. {
  5511. tempIndex = ((gun_index==2) ? 1: 0);
  5512. }
  5513. else
  5514. {
  5515. tempIndex = gun_index;
  5516. }
  5517. for (int index = 0; index < CCS_QUANTITY; index++)
  5518. {
  5519. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5520. {
  5521. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
  5522. }
  5523. } // END OF CCS_QUANTITY
  5524. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5525. }
  5526. else if(gunType[gun_index] == 'G')
  5527. {
  5528. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5529. {
  5530. tempIndex = ((gun_index==2) ? 1: 0);
  5531. }
  5532. else
  5533. {
  5534. tempIndex = gun_index;
  5535. }
  5536. for (int index = 0; index < GB_QUANTITY; index++)
  5537. {
  5538. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5539. {
  5540. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
  5541. }
  5542. } // END OF GB_QUANTITY
  5543. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5544. }
  5545. else if(gunType[gun_index] == 'O')
  5546. {
  5547. tempIndex = gun_index;
  5548. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5549. {
  5550. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5551. {
  5552. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy;
  5553. }
  5554. }
  5555. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5556. }
  5557. else
  5558. {
  5559. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5560. {
  5561. tempIndex = 2;
  5562. }
  5563. else
  5564. {
  5565. tempIndex = gun_index;
  5566. }
  5567. for (int index = 0; index < AC_QUANTITY; index++)
  5568. {
  5569. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5570. {
  5571. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
  5572. }
  5573. }
  5574. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5575. }
  5576. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  5577. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  5578. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5579. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  5580. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5581. //idx_sample=3;
  5582. //********************************(4)Power.Active.Import************************************************/
  5583. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5584. if(gunType[gun_index] == 'J')
  5585. {
  5586. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5587. {
  5588. tempIndex = ((gun_index==2) ? 1: 0);
  5589. }
  5590. else
  5591. {
  5592. tempIndex = gun_index;
  5593. }
  5594. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5595. {
  5596. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5597. {
  5598. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower;
  5599. }
  5600. } // END OF FOR
  5601. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5602. }
  5603. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5604. {
  5605. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5606. {
  5607. tempIndex = ((gun_index==2) ? 1: 0);
  5608. }
  5609. else
  5610. {
  5611. tempIndex = gun_index;
  5612. }
  5613. for (int index = 0; index < CCS_QUANTITY; index++)
  5614. {
  5615. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5616. {
  5617. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower;
  5618. }
  5619. }
  5620. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5621. }
  5622. else if(gunType[gun_index] == 'G')
  5623. {
  5624. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5625. {
  5626. tempIndex = ((gun_index==2) ? 1: 0);
  5627. }
  5628. else
  5629. {
  5630. tempIndex = gun_index;
  5631. }
  5632. for (int index = 0; index < GB_QUANTITY; index++)
  5633. {
  5634. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5635. {
  5636. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5637. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower;
  5638. }
  5639. }
  5640. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5641. }
  5642. else if(gunType[gun_index] == 'O')
  5643. {
  5644. tempIndex = gun_index;
  5645. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5646. {
  5647. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5648. {
  5649. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5650. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower;
  5651. }
  5652. }
  5653. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5654. }
  5655. else
  5656. {
  5657. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5658. {
  5659. tempIndex = 2;
  5660. }
  5661. else
  5662. {
  5663. tempIndex = gun_index;
  5664. }
  5665. for (int index = 0; index < AC_QUANTITY; index++)
  5666. {
  5667. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5668. {
  5669. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower;
  5670. }
  5671. }
  5672. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5673. }
  5674. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  5675. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  5676. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5677. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  5678. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  5679. //idx_sample=4;
  5680. //***********************************************(5)VOLTAGE L1******************************************************/
  5681. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5682. if(gunType[gun_index] == 'J')
  5683. {
  5684. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5685. {
  5686. tempIndex = ((gun_index==2) ? 1: 0);
  5687. }
  5688. else
  5689. {
  5690. tempIndex = gun_index;
  5691. }
  5692. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5693. {
  5694. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5695. {
  5696. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage;
  5697. }
  5698. }
  5699. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5700. }
  5701. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5702. {
  5703. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5704. {
  5705. tempIndex = ((gun_index==2) ? 1: 0);
  5706. }
  5707. else
  5708. {
  5709. tempIndex = gun_index;
  5710. }
  5711. for (int index = 0; index < CCS_QUANTITY; index++)
  5712. {
  5713. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5714. {
  5715. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage;
  5716. }
  5717. }
  5718. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5719. }
  5720. else if(gunType[gun_index] == 'G')
  5721. {
  5722. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5723. {
  5724. tempIndex = ((gun_index==2) ? 1: 0);
  5725. }
  5726. else
  5727. {
  5728. tempIndex = gun_index;
  5729. }
  5730. for (int index = 0; index < GB_QUANTITY; index++)
  5731. {
  5732. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5733. {
  5734. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage;
  5735. }
  5736. }
  5737. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5738. }
  5739. else if(gunType[gun_index] == 'O')
  5740. {
  5741. tempIndex = gun_index;
  5742. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5743. {
  5744. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5745. {
  5746. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage;
  5747. }
  5748. }
  5749. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5750. }
  5751. else
  5752. {
  5753. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5754. {
  5755. tempIndex = 2;
  5756. }
  5757. else
  5758. {
  5759. tempIndex = gun_index;
  5760. }
  5761. for (int index = 0; index < AC_QUANTITY; index++)
  5762. {
  5763. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5764. {
  5765. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage;
  5766. }
  5767. }
  5768. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5769. }
  5770. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  5771. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5772. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5773. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  5774. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  5775. //***********************************************(6)SOC******************************************************/
  5776. if((gunType[gun_index] == 'J')||(gunType[gun_index] == 'U')||(gunType[gun_index] == 'E')||(gunType[gun_index] == 'G'))
  5777. {
  5778. //idx_sample=5;
  5779. //sampledValue = NULL;
  5780. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5781. {
  5782. tempIndex = ((gun_index==2) ? 1: 0);
  5783. }
  5784. else
  5785. {
  5786. tempIndex = gun_index;
  5787. }
  5788. if(gunType[gun_index] == 'J')
  5789. {
  5790. //tempIndex = ((gun_index==2) ? 1: 0);
  5791. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5792. {
  5793. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5794. {
  5795. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  5796. }
  5797. }
  5798. }
  5799. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5800. {
  5801. //tempIndex = ((gun_index==2) ? 1: 0);
  5802. for (int index = 0; index < CCS_QUANTITY; index++)
  5803. {
  5804. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5805. {
  5806. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  5807. }
  5808. }
  5809. }
  5810. else if(gunType[gun_index] == 'G')
  5811. {
  5812. //tempIndex = ((gun_index==2) ? 1: 0);
  5813. for (int index = 0; index < GB_QUANTITY; index++)
  5814. {
  5815. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5816. {
  5817. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  5818. }
  5819. }
  5820. }
  5821. else if(gunType[gun_index] == 'O')
  5822. {
  5823. //tempIndex = ((gun_index==2) ? 1: 0);
  5824. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5825. {
  5826. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5827. {
  5828. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  5829. }
  5830. }
  5831. }
  5832. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  5833. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  5834. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5835. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  5836. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  5837. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  5838. }
  5839. //********************************(7)Current.Import L2************************************************/
  5840. // Only for AC 3 phase
  5841. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5842. {
  5843. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5844. {
  5845. tempIndex = 2;
  5846. }
  5847. else
  5848. {
  5849. tempIndex = gun_index;
  5850. }
  5851. for (int index = 0; index < AC_QUANTITY; index++)
  5852. {
  5853. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5854. {
  5855. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2;
  5856. }
  5857. }
  5858. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5859. }
  5860. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  5861. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5862. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5863. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  5864. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  5865. //********************************(8)Current.Import L3************************************************/
  5866. // Only for AC 3 phase
  5867. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5868. {
  5869. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5870. {
  5871. tempIndex = 2;
  5872. }
  5873. else
  5874. {
  5875. tempIndex = gun_index;
  5876. }
  5877. for (int index = 0; index < AC_QUANTITY; index++)
  5878. {
  5879. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5880. {
  5881. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3;
  5882. }
  5883. }
  5884. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5885. }
  5886. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  5887. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5888. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5889. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  5890. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  5891. //***********************************************(9)VOLTAGE L2******************************************************/
  5892. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5893. {
  5894. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5895. {
  5896. tempIndex = 2;
  5897. }
  5898. else
  5899. {
  5900. tempIndex = gun_index;
  5901. }
  5902. for (int index = 0; index < AC_QUANTITY; index++)
  5903. {
  5904. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5905. {
  5906. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2;
  5907. }
  5908. }
  5909. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5910. }
  5911. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  5912. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5913. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5914. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  5915. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  5916. //***********************************************(10)VOLTAGE L3******************************************************/
  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[9].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3;
  5932. }
  5933. }
  5934. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5935. }
  5936. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  5937. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5938. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5939. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  5940. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  5941. // Message create ====================================================================================================
  5942. random_uuid(guid);
  5943. uint8_t idxMeter = 0;
  5944. while(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp) > 0)
  5945. {
  5946. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  5947. {
  5948. if(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value > 0)
  5949. {
  5950. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  5951. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  5952. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  5953. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  5954. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  5955. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  5956. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  5957. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  5958. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  5959. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  5960. {
  5961. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  5962. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  5963. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  5964. }
  5965. json_object_array_add(sampledValues, sampledValue);
  5966. }
  5967. }
  5968. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  5969. json_object_object_add(meterValue, "sampledValue", sampledValues);
  5970. json_object_array_add(meterValues, meterValue);
  5971. idxMeter++;
  5972. }
  5973. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  5974. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  5975. sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",%s]"
  5976. ,gun_index + 1
  5977. ,MESSAGE_TYPE_CALL
  5978. ,guid
  5979. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  5980. json_object_put(MeterValueReq);
  5981. if((strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]) == 0) ||
  5982. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]) == 0) ||
  5983. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]) == 0))
  5984. {
  5985. // Transaction meter value send by TransactionEvent message
  5986. memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
  5987. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  5988. result = PASS;
  5989. }
  5990. else
  5991. {
  5992. // Put request guid to hash map
  5993. sprintf(tempdata, "MeterValues,%d", (gun_index));
  5994. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5995. {
  5996. result = PASS;
  5997. }
  5998. if((dataType != ReadingContextEnumType_Trigger) &&
  5999. (dataType != ReadingContextEnumType_Sample_Clock))
  6000. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  6001. else
  6002. {
  6003. if(FirstHeartBeat)
  6004. LWS_Send(queuedata +2);
  6005. }
  6006. }
  6007. return result;
  6008. }
  6009. int sendNotifyChargingLimitRequest(int gun_index)
  6010. {
  6011. mtrace();
  6012. int result = FAIL;
  6013. char message[4096]={0};
  6014. char guid[37]={0};
  6015. char tempdata[128]={0};
  6016. json_object *NotifyChargingLimit = json_object_new_object();
  6017. json_object *chargingLimit = json_object_new_object();
  6018. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  6019. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  6020. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  6021. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  6022. random_uuid(guid);
  6023. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  6024. json_object_put(NotifyChargingLimit);
  6025. LWS_Send(message);
  6026. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  6027. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6028. {
  6029. result = PASS;
  6030. }
  6031. return result;
  6032. }
  6033. int sendNotifyCustomerInformationRequest()
  6034. {
  6035. mtrace();
  6036. int result = FAIL;
  6037. char message[4096]={0};
  6038. char guid[37]={0};
  6039. char tempdata[128]={0};
  6040. json_object *NotifyCustomerInformation = json_object_new_object();
  6041. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  6042. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  6043. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  6044. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  6045. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  6046. random_uuid(guid);
  6047. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  6048. json_object_put(NotifyCustomerInformation);
  6049. LWS_Send(message);
  6050. sprintf(tempdata, "NotifyCustomerInformation,0");
  6051. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6052. {
  6053. result = PASS;
  6054. }
  6055. return result;
  6056. }
  6057. int sendNotifyDisplayMessagesRequest()
  6058. {
  6059. mtrace();
  6060. int result = FAIL;
  6061. char message[4096]={0};
  6062. char guid[37]={0};
  6063. char tempdata[128]={0};
  6064. json_object *NotifyDisplayMessages = json_object_new_object();
  6065. json_object *messageInfos = json_object_new_array();
  6066. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  6067. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  6068. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  6069. {
  6070. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  6071. {
  6072. json_object *messageInfo = json_object_new_object();
  6073. json_object *message = json_object_new_object();
  6074. json_object *display = json_object_new_object();
  6075. json_object *evse = json_object_new_object();
  6076. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  6077. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  6078. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  6079. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  6080. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  6081. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  6082. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  6083. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  6084. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  6085. json_object_object_add(messageInfo, "message", message);
  6086. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  6087. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  6088. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  6089. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  6090. json_object_object_add(display, "evse",evse);
  6091. json_object_object_add(messageInfo, "evse", display);
  6092. json_object_array_add(messageInfos, messageInfo);
  6093. }
  6094. }
  6095. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  6096. random_uuid(guid);
  6097. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  6098. json_object_put(NotifyDisplayMessages);
  6099. LWS_Send(message);
  6100. sprintf(tempdata, "NotifyDisplayMessages,0");
  6101. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6102. {
  6103. result = PASS;
  6104. }
  6105. return result;
  6106. }
  6107. int sendNotifyEVChargingNeedsRequest(int gun_index)
  6108. {
  6109. mtrace();
  6110. int result = FAIL;
  6111. char message[4096]={0};
  6112. char guid[37]={0};
  6113. char tempdata[128]={0};
  6114. json_object *NotifyEVChargingNeeds = json_object_new_object();
  6115. json_object *chargingNeeds = json_object_new_object();
  6116. json_object *acChargingParameters = json_object_new_object();
  6117. json_object *dcChargingParameters = json_object_new_object();
  6118. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  6119. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  6120. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  6121. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  6122. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  6123. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  6124. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  6125. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  6126. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  6127. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  6128. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  6129. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  6130. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  6131. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  6132. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  6133. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  6134. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  6135. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  6136. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  6137. random_uuid(guid);
  6138. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  6139. json_object_put(NotifyEVChargingNeeds);
  6140. LWS_Send(message);
  6141. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  6142. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6143. {
  6144. result = PASS;
  6145. }
  6146. return result;
  6147. }
  6148. int sendNotifyEVChargingScheduleRequest(int gun_index)
  6149. {
  6150. mtrace();
  6151. int result = FAIL;
  6152. char message[4096]={0};
  6153. char guid[37]={0};
  6154. char tempdata[128]={0};
  6155. json_object *NotifyEVChargingSchedule = json_object_new_object();
  6156. json_object *chargingSchedule = json_object_new_object();
  6157. json_object *periods = json_object_new_array();
  6158. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  6159. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  6160. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  6161. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  6162. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  6163. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  6164. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  6165. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  6166. {
  6167. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  6168. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  6169. {
  6170. json_object *Period = json_object_new_object();
  6171. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  6172. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  6173. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  6174. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  6175. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  6176. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  6177. json_object_array_add(periods, Period);
  6178. }
  6179. }
  6180. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  6181. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  6182. random_uuid(guid);
  6183. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  6184. json_object_put(NotifyEVChargingSchedule);
  6185. LWS_Send(message);
  6186. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  6187. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6188. {
  6189. result = PASS;
  6190. }
  6191. return result;
  6192. }
  6193. int sendNotifyEventRequest()
  6194. {
  6195. mtrace();
  6196. int result = FAIL;
  6197. char message[4096]={0};
  6198. char guid[37]={0};
  6199. char tempdata[128]={0};
  6200. json_object *NotifyEvent = json_object_new_object();
  6201. json_object *eventDatas = json_object_new_array();
  6202. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  6203. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  6204. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  6205. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  6206. {
  6207. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  6208. {
  6209. json_object *eventData = json_object_new_object();
  6210. json_object *component = json_object_new_object();
  6211. json_object *evse = json_object_new_object();
  6212. json_object *variable = json_object_new_object();
  6213. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  6214. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  6215. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  6216. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  6217. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  6218. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  6219. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  6220. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  6221. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  6222. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  6223. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  6224. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  6225. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  6226. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  6227. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  6228. json_object_object_add(component, "evse",evse);
  6229. json_object_object_add(eventData, "component", component);
  6230. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  6231. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  6232. json_object_object_add(eventData, "variable", variable);
  6233. json_object_array_add(eventDatas, eventData);
  6234. }
  6235. }
  6236. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  6237. random_uuid(guid);
  6238. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  6239. json_object_put(NotifyEvent);
  6240. LWS_Send(message);
  6241. sprintf(tempdata, "NotifyEvent,0");
  6242. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6243. {
  6244. result = PASS;
  6245. }
  6246. return result;
  6247. }
  6248. int sendNotifyMonitoringReportRequest()
  6249. {
  6250. mtrace();
  6251. int result = FAIL;
  6252. char message[4096]={0};
  6253. char guid[37]={0};
  6254. char tempdata[128]={0};
  6255. json_object *NotifyMonitoringReport = json_object_new_object();
  6256. json_object *monitors = json_object_new_array();
  6257. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  6258. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  6259. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  6260. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  6261. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  6262. {
  6263. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  6264. {
  6265. json_object *monitor = json_object_new_object();
  6266. json_object *component = json_object_new_object();
  6267. json_object *evse = json_object_new_object();
  6268. json_object *variable = json_object_new_object();
  6269. json_object *variableMonitorings = json_object_new_array();
  6270. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  6271. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  6272. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  6273. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  6274. json_object_object_add(component, "evse",evse);
  6275. json_object_object_add(monitor, "component", component);
  6276. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  6277. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  6278. json_object_object_add(monitor, "variable", variable);
  6279. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  6280. {
  6281. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  6282. {
  6283. json_object *variableMonitoring = json_object_new_object();
  6284. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  6285. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  6286. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  6287. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  6288. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  6289. json_object_array_add(variableMonitorings, variableMonitoring);
  6290. }
  6291. }
  6292. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  6293. json_object_array_add(monitors, monitor);
  6294. }
  6295. }
  6296. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  6297. random_uuid(guid);
  6298. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  6299. json_object_put(NotifyMonitoringReport);
  6300. LWS_Send(message);
  6301. sprintf(tempdata, "NotifyMonitoringReport,0");
  6302. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6303. {
  6304. result = PASS;
  6305. }
  6306. return result;
  6307. }
  6308. int sendNotifyReportRequest()
  6309. {
  6310. mtrace();
  6311. int result = FAIL;
  6312. char message[4096]={0};
  6313. char guid[37]={0};
  6314. char tempdata[128]={0};
  6315. json_object *NotifyReport = json_object_new_object();
  6316. json_object *reportDatas = json_object_new_array();
  6317. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  6318. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  6319. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  6320. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  6321. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  6322. {
  6323. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  6324. {
  6325. json_object *reportData = json_object_new_object();
  6326. json_object *component = json_object_new_object();
  6327. json_object *evse = json_object_new_object();
  6328. json_object *variable = json_object_new_object();
  6329. json_object *variableAttributes = json_object_new_array();
  6330. json_object *variableCharacteristics = json_object_new_object();
  6331. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  6332. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  6333. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  6334. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  6335. json_object_object_add(component, "evse",evse);
  6336. json_object_object_add(reportData, "component", component);
  6337. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  6338. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  6339. json_object_object_add(reportData, "variable",variable);
  6340. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  6341. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  6342. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  6343. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  6344. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  6345. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  6346. {
  6347. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  6348. {
  6349. json_object *variableAttribute = json_object_new_object();
  6350. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  6351. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  6352. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  6353. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  6354. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  6355. json_object_array_add(variableAttributes, variableAttribute);
  6356. }
  6357. }
  6358. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  6359. json_object_array_add(reportDatas, reportData);
  6360. }
  6361. }
  6362. json_object_object_add(NotifyReport, "reportData", reportDatas);
  6363. random_uuid(guid);
  6364. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  6365. json_object_put(NotifyReport);
  6366. LWS_Send(message);
  6367. sprintf(tempdata, "NotifyReport,0");
  6368. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6369. {
  6370. result = PASS;
  6371. }
  6372. return result;
  6373. }
  6374. int sendPublishFirmwareStatusNotificationRequest()
  6375. {
  6376. mtrace();
  6377. int result = FAIL;
  6378. char message[4096]={0};
  6379. char guid[37]={0};
  6380. char tempdata[128]={0};
  6381. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  6382. json_object *locations = json_object_new_array();
  6383. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  6384. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  6385. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  6386. {
  6387. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  6388. }
  6389. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  6390. random_uuid(guid);
  6391. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  6392. json_object_put(PublishFirmwareStatusNotification);
  6393. LWS_Send(message);
  6394. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  6395. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6396. {
  6397. result = PASS;
  6398. }
  6399. return result;
  6400. }
  6401. int sendReportChargingProfilesRequest(int gun_index)
  6402. {
  6403. mtrace();
  6404. int result = FAIL;
  6405. char message[4096]={0};
  6406. char guid[37]={0};
  6407. char tempdata[128]={0};
  6408. json_object *ReportChargingProfiles = json_object_new_object();
  6409. json_object *chargingProfiles = json_object_new_array();
  6410. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  6411. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  6412. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  6413. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  6414. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  6415. {
  6416. json_object *chargingProfile = json_object_new_object();
  6417. json_object *chargingSchedules = json_object_new_array();
  6418. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  6419. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  6420. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  6421. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  6422. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  6423. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  6424. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  6425. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  6426. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  6427. {
  6428. json_object *chargingSchedule = json_object_new_object();
  6429. json_object *chargingSchedulePeriods = json_object_new_array();
  6430. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  6431. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  6432. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  6433. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  6434. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  6435. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  6436. {
  6437. json_object *chargingSchedulePeriod = json_object_new_object();
  6438. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  6439. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  6440. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  6441. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  6442. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  6443. }
  6444. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  6445. json_object_array_add(chargingSchedules, chargingSchedule);
  6446. }
  6447. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  6448. json_object_array_add(chargingProfiles, chargingProfile);
  6449. }
  6450. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  6451. random_uuid(guid);
  6452. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  6453. json_object_put(ReportChargingProfiles);
  6454. LWS_Send(message);
  6455. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  6456. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6457. {
  6458. result = PASS;
  6459. }
  6460. return result;
  6461. }
  6462. int sendReservationStatusUpdateRequest(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 *ReservationStatusUpdate = json_object_new_object();
  6470. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  6471. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  6472. random_uuid(guid);
  6473. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  6474. json_object_put(ReservationStatusUpdate);
  6475. LWS_Send(message);
  6476. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  6477. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6478. {
  6479. result = PASS;
  6480. }
  6481. return result;
  6482. }
  6483. int sendSecurityEventNotificationRequest()
  6484. {
  6485. mtrace();
  6486. int result = FAIL;
  6487. char message[4096]={0};
  6488. char guid[37]={0};
  6489. char tempdata[128]={0};
  6490. json_object *SecurityEventNotification = json_object_new_object();
  6491. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  6492. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  6493. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techinfo));
  6494. random_uuid(guid);
  6495. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  6496. json_object_put(SecurityEventNotification);
  6497. LWS_Send(message);
  6498. sprintf(tempdata, "SecurityEventNotification,0");
  6499. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6500. {
  6501. result = PASS;
  6502. }
  6503. return result;
  6504. }
  6505. int sendSignCertificateRequest()
  6506. {
  6507. mtrace();
  6508. int result = FAIL;
  6509. char message[4096]={0};
  6510. char guid[37]={0};
  6511. char tempdata[128]={0};
  6512. json_object *SignCertificate = json_object_new_object();
  6513. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  6514. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  6515. random_uuid(guid);
  6516. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  6517. json_object_put(SignCertificate);
  6518. LWS_Send(message);
  6519. sprintf(tempdata, "SignCertificate,0");
  6520. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6521. {
  6522. result = PASS;
  6523. }
  6524. return result;
  6525. }
  6526. int sendStatusNotificationRequest(int gun_index)
  6527. {
  6528. mtrace();
  6529. int result = FAIL;
  6530. char message[600]={0};
  6531. char guid[37];
  6532. int currentStatus = 0;
  6533. struct timeval tmnow;
  6534. struct tm *tm;
  6535. char buf[28];//, usec_buf[6];
  6536. char tempdata[65]={0};
  6537. int tempIndex = 0;
  6538. gettimeofday(&tmnow, NULL);
  6539. time_t t;
  6540. t = time(NULL);
  6541. /*UTC time and date*/
  6542. tm = gmtime(&t);
  6543. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  6544. #if 0 // remove temporally
  6545. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  6546. strcat(buf,".");
  6547. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  6548. strcat(buf,usec_buf);
  6549. #endif
  6550. printf("%s",buf);
  6551. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  6552. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  6553. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  6554. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  6555. /*
  6556. enum _SYSTEM_STATUS
  6557. {
  6558. S_BOOTING = 0,
  6559. S_IDLE, = 1
  6560. S_AUTHORIZING, =2
  6561. S_REASSIGN_CHECK, =3
  6562. S_REASSIGN, =4
  6563. S_PRECHARGE, =5
  6564. S_PREPARING_FOR_EV, =6
  6565. S_PREPARING_FOR_EVSE, =7
  6566. S_CHARGING, =8
  6567. S_TERMINATING, =9
  6568. S_COMPLETE, =10
  6569. S_ALARM, =11
  6570. S_FAULT =12
  6571. }
  6572. */
  6573. //check Transaction active
  6574. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  6575. if(gunType[gun_index] == 'J')
  6576. {
  6577. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6578. {
  6579. tempIndex = ((gun_index==2) ? 1: 0);
  6580. }
  6581. else
  6582. {
  6583. tempIndex = gun_index;
  6584. }
  6585. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6586. {
  6587. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6588. {
  6589. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6590. {
  6591. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6592. {
  6593. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6594. }
  6595. else
  6596. {
  6597. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6598. }
  6599. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6600. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6601. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6602. }
  6603. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6604. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6605. ) //S_PRECHARGE
  6606. {
  6607. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6608. }
  6609. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6610. {
  6611. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6612. }
  6613. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6614. {
  6615. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6616. }
  6617. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6618. {
  6619. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6620. }
  6621. 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
  6622. {
  6623. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6624. }
  6625. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6626. {
  6627. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6628. }
  6629. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6630. {
  6631. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6632. }
  6633. } //end of the same index
  6634. }//end of for CHAdeMO_QUANTITY
  6635. }
  6636. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  6637. {
  6638. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6639. {
  6640. tempIndex = ((gun_index==2) ? 1: 0);
  6641. }
  6642. else
  6643. {
  6644. tempIndex = gun_index;
  6645. }
  6646. for (int index = 0; index < CCS_QUANTITY; index++)
  6647. {
  6648. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6649. {
  6650. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6651. {
  6652. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  6653. {
  6654. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6655. }
  6656. else
  6657. {
  6658. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6659. }
  6660. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6661. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6662. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6663. }
  6664. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6665. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6666. ) //S_PRECHARGE
  6667. {
  6668. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6669. }
  6670. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6671. {
  6672. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6673. }
  6674. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6675. {
  6676. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6677. }
  6678. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  6679. {
  6680. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6681. }
  6682. 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
  6683. {
  6684. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  6685. }
  6686. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6687. {
  6688. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6689. }
  6690. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6691. {
  6692. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6693. }
  6694. } //end of the same index
  6695. } // end of for CCS_QUANTITY
  6696. }
  6697. else if(gunType[gun_index] == 'G')
  6698. {
  6699. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6700. {
  6701. tempIndex = ((gun_index==2) ? 1: 0);
  6702. }
  6703. else
  6704. {
  6705. tempIndex = gun_index;
  6706. }
  6707. for (int index = 0; index < GB_QUANTITY; index++)
  6708. {
  6709. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6710. {
  6711. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6712. {
  6713. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6714. {
  6715. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6716. }
  6717. else
  6718. {
  6719. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6720. }
  6721. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6722. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6723. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6724. }
  6725. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6726. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6727. ) //S_PRECHARGE
  6728. {
  6729. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6730. }
  6731. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6732. {
  6733. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6734. }
  6735. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6736. {
  6737. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6738. }
  6739. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6740. {
  6741. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6742. }
  6743. 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
  6744. {
  6745. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6746. }
  6747. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6748. {
  6749. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6750. }
  6751. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6752. {
  6753. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6754. }
  6755. } //end of the same index
  6756. } // end of for GB_QUANTITY
  6757. }
  6758. else if(gunType[gun_index] == 'O')
  6759. {
  6760. tempIndex = gun_index;
  6761. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6762. {
  6763. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6764. {
  6765. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6766. {
  6767. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6768. {
  6769. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6770. }
  6771. else
  6772. {
  6773. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6774. }
  6775. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6776. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6777. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6778. }
  6779. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6780. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6781. ) //S_PRECHARGE
  6782. {
  6783. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6784. }
  6785. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6786. {
  6787. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6788. }
  6789. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6790. {
  6791. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6792. }
  6793. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6794. {
  6795. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6796. }
  6797. 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
  6798. {
  6799. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6800. }
  6801. 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
  6802. {
  6803. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6804. }
  6805. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6806. {
  6807. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6808. }
  6809. } //end of the same index
  6810. }
  6811. }
  6812. else
  6813. {
  6814. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6815. {
  6816. tempIndex = 2;
  6817. }
  6818. else
  6819. {
  6820. tempIndex = gun_index;
  6821. }
  6822. for (int index = 0; index < AC_QUANTITY; index++)
  6823. {
  6824. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6825. {
  6826. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  6827. {
  6828. 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))
  6829. {
  6830. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6831. }
  6832. else
  6833. {
  6834. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6835. }
  6836. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6837. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6838. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6839. }
  6840. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  6841. {
  6842. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6843. }
  6844. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  6845. {
  6846. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6847. }
  6848. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  6849. {
  6850. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6851. }
  6852. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6853. {
  6854. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6855. }
  6856. 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
  6857. {
  6858. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6859. }
  6860. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6861. {
  6862. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6863. }
  6864. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6865. {
  6866. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6867. }
  6868. }//end of the same index
  6869. }//end of for AC_QUANTITY
  6870. }
  6871. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  6872. random_uuid(guid);
  6873. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  6874. , MESSAGE_TYPE_CALL
  6875. , guid
  6876. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  6877. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  6878. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  6879. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  6880. if((server_sign == TRUE))
  6881. {
  6882. LWS_Send(message);
  6883. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  6884. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6885. {
  6886. result = PASS;
  6887. }
  6888. }
  6889. else
  6890. {
  6891. result = PASS;
  6892. }
  6893. return result;
  6894. }
  6895. int sendTransactionEventRequest(int gun_index)
  6896. {
  6897. mtrace();
  6898. int result = FAIL;
  6899. char message[1024*20]={0};
  6900. char guid[37]={0};
  6901. char tempdata[128]={0};
  6902. uint8_t tempIndex;
  6903. json_object *TransactionEvent = json_object_new_object();
  6904. json_object *transactionInfo = json_object_new_object();
  6905. json_object *idToken = json_object_new_object();
  6906. json_object *evse = json_object_new_object();
  6907. json_object *meterValues = json_object_new_array();
  6908. if(gunType[gun_index] == 'J')
  6909. {
  6910. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6911. {
  6912. tempIndex = ((gun_index==2) ? 1: 0);
  6913. }
  6914. else
  6915. {
  6916. tempIndex = gun_index;
  6917. }
  6918. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6919. {
  6920. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6921. {
  6922. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  6923. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  6924. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  6925. else
  6926. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  6927. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  6928. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  6929. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  6930. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6931. {
  6932. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6933. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6934. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6935. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6936. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6937. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6938. {
  6939. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  6940. }
  6941. else
  6942. {
  6943. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  6944. }
  6945. }
  6946. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  6947. {
  6948. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6949. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6950. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  6951. }
  6952. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6953. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6954. ) //S_PRECHARGE
  6955. {
  6956. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  6957. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  6958. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6959. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  6960. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6961. }
  6962. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6963. {
  6964. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  6965. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6966. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6967. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6968. }
  6969. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6970. {
  6971. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  6972. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6973. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6974. }
  6975. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6976. {
  6977. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6978. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  6979. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6980. }
  6981. 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
  6982. {
  6983. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6984. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6985. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6986. }
  6987. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6988. {
  6989. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6990. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6991. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6992. }
  6993. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6994. {
  6995. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6996. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6997. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6998. }
  6999. } //end of the same index
  7000. }//end of for CHAdeMO_QUANTITY
  7001. }
  7002. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  7003. {
  7004. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7005. {
  7006. tempIndex = ((gun_index==2) ? 1: 0);
  7007. }
  7008. else
  7009. {
  7010. tempIndex = gun_index;
  7011. }
  7012. for (int index = 0; index < CCS_QUANTITY; index++)
  7013. {
  7014. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7015. {
  7016. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7017. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7018. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7019. else
  7020. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7021. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7022. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  7023. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7024. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7025. {
  7026. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7027. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7028. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7029. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7030. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7031. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7032. {
  7033. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7034. }
  7035. else
  7036. {
  7037. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7038. }
  7039. }
  7040. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7041. {
  7042. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7043. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7044. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7045. }
  7046. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7047. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7048. ) //S_PRECHARGE
  7049. {
  7050. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7051. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7052. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7053. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7054. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7055. }
  7056. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7057. {
  7058. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  7059. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7060. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7061. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7062. }
  7063. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7064. {
  7065. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7066. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7067. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7068. }
  7069. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7070. {
  7071. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7072. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7073. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7074. }
  7075. 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
  7076. {
  7077. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7078. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7079. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7080. }
  7081. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7082. {
  7083. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7084. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7085. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7086. }
  7087. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7088. {
  7089. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7090. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7091. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7092. }
  7093. } //end of the same index
  7094. } // end of for CCS_QUANTITY
  7095. }
  7096. else if(gunType[gun_index] == 'G')
  7097. {
  7098. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7099. {
  7100. tempIndex = ((gun_index==2) ? 1: 0);
  7101. }
  7102. else
  7103. {
  7104. tempIndex = gun_index;
  7105. }
  7106. for (int index = 0; index < GB_QUANTITY; index++)
  7107. {
  7108. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7109. {
  7110. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7111. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7112. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7113. else
  7114. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7115. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7116. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  7117. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7118. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7119. {
  7120. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7121. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7122. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7123. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7124. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7125. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7126. {
  7127. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7128. }
  7129. else
  7130. {
  7131. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7132. }
  7133. }
  7134. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7135. {
  7136. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7137. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7138. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7139. }
  7140. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7141. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7142. ) //S_PRECHARGE
  7143. {
  7144. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7145. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7146. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7147. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7148. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7149. }
  7150. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7151. {
  7152. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  7153. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7154. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7155. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7156. }
  7157. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7158. {
  7159. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7160. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7161. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7162. }
  7163. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7164. {
  7165. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7166. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7167. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7168. }
  7169. 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
  7170. {
  7171. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7172. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7173. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7174. }
  7175. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7176. {
  7177. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7178. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7179. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7180. }
  7181. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7182. {
  7183. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7184. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7185. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7186. }
  7187. } //end of the same index
  7188. } // end of for GB_QUANTITY
  7189. }
  7190. else if(gunType[gun_index] == 'O')
  7191. {
  7192. tempIndex = gun_index;
  7193. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7194. {
  7195. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7196. {
  7197. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7198. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7199. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7200. else
  7201. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7202. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7203. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  7204. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7205. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7206. {
  7207. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7208. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7209. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7210. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7211. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7212. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7213. {
  7214. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7215. }
  7216. else
  7217. {
  7218. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7219. }
  7220. }
  7221. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7222. {
  7223. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7224. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7225. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7226. }
  7227. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7228. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7229. ) //S_PRECHARGE
  7230. {
  7231. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7232. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7233. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7234. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7235. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7236. }
  7237. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7238. {
  7239. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  7240. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7241. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7242. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7243. }
  7244. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7245. {
  7246. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7247. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7248. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7249. }
  7250. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7251. {
  7252. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7253. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7254. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7255. }
  7256. 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
  7257. {
  7258. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7259. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7260. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7261. }
  7262. 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
  7263. {
  7264. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7265. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7266. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7267. }
  7268. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7269. {
  7270. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7271. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7272. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7273. }
  7274. } //end of the same index
  7275. }
  7276. }
  7277. else
  7278. {
  7279. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7280. {
  7281. tempIndex = 2;
  7282. }
  7283. else
  7284. {
  7285. tempIndex = gun_index;
  7286. }
  7287. for (int index = 0; index < AC_QUANTITY; index++)
  7288. {
  7289. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7290. {
  7291. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7292. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7293. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7294. else
  7295. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7296. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7297. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  7298. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7299. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  7300. {
  7301. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7302. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7303. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7304. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7305. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7306. 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))
  7307. {
  7308. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7309. }
  7310. else
  7311. {
  7312. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7313. }
  7314. }
  7315. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7316. {
  7317. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7318. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7319. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7320. }
  7321. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7322. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7323. ) //S_PRECHARGE
  7324. {
  7325. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7326. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7327. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7328. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7329. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7330. }
  7331. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7332. {
  7333. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  7334. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7335. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7336. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7337. }
  7338. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7339. {
  7340. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7341. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7342. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7343. }
  7344. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7345. {
  7346. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7347. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7348. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7349. }
  7350. 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
  7351. {
  7352. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7353. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7354. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7355. }
  7356. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7357. {
  7358. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7359. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7360. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7361. }
  7362. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7363. {
  7364. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7365. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7366. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7367. }
  7368. }//end of the same index
  7369. }//end of for AC_QUANTITY
  7370. }
  7371. // Message
  7372. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7373. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  7374. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  7375. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  7376. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  7377. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  7378. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  7379. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  7380. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  7381. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  7382. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  7383. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  7384. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  7385. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  7386. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  7387. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  7388. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  7389. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  7390. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  7391. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  7392. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  7393. {
  7394. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  7395. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  7396. json_object_object_add(TransactionEvent, "idToken", idToken);
  7397. }
  7398. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  7399. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  7400. json_object_object_add(TransactionEvent, "evse", evse);
  7401. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  7402. {
  7403. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  7404. {
  7405. json_object *meterValue = json_object_new_object();
  7406. json_object *sampledValues = json_object_new_array();
  7407. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  7408. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  7409. {
  7410. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7411. {
  7412. json_object *sampledValue = json_object_new_object();
  7413. json_object *unitOfMeasure = json_object_new_object();
  7414. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  7415. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  7416. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  7417. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  7418. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  7419. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  7420. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  7421. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  7422. json_object_array_add(sampledValues, sampledValue);
  7423. }
  7424. }
  7425. json_object_object_add(meterValue, "sampledValue", sampledValues);
  7426. json_object_array_add(meterValues, meterValue);
  7427. }
  7428. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  7429. }
  7430. random_uuid(guid);
  7431. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  7432. json_object_put(TransactionEvent);
  7433. LWS_Send(message);
  7434. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  7435. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7436. {
  7437. result = PASS;
  7438. }
  7439. return result;
  7440. }
  7441. //==========================================
  7442. // send confirm routine
  7443. //==========================================
  7444. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  7445. {
  7446. mtrace();
  7447. int result = FAIL;
  7448. char message[4096]={0};
  7449. json_object *CancelReservation = json_object_new_object();
  7450. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  7451. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  7452. sprintf(message,"[%d,\"%s\",%s]"
  7453. ,MESSAGE_TYPE_CALLRESULT
  7454. ,uuid
  7455. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  7456. json_object_put(CancelReservation);
  7457. ShmOCPP20Data->CsMsg.bits[0].CancelReservationConf = OFF;
  7458. LWS_Send(message);
  7459. result = TRUE;
  7460. return result;
  7461. }
  7462. int sendCertificateSignedConfirmation(char *uuid)
  7463. {
  7464. mtrace();
  7465. int result = FAIL;
  7466. char message[4096]={0};
  7467. json_object *CertificateSigned = json_object_new_object();
  7468. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  7469. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  7470. sprintf(message,"[%d,\"%s\",%s]"
  7471. ,MESSAGE_TYPE_CALLRESULT
  7472. ,uuid
  7473. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  7474. json_object_put(CertificateSigned);
  7475. LWS_Send(message);
  7476. result = TRUE;
  7477. return result;
  7478. }
  7479. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  7480. {
  7481. mtrace();
  7482. int result = FAIL;
  7483. char message[4096]={0};
  7484. json_object *ChangeAvailability = json_object_new_object();
  7485. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  7486. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  7487. sprintf(message,"[%d,\"%s\",%s]"
  7488. ,MESSAGE_TYPE_CALLRESULT
  7489. ,uuid
  7490. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  7491. json_object_put(ChangeAvailability);
  7492. LWS_Send(message);
  7493. result = TRUE;
  7494. return result;
  7495. }
  7496. int sendClearCacheConfirmation(char *uuid)
  7497. {
  7498. mtrace();
  7499. int result = FAIL;
  7500. char message[4096]={0};
  7501. json_object *ClearCache = json_object_new_object();
  7502. DEBUG_INFO("sendClearCacheConfirmation...\n");
  7503. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  7504. sprintf(message,"[%d,\"%s\",%s]"
  7505. ,MESSAGE_TYPE_CALLRESULT
  7506. ,uuid
  7507. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  7508. json_object_put(ClearCache);
  7509. LWS_Send(message);
  7510. result = TRUE;
  7511. return result;
  7512. }
  7513. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  7514. {
  7515. mtrace();
  7516. int result = FAIL;
  7517. char message[500]={0};
  7518. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  7519. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  7520. LWS_Send(message);
  7521. return result;
  7522. }
  7523. int sendClearDisplayMessageConfirmation(char *uuid)
  7524. {
  7525. mtrace();
  7526. int result = FAIL;
  7527. char message[4096]={0};
  7528. json_object *ClearDisplayMessage = json_object_new_object();
  7529. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  7530. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  7531. sprintf(message,"[%d,\"%s\",%s]"
  7532. ,MESSAGE_TYPE_CALLRESULT
  7533. ,uuid
  7534. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  7535. json_object_put(ClearDisplayMessage);
  7536. LWS_Send(message);
  7537. result = TRUE;
  7538. return result;
  7539. }
  7540. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  7541. {
  7542. mtrace();
  7543. int result = FAIL;
  7544. char message[4096]={0};
  7545. json_object *ClearVariableMonitoring = json_object_new_object();
  7546. json_object *clearMonitoringResults = json_object_new_array();
  7547. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  7548. for(int idx=0;idx<variableQuantity;idx++)
  7549. {
  7550. json_object *clearMonitoringResult = json_object_new_object();
  7551. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  7552. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  7553. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  7554. }
  7555. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  7556. sprintf(message,"[%d,\"%s\",%s]"
  7557. ,MESSAGE_TYPE_CALLRESULT
  7558. ,uuid
  7559. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  7560. json_object_put(ClearVariableMonitoring);
  7561. LWS_Send(message);
  7562. result = TRUE;
  7563. return result;
  7564. }
  7565. int sendCostUpdatedConfirmation(char *uuid)
  7566. {
  7567. mtrace();
  7568. int result = FAIL;
  7569. char message[4096]={0};
  7570. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  7571. sprintf(message,"[%d,\"%s\",{}]"
  7572. ,MESSAGE_TYPE_CALLRESULT
  7573. ,uuid);
  7574. LWS_Send(message);
  7575. result = TRUE;
  7576. return result;
  7577. }
  7578. int sendCustomerInformationConfirmation(char *uuid)
  7579. {
  7580. mtrace();
  7581. int result = FAIL;
  7582. char message[4096]={0};
  7583. json_object *CustomerInformation = json_object_new_object();
  7584. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  7585. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  7586. sprintf(message,"[%d,\"%s\",%s]"
  7587. ,MESSAGE_TYPE_CALLRESULT
  7588. ,uuid
  7589. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  7590. json_object_put(CustomerInformation);
  7591. LWS_Send(message);
  7592. result = TRUE;
  7593. return result;
  7594. }
  7595. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  7596. {
  7597. mtrace();
  7598. int result = FAIL;
  7599. char message[4096]={0};
  7600. json_object *DataTransfer = json_object_new_object();
  7601. DEBUG_INFO("sendDataTransferConfirmation...\n");
  7602. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  7603. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  7604. sprintf(message,"[%d,\"%s\",%s]"
  7605. ,MESSAGE_TYPE_CALLRESULT
  7606. ,uuid
  7607. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  7608. json_object_put(DataTransfer);
  7609. LWS_Send(message);
  7610. result = TRUE;
  7611. return result;
  7612. }
  7613. int sendDeleteCertificateConfirmation(char *uuid)
  7614. {
  7615. mtrace();
  7616. int result = FAIL;
  7617. char message[4096]={0};
  7618. json_object *DeleteCertificate = json_object_new_object();
  7619. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  7620. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  7621. sprintf(message,"[%d,\"%s\",%s]"
  7622. ,MESSAGE_TYPE_CALLRESULT
  7623. ,uuid
  7624. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  7625. json_object_put(DeleteCertificate);
  7626. LWS_Send(message);
  7627. result = TRUE;
  7628. return result;
  7629. }
  7630. int sendGetBaseReportConfirmation(char *uuid)
  7631. {
  7632. mtrace();
  7633. int result = FAIL;
  7634. char message[4096]={0};
  7635. json_object *GetBaseReport = json_object_new_object();
  7636. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  7637. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  7638. sprintf(message,"[%d,\"%s\",%s]"
  7639. ,MESSAGE_TYPE_CALLRESULT
  7640. ,uuid
  7641. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  7642. json_object_put(GetBaseReport);
  7643. LWS_Send(message);
  7644. result = TRUE;
  7645. return result;
  7646. }
  7647. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  7648. {
  7649. mtrace();
  7650. int result = FAIL;
  7651. char message[4096]={0};
  7652. json_object *GetChargingProfiles = json_object_new_object();
  7653. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  7654. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  7655. sprintf(message,"[%d,\"%s\",%s]"
  7656. ,MESSAGE_TYPE_CALLRESULT
  7657. ,uuid
  7658. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  7659. json_object_put(GetChargingProfiles);
  7660. LWS_Send(message);
  7661. result = TRUE;
  7662. return result;
  7663. }
  7664. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  7665. {
  7666. mtrace();
  7667. int result = FAIL;
  7668. char message[4096]={0};
  7669. int CompositeScheduleIndex = 0;
  7670. json_object *GetCompositeSchedule = json_object_new_object();
  7671. json_object *schedule = json_object_new_object();
  7672. json_object *chargingSchedule = json_object_new_object();
  7673. json_object *chargingSchedulePeriod = json_object_new_array();
  7674. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  7675. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  7676. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  7677. if(nPeriod == 0)
  7678. {
  7679. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  7680. {
  7681. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7682. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7683. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7684. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7685. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7686. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7687. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7688. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7689. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7690. {
  7691. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7692. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7693. {
  7694. json_object *Period = json_object_new_object();
  7695. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7696. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7697. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7698. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7699. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7700. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7701. json_object_array_add(chargingSchedulePeriod, Period);
  7702. }
  7703. }
  7704. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7705. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7706. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7707. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7708. }
  7709. }
  7710. else
  7711. {
  7712. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7713. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7714. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7715. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7716. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7717. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7718. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7719. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7720. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7721. {
  7722. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7723. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7724. {
  7725. json_object *Period = json_object_new_object();
  7726. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7727. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7728. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7729. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7730. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7731. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7732. json_object_array_add(chargingSchedulePeriod, Period);
  7733. }
  7734. }
  7735. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7736. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7737. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7738. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7739. }
  7740. sprintf(message,"[%d,\"%s\",%s]"
  7741. ,MESSAGE_TYPE_CALLRESULT
  7742. ,uuid
  7743. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  7744. json_object_put(GetCompositeSchedule);
  7745. LWS_Send(message);
  7746. result = TRUE;
  7747. return result;
  7748. }
  7749. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  7750. {
  7751. mtrace();
  7752. int result = FAIL;
  7753. char message[4096]={0};
  7754. json_object *GetGetDisplayMessages = json_object_new_object();
  7755. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  7756. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  7757. sprintf(message,"[%d,\"%s\",%s]"
  7758. ,MESSAGE_TYPE_CALLRESULT
  7759. ,uuid
  7760. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  7761. json_object_put(GetGetDisplayMessages);
  7762. LWS_Send(message);
  7763. result = TRUE;
  7764. return result;
  7765. }
  7766. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  7767. {
  7768. mtrace();
  7769. int result = FAIL;
  7770. char message[4096]={0};
  7771. json_object *GetInstalledCertificateIds = json_object_new_object();
  7772. json_object *certificateHashDataChains = json_object_new_array();
  7773. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  7774. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  7775. for(int idx=0;idx<certQuantity;idx++)
  7776. {
  7777. json_object *cert = json_object_new_object();
  7778. json_object *certificateHashData = json_object_new_object();
  7779. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  7780. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  7781. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  7782. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  7783. json_object_object_add(cert, "certificateHashData", certificateHashData);
  7784. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  7785. json_object_array_add(certificateHashDataChains, cert);
  7786. }
  7787. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  7788. sprintf(message,"[%d,\"%s\",%s]"
  7789. ,MESSAGE_TYPE_CALLRESULT
  7790. ,uuid
  7791. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  7792. json_object_put(GetInstalledCertificateIds);
  7793. LWS_Send(message);
  7794. result = TRUE;
  7795. return result;
  7796. }
  7797. int sendGetLocalListVersionConfirmation(char *uuid)
  7798. {
  7799. mtrace();
  7800. int result = FAIL;
  7801. char message[4096]={0};
  7802. json_object *GetLocalListVersion = json_object_new_object();
  7803. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  7804. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  7805. sprintf(message,"[%d,\"%s\",%s]"
  7806. ,MESSAGE_TYPE_CALLRESULT
  7807. ,uuid
  7808. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  7809. json_object_put(GetLocalListVersion);
  7810. LWS_Send(message);
  7811. result = TRUE;
  7812. return result;
  7813. }
  7814. int sendGetLogConfirmation(char *uuid)
  7815. {
  7816. mtrace();
  7817. int result = FAIL;
  7818. char message[4096]={0};
  7819. json_object *GetLog = json_object_new_object();
  7820. DEBUG_INFO("sendGetLogConfirmation...\n");
  7821. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  7822. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  7823. sprintf(message,"[%d,\"%s\",%s]"
  7824. ,MESSAGE_TYPE_CALLRESULT
  7825. ,uuid
  7826. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  7827. json_object_put(GetLog);
  7828. LWS_Send(message);
  7829. result = TRUE;
  7830. return result;
  7831. }
  7832. int sendGetMonitoringReportConfirmation(char *uuid)
  7833. {
  7834. mtrace();
  7835. int result = FAIL;
  7836. char message[4096]={0};
  7837. json_object *GetMonitoringReport = json_object_new_object();
  7838. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  7839. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  7840. sprintf(message,"[%d,\"%s\",%s]"
  7841. ,MESSAGE_TYPE_CALLRESULT
  7842. ,uuid
  7843. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  7844. json_object_put(GetMonitoringReport);
  7845. LWS_Send(message);
  7846. result = TRUE;
  7847. return result;
  7848. }
  7849. int sendGetReportConfirmation(char *uuid)
  7850. {
  7851. mtrace();
  7852. int result = FAIL;
  7853. char message[4096]={0};
  7854. json_object *GetReport = json_object_new_object();
  7855. DEBUG_INFO("sendGetReportConfirmation...\n");
  7856. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  7857. sprintf(message,"[%d,\"%s\",%s]"
  7858. ,MESSAGE_TYPE_CALLRESULT
  7859. ,uuid
  7860. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  7861. json_object_put(GetReport);
  7862. LWS_Send(message);
  7863. result = TRUE;
  7864. return result;
  7865. }
  7866. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  7867. {
  7868. mtrace();
  7869. int result = FAIL;
  7870. char message[4096]={0};
  7871. json_object *GetTransactionStatus = json_object_new_object();
  7872. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  7873. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  7874. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  7875. sprintf(message,"[%d,\"%s\",%s]"
  7876. ,MESSAGE_TYPE_CALLRESULT
  7877. ,uuid
  7878. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  7879. json_object_put(GetTransactionStatus);
  7880. LWS_Send(message);
  7881. result = TRUE;
  7882. return result;
  7883. }
  7884. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  7885. {
  7886. mtrace();
  7887. int result = FAIL;
  7888. char message[4096]={0};
  7889. json_object *GetVariables = json_object_new_object();
  7890. json_object *getVariableResults = json_object_new_array();
  7891. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  7892. for(int idx=0;idx<variableQuantity;idx++)
  7893. {
  7894. json_object *variableResult = json_object_new_object();
  7895. json_object *component = json_object_new_object();
  7896. json_object *variable = json_object_new_object();
  7897. json_object *evse = json_object_new_object();
  7898. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  7899. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  7900. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  7901. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  7902. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  7903. json_object_object_add(component, "component", evse);
  7904. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  7905. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  7906. json_object_object_add(variableResult, "component", component);
  7907. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  7908. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  7909. json_object_object_add(variableResult, "variable", variable);
  7910. json_object_array_add(getVariableResults, variableResult);
  7911. }
  7912. json_object_object_add(GetVariables , "setVariableResult", getVariableResults);
  7913. sprintf(message,"[%d,\"%s\",%s]"
  7914. ,MESSAGE_TYPE_CALLRESULT
  7915. ,uuid
  7916. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  7917. json_object_put(GetVariables);
  7918. LWS_Send(message);
  7919. result = TRUE;
  7920. return result;
  7921. }
  7922. int sendInstallCertificateConfirmation(char *uuid)
  7923. {
  7924. mtrace();
  7925. int result = FAIL;
  7926. char message[4096]={0};
  7927. json_object *InstallCertificate = json_object_new_object();
  7928. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  7929. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  7930. sprintf(message,"[%d,\"%s\",%s]"
  7931. ,MESSAGE_TYPE_CALLRESULT
  7932. ,uuid
  7933. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  7934. json_object_put(InstallCertificate);
  7935. LWS_Send(message);
  7936. result = TRUE;
  7937. return result;
  7938. }
  7939. int sendPublishFirmwareConfirmation(char *uuid)
  7940. {
  7941. mtrace();
  7942. int result = FAIL;
  7943. char message[4096]={0};
  7944. json_object *PublishFirmware = json_object_new_object();
  7945. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  7946. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  7947. sprintf(message,"[%d,\"%s\",%s]"
  7948. ,MESSAGE_TYPE_CALLRESULT
  7949. ,uuid
  7950. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  7951. json_object_put(PublishFirmware);
  7952. LWS_Send(message);
  7953. result = TRUE;
  7954. return result;
  7955. }
  7956. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  7957. {
  7958. mtrace();
  7959. int result = FAIL;
  7960. char message[4096]={0};
  7961. json_object *RemoteStartTransaction = json_object_new_object();
  7962. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  7963. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  7964. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  7965. sprintf(message,"[%d,\"%s\",%s]"
  7966. ,MESSAGE_TYPE_CALLRESULT
  7967. ,uuid
  7968. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  7969. json_object_put(RemoteStartTransaction);
  7970. LWS_Send(message);
  7971. result = TRUE;
  7972. return result;
  7973. }
  7974. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  7975. {
  7976. mtrace();
  7977. int result = FAIL;
  7978. char message[4096]={0};
  7979. json_object *RemoteStopTransaction = json_object_new_object();
  7980. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  7981. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  7982. sprintf(message,"[%d,\"%s\",%s]"
  7983. ,MESSAGE_TYPE_CALLRESULT
  7984. ,uuid
  7985. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  7986. json_object_put(RemoteStopTransaction);
  7987. LWS_Send(message);
  7988. result = TRUE;
  7989. return result;
  7990. }
  7991. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  7992. {
  7993. mtrace();
  7994. int result = FAIL;
  7995. char message[4096]={0};
  7996. json_object *ReserveNow = json_object_new_object();
  7997. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  7998. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  7999. sprintf(message,"[%d,\"%s\",%s]"
  8000. ,MESSAGE_TYPE_CALLRESULT
  8001. ,uuid
  8002. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  8003. json_object_put(ReserveNow);
  8004. LWS_Send(message);
  8005. result = TRUE;
  8006. return result;
  8007. }
  8008. int sendResetConfirmation(char *uuid)
  8009. {
  8010. mtrace();
  8011. int result = FAIL;
  8012. char message[4096]={0};
  8013. json_object *Reset = json_object_new_object();
  8014. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  8015. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  8016. sprintf(message,"[%d,\"%s\",%s]"
  8017. ,MESSAGE_TYPE_CALLRESULT
  8018. ,uuid
  8019. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  8020. json_object_put(Reset);
  8021. LWS_Send(message);
  8022. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  8023. {
  8024. DB_updateBootType(BootReasonEnumType_RemoteReset);
  8025. }
  8026. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  8027. {
  8028. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  8029. }
  8030. result = TRUE;
  8031. return result;
  8032. }
  8033. int sendSendLocalListConfirmation(char *uuid)
  8034. {
  8035. mtrace();
  8036. int result = FAIL;
  8037. char message[4096]={0};
  8038. json_object *SendLocalList = json_object_new_object();
  8039. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  8040. sprintf(message,"[%d,\"%s\",%s]"
  8041. ,MESSAGE_TYPE_CALLRESULT
  8042. ,uuid
  8043. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  8044. json_object_put(SendLocalList);
  8045. LWS_Send(message);
  8046. result = TRUE;
  8047. return result;
  8048. }
  8049. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  8050. {
  8051. mtrace();
  8052. int result = FAIL;
  8053. char message[4096]={0};
  8054. json_object *SetChargingProfile = json_object_new_object();
  8055. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  8056. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  8057. sprintf(message,"[%d,\"%s\",%s]"
  8058. ,MESSAGE_TYPE_CALLRESULT
  8059. ,uuid
  8060. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  8061. json_object_put(SetChargingProfile);
  8062. LWS_Send(message);
  8063. result = TRUE;
  8064. return result;
  8065. }
  8066. int sendSetDisplayMessageConfirmation(char *uuid)
  8067. {
  8068. mtrace();
  8069. int result = FAIL;
  8070. char message[4096]={0};
  8071. json_object *SetDisplayMessage = json_object_new_object();
  8072. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  8073. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  8074. sprintf(message,"[%d,\"%s\",%s]"
  8075. ,MESSAGE_TYPE_CALLRESULT
  8076. ,uuid
  8077. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  8078. json_object_put(SetDisplayMessage);
  8079. LWS_Send(message);
  8080. result = TRUE;
  8081. return result;
  8082. }
  8083. int sendSetMonitoringBaseConfirmation(char *uuid)
  8084. {
  8085. mtrace();
  8086. int result = FAIL;
  8087. char message[4096]={0};
  8088. json_object *SetMonitoringBase = json_object_new_object();
  8089. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  8090. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  8091. sprintf(message,"[%d,\"%s\",%s]"
  8092. ,MESSAGE_TYPE_CALLRESULT
  8093. ,uuid
  8094. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  8095. json_object_put(SetMonitoringBase);
  8096. LWS_Send(message);
  8097. result = TRUE;
  8098. return result;
  8099. }
  8100. int sendSetMonitoringLevelConfirmation(char *uuid)
  8101. {
  8102. mtrace();
  8103. int result = FAIL;
  8104. char message[4096]={0};
  8105. json_object *SetMonitoringLevel = json_object_new_object();
  8106. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  8107. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  8108. sprintf(message,"[%d,\"%s\",%s]"
  8109. ,MESSAGE_TYPE_CALLRESULT
  8110. ,uuid
  8111. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  8112. json_object_put(SetMonitoringLevel);
  8113. LWS_Send(message);
  8114. result = TRUE;
  8115. return result;
  8116. }
  8117. int sendSetNetworkProfileConfirmation(char *uuid)
  8118. {
  8119. mtrace();
  8120. int result = FAIL;
  8121. char message[4096]={0};
  8122. json_object *SetNetworkProfile = json_object_new_object();
  8123. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  8124. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  8125. sprintf(message,"[%d,\"%s\",%s]"
  8126. ,MESSAGE_TYPE_CALLRESULT
  8127. ,uuid
  8128. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  8129. json_object_put(SetNetworkProfile);
  8130. LWS_Send(message);
  8131. result = TRUE;
  8132. return result;
  8133. }
  8134. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  8135. {
  8136. mtrace();
  8137. int result = FAIL;
  8138. char message[4096]={0};
  8139. json_object *SetVariableMonitoring = json_object_new_object();
  8140. json_object *setMonitoringResults = json_object_new_array();
  8141. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  8142. for(int idx=0;idx<variableQuantity;idx++)
  8143. {
  8144. json_object *variableMonitorResult = json_object_new_object();
  8145. json_object *component = json_object_new_object();
  8146. json_object *variable = json_object_new_object();
  8147. json_object *evse = json_object_new_object();
  8148. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  8149. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  8150. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  8151. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  8152. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  8153. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  8154. json_object_object_add(component, "component", evse);
  8155. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  8156. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  8157. json_object_object_add(variableMonitorResult, "component", component);
  8158. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  8159. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  8160. json_object_object_add(variableMonitorResult, "variable", variable);
  8161. json_object_array_add(setMonitoringResults, variableMonitorResult);
  8162. }
  8163. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  8164. sprintf(message,"[%d,\"%s\",%s]"
  8165. ,MESSAGE_TYPE_CALLRESULT
  8166. ,uuid
  8167. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  8168. json_object_put(SetVariableMonitoring);
  8169. LWS_Send(message);
  8170. result = TRUE;
  8171. return result;
  8172. }
  8173. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  8174. {
  8175. mtrace();
  8176. int result = FAIL;
  8177. char message[4096]={0};
  8178. json_object *SetVariable = json_object_new_object();
  8179. json_object *setVariableResults = json_object_new_array();
  8180. DEBUG_INFO("sendSetVariableConfirmation...\n");
  8181. for(int idx=0;idx<variableQuantity;idx++)
  8182. {
  8183. json_object *variableResult = json_object_new_object();
  8184. json_object *component = json_object_new_object();
  8185. json_object *variable = json_object_new_object();
  8186. json_object *evse = json_object_new_object();
  8187. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  8188. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  8189. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  8190. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  8191. json_object_object_add(component, "component", evse);
  8192. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  8193. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  8194. json_object_object_add(variableResult, "component", component);
  8195. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  8196. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  8197. json_object_object_add(variableResult, "variable", variable);
  8198. json_object_array_add(setVariableResults, variableResult);
  8199. }
  8200. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  8201. sprintf(message,"[%d,\"%s\",%s]"
  8202. ,MESSAGE_TYPE_CALLRESULT
  8203. ,uuid
  8204. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  8205. json_object_put(SetVariable);
  8206. LWS_Send(message);
  8207. result = TRUE;
  8208. return result;
  8209. }
  8210. int sendTriggerMessageConfirmation(char *uuid)
  8211. {
  8212. mtrace();
  8213. int result = FAIL;
  8214. char message[4096]={0};
  8215. json_object *TriggerMessage = json_object_new_object();
  8216. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  8217. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  8218. sprintf(message,"[%d,\"%s\",%s]",
  8219. MESSAGE_TYPE_CALLRESULT,
  8220. uuid,
  8221. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  8222. json_object_put(TriggerMessage);
  8223. LWS_Send(message);
  8224. result = TRUE;
  8225. return result;
  8226. }
  8227. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  8228. {
  8229. mtrace();
  8230. int result = FAIL;
  8231. char message[4096]={0};
  8232. json_object *UnlockConnector = json_object_new_object();
  8233. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  8234. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  8235. sprintf(message,"[%d,\"%s\",%s]",
  8236. MESSAGE_TYPE_CALLRESULT,
  8237. uuid,
  8238. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  8239. json_object_put(UnlockConnector);
  8240. LWS_Send(message);
  8241. result = TRUE;
  8242. return result;
  8243. }
  8244. int sendUnpublishFirmwareConfirmation(char *uuid)
  8245. {
  8246. mtrace();
  8247. int result = FAIL;
  8248. char message[4096]={0};
  8249. json_object *UnpublishFirmware = json_object_new_object();
  8250. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  8251. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  8252. sprintf(message,"[%d,\"%s\",%s]"
  8253. ,MESSAGE_TYPE_CALLRESULT
  8254. ,uuid
  8255. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  8256. json_object_put(UnpublishFirmware);
  8257. LWS_Send(message);
  8258. result = TRUE;
  8259. return result;
  8260. }
  8261. int sendUpdateFirmwareConfirmation(char *uuid)
  8262. {
  8263. mtrace();
  8264. int result = FAIL;
  8265. char message[4096]={0};
  8266. json_object *UpdateFirmware = json_object_new_object();
  8267. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  8268. sprintf((char*)ShmOCPP20Data->UpdateFirmware.Response_status, "%s", UpdateFirmwareStatusEnumTypeStr[UpdateFirmwareStatusEnumType_Accepted]);
  8269. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  8270. sprintf(message,"[%d,\"%s\",%s]"
  8271. ,MESSAGE_TYPE_CALLRESULT
  8272. ,uuid
  8273. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  8274. json_object_put(UpdateFirmware);
  8275. LWS_Send(message);
  8276. result = TRUE;
  8277. return result;
  8278. }
  8279. //==========================================
  8280. // send CallError routine
  8281. //==========================================
  8282. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  8283. {
  8284. mtrace();
  8285. char message[220]={0};
  8286. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  8287. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  8288. LWS_Send(message);
  8289. }
  8290. //==========================================
  8291. // Handle server request routine Start
  8292. //==========================================
  8293. int handleCancelReservationRequest(char *uuid, char *payload)
  8294. {
  8295. mtrace();
  8296. int result = FAIL;
  8297. int gunNO = 0;
  8298. int reservationIdInt = -1;
  8299. DEBUG_INFO("handleCancelReservationRequest...\n");
  8300. json_object *CancelReservation;
  8301. CancelReservation = json_tokener_parse(payload);
  8302. if(!is_error(CancelReservation))
  8303. {
  8304. // Required data
  8305. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  8306. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  8307. }
  8308. json_object_put(CancelReservation);
  8309. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  8310. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  8311. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  8312. if(reservationIdInt != -1)
  8313. {
  8314. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  8315. //check Transaction active
  8316. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  8317. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8318. {
  8319. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  8320. {
  8321. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8322. if(gunType[2] == 'J')
  8323. {
  8324. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  8325. }
  8326. else
  8327. {
  8328. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  8329. }
  8330. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8331. goto end;
  8332. }
  8333. }
  8334. for (int index = 0; index < CCS_QUANTITY; index++)
  8335. {
  8336. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  8337. {
  8338. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8339. if((gunType[2] == 'U') || (gunType[2] == 'E'))
  8340. {
  8341. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  8342. }
  8343. else
  8344. {
  8345. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  8346. }
  8347. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8348. goto end;
  8349. }
  8350. }
  8351. for (int index = 0; index < GB_QUANTITY; index++)
  8352. {
  8353. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  8354. {
  8355. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8356. if(gunType[2] == 'G')
  8357. {
  8358. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  8359. }
  8360. else
  8361. {
  8362. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  8363. }
  8364. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8365. goto end;
  8366. }
  8367. }
  8368. for (int index = 0; index < AC_QUANTITY; index++)
  8369. {
  8370. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  8371. {
  8372. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8373. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8374. {
  8375. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  8376. }
  8377. else
  8378. {
  8379. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  8380. }
  8381. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8382. goto end;
  8383. }
  8384. }
  8385. }
  8386. //The reservationId does NOT match the reservationId
  8387. sendCancelReservationConfirmation(uuid, gunNO);
  8388. end:
  8389. // Fill in ocpp packet uuid
  8390. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  8391. return result;
  8392. }
  8393. int handleCertificateSignedRequest(char *uuid, char *payload)
  8394. {
  8395. mtrace();
  8396. int result = FAIL;
  8397. json_object *CertificateSigned;
  8398. DEBUG_INFO("handleCertificateSignedRequest...\n");
  8399. CertificateSigned = json_tokener_parse(payload);
  8400. if(!is_error(CertificateSigned))
  8401. {
  8402. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  8403. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  8404. // Required data
  8405. if(json_object_array_length(json_object_object_get(CertificateSigned, "certificate")) <= ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.certificate))
  8406. {
  8407. for(int idx=0;idx<json_object_array_length(json_object_object_get(CertificateSigned, "certificate"));idx++)
  8408. {
  8409. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificate[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(CertificateSigned, "certificateType"), idx)));
  8410. /*
  8411. * TODO:
  8412. * 1. Certificate install response
  8413. */
  8414. }
  8415. }
  8416. // Optional data
  8417. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  8418. {
  8419. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  8420. }
  8421. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  8422. }
  8423. else
  8424. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  8425. json_object_put(CertificateSigned);
  8426. sendCertificateSignedConfirmation(uuid);
  8427. return result;
  8428. }
  8429. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  8430. {
  8431. mtrace();
  8432. int result = FAIL;
  8433. int evseId = 0, gunIndex = 0;
  8434. char operationalStatus[16]={0};
  8435. char comfirmstr[20];
  8436. int specificId = FALSE;
  8437. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  8438. json_object *ChangeAvailability;
  8439. ChangeAvailability = json_tokener_parse(payload);
  8440. if(!is_error(ChangeAvailability))
  8441. {
  8442. // Required data
  8443. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  8444. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  8445. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  8446. {
  8447. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  8448. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  8449. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  8450. }
  8451. }
  8452. json_object_put(ChangeAvailability);
  8453. if((evseId != 0) && (evseId <= gunTotalNumber))
  8454. {
  8455. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  8456. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  8457. }
  8458. else if(evseId == 0)
  8459. {
  8460. for(int i=0; i < gunTotalNumber; i++)
  8461. {
  8462. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  8463. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8464. }
  8465. }
  8466. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8467. {
  8468. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  8469. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  8470. }
  8471. else if(gunIndex == 0)
  8472. {
  8473. for(int i=0; i < gunTotalNumber; i++)
  8474. {
  8475. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  8476. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8477. }
  8478. }
  8479. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  8480. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8481. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  8482. {
  8483. specificId = TRUE;
  8484. }
  8485. if(specificId == FALSE)
  8486. goto end;
  8487. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  8488. {
  8489. //----------------------gunIndex is 0 ------------------------------------------------//
  8490. if(gunIndex == 0)
  8491. {
  8492. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8493. {
  8494. for(int i=0; i < gunTotalNumber; i++)
  8495. {
  8496. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8497. {
  8498. if ((gunType[i] == 'J')&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  8499. {
  8500. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8501. {
  8502. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8503. goto end;
  8504. }
  8505. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8506. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8507. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8508. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8509. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8510. {
  8511. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8512. goto end;
  8513. }
  8514. }
  8515. }//END FOR CHAdeMO_QUANTITY
  8516. for (int index = 0; index < CCS_QUANTITY; index++)
  8517. {
  8518. if (((gunType[i] == 'U')||(gunType[i] == 'E'))&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  8519. {
  8520. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  8521. {
  8522. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8523. goto end;
  8524. }
  8525. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8526. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8527. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8528. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8529. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8530. {
  8531. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8532. goto end;
  8533. }
  8534. }
  8535. }//END FOR CCS_QUANTITY
  8536. for (int index = 0; index < GB_QUANTITY; index++)
  8537. {
  8538. if ((gunType[i] == 'G')&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  8539. {
  8540. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8541. {
  8542. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8543. goto end;
  8544. }
  8545. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8546. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8547. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8548. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8549. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8550. {
  8551. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8552. goto end;
  8553. }
  8554. }
  8555. }// END FOR GB_QUANTITY
  8556. for (int index = 0; index < AC_QUANTITY; index++)
  8557. {
  8558. if (((gunType[i] > '0')&&(gunType[i] <= '9'))&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  8559. {
  8560. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8561. {
  8562. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8563. goto end;
  8564. }
  8565. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8566. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8567. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8568. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8569. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8570. {
  8571. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8572. goto end;
  8573. }
  8574. }
  8575. }//END FOR AC_QUANTITY
  8576. }// END FOR gunTotalNumber
  8577. }
  8578. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8579. {
  8580. for(int i=0; i < gunTotalNumber; i++)
  8581. {
  8582. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8583. {
  8584. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8585. goto end;
  8586. }
  8587. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8588. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  8589. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  8590. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  8591. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8592. {
  8593. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8594. goto end;
  8595. }
  8596. }
  8597. }
  8598. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8599. goto end;
  8600. }
  8601. //----------------------gunIndex is not 0 ------------------------------------------------//
  8602. //check Transaction active
  8603. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8604. {
  8605. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J'))
  8606. {
  8607. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  8608. {
  8609. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8610. goto end;
  8611. }
  8612. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8613. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8614. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8615. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8616. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8617. {
  8618. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8619. goto end;
  8620. }
  8621. else
  8622. {
  8623. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  8624. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8625. goto end;
  8626. }
  8627. }
  8628. }//END FOR CHAdeMO_QUANTITY
  8629. for (int index = 0; index < CCS_QUANTITY; index++)
  8630. {
  8631. if ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E')))
  8632. {
  8633. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  8634. {
  8635. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8636. goto end;
  8637. }
  8638. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8639. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8640. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8641. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8642. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8643. {
  8644. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8645. goto end;
  8646. }
  8647. else
  8648. {
  8649. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  8650. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8651. goto end;
  8652. }
  8653. }
  8654. }//END FOR CCS_QUANTITY
  8655. for (int index = 0; index < GB_QUANTITY; index++)
  8656. {
  8657. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))
  8658. {
  8659. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8660. {
  8661. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8662. goto end;
  8663. }
  8664. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8665. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8666. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8667. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8668. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8669. {
  8670. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8671. goto end;
  8672. }
  8673. else
  8674. {
  8675. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  8676. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8677. goto end;
  8678. }
  8679. }
  8680. }// END FOR GB_QUANTITY
  8681. for (int index = 0; index < AC_QUANTITY; index++)
  8682. {
  8683. if ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))
  8684. {
  8685. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8686. {
  8687. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8688. goto end;
  8689. }
  8690. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8691. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8692. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8693. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8694. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8695. {
  8696. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8697. goto end;
  8698. }
  8699. else
  8700. {
  8701. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  8702. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8703. goto end;
  8704. }
  8705. }
  8706. }//END FOR AC_QUANTITY
  8707. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  8708. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  8709. {
  8710. //----------------------gunIndex is 0 ------------------------------------------------//
  8711. if(gunIndex == 0)
  8712. {
  8713. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8714. {
  8715. for(int i=0; i < gunTotalNumber; i++)
  8716. {
  8717. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8718. {
  8719. 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
  8720. {
  8721. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8722. goto end;
  8723. }
  8724. }//END FOR CHAdeMO_QUANTITY
  8725. for (int index = 0; index < CCS_QUANTITY; index++)
  8726. {
  8727. 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
  8728. {
  8729. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8730. goto end;
  8731. }
  8732. }//END FOR CCS_QUANTITY
  8733. for (int index = 0; index < GB_QUANTITY; index++)
  8734. {
  8735. 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
  8736. {
  8737. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8738. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8739. goto end;
  8740. }
  8741. }// END FOR GB_QUANTITY
  8742. for (int index = 0; index < AC_QUANTITY; index++)
  8743. {
  8744. 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
  8745. {
  8746. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8747. goto end;
  8748. }
  8749. }//END FOR CHAdeMO_QUANTITY
  8750. }// END FOR gunTotalNumber
  8751. }
  8752. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8753. {
  8754. for(int i=0; i < gunTotalNumber; i++)
  8755. {
  8756. for (int index = 0; index < AC_QUANTITY; index++)
  8757. {
  8758. 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
  8759. {
  8760. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8761. goto end;
  8762. }
  8763. }//END FOR CHAdeMO_QUANTITY
  8764. } // END FOR gunTotalNumber
  8765. }
  8766. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8767. goto end;
  8768. }
  8769. //----------------------gunIndex is not 0 ------------------------------------------------//
  8770. //check Transaction active
  8771. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8772. {
  8773. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'J') ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8774. {
  8775. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8776. goto end;
  8777. }
  8778. }//END FOR CHAdeMO_QUANTITY
  8779. for (int index = 0; index < CCS_QUANTITY; index++)
  8780. {
  8781. if ((((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8782. {
  8783. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8784. goto end;
  8785. }
  8786. }//END FOR CCS_QUANTITY
  8787. for (int index = 0; index < GB_QUANTITY; index++)
  8788. {
  8789. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8790. {
  8791. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8792. goto end;
  8793. }
  8794. }// END FOR GB_QUANTITY
  8795. for (int index = 0; index < AC_QUANTITY; index++)
  8796. {
  8797. if (((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9'))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8798. {
  8799. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8800. goto end;
  8801. }
  8802. }//END FOR AC_QUANTITY
  8803. }//END FOR AvailabilityEnumTypeStr[Operative]
  8804. end:
  8805. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8806. {
  8807. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  8808. }
  8809. else
  8810. {
  8811. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  8812. }
  8813. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8814. {
  8815. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  8816. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8817. }
  8818. else if(gunIndex == 0)
  8819. {
  8820. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  8821. {
  8822. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  8823. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  8824. }
  8825. }
  8826. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  8827. return result;
  8828. }
  8829. int handleClearCacheRequest(char *uuid, char *payload)
  8830. {
  8831. mtrace();
  8832. int result = FAIL;
  8833. char rmFileCmd[100]={0};
  8834. struct stat stats;
  8835. DEBUG_INFO("handleClearCacheRequest...\n");
  8836. stat("/Storage/OCPP", &stats);
  8837. // Check for directory existence
  8838. if (S_ISDIR(stats.st_mode) == 1)
  8839. {}
  8840. else
  8841. {
  8842. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  8843. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  8844. system(rmFileCmd);
  8845. }
  8846. /*
  8847. * TODO:
  8848. * 1. Clear cache from sqlite db
  8849. */
  8850. if(1)
  8851. {
  8852. DEBUG_INFO("open AuthorizationCache file failed\n");
  8853. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  8854. }
  8855. else
  8856. {
  8857. DEBUG_INFO("open AuthorizationCache file successful\n");
  8858. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  8859. }
  8860. sendClearCacheConfirmation(uuid);
  8861. return result;
  8862. }
  8863. int handleClearChargingProfileRequest(char *uuid, char *payload)
  8864. {
  8865. mtrace();
  8866. int result = FAIL;
  8867. int resultRename;
  8868. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  8869. char chargingProfilePurposeStr[26]={0};
  8870. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  8871. char tempchargingProfilePurposeStr[26]={0};
  8872. char sstr[160]={0};
  8873. char str[100]={0};
  8874. int c = 0;
  8875. char *loc;
  8876. char fname[200]={0};
  8877. char comfirmstr[20]={0};
  8878. char word[1600]={0};
  8879. int clearflag = FALSE;
  8880. int chargingProfileIdIsNULL = FALSE;
  8881. int connectorIsNULL = FALSE;
  8882. int chargingProfilePurposeIsNULL = FALSE;
  8883. int stackLevelIsNULL = FALSE;
  8884. //int GotoEnd = FALSE;
  8885. FILE *fptr1, *fptr2;
  8886. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  8887. int n_chargingProfile=0;
  8888. int isEmptyFile = FALSE;
  8889. char sLineWord[1600]={0};
  8890. char chargingProfiles[10][100]={0};
  8891. int ChargeProfileCount = 0;
  8892. int ch;
  8893. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  8894. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  8895. json_object *ClearChargingProfile;
  8896. ClearChargingProfile = json_tokener_parse(payload);
  8897. if(!is_error(ClearChargingProfile))
  8898. {
  8899. // Optional data
  8900. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  8901. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  8902. else
  8903. chargingProfileIdIsNULL = TRUE;
  8904. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  8905. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  8906. else
  8907. connectorIsNULL = TRUE;
  8908. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  8909. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  8910. else
  8911. chargingProfilePurposeIsNULL = TRUE;
  8912. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  8913. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  8914. else
  8915. stackLevelIsNULL = TRUE;
  8916. }
  8917. json_object_put(ClearChargingProfile);
  8918. if(connectorIsNULL == FALSE)
  8919. {
  8920. switch(connectorIdInt)
  8921. {
  8922. case 0:
  8923. if(chargingProfilePurposeIsNULL == TRUE)
  8924. {
  8925. int l = 0;
  8926. strcpy(fname, ChargePointMaxProfile_JSON);
  8927. if((access(fname,F_OK))!=-1)
  8928. {
  8929. strcpy(chargingProfiles[l], fname);
  8930. l = l + 1;
  8931. }
  8932. strcpy(fname, TxDefaultProfile_0_JSON);
  8933. if((access(fname,F_OK))!=-1)
  8934. {
  8935. strcpy(chargingProfiles[l], fname);
  8936. l = l + 1;
  8937. }
  8938. ChargeProfileCount = l;
  8939. }
  8940. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  8941. {
  8942. strcpy(fname, ChargePointMaxProfile_JSON);
  8943. if((access(fname,F_OK))!=-1)
  8944. {
  8945. strcpy(chargingProfiles[0], fname);
  8946. ChargeProfileCount = 1;
  8947. }
  8948. }
  8949. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  8950. {
  8951. strcpy(fname, TxDefaultProfile_0_JSON);
  8952. if((access(fname,F_OK))!=-1)
  8953. {
  8954. strcpy(chargingProfiles[0], fname);
  8955. ChargeProfileCount = 1;
  8956. }
  8957. }
  8958. break;
  8959. default:
  8960. if(chargingProfilePurposeIsNULL == TRUE)
  8961. {
  8962. int m = 0;
  8963. memset(fname, 0, ARRAY_SIZE(fname));
  8964. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  8965. if((access(fname,F_OK))!=-1)
  8966. {
  8967. strcpy(chargingProfiles[m], fname);
  8968. m = m + 1;
  8969. }
  8970. memset(fname, 0, ARRAY_SIZE(fname));
  8971. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  8972. if((access(fname,F_OK))!=-1)
  8973. {
  8974. strcpy(chargingProfiles[m], fname);
  8975. m = m + 1;
  8976. }
  8977. ChargeProfileCount = m;
  8978. }
  8979. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  8980. {
  8981. //strcpy(fname, TxDefaultProfile_1_JSON);
  8982. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  8983. if((access(fname,F_OK))!=-1)
  8984. {
  8985. strcpy(chargingProfiles[0], fname);
  8986. ChargeProfileCount = 1;
  8987. }
  8988. }
  8989. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  8990. {
  8991. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  8992. if((access(fname,F_OK))!=-1)
  8993. {
  8994. strcpy(chargingProfiles[0], fname);
  8995. ChargeProfileCount = 1;
  8996. }
  8997. }
  8998. //strcpy(fname, ChargePointMaxProfile_JSON );
  8999. break;
  9000. }
  9001. }
  9002. else // Check all Charging Profiles
  9003. {
  9004. int i = 0;
  9005. char fnametemp[200]={0};
  9006. ChargeProfileCount = 0;
  9007. //Check ChargePointMaxProfile.json exit
  9008. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  9009. {
  9010. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  9011. i = i + 1;
  9012. }
  9013. //Check TxDefaultProfile_0.json exit
  9014. if((access("/Storage/OCPP/TxDefaultProfile_0.json",F_OK))!=-1)
  9015. {
  9016. strcpy(chargingProfiles[i], "/Storage/OCPP/TxDefaultProfile_0.json");
  9017. i = i + 1;
  9018. }
  9019. //Check TxDefaultProfile_%d.json
  9020. for(int j=1; j <= gunTotalNumber; j++)
  9021. {
  9022. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  9023. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d.json", j);
  9024. if((access(fnametemp,F_OK))!=-1)
  9025. {
  9026. strcpy(chargingProfiles[i], fnametemp);
  9027. i = i + 1;
  9028. }
  9029. }
  9030. //Check TxProfile_%d.json
  9031. for(int j=1; j <= gunTotalNumber; j++)
  9032. {
  9033. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  9034. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d.json", j);
  9035. if((access(fnametemp,F_OK))!=-1)
  9036. {
  9037. strcpy(chargingProfiles[i], fnametemp);
  9038. i = i + 1;
  9039. }
  9040. }
  9041. ChargeProfileCount = i;
  9042. }// End connectorIsNULL is TRUE
  9043. if(ChargeProfileCount == 0)
  9044. {
  9045. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9046. goto end;
  9047. }
  9048. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  9049. {
  9050. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9051. goto end;
  9052. }
  9053. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  9054. {
  9055. memset(str, 0, ARRAY_SIZE(str));
  9056. // clear temp file
  9057. sprintf(str,"rm -f %s",temp);
  9058. system(str);
  9059. for(int k=0; k < ChargeProfileCount; k++)
  9060. {
  9061. memset(str, 0, ARRAY_SIZE(str));
  9062. //clear file in C
  9063. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9064. system(str);
  9065. }
  9066. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9067. goto end;
  9068. }
  9069. else if(connectorIsNULL == TRUE)
  9070. {
  9071. for(int k=0; k < ChargeProfileCount; k++)
  9072. {
  9073. fptr1 = fopen(chargingProfiles[k], "r");
  9074. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  9075. //Check Charging Profile Count
  9076. while(fscanf(fptr1, "%s", word) != EOF)
  9077. {
  9078. //DEBUG_INFO("word=%s\n",word);
  9079. if(strstr(word, "chargingProfileId")!= NULL)
  9080. {
  9081. //DEBUG_INFO("test chargingProfileId \n");
  9082. n_chargingProfile = n_chargingProfile + 1;
  9083. //DEBUG_INFO("chargingProfileId Found\n");
  9084. }
  9085. }
  9086. rewind(fptr1);
  9087. //search Charging Profile Element
  9088. //int i= 0;
  9089. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9090. {
  9091. //------------------------tempconnectorIdInt------------------------//
  9092. loc = strstr(sLineWord, "connectorId");
  9093. c = 0;
  9094. memset(sstr ,0, sizeof(sstr) );
  9095. while (loc[strlen("connectorId")+2+c] != ',')
  9096. {
  9097. sstr[c] = loc[strlen("connectorId")+2+c];
  9098. c++;
  9099. }
  9100. sstr[c] = '\0';
  9101. tempconnectorIdInt = atoi(sstr);
  9102. printf("file's gun number is %d\n", tempconnectorIdInt);
  9103. //--------------------------chargingProfileId--------------------//
  9104. c = 0;
  9105. loc = strstr(sLineWord, "chargingProfileId");
  9106. memset(sstr ,0, ARRAY_SIZE(sstr));
  9107. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9108. {
  9109. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9110. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9111. c++;
  9112. }
  9113. sstr[c] = '\0';
  9114. tempchargingProfileIdInt = atoi(sstr);
  9115. //stackLevel
  9116. c = 0;
  9117. loc = strstr(sLineWord, "stackLevel");
  9118. memset(sstr ,0, ARRAY_SIZE(sstr));
  9119. while (loc[strlen("stackLevel")+2+c] != ',')
  9120. {
  9121. sstr[c] = loc[strlen("stackLevel")+2+c];
  9122. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9123. c++;
  9124. }
  9125. sstr[c] = '\0';
  9126. tempstackLevelInt = atoi(sstr);
  9127. c = 0;
  9128. loc = strstr(sLineWord, "chargingProfilePurpose");
  9129. memset(sstr ,0, ARRAY_SIZE(sstr));
  9130. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9131. {
  9132. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9133. c++;
  9134. }
  9135. sstr[c] = '\0';
  9136. strcpy(tempchargingProfilePurposeStr, sstr);
  9137. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9138. {
  9139. //------- not write to fptr2-------//
  9140. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9141. //clearflag = TRUE;
  9142. }
  9143. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  9144. {
  9145. //------- not write to fptr2-------//
  9146. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9147. }
  9148. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9149. {
  9150. //------- not write to fptr2-------//
  9151. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9152. }
  9153. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  9154. {
  9155. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9156. }
  9157. else
  9158. {
  9159. fprintf(fptr2, sLineWord);//writing data into file
  9160. }
  9161. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9162. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9163. if(clearflag == TRUE)
  9164. {
  9165. fclose(fptr1);
  9166. fclose(fptr2);
  9167. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9168. system(str);
  9169. // clear temp file
  9170. sprintf(str,"rm -f %s",temp);
  9171. system(str);
  9172. }
  9173. else
  9174. {
  9175. fclose(fptr1);
  9176. fclose(fptr2);
  9177. memset(str, 0, ARRAY_SIZE(str));
  9178. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9179. system(str);
  9180. resultRename = rename(temp, chargingProfiles[k]);
  9181. if(resultRename == 0)
  9182. {
  9183. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  9184. }
  9185. else
  9186. {
  9187. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  9188. }
  9189. if(comfirmstr[0]== 0)
  9190. {
  9191. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9192. }
  9193. //Check chargingProfile is empty file
  9194. /*------ Read the file ----------------*/
  9195. fptr1=fopen(chargingProfiles[k],"r");
  9196. ch=fgetc(fptr1);
  9197. rewind(fptr1);
  9198. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9199. if(ch!=EOF)
  9200. {
  9201. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9202. {
  9203. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9204. if(sLineWord[0]=='\0')
  9205. {
  9206. isEmptyFile = TRUE;
  9207. break;
  9208. }
  9209. else
  9210. {
  9211. isEmptyFile = FALSE;
  9212. break;
  9213. }
  9214. }
  9215. }
  9216. else
  9217. isEmptyFile = TRUE;
  9218. fclose(fptr1);
  9219. if(isEmptyFile == TRUE)
  9220. {
  9221. memset(str, 0, ARRAY_SIZE(str));
  9222. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9223. system(str);
  9224. }
  9225. }
  9226. }// End of while(int k=0; k < ChargePointCount; k++)
  9227. }
  9228. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  9229. {
  9230. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  9231. for(int k=0; k < ChargeProfileCount; k++)
  9232. {
  9233. fptr1 = fopen(chargingProfiles[k], "r");
  9234. fptr2 = fopen(temp, "w+");
  9235. //Check Charging Profile Count
  9236. while(fscanf(fptr1, "%s", word) != EOF)
  9237. {
  9238. //DEBUG_INFO("word=%s\n",word);
  9239. if(strstr(word, "chargingProfileId")!= NULL)
  9240. {
  9241. n_chargingProfile = n_chargingProfile + 1;
  9242. }
  9243. }
  9244. rewind(fptr1);
  9245. //search Charging Profile Element
  9246. //int i= 0;
  9247. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9248. {
  9249. //*************************tempconnectorIdInt*********************************/
  9250. loc = strstr(sLineWord, "connectorId");
  9251. c = 0;
  9252. memset(sstr ,0, ARRAY_SIZE(sstr));
  9253. while (loc[strlen("connectorId")+2+c] != ',')
  9254. {
  9255. sstr[c] = loc[strlen("connectorId")+2+c];
  9256. c++;
  9257. }
  9258. sstr[c] = '\0';
  9259. tempconnectorIdInt = atoi(sstr);
  9260. //chargingProfileId
  9261. c = 0;
  9262. loc = strstr(sLineWord, "chargingProfileId");
  9263. memset(sstr ,0, ARRAY_SIZE(sstr));
  9264. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9265. {
  9266. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9267. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9268. c++;
  9269. }
  9270. sstr[c] = '\0';
  9271. tempchargingProfileIdInt = atoi(sstr);
  9272. //stackLevel
  9273. c = 0;
  9274. loc = strstr(sLineWord, "stackLevel");
  9275. memset(sstr ,0, ARRAY_SIZE(sstr));
  9276. while (loc[strlen("stackLevel")+2+c] != ',')
  9277. {
  9278. sstr[c] = loc[strlen("stackLevel")+2+c];
  9279. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9280. c++;
  9281. }
  9282. sstr[c] = '\0';
  9283. tempstackLevelInt = atoi(sstr);
  9284. c = 0;
  9285. loc = strstr(sLineWord, "chargingProfilePurpose");
  9286. memset(sstr ,0, ARRAY_SIZE(sstr));
  9287. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9288. {
  9289. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9290. c++;
  9291. }
  9292. sstr[c] = '\0';
  9293. strcpy(tempchargingProfilePurposeStr, sstr);
  9294. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9295. {
  9296. //------- not write to fptr2-------//
  9297. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9298. //clearflag = TRUE;
  9299. }
  9300. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9301. {
  9302. //------- not write to fptr2-------//
  9303. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9304. }
  9305. else if(stackLevelIsNULL == TRUE)
  9306. {
  9307. //Clear Whole File
  9308. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9309. clearflag = TRUE;
  9310. break;
  9311. }
  9312. else
  9313. {
  9314. fprintf(fptr2, sLineWord);//writing data into file
  9315. }
  9316. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9317. }
  9318. if(clearflag == TRUE)
  9319. {
  9320. fclose(fptr1);
  9321. fclose(fptr2);
  9322. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9323. system(str);
  9324. // clear temp file
  9325. sprintf(str,"rm -f %s",temp);
  9326. system(str);
  9327. }
  9328. else
  9329. {
  9330. fclose(fptr1);
  9331. fclose(fptr2);
  9332. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9333. system(str);
  9334. resultRename = rename(temp, chargingProfiles[k]);
  9335. if(resultRename == 0)
  9336. {
  9337. DEBUG_INFO("File ChargingProfile renamed successfully");
  9338. }
  9339. else
  9340. {
  9341. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  9342. }
  9343. if(comfirmstr[0]== 0)
  9344. {
  9345. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9346. }
  9347. //Check chargingProfile is empty file
  9348. /*------ Read the file ----------------*/
  9349. fptr1=fopen(chargingProfiles[k],"r");
  9350. ch=fgetc(fptr1);
  9351. rewind(fptr1);
  9352. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9353. if(ch!=EOF)
  9354. {
  9355. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9356. {
  9357. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9358. if(sLineWord[0]=='\0')
  9359. {
  9360. isEmptyFile = TRUE;
  9361. break;
  9362. }
  9363. else
  9364. {
  9365. isEmptyFile = FALSE;
  9366. break;
  9367. }
  9368. }
  9369. }
  9370. else
  9371. isEmptyFile = TRUE;
  9372. fclose(fptr1);
  9373. if(isEmptyFile == TRUE)
  9374. {
  9375. memset(str, 0, ARRAY_SIZE(str));
  9376. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9377. system(str);
  9378. }
  9379. /*------- End of reading ---------------*/
  9380. }
  9381. } // while(int k=0; k < ChargeProfileCount; k++)
  9382. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  9383. end:
  9384. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  9385. {
  9386. if(connectorIdInt == 0)
  9387. {
  9388. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  9389. {
  9390. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  9391. }
  9392. }
  9393. else
  9394. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1]);
  9395. }
  9396. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  9397. return result;
  9398. }
  9399. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  9400. {
  9401. mtrace();
  9402. int result = FAIL;
  9403. json_object *ClearDisplayMessage;
  9404. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  9405. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  9406. ClearDisplayMessage = json_tokener_parse(payload);
  9407. if(!is_error(ClearDisplayMessage))
  9408. {
  9409. // Required data
  9410. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  9411. {
  9412. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  9413. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  9414. }
  9415. }
  9416. json_object_put(ClearDisplayMessage);
  9417. sendCostUpdatedConfirmation(uuid);
  9418. return result;
  9419. }
  9420. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  9421. {
  9422. mtrace();
  9423. int result = FAIL;
  9424. json_object *ClearVariableMonitorin;
  9425. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  9426. ClearVariableMonitorin = json_tokener_parse(payload);
  9427. if(!is_error(ClearVariableMonitorin))
  9428. {
  9429. // Required data
  9430. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  9431. {
  9432. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  9433. {
  9434. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  9435. /*
  9436. * TODO:
  9437. * 1. Check response
  9438. */
  9439. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  9440. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  9441. }
  9442. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  9443. }
  9444. }
  9445. json_object_put(ClearVariableMonitorin);
  9446. return result;
  9447. }
  9448. int handleCostUpdatedRequest(char *uuid, char *payload)
  9449. {
  9450. mtrace();
  9451. int result = FAIL;
  9452. json_object *CostUpdate;
  9453. DEBUG_INFO("handleCostUpdatedRequest...\n");
  9454. CostUpdate = json_tokener_parse(payload);
  9455. if(!is_error(CostUpdate))
  9456. {
  9457. // Required data
  9458. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  9459. {
  9460. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  9461. }
  9462. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  9463. {
  9464. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  9465. }
  9466. }
  9467. json_object_put(CostUpdate);
  9468. sendCostUpdatedConfirmation(uuid);
  9469. return result;
  9470. }
  9471. int handleCustomerInformationRequest(char *uuid, char *payload)
  9472. {
  9473. mtrace();
  9474. int result = FAIL;
  9475. json_object *CustomerInformation;
  9476. DEBUG_INFO("handleCustomerInformationRequest...\n");
  9477. CustomerInformation = json_tokener_parse(payload);
  9478. if(!is_error(CustomerInformation))
  9479. {
  9480. // Required data
  9481. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  9482. {
  9483. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  9484. }
  9485. if(json_object_object_get(CustomerInformation, "report") != NULL)
  9486. {
  9487. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  9488. }
  9489. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  9490. {
  9491. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  9492. }
  9493. // Optional data
  9494. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  9495. {
  9496. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  9497. {
  9498. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  9499. }
  9500. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  9501. {
  9502. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  9503. }
  9504. }
  9505. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  9506. {
  9507. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  9508. {
  9509. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  9510. }
  9511. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  9512. {
  9513. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  9514. }
  9515. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  9516. {
  9517. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  9518. }
  9519. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  9520. {
  9521. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  9522. }
  9523. }
  9524. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  9525. }
  9526. else
  9527. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  9528. json_object_put(CustomerInformation);
  9529. sendCustomerInformationConfirmation(uuid);
  9530. return result;
  9531. }
  9532. void createFirmwareVersionByDataTransfer(void)
  9533. {
  9534. json_object *FirmwareDataTransfer = json_object_new_object();
  9535. // AC & DC model
  9536. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  9537. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  9538. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  9539. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  9540. // DC model
  9541. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]!='O')
  9542. {
  9543. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  9544. {
  9545. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  9546. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  9547. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  9548. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  9549. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  9550. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  9551. }
  9552. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
  9553. ((gunType[1] != '0') || (gunType[2] != '0') || (gunType[3] != '0')))
  9554. {
  9555. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  9556. }
  9557. }
  9558. else
  9559. {
  9560. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  9561. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  9562. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  9563. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  9564. json_object_object_add(FirmwareDataTransfer, "DD0_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuBootLoadFwRev));
  9565. json_object_object_add(FirmwareDataTransfer, "DD0_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuKernelFwRev));
  9566. json_object_object_add(FirmwareDataTransfer, "DD0_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuRootFsFwRev));
  9567. json_object_object_add(FirmwareDataTransfer, "DD0_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuPrimFwRev));
  9568. json_object_object_add(FirmwareDataTransfer, "DD0_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].FanModuleFwRev));
  9569. json_object_object_add(FirmwareDataTransfer, "DD0_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].RelayModuleFwRev));
  9570. json_object_object_add(FirmwareDataTransfer, "DD0_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].LedModuleFwRev));
  9571. json_object_object_add(FirmwareDataTransfer, "DD0_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector1FwRev));
  9572. json_object_object_add(FirmwareDataTransfer, "DD0_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector2FwRev));
  9573. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev) > 0)
  9574. json_object_object_add(FirmwareDataTransfer, "DD1_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev));
  9575. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev) > 0)
  9576. json_object_object_add(FirmwareDataTransfer, "DD1_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev));
  9577. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev) > 0)
  9578. json_object_object_add(FirmwareDataTransfer, "DD1_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev));
  9579. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev) > 0)
  9580. json_object_object_add(FirmwareDataTransfer, "DD1_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev));
  9581. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev) > 0)
  9582. json_object_object_add(FirmwareDataTransfer, "DD1_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev));
  9583. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev) > 0)
  9584. json_object_object_add(FirmwareDataTransfer, "DD1_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev));
  9585. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev) > 0)
  9586. json_object_object_add(FirmwareDataTransfer, "DD1_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev));
  9587. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev) > 0)
  9588. json_object_object_add(FirmwareDataTransfer, "DD1_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev));
  9589. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev) > 0)
  9590. json_object_object_add(FirmwareDataTransfer, "DD1_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev));
  9591. }
  9592. // 4G model
  9593. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  9594. {
  9595. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  9596. }
  9597. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "Phihong Technology");
  9598. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion");
  9599. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, json_object_to_json_string(FirmwareDataTransfer));
  9600. }
  9601. int handleDataTransferRequest(char *uuid, char *payload)
  9602. {
  9603. mtrace();
  9604. int result = PASS;
  9605. DEBUG_INFO("handleDataTransferRequest...\n");
  9606. if((uuid != NULL) && (payload != NULL))
  9607. {
  9608. json_object *DataTransfer;
  9609. DataTransfer = json_tokener_parse(payload);
  9610. if(!is_error(DataTransfer))
  9611. {
  9612. // Required data
  9613. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  9614. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  9615. // Optional data
  9616. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  9617. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  9618. if(json_object_object_get(DataTransfer, "data") != NULL)
  9619. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  9620. result = PASS;
  9621. }
  9622. json_object_put(DataTransfer);
  9623. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  9624. {
  9625. // Send all moudle firmware version on EVSE
  9626. createFirmwareVersionByDataTransfer();
  9627. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9628. }
  9629. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_Tmate") != NULL)
  9630. {
  9631. system("/usr/bin/run_tmate_restart.sh &");
  9632. }
  9633. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  9634. {
  9635. json_object *data;
  9636. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  9637. if(!is_error(data))
  9638. {
  9639. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  9640. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  9641. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  9642. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  9643. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  9644. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  9645. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  9646. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  9647. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  9648. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  9649. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9650. }
  9651. else
  9652. {
  9653. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  9654. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  9655. }
  9656. json_object_put(data);
  9657. }
  9658. else
  9659. {
  9660. // Can not find valid message id
  9661. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9662. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  9663. ,ShmOCPP20Data->DataTransfer[0].vendorId
  9664. ,ShmOCPP20Data->DataTransfer[0].messageId
  9665. ,ShmOCPP20Data->DataTransfer[0].data);
  9666. }
  9667. }
  9668. else
  9669. {
  9670. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9671. result = FAIL;
  9672. }
  9673. sendDataTransferConfirmation(uuid, 0);
  9674. return result;
  9675. }
  9676. int handleDeleteCertificateRequest(char *uuid, char *payload)
  9677. {
  9678. mtrace();
  9679. int result = FAIL;
  9680. json_object *DeleteCertificate;
  9681. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  9682. DeleteCertificate = json_tokener_parse(payload);
  9683. if(!is_error(DeleteCertificate))
  9684. {
  9685. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  9686. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  9687. // Required data
  9688. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  9689. {
  9690. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  9691. {
  9692. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  9693. }
  9694. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  9695. {
  9696. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  9697. }
  9698. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  9699. {
  9700. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  9701. }
  9702. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  9703. {
  9704. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  9705. }
  9706. /*
  9707. * TODO:
  9708. * 1. Delete certification and response
  9709. */
  9710. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  9711. }
  9712. }
  9713. else
  9714. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  9715. json_object_put(DeleteCertificate);
  9716. sendDeleteCertificateConfirmation(uuid);
  9717. return result;
  9718. }
  9719. int handleGetBaseReportRequest(char *uuid, char *payload)
  9720. {
  9721. mtrace();
  9722. int result = FAIL;
  9723. json_object *GetBaseRepor;
  9724. DEBUG_INFO("handleGetBaseReportRequest...\n");
  9725. GetBaseRepor = json_tokener_parse(payload);
  9726. if(!is_error(GetBaseRepor))
  9727. {
  9728. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  9729. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  9730. // Required data
  9731. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  9732. {
  9733. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  9734. }
  9735. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  9736. {
  9737. sprintf((char*)ShmOCPP20Data->GetBaseReport.reportBase, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  9738. }
  9739. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  9740. }
  9741. else
  9742. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  9743. json_object_put(GetBaseRepor);
  9744. sendGetBaseReportConfirmation(uuid);
  9745. return result;
  9746. }
  9747. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  9748. {
  9749. mtrace();
  9750. int result = FAIL;
  9751. int gun_index = -1;
  9752. json_object *GetChargingProfiles;
  9753. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  9754. GetChargingProfiles = json_tokener_parse(payload);
  9755. if(!is_error(GetChargingProfiles))
  9756. {
  9757. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  9758. {
  9759. 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;
  9760. }
  9761. if(gun_index >-1)
  9762. {
  9763. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  9764. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  9765. // Required data
  9766. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  9767. {
  9768. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  9769. }
  9770. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  9771. {
  9772. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  9773. {
  9774. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  9775. }
  9776. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  9777. {
  9778. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  9779. }
  9780. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  9781. {
  9782. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  9783. {
  9784. 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)));
  9785. }
  9786. }
  9787. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  9788. {
  9789. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  9790. {
  9791. 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));
  9792. }
  9793. }
  9794. }
  9795. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  9796. }
  9797. else
  9798. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  9799. }
  9800. json_object_put(GetChargingProfiles);
  9801. sendGetChargingProfilesConfirmation(uuid, gun_index);
  9802. return result;
  9803. }
  9804. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  9805. {
  9806. mtrace();
  9807. int result = FAIL;
  9808. int connectorIdInt, durationInt;
  9809. char chargingRateUnitStr[4]={0};
  9810. char comfirmstr[20];
  9811. int confirmPeriods = 0;
  9812. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  9813. json_object *GetCompositeSchedule;
  9814. GetCompositeSchedule = json_tokener_parse(payload);
  9815. if(!is_error(GetCompositeSchedule))
  9816. {
  9817. // Required data
  9818. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  9819. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  9820. else
  9821. connectorIdInt = -1;
  9822. if(json_object_object_get(GetCompositeSchedule, "duration"))
  9823. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  9824. else
  9825. durationInt = 86400;
  9826. // Optional data
  9827. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  9828. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  9829. }
  9830. json_object_put(GetCompositeSchedule);
  9831. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  9832. if((connectorIdInt == 0) ||
  9833. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  9834. {
  9835. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  9836. struct ChargingProfileType tmpProfile[1];
  9837. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  9838. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  9839. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0]);
  9840. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  9841. {
  9842. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  9843. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  9844. }
  9845. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  9846. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  9847. {
  9848. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  9849. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  9850. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  9851. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0))
  9852. {
  9853. confirmPeriods = idx;
  9854. break;
  9855. }
  9856. }
  9857. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  9858. }
  9859. else
  9860. {
  9861. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  9862. }
  9863. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  9864. return result;
  9865. }
  9866. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  9867. {
  9868. mtrace();
  9869. int result = FAIL;
  9870. json_object *GetDisplayMessages;
  9871. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  9872. GetDisplayMessages = json_tokener_parse(payload);
  9873. if(!is_error(GetDisplayMessages))
  9874. {
  9875. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  9876. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  9877. // Required data
  9878. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  9879. {
  9880. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  9881. }
  9882. // Optional data
  9883. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  9884. {
  9885. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  9886. }
  9887. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  9888. {
  9889. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  9890. }
  9891. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  9892. {
  9893. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  9894. {
  9895. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  9896. }
  9897. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  9898. }
  9899. else
  9900. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  9901. }
  9902. json_object_put(GetDisplayMessages);
  9903. return result;
  9904. }
  9905. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  9906. {
  9907. mtrace();
  9908. int result = FAIL;
  9909. json_object *GetInstalledCertificateIds;
  9910. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  9911. GetInstalledCertificateIds = json_tokener_parse(payload);
  9912. if(!is_error(GetInstalledCertificateIds))
  9913. {
  9914. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  9915. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  9916. // Optional data
  9917. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  9918. {
  9919. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  9920. {
  9921. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  9922. /*
  9923. * TODO:
  9924. * 1. Get installed certificate info for response
  9925. */
  9926. }
  9927. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  9928. }
  9929. else
  9930. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  9931. }
  9932. json_object_put(GetInstalledCertificateIds);
  9933. sendInstallCertificateConfirmation(uuid);
  9934. return result;
  9935. }
  9936. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  9937. {
  9938. mtrace();
  9939. int result = FAIL;
  9940. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  9941. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  9942. {
  9943. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  9944. localversion = -1;
  9945. }
  9946. else
  9947. {
  9948. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  9949. DB_getListVerion();
  9950. }
  9951. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  9952. sendGetLocalListVersionConfirmation(uuid);
  9953. return result;
  9954. }
  9955. static char fnamePlusPath[100]={0};
  9956. static char fnamePWithNoPath[60]={0};
  9957. void checkUploadLog(void)
  9958. {
  9959. FILE *fp;
  9960. /* Open the command for reading. */
  9961. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  9962. if (fp == NULL) {
  9963. printf("Failed to run command\n" );
  9964. exit(1);
  9965. }
  9966. int ftppathlen = 0;
  9967. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  9968. int i = 0;
  9969. /* Read the output a line at a time - output it. */
  9970. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  9971. if(i==0)
  9972. {
  9973. ftppathlen = strlen(fnamePlusPath);
  9974. printf("%s\n", fnamePlusPath);
  9975. fnamePlusPath[ftppathlen]='\0';
  9976. break;
  9977. }
  9978. i= i+1;
  9979. }
  9980. /* close */
  9981. pclose(fp);
  9982. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  9983. {
  9984. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  9985. {
  9986. fnamePlusPath[k]='\0';
  9987. }
  9988. }
  9989. i=1;
  9990. //char fname[60]={0};
  9991. while(i < ftppathlen)
  9992. {
  9993. int len=ftppathlen-i;
  9994. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  9995. {
  9996. printf("compare '/' all right\n");
  9997. break;
  9998. }
  9999. i=i+1;
  10000. }
  10001. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  10002. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  10003. fnamePWithNoPath[i+1] = '\0';
  10004. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  10005. {
  10006. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  10007. {
  10008. fnamePWithNoPath[j]='\0';
  10009. }
  10010. }
  10011. FILE* fp1 = fopen(fnamePlusPath, "r");
  10012. if (fp1)
  10013. {
  10014. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  10015. // file exists
  10016. fclose(fp1);
  10017. }
  10018. else
  10019. {
  10020. // file doesn't exist
  10021. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  10022. }
  10023. }
  10024. void* GetLogProcess(void* data)
  10025. {
  10026. pthread_detach(pthread_self());
  10027. mtrace();
  10028. int requestId, retriesInt=0, retryIntervalInt=0;
  10029. char logType[32], remoteLocation[512]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  10030. 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};
  10031. int port=0;
  10032. int isSuccess = FALSE;
  10033. char ftpbuf[200]={0};
  10034. json_object *GetLog;
  10035. DEBUG_INFO("GetGetProcess...\n");
  10036. GetLog = json_tokener_parse(data);
  10037. if(!is_error(GetLog))
  10038. {
  10039. // Required data
  10040. if(json_object_object_get(GetLog, "requestId") != NULL)
  10041. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  10042. if(json_object_object_get(GetLog, "logType") != NULL)
  10043. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  10044. if(json_object_object_get(GetLog, "log") != NULL)
  10045. {
  10046. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  10047. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  10048. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  10049. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  10050. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  10051. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  10052. }
  10053. // Optional data
  10054. if(json_object_object_get(GetLog, "retries") != NULL)
  10055. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  10056. else
  10057. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  10058. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  10059. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  10060. else
  10061. retryIntervalInt = 30;
  10062. }
  10063. json_object_put(GetLog);
  10064. ShmOCPP20Data->GetLog.requestId = requestId;
  10065. //****************location*******************/
  10066. if(strcmp(remoteLocation,"")==0)
  10067. {
  10068. DEBUG_INFO("remoteLocation is <Empty>!\n");
  10069. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10070. goto end;
  10071. }
  10072. memset(protocol, 0, ARRAY_SIZE(protocol));
  10073. memset(user, 0, ARRAY_SIZE(user) );
  10074. memset(password, 0, ARRAY_SIZE(password));
  10075. memset(host, 0, ARRAY_SIZE(host));
  10076. memset(path, 0, ARRAY_SIZE(path));
  10077. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  10078. memset(host1, 0, ARRAY_SIZE(host1));
  10079. memset(path1, 0, ARRAY_SIZE(path1));
  10080. /*location: ftp://user:password@host:port/path*/
  10081. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  10082. if((access(fnamePlusPath,F_OK))!=-1)
  10083. {
  10084. DEBUG_INFO("fnamePlusPath exist.\n");
  10085. }
  10086. else
  10087. {
  10088. DEBUG_INFO("fnamePlusPath not exist!\n");
  10089. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10090. goto end;
  10091. }
  10092. if(strchr(remoteLocation,'@')==NULL)
  10093. {
  10094. sscanf(remoteLocation,
  10095. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  10096. protocol, host, &port, path);
  10097. strcpy(user,"anonymous");
  10098. strcpy(password,"");
  10099. }
  10100. else
  10101. {
  10102. //DEBUG_INFO("pch=%s\n", pch);
  10103. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  10104. protocol, user, password, host, &port, path);
  10105. }
  10106. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
  10107. {
  10108. DEBUG_INFO("protocol is not ftp/http ! \n");
  10109. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10110. goto end;
  10111. }
  10112. if(strncmp(remoteLocation,"http", 4) == 0)
  10113. {
  10114. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  10115. sprintf(ftppath,"/%s", path);
  10116. do
  10117. {
  10118. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  10119. sleep(3);
  10120. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  10121. if(!isSuccess)
  10122. {
  10123. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  10124. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10125. sleep(retryIntervalInt);
  10126. }
  10127. else
  10128. {
  10129. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  10130. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  10131. }
  10132. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt--));
  10133. }
  10134. else
  10135. {
  10136. sscanf(host,"%[^/]%s",host1, path1);
  10137. sprintf(ftppath,"%s", path1);
  10138. int ftppathlen=strlen(ftppath);
  10139. int i=1;
  10140. char filenametemp[50];
  10141. while(i < ftppathlen)
  10142. {
  10143. int len=ftppathlen-i;
  10144. if(ftppath[len]== 47) // '/' ascll code: 47
  10145. {
  10146. DEBUG_INFO("find '/' all right\n");
  10147. break;
  10148. }
  10149. i=i+1;
  10150. }
  10151. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  10152. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  10153. filenametemp[i+1] = 0;
  10154. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  10155. if(port == 0)
  10156. port = 21;
  10157. do
  10158. {
  10159. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  10160. sleep(3);
  10161. isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  10162. if(!isSuccess)
  10163. {
  10164. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  10165. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10166. sleep(retryIntervalInt);
  10167. }
  10168. else
  10169. {
  10170. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  10171. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  10172. }
  10173. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  10174. }
  10175. end:
  10176. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  10177. pthread_exit(NULL);
  10178. }
  10179. int handleGetLogRequest(char *uuid, char *payload)
  10180. {
  10181. mtrace();
  10182. int result = FAIL;
  10183. char cmdBuf[512];
  10184. char fName[258];
  10185. time_t CurrentTime;
  10186. struct tm *tm;
  10187. pthread_t th_Status;
  10188. CurrentTime = time(NULL);
  10189. tm = localtime(&CurrentTime);
  10190. 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);
  10191. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  10192. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  10193. sendGetLogConfirmation(uuid);
  10194. system("exec /root/logPackTools 'log' 6");
  10195. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", fName);
  10196. system(cmdBuf);
  10197. checkUploadLog();
  10198. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  10199. return result;
  10200. }
  10201. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  10202. {
  10203. mtrace();
  10204. int result = FAIL;
  10205. json_object *GetMonitoringReport;
  10206. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  10207. GetMonitoringReport = json_tokener_parse(payload);
  10208. if(!is_error(GetMonitoringReport))
  10209. {
  10210. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  10211. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  10212. // Required data
  10213. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  10214. {
  10215. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  10216. }
  10217. // Optional data
  10218. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  10219. {
  10220. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  10221. }
  10222. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  10223. {
  10224. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  10225. {
  10226. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  10227. {
  10228. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  10229. {
  10230. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  10231. {
  10232. 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")));
  10233. }
  10234. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10235. {
  10236. 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")));
  10237. }
  10238. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10239. {
  10240. 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)
  10241. {
  10242. 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"));
  10243. }
  10244. 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)
  10245. {
  10246. 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"));
  10247. }
  10248. }
  10249. }
  10250. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  10251. {
  10252. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10253. {
  10254. 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")));
  10255. }
  10256. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10257. {
  10258. 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")));
  10259. }
  10260. }
  10261. }
  10262. }
  10263. }
  10264. }
  10265. json_object_put(GetMonitoringReport);
  10266. /*
  10267. * TODO:
  10268. * 1. Response result
  10269. */
  10270. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10271. sendGetMonitoringReportConfirmation(uuid);
  10272. return result;
  10273. }
  10274. int handleGetReportRequest(char *uuid, char *payload)
  10275. {
  10276. mtrace();
  10277. int result = FAIL;
  10278. json_object *GetReport;
  10279. DEBUG_INFO("handleGetReportRequest...\n");
  10280. GetReport = json_tokener_parse(payload);
  10281. if(!is_error(GetReport))
  10282. {
  10283. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  10284. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  10285. // Required data
  10286. if(json_object_object_get(GetReport, "requestId") != NULL)
  10287. {
  10288. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  10289. }
  10290. // Optional data
  10291. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  10292. {
  10293. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  10294. }
  10295. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  10296. {
  10297. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  10298. {
  10299. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  10300. {
  10301. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  10302. {
  10303. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  10304. {
  10305. 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")));
  10306. }
  10307. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10308. {
  10309. 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")));
  10310. }
  10311. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10312. {
  10313. 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)
  10314. {
  10315. 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"));
  10316. }
  10317. 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)
  10318. {
  10319. 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"));
  10320. }
  10321. }
  10322. }
  10323. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  10324. {
  10325. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10326. {
  10327. 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")));
  10328. }
  10329. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10330. {
  10331. 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")));
  10332. }
  10333. }
  10334. }
  10335. }
  10336. }
  10337. }
  10338. json_object_put(GetReport);
  10339. /*
  10340. * TODO:
  10341. * 1. Response result
  10342. */
  10343. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10344. sendGetReportConfirmation(uuid);
  10345. return result;
  10346. }
  10347. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  10348. {
  10349. mtrace();
  10350. int result = FAIL;
  10351. int8_t gun_index = -1;
  10352. json_object *GetTransactionStatus;
  10353. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  10354. GetTransactionStatus = json_tokener_parse(payload);
  10355. if(!is_error(GetTransactionStatus))
  10356. {
  10357. /*
  10358. * TODO:
  10359. * 1. Check transaction locate which connector
  10360. */
  10361. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  10362. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  10363. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  10364. {
  10365. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  10366. }
  10367. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  10368. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  10369. }
  10370. json_object_put(GetTransactionStatus);
  10371. sendGetTransactionStatusConfirmation(uuid, gun_index);
  10372. return result;
  10373. }
  10374. int handleGetVariablesRequest(char *uuid, char *payload)
  10375. {
  10376. mtrace();
  10377. int result = FAIL;
  10378. json_object *GetVariables;
  10379. DEBUG_INFO("handleGetVariablesRequest...\n");
  10380. GetVariables = json_tokener_parse(payload);
  10381. if(!is_error(GetVariables))
  10382. {
  10383. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  10384. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  10385. // Required data
  10386. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  10387. {
  10388. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  10389. {
  10390. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  10391. {
  10392. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  10393. {
  10394. 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")));
  10395. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  10396. }
  10397. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  10398. {
  10399. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  10400. {
  10401. 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")));
  10402. }
  10403. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  10404. {
  10405. 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")));
  10406. }
  10407. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  10408. {
  10409. 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)
  10410. {
  10411. 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"));
  10412. }
  10413. 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)
  10414. {
  10415. 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"));
  10416. }
  10417. }
  10418. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  10419. }
  10420. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  10421. {
  10422. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  10423. {
  10424. 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")));
  10425. }
  10426. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  10427. {
  10428. 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")));
  10429. }
  10430. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  10431. }
  10432. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  10433. {
  10434. if((strstr((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) != NULL) &&
  10435. (strlen((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance)>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.instance) != NULL):TRUE) &&
  10436. (strstr((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) != NULL) &&
  10437. (strlen((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance)>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.instance, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.instance) != NULL):TRUE))
  10438. {
  10439. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  10440. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type);
  10441. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  10442. }
  10443. else
  10444. {
  10445. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  10446. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  10447. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  10448. }
  10449. }
  10450. }
  10451. }
  10452. }
  10453. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  10454. }
  10455. json_object_put(GetVariables);
  10456. return result;
  10457. }
  10458. int handleInstallCertificateRequest(char *uuid, char *payload)
  10459. {
  10460. mtrace();
  10461. int result = FAIL;
  10462. json_object *InstallCertificate;
  10463. DEBUG_INFO("handleInstallCertificateRequest...\n");
  10464. InstallCertificate = json_tokener_parse(payload);
  10465. if(!is_error(InstallCertificate))
  10466. {
  10467. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  10468. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  10469. // Required data
  10470. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  10471. {
  10472. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  10473. }
  10474. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  10475. {
  10476. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  10477. }
  10478. }
  10479. json_object_put(InstallCertificate);
  10480. /*
  10481. * TODO:
  10482. * 1. Install certification preocess and response
  10483. */
  10484. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10485. sendInstallCertificateConfirmation(uuid);
  10486. return result;
  10487. }
  10488. int handlePublishFirmwareRequest(char *uuid, char *payload)
  10489. {
  10490. mtrace();
  10491. int result = FAIL;
  10492. json_object *PublishFirmware;
  10493. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  10494. PublishFirmware = json_tokener_parse(payload);
  10495. if(!is_error(PublishFirmware))
  10496. {
  10497. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  10498. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  10499. // Required data
  10500. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  10501. {
  10502. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  10503. }
  10504. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  10505. {
  10506. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  10507. }
  10508. // Optional data
  10509. if(json_object_object_get(PublishFirmware, "location") != NULL)
  10510. {
  10511. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  10512. }
  10513. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  10514. {
  10515. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  10516. }
  10517. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  10518. {
  10519. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  10520. }
  10521. }
  10522. json_object_put(PublishFirmware);
  10523. /*
  10524. * TODO:
  10525. * 1. Publish firmware preocess and response
  10526. */
  10527. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10528. sendPublishFirmwareConfirmation(uuid);
  10529. return result;
  10530. }
  10531. int handleRemoteStartTransactionRequest(char *uuid, char *payload)
  10532. {
  10533. mtrace();
  10534. int result = FAIL;
  10535. int8_t gun_index = -1;
  10536. uint8_t isPeriodOverMax = FALSE;
  10537. uint8_t isProfileOverMax = FALSE;
  10538. uint8_t isConnectorMismatch = FALSE;
  10539. uint8_t isTxProfile = FALSE;
  10540. uint8_t existProfileQuantity = 0;
  10541. uint8_t filename[128]={0};
  10542. uint8_t word[2048]={0};
  10543. FILE *filePtr;
  10544. json_object *RemoteStartTransaction;
  10545. DEBUG_INFO("handleRemoteStartTransactionRequest...\n");
  10546. RemoteStartTransaction = json_tokener_parse(payload);
  10547. if(!is_error(RemoteStartTransaction))
  10548. {
  10549. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  10550. {
  10551. gun_index = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
  10552. }
  10553. else
  10554. {
  10555. /*
  10556. * TODO:
  10557. * 1. Selected connector process
  10558. */
  10559. gun_index = 0;
  10560. }
  10561. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  10562. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  10563. // Required data
  10564. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  10565. {
  10566. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  10567. }
  10568. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  10569. {
  10570. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  10571. {
  10572. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  10573. }
  10574. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  10575. {
  10576. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  10577. }
  10578. }
  10579. // Optional data
  10580. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  10581. {
  10582. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  10583. {
  10584. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  10585. }
  10586. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  10587. {
  10588. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  10589. }
  10590. }
  10591. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  10592. {
  10593. // Check periods is over max configuration
  10594. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  10595. {
  10596. isPeriodOverMax = TRUE;
  10597. }
  10598. // Check periods is over max configuration
  10599. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  10600. {
  10601. if(gun_index > 0)
  10602. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  10603. else
  10604. isConnectorMismatch = TRUE;
  10605. if(!isConnectorMismatch)
  10606. {
  10607. filePtr = fopen((char*)filename, "r");
  10608. if (!filePtr)
  10609. {
  10610. DEBUG_INFO("%s not exist, create it.\n", filename);
  10611. filePtr = fopen((char*)filename, "w+");
  10612. }
  10613. else
  10614. {
  10615. //Check Charging Profile Count
  10616. while(fscanf(filePtr, "%s", word) != EOF)
  10617. {
  10618. //DEBUG_INFO("word=%s\n",word);
  10619. if(strstr((char*)word, "chargingProfileId")!= NULL)
  10620. {
  10621. existProfileQuantity += 1;
  10622. }
  10623. }
  10624. }
  10625. fclose(filePtr);
  10626. }
  10627. }
  10628. else
  10629. {
  10630. }
  10631. if(existProfileQuantity > 3)
  10632. isProfileOverMax = TRUE;
  10633. }
  10634. // Profile replace or add info
  10635. if((gun_index > 0) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTxProfile)
  10636. {
  10637. FILE *infile;
  10638. FILE *outfile;
  10639. char tmpProfileName[32];
  10640. char rmFileCmd[128];
  10641. char tempchargingProfilePurposeStr[30]={0};
  10642. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  10643. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfileRemote");
  10644. infile = fopen ((char*)filename, "r");
  10645. outfile = fopen ((char*)tmpProfileName, "w");
  10646. int d = fgetc(infile);
  10647. rewind(infile);
  10648. if(d == EOF)
  10649. {
  10650. // Profile is empty
  10651. fprintf(outfile,"%s\n", payload);
  10652. fclose(infile);
  10653. fclose(outfile);
  10654. sprintf(rmFileCmd,"rm -f %s",filename);
  10655. system(rmFileCmd);
  10656. rename((char*)tmpProfileName, (char*)filename);
  10657. }
  10658. else
  10659. {
  10660. // Profile is not empty
  10661. char buf[2048]={0};
  10662. int ChargingProfileAdded = FALSE;
  10663. while (fgets(buf, sizeof(buf), infile) != NULL)
  10664. {
  10665. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  10666. json_object *tmpChargingProfile;
  10667. tmpChargingProfile = json_tokener_parse(buf);
  10668. if(!is_error(tmpChargingProfile))
  10669. {
  10670. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  10671. {
  10672. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  10673. }
  10674. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  10675. {
  10676. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  10677. {
  10678. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  10679. }
  10680. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  10681. {
  10682. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  10683. }
  10684. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  10685. {
  10686. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  10687. }
  10688. }
  10689. }
  10690. json_object_put(tmpChargingProfile);
  10691. if((tempconnectorIdInt == gun_index) &&
  10692. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId"))))
  10693. {
  10694. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel"))) &&
  10695. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  10696. {
  10697. if(ChargingProfileAdded == FALSE)
  10698. {
  10699. fprintf(outfile,"%s\n",payload);
  10700. ChargingProfileAdded = TRUE;
  10701. }
  10702. }
  10703. else
  10704. {
  10705. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10706. {
  10707. if(ChargingProfileAdded == FALSE)
  10708. {
  10709. fprintf(outfile,"%s\n",buf);
  10710. fprintf(outfile,"%s\n",payload);
  10711. ChargingProfileAdded = TRUE;
  10712. }
  10713. else
  10714. {
  10715. fprintf(outfile,"%s\n",buf);
  10716. }
  10717. }
  10718. else
  10719. {
  10720. if(ChargingProfileAdded == FALSE)
  10721. {
  10722. fprintf(outfile,"%s\n",buf);
  10723. fprintf(outfile,"%s\n",payload);
  10724. ChargingProfileAdded = TRUE;
  10725. }
  10726. else
  10727. {
  10728. fprintf(outfile,"%s\n",buf);
  10729. }
  10730. }
  10731. }
  10732. }
  10733. else
  10734. {
  10735. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId")))
  10736. {
  10737. if(ChargingProfileAdded == FALSE)
  10738. {
  10739. fprintf(outfile,"%s\n",buf);
  10740. fprintf(outfile,"%s\n",payload);
  10741. ChargingProfileAdded = TRUE;
  10742. }
  10743. else
  10744. {
  10745. fprintf(outfile,"%s\n",buf);
  10746. }
  10747. }
  10748. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10749. {
  10750. if(ChargingProfileAdded == FALSE)
  10751. {
  10752. fprintf(outfile,"%s\n",buf);
  10753. fprintf(outfile,"%s\n",payload);
  10754. ChargingProfileAdded = TRUE;
  10755. }
  10756. else
  10757. {
  10758. fprintf(outfile,"%s\n",buf);
  10759. }
  10760. }
  10761. else
  10762. {
  10763. if(ChargingProfileAdded == FALSE)
  10764. {
  10765. fprintf(outfile,"%s\n",buf);
  10766. fprintf(outfile,"%s\n",payload);
  10767. ChargingProfileAdded = TRUE;
  10768. }
  10769. else
  10770. {
  10771. fprintf(outfile,"%s\n",buf);
  10772. }
  10773. }
  10774. }
  10775. } // end of while loop
  10776. fclose(infile);
  10777. fclose(outfile);
  10778. sprintf(rmFileCmd,"rm -f %s",filename);
  10779. system(rmFileCmd);
  10780. rename((char*)tmpProfileName, (char*)filename);
  10781. }
  10782. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted] );
  10783. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_transactionId);
  10784. result = PASS;
  10785. }
  10786. else
  10787. {
  10788. if(gun_index <= 0)
  10789. DEBUG_WARN("Connector id is wrong.\n");
  10790. if(isConnectorMismatch)
  10791. DEBUG_WARN("Connector id is mismatch.\n");
  10792. if(isPeriodOverMax)
  10793. DEBUG_WARN("Profile periods quantity is over spec.\n");
  10794. if(isProfileOverMax)
  10795. DEBUG_WARN("Profile quantity is over spec.\n");
  10796. if(!isTxProfile)
  10797. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  10798. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  10799. }
  10800. }
  10801. json_object_put(RemoteStartTransaction);
  10802. sendRemoteStartTransactionConfirmation(uuid, gun_index);
  10803. return result;
  10804. }
  10805. int handleRemoteStopTransactionRequest(char *uuid, char *payload)
  10806. {
  10807. mtrace();
  10808. int result = FAIL;
  10809. int match = FALSE;
  10810. int GunNO = 0;
  10811. int tempIndex = 0;
  10812. char transactionIdStr[37];
  10813. int transactionIdIsNULL= TRUE;
  10814. json_object *RemoteStopTransaction;
  10815. DEBUG_INFO("handleRemoteStopTransactionRequest...\n");
  10816. if(server_pending == TRUE)
  10817. {
  10818. return 0;
  10819. }
  10820. RemoteStopTransaction = json_tokener_parse(payload);
  10821. if(!is_error(RemoteStopTransaction))
  10822. {
  10823. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  10824. {
  10825. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  10826. transactionIdIsNULL = FALSE;
  10827. }
  10828. }
  10829. json_object_put(RemoteStopTransaction);
  10830. if(transactionIdIsNULL == FALSE)
  10831. {
  10832. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  10833. {
  10834. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  10835. {
  10836. //check Transaction active
  10837. if(gunType[gun_index] == 'J')
  10838. {
  10839. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10840. {
  10841. tempIndex = ((gun_index==2) ? 1: 0);
  10842. }
  10843. else
  10844. {
  10845. tempIndex = gun_index;
  10846. }
  10847. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10848. {
  10849. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  10850. {
  10851. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10852. {
  10853. match = TRUE;
  10854. GunNO = gun_index;
  10855. }
  10856. }
  10857. }// END FOR CHAdeMO_QUANTITY
  10858. }
  10859. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  10860. {
  10861. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10862. {
  10863. tempIndex = ((gun_index==2) ? 1: 0);
  10864. }
  10865. else
  10866. {
  10867. tempIndex = gun_index;
  10868. }
  10869. for (int index = 0; index < CCS_QUANTITY; index++)
  10870. {
  10871. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  10872. {
  10873. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10874. {
  10875. match = TRUE;
  10876. GunNO = gun_index;
  10877. }
  10878. }
  10879. }// END FOR CCS_QUANTITY
  10880. }
  10881. else if(gunType[gun_index] == 'G')
  10882. {
  10883. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10884. {
  10885. tempIndex = ((gun_index==2) ? 1: 0);
  10886. }
  10887. else
  10888. {
  10889. tempIndex = gun_index;
  10890. }
  10891. for (int index = 0; index < GB_QUANTITY; index++)
  10892. {
  10893. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  10894. {
  10895. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10896. {
  10897. match = TRUE;
  10898. GunNO = gun_index;
  10899. }
  10900. }
  10901. }// END FOR GB_QUANTITY
  10902. }
  10903. else if(gunType[gun_index] == 'O')
  10904. {
  10905. tempIndex = gun_index;
  10906. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10907. {
  10908. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  10909. {
  10910. 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
  10911. {
  10912. match = TRUE;
  10913. GunNO = gun_index;
  10914. }
  10915. }
  10916. }// END FOR GB_QUANTITY
  10917. }
  10918. else
  10919. {
  10920. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10921. {
  10922. tempIndex = 2;
  10923. }
  10924. else
  10925. {
  10926. tempIndex = gun_index;
  10927. }
  10928. for (int index = 0; index < AC_QUANTITY; index++)
  10929. {
  10930. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  10931. {
  10932. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10933. {
  10934. match = TRUE;
  10935. GunNO = gun_index;
  10936. }
  10937. }
  10938. }// END FOR CHAdeMO_QUANTITY
  10939. } // END FOR AC ELSE
  10940. }// CHECK IF ResponseTransactionId == transactionIdInt
  10941. }//END FOR
  10942. if( match == TRUE)
  10943. {
  10944. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  10945. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  10946. }
  10947. else
  10948. {
  10949. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  10950. }
  10951. }
  10952. else
  10953. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  10954. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  10955. return result;
  10956. }
  10957. int handleReserveNowRequest(char *uuid, char *payload)
  10958. {
  10959. mtrace();
  10960. int result = FAIL;
  10961. int connectorIdInt=0, reservationIdInt=0;
  10962. int tempIndex = 0;
  10963. json_object *ReserveNow;
  10964. DEBUG_INFO("handleReserveNowRequest ...\n");
  10965. ReserveNow = json_tokener_parse(payload);
  10966. if(!is_error(ReserveNow))
  10967. {
  10968. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  10969. {
  10970. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  10971. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  10972. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  10973. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  10974. }
  10975. // Required data
  10976. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  10977. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  10978. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  10979. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  10980. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  10981. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  10982. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  10983. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  10984. // Optional data
  10985. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  10986. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  10987. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  10988. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  10989. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  10990. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  10991. result = PASS;
  10992. }
  10993. json_object_put(ReserveNow);
  10994. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10995. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  10996. {
  10997. //check Transaction active
  10998. if(gunType[connectorIdInt -1] == 'J')
  10999. {
  11000. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11001. {
  11002. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11003. }
  11004. else
  11005. {
  11006. tempIndex = connectorIdInt -1;
  11007. }
  11008. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11009. {
  11010. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  11011. {
  11012. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  11013. {
  11014. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  11015. {
  11016. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11017. {
  11018. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11019. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11020. }
  11021. 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'))
  11022. {
  11023. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11024. }
  11025. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11026. {
  11027. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11028. }
  11029. else
  11030. {
  11031. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11032. }
  11033. }
  11034. 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
  11035. {
  11036. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11037. }
  11038. }
  11039. else
  11040. {
  11041. //replace reservation
  11042. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11043. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11044. }
  11045. }
  11046. } // END FOR CHAdeMO_QUANTITY
  11047. }
  11048. else if((gunType[connectorIdInt -1] == 'U')||(gunType[connectorIdInt -1] == 'E'))
  11049. {
  11050. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11051. {
  11052. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11053. }
  11054. else
  11055. {
  11056. tempIndex = connectorIdInt -1;
  11057. }
  11058. for (int index = 0; index < CCS_QUANTITY; index++)
  11059. {
  11060. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  11061. {
  11062. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  11063. {
  11064. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11065. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  11066. {
  11067. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11068. {
  11069. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11070. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11071. }
  11072. 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'))
  11073. {
  11074. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11075. }
  11076. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  11077. {
  11078. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11079. }
  11080. else
  11081. {
  11082. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11083. }
  11084. }
  11085. 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
  11086. {
  11087. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11088. }
  11089. }
  11090. else
  11091. {
  11092. //replace reservation
  11093. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11094. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11095. }
  11096. }
  11097. } // END FOR CCS_QUANTITY
  11098. }
  11099. else if(gunType[connectorIdInt -1] == 'G')
  11100. {
  11101. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11102. {
  11103. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11104. }
  11105. else
  11106. {
  11107. tempIndex = connectorIdInt -1;
  11108. }
  11109. for (int index = 0; index < GB_QUANTITY; index++)
  11110. {
  11111. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  11112. {
  11113. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  11114. {
  11115. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11116. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11117. {
  11118. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11119. {
  11120. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11121. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11122. }
  11123. 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'))
  11124. {
  11125. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11126. }
  11127. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11128. {
  11129. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11130. }
  11131. else
  11132. {
  11133. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11134. }
  11135. }
  11136. 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
  11137. {
  11138. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11139. }
  11140. }
  11141. else
  11142. {
  11143. //replace reservation
  11144. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11145. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11146. }
  11147. }
  11148. }// END FOR GB_QUANTITY
  11149. }
  11150. else
  11151. {
  11152. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11153. {
  11154. tempIndex = 2;
  11155. }
  11156. else
  11157. {
  11158. tempIndex = (connectorIdInt -1);
  11159. }
  11160. for (int index = 0; index < AC_QUANTITY; index++)
  11161. {
  11162. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  11163. {
  11164. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11165. {
  11166. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11167. {
  11168. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11169. {
  11170. 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))
  11171. {
  11172. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11173. }
  11174. else
  11175. {
  11176. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11177. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11178. }
  11179. }
  11180. 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'))
  11181. {
  11182. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11183. }
  11184. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11185. {
  11186. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11187. }
  11188. else
  11189. {
  11190. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11191. }
  11192. }
  11193. 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
  11194. {
  11195. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11196. }
  11197. }
  11198. else
  11199. {
  11200. //replace reservation
  11201. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11202. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11203. }
  11204. }
  11205. } // END FOR AC_QUANTITY
  11206. }
  11207. }
  11208. else if(connectorIdInt == 0)
  11209. {
  11210. //check Transaction active
  11211. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11212. {
  11213. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  11214. {
  11215. 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'))
  11216. {
  11217. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11218. goto end;
  11219. }
  11220. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11221. {
  11222. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11223. goto end;
  11224. }
  11225. 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
  11226. {
  11227. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11228. goto end;
  11229. }
  11230. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11231. {
  11232. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11233. goto end;
  11234. }
  11235. }
  11236. }// END FOR CHAdeMO_QUANTITY
  11237. for (int index = 0; index < CCS_QUANTITY; index++)
  11238. {
  11239. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  11240. {
  11241. 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'))
  11242. {
  11243. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11244. goto end;
  11245. }
  11246. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  11247. {
  11248. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11249. goto end;
  11250. }
  11251. 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
  11252. {
  11253. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11254. goto end;
  11255. }
  11256. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11257. {
  11258. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11259. goto end;
  11260. }
  11261. }
  11262. } // END FOR CCS_QUANTITY
  11263. for (int index = 0; index < GB_QUANTITY; index++)
  11264. {
  11265. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  11266. {
  11267. 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'))
  11268. {
  11269. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11270. goto end;
  11271. }
  11272. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11273. {
  11274. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11275. goto end;
  11276. }
  11277. 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
  11278. {
  11279. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11280. goto end;
  11281. }
  11282. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11283. {
  11284. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11285. goto end;
  11286. }
  11287. }
  11288. } // END FOR GB_QUANTITY
  11289. for (int index = 0; index < AC_QUANTITY; index++)
  11290. {
  11291. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11292. {
  11293. 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'))
  11294. {
  11295. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11296. goto end;
  11297. }
  11298. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11299. {
  11300. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11301. goto end;
  11302. }
  11303. 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
  11304. {
  11305. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11306. goto end;
  11307. }
  11308. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11309. {
  11310. 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))
  11311. {
  11312. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11313. goto end;
  11314. }
  11315. }
  11316. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11317. {
  11318. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11319. goto end;
  11320. }
  11321. }
  11322. }// END FOR AC_QUANTITY
  11323. //The connectorId is 0
  11324. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  11325. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11326. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  11327. result = TRUE;
  11328. return result;
  11329. }
  11330. else
  11331. {
  11332. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11333. }
  11334. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  11335. {
  11336. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  11337. result = TRUE;
  11338. return result;
  11339. }
  11340. end:
  11341. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  11342. return result;
  11343. }
  11344. int handleResetRequest(char *uuid, char *payload)
  11345. {
  11346. mtrace();
  11347. int result = FAIL;
  11348. json_object *Reset = json_object_new_object();
  11349. DEBUG_INFO("handleResetRequest...\n");
  11350. Reset = json_tokener_parse(payload);
  11351. if(!is_error(Reset))
  11352. {
  11353. // Required data
  11354. if(json_object_object_get(Reset, "type") != NULL)
  11355. {
  11356. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  11357. }
  11358. if(json_object_object_get(Reset, "evseId") != NULL)
  11359. {
  11360. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  11361. }
  11362. }
  11363. json_object_put(Reset);
  11364. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  11365. {
  11366. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  11367. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  11368. result = TRUE;
  11369. return result;
  11370. }
  11371. else
  11372. {
  11373. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  11374. goto errorend;
  11375. }
  11376. errorend:
  11377. sendResetConfirmation(uuid);
  11378. return result;
  11379. }
  11380. int handleSendLocalListRequest(char *uuid, char *payload)
  11381. {
  11382. mtrace();
  11383. int result = FAIL;
  11384. char updateTypestr[15]={0};
  11385. int checkState_Faulted = FALSE;
  11386. json_object *SendLocalList;
  11387. DEBUG_INFO("handleSendLocalListRequest...\n");
  11388. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  11389. {
  11390. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11391. goto end;
  11392. }
  11393. SendLocalList = json_tokener_parse(payload);
  11394. if(!is_error(SendLocalList))
  11395. {
  11396. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  11397. // Required data
  11398. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  11399. {
  11400. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  11401. }
  11402. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  11403. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  11404. // Optional data
  11405. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  11406. {
  11407. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  11408. {
  11409. // Required data
  11410. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  11411. {
  11412. 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")));
  11413. 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")));
  11414. }
  11415. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  11416. {
  11417. 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")));
  11418. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  11419. 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")));
  11420. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  11421. 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"));
  11422. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  11423. {
  11424. 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")));
  11425. 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")));
  11426. }
  11427. }
  11428. }
  11429. }
  11430. }
  11431. json_object_put(SendLocalList);
  11432. //check Charge Point state
  11433. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11434. {
  11435. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11436. {
  11437. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11438. }
  11439. }
  11440. for (int index = 0; index < CCS_QUANTITY; index++)
  11441. {
  11442. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11443. {
  11444. checkState_Faulted = TRUE; //OCPP Status
  11445. }
  11446. }
  11447. for (int index = 0; index < GB_QUANTITY; index++)
  11448. {
  11449. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11450. {
  11451. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11452. }
  11453. }
  11454. for (int index = 0; index < AC_QUANTITY; index++)
  11455. {
  11456. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11457. {
  11458. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11459. }
  11460. }
  11461. if(checkState_Faulted == TRUE)
  11462. {
  11463. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11464. goto end;
  11465. }
  11466. // Check update type
  11467. if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  11468. {
  11469. //Local list full update
  11470. DEBUG_INFO("Local list full update.\n");
  11471. DB_getListVerion();
  11472. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11473. {
  11474. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11475. goto end;
  11476. }
  11477. DB_cleanLocalList();
  11478. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11479. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11480. }
  11481. else if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  11482. {
  11483. //Local list different update
  11484. DEBUG_INFO("Local list different update.\n");
  11485. DB_getListVerion();
  11486. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11487. {
  11488. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  11489. goto end;
  11490. }
  11491. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11492. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11493. }
  11494. else
  11495. {
  11496. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11497. goto end;
  11498. }
  11499. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  11500. end:
  11501. sendSendLocalListConfirmation(uuid);
  11502. return result;
  11503. }
  11504. int handleSetChargingProfileRequest(char *uuid, char *payload)
  11505. {
  11506. mtrace();
  11507. int result = FAIL;
  11508. int8_t gun_index = -1;
  11509. uint8_t isPeriodOverMax = FALSE;
  11510. uint8_t isProfileOverMax = FALSE;
  11511. uint8_t isConnectorMismatch = FALSE;
  11512. uint8_t existProfileQuantity = 0;
  11513. uint8_t filename[128]={0};
  11514. uint8_t word[2048]={0};
  11515. FILE *filePtr;
  11516. json_object *SetChargingProfile;
  11517. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  11518. SetChargingProfile = json_tokener_parse(payload);
  11519. if(!is_error(SetChargingProfile))
  11520. {
  11521. // Required data
  11522. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  11523. {
  11524. gun_index = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  11525. }
  11526. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  11527. {
  11528. // Check periods is over max configuration
  11529. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  11530. {
  11531. isPeriodOverMax = TRUE;
  11532. }
  11533. // Check periods is over max configuration
  11534. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  11535. {
  11536. if(gun_index == 0)
  11537. {
  11538. sprintf((char*)filename, ChargePointMaxProfile_JSON);
  11539. filePtr = fopen((char*)filename, "r");
  11540. if (!filePtr)
  11541. {
  11542. DEBUG_INFO("%s not exist, create it.\n", ChargePointMaxProfile_JSON);
  11543. filePtr = fopen((char*)filename, "w+");
  11544. }
  11545. else
  11546. {
  11547. //Check Charging Profile Count
  11548. while(fscanf(filePtr, "%s", word) != EOF)
  11549. {
  11550. //DEBUG_INFO("word=%s\n",word);
  11551. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11552. {
  11553. existProfileQuantity += 1;
  11554. }
  11555. }
  11556. }
  11557. fclose(filePtr);
  11558. }
  11559. else
  11560. isConnectorMismatch = TRUE;
  11561. }
  11562. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  11563. {
  11564. if(gun_index < 5)
  11565. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", gun_index);
  11566. else
  11567. isConnectorMismatch = TRUE;
  11568. if(!isConnectorMismatch)
  11569. {
  11570. filePtr = fopen((char*)filename, "r");
  11571. if (!filePtr)
  11572. {
  11573. DEBUG_INFO("%s not exist, create it.\n", filename);
  11574. filePtr = fopen((char*)filename, "w+");
  11575. }
  11576. else
  11577. {
  11578. //Check Charging Profile Count
  11579. while(fscanf(filePtr, "%s", word) != EOF)
  11580. {
  11581. //DEBUG_INFO("word=%s\n",word);
  11582. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11583. {
  11584. existProfileQuantity += 1;
  11585. }
  11586. }
  11587. }
  11588. fclose(filePtr);
  11589. }
  11590. }
  11591. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  11592. {
  11593. if(gun_index>0)
  11594. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  11595. else
  11596. isConnectorMismatch = TRUE;
  11597. if(!isConnectorMismatch)
  11598. {
  11599. filePtr = fopen((char*)filename, "r");
  11600. if (!filePtr)
  11601. {
  11602. DEBUG_INFO("%s not exist, create it.\n", filename);
  11603. filePtr = fopen((char*)filename, "w+");
  11604. }
  11605. else
  11606. {
  11607. //Check Charging Profile Count
  11608. while(fscanf(filePtr, "%s", word) != EOF)
  11609. {
  11610. //DEBUG_INFO("word=%s\n",word);
  11611. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11612. {
  11613. existProfileQuantity += 1;
  11614. }
  11615. }
  11616. }
  11617. fclose(filePtr);
  11618. }
  11619. }
  11620. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  11621. {
  11622. }
  11623. else
  11624. {
  11625. }
  11626. if(existProfileQuantity > 3)
  11627. isProfileOverMax = TRUE;
  11628. }
  11629. // Profile replace or add info
  11630. if((gun_index > -1) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch)
  11631. {
  11632. FILE *infile;
  11633. FILE *outfile;
  11634. char tmpProfileName[32];
  11635. char rmFileCmd[128];
  11636. char tempchargingProfilePurposeStr[30]={0};
  11637. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  11638. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfile");
  11639. infile = fopen ((char*)filename, "r");
  11640. outfile = fopen ((char*)tmpProfileName, "w");
  11641. int d = fgetc(infile);
  11642. rewind(infile);
  11643. if(d == EOF)
  11644. {
  11645. // Profile is empty
  11646. fprintf(outfile,"%s\n", payload);
  11647. fclose(infile);
  11648. fclose(outfile);
  11649. sprintf(rmFileCmd,"rm -f %s",filename);
  11650. system(rmFileCmd);
  11651. rename((char*)tmpProfileName, (char*)filename);
  11652. }
  11653. else
  11654. {
  11655. // Profile is not empty
  11656. char buf[2048]={0};
  11657. int ChargingProfileAdded = FALSE;
  11658. while (fgets(buf, sizeof(buf), infile) != NULL)
  11659. {
  11660. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  11661. json_object *tmpChargingProfile;
  11662. tmpChargingProfile = json_tokener_parse(buf);
  11663. if(!is_error(tmpChargingProfile))
  11664. {
  11665. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  11666. {
  11667. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  11668. }
  11669. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  11670. {
  11671. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  11672. {
  11673. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  11674. }
  11675. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  11676. {
  11677. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  11678. }
  11679. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  11680. {
  11681. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  11682. }
  11683. }
  11684. }
  11685. json_object_put(tmpChargingProfile);
  11686. if((tempconnectorIdInt == gun_index) &&
  11687. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId"))))
  11688. {
  11689. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel"))) &&
  11690. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  11691. {
  11692. //DEBUG_INFO("update set chargingProfile to file -0\n");
  11693. if(ChargingProfileAdded == FALSE)
  11694. {
  11695. fprintf(outfile,"%s\n",payload);
  11696. ChargingProfileAdded = TRUE;
  11697. }
  11698. }
  11699. else
  11700. {
  11701. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11702. {
  11703. if(ChargingProfileAdded == FALSE)
  11704. {
  11705. fprintf(outfile,"%s\n",buf);
  11706. fprintf(outfile,"%s\n",payload);
  11707. ChargingProfileAdded = TRUE;
  11708. }
  11709. else
  11710. {
  11711. fprintf(outfile,"%s\n",buf);
  11712. }
  11713. }
  11714. else
  11715. {
  11716. if(ChargingProfileAdded == FALSE)
  11717. {
  11718. fprintf(outfile,"%s\n",buf);
  11719. fprintf(outfile,"%s\n",payload);
  11720. ChargingProfileAdded = TRUE;
  11721. }
  11722. else
  11723. {
  11724. fprintf(outfile,"%s\n",buf);
  11725. }
  11726. }
  11727. }
  11728. }
  11729. else
  11730. {
  11731. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId")))
  11732. {
  11733. if(ChargingProfileAdded == FALSE)
  11734. {
  11735. fprintf(outfile,"%s\n",buf);
  11736. fprintf(outfile,"%s\n",payload);
  11737. ChargingProfileAdded = TRUE;
  11738. }
  11739. else
  11740. {
  11741. fprintf(outfile,"%s\n",buf);
  11742. }
  11743. }
  11744. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11745. {
  11746. if(ChargingProfileAdded == FALSE)
  11747. {
  11748. fprintf(outfile,"%s\n",buf);
  11749. fprintf(outfile,"%s\n",payload);
  11750. ChargingProfileAdded = TRUE;
  11751. }
  11752. else
  11753. {
  11754. fprintf(outfile,"%s\n",buf);
  11755. }
  11756. }
  11757. else
  11758. {
  11759. if(ChargingProfileAdded == FALSE)
  11760. {
  11761. fprintf(outfile,"%s\n",buf);
  11762. fprintf(outfile,"%s\n",payload);
  11763. ChargingProfileAdded = TRUE;
  11764. }
  11765. else
  11766. {
  11767. fprintf(outfile,"%s\n",buf);
  11768. }
  11769. }
  11770. }
  11771. } // end of while loop
  11772. fclose(infile);
  11773. fclose(outfile);
  11774. sprintf(rmFileCmd,"rm -f %s",filename);
  11775. system(rmFileCmd);
  11776. rename((char*)tmpProfileName, (char*)filename);
  11777. }
  11778. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  11779. result = PASS;
  11780. }
  11781. else
  11782. {
  11783. if(gun_index == -1)
  11784. DEBUG_WARN("Connector id is wrong.\n");
  11785. if(isConnectorMismatch)
  11786. DEBUG_WARN("Connector id is mismatch.\n");
  11787. if(isPeriodOverMax)
  11788. DEBUG_WARN("Profile periods quantity is over spec.\n");
  11789. if(isProfileOverMax)
  11790. DEBUG_WARN("Profile quantity is over spec.\n");
  11791. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  11792. }
  11793. }
  11794. json_object_put(SetChargingProfile);
  11795. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  11796. {
  11797. if(gun_index == 0)
  11798. {
  11799. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  11800. {
  11801. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  11802. }
  11803. }
  11804. else
  11805. checkCompositeSchedule(gun_index, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index-1]);
  11806. }
  11807. sendSetChargingProfileConfirmation(uuid, (gun_index==0?gun_index:gun_index-1));
  11808. return result;
  11809. }
  11810. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  11811. {
  11812. mtrace();
  11813. int result = FAIL;
  11814. json_object *SetDisplayMessage;
  11815. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  11816. SetDisplayMessage = json_tokener_parse(payload);
  11817. if(!is_error(SetDisplayMessage))
  11818. {
  11819. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  11820. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  11821. // Required data
  11822. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  11823. {
  11824. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  11825. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  11826. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  11827. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  11828. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  11829. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  11830. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  11831. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  11832. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  11833. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  11834. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  11835. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  11836. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  11837. {
  11838. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  11839. 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")));
  11840. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  11841. 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")));
  11842. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  11843. 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")));
  11844. }
  11845. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  11846. {
  11847. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  11848. 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")));
  11849. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  11850. 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")));
  11851. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  11852. {
  11853. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  11854. 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"));
  11855. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  11856. 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"));
  11857. }
  11858. }
  11859. }
  11860. }
  11861. json_object_put(SetDisplayMessage);
  11862. /*
  11863. * TODO:
  11864. * 1. Configure display message and response
  11865. */
  11866. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  11867. sendSetMonitoringBaseConfirmation(uuid);
  11868. return result;
  11869. }
  11870. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  11871. {
  11872. mtrace();
  11873. int result = FAIL;
  11874. json_object *SetMonitoringBase;
  11875. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  11876. SetMonitoringBase = json_tokener_parse(payload);
  11877. if(!is_error(SetMonitoringBase))
  11878. {
  11879. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  11880. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  11881. // Required data
  11882. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  11883. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  11884. }
  11885. json_object_put(SetMonitoringBase);
  11886. /*
  11887. * TODO:
  11888. * 1. Configure monitor base and response
  11889. */
  11890. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  11891. sendSetMonitoringBaseConfirmation(uuid);
  11892. return result;
  11893. }
  11894. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  11895. {
  11896. mtrace();
  11897. int result = FAIL;
  11898. json_object *SetMonitoringLevel;
  11899. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  11900. SetMonitoringLevel = json_tokener_parse(payload);
  11901. if(!is_error(SetMonitoringLevel))
  11902. {
  11903. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  11904. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  11905. // Required data
  11906. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  11907. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  11908. }
  11909. json_object_put(SetMonitoringLevel);
  11910. /*
  11911. * TODO:
  11912. * Configure monitor status and response
  11913. */
  11914. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  11915. sendSetMonitoringLevelConfirmation(uuid);
  11916. return result;
  11917. }
  11918. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  11919. {
  11920. mtrace();
  11921. int result = FAIL;
  11922. json_object *SetNetworkProfile;
  11923. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  11924. SetNetworkProfile = json_tokener_parse(payload);
  11925. if(!is_error(SetNetworkProfile))
  11926. {
  11927. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  11928. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  11929. // Required data
  11930. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  11931. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  11932. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  11933. {
  11934. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  11935. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  11936. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  11937. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  11938. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  11939. {
  11940. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  11941. memcpy((char*)ShmSysConfigAndInfo->SysConfig.OcppServerURL, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl));
  11942. }
  11943. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  11944. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  11945. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  11946. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  11947. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  11948. {
  11949. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  11950. 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")));
  11951. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  11952. 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")));
  11953. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  11954. 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")));
  11955. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  11956. 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")));
  11957. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  11958. 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")));
  11959. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  11960. 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")));
  11961. }
  11962. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  11963. {
  11964. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  11965. {
  11966. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  11967. 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")));
  11968. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  11969. }
  11970. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  11971. {
  11972. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  11973. 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")));
  11974. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  11975. }
  11976. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  11977. {
  11978. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  11979. 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")));
  11980. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  11981. }
  11982. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  11983. 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"));
  11984. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  11985. 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")));
  11986. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  11987. 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"));
  11988. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  11989. 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")));
  11990. }
  11991. DB_addNetworkProfile(ShmOCPP20Data->SetNetworkProfile.configurationSlot, (char*)json_object_get_string(json_object_object_get(SetNetworkProfile, "connectionData")));
  11992. }
  11993. }
  11994. json_object_put(SetNetworkProfile);
  11995. /*
  11996. * TODO:
  11997. * 1. Process network configuration and response
  11998. */
  11999. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  12000. {
  12001. }
  12002. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  12003. {
  12004. }
  12005. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  12006. {
  12007. }
  12008. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  12009. {
  12010. }
  12011. else
  12012. {
  12013. }
  12014. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  12015. {
  12016. }
  12017. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  12018. {
  12019. }
  12020. else
  12021. {
  12022. }
  12023. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  12024. {
  12025. }
  12026. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  12027. {
  12028. }
  12029. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  12030. {
  12031. }
  12032. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  12033. {
  12034. }
  12035. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  12036. {
  12037. }
  12038. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  12039. {
  12040. }
  12041. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  12042. {
  12043. }
  12044. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  12045. {
  12046. }
  12047. else
  12048. {
  12049. }
  12050. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  12051. {
  12052. }
  12053. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  12054. {
  12055. }
  12056. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  12057. {
  12058. }
  12059. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  12060. {
  12061. }
  12062. else
  12063. {
  12064. }
  12065. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  12066. {
  12067. }
  12068. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  12069. {
  12070. }
  12071. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  12072. {
  12073. }
  12074. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  12075. {
  12076. }
  12077. else
  12078. {
  12079. }
  12080. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  12081. sendSetNetworkProfileConfirmation(uuid);
  12082. return result;
  12083. }
  12084. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  12085. {
  12086. mtrace();
  12087. int result = FAIL;
  12088. json_object *SetVariableMonitoring;
  12089. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  12090. SetVariableMonitoring = json_tokener_parse(payload);
  12091. if(!is_error(SetVariableMonitoring))
  12092. {
  12093. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  12094. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  12095. // Required data
  12096. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  12097. {
  12098. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  12099. {
  12100. 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"));
  12101. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  12102. }
  12103. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  12104. {
  12105. 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"));
  12106. /*
  12107. * TODO:
  12108. * 1. Check monitor value status
  12109. */
  12110. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, MonitorEnumTypeStr[MonitorEnumType_Delta]);
  12111. }
  12112. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  12113. {
  12114. 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")));
  12115. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  12116. }
  12117. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  12118. {
  12119. 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"));
  12120. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  12121. }
  12122. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  12123. {
  12124. 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"));
  12125. }
  12126. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component") != NULL)
  12127. {
  12128. 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)
  12129. {
  12130. 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")));
  12131. }
  12132. 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)
  12133. {
  12134. 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")));
  12135. }
  12136. 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)
  12137. {
  12138. 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)
  12139. {
  12140. 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"));
  12141. }
  12142. 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)
  12143. {
  12144. 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"));
  12145. }
  12146. }
  12147. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  12148. }
  12149. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable") != NULL)
  12150. {
  12151. 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)
  12152. {
  12153. 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")));
  12154. }
  12155. 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)
  12156. {
  12157. 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")));
  12158. }
  12159. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  12160. }
  12161. }
  12162. }
  12163. json_object_put(SetVariableMonitoring);
  12164. return result;
  12165. }
  12166. int handleSetVariablesRequest(char *uuid, char *payload)
  12167. {
  12168. mtrace();
  12169. int result = FAIL;
  12170. json_object *SetVariables;
  12171. DEBUG_INFO("handleSetVariablesRequest...\n");
  12172. SetVariables = json_tokener_parse(payload);
  12173. if(!is_error(SetVariables))
  12174. {
  12175. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  12176. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  12177. // Required data
  12178. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  12179. {
  12180. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  12181. {
  12182. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  12183. {
  12184. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  12185. {
  12186. 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")));
  12187. }
  12188. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  12189. {
  12190. 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")));
  12191. }
  12192. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  12193. {
  12194. 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)
  12195. {
  12196. 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"));
  12197. }
  12198. 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)
  12199. {
  12200. 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"));
  12201. }
  12202. }
  12203. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  12204. }
  12205. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  12206. {
  12207. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  12208. {
  12209. 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")));
  12210. }
  12211. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  12212. {
  12213. 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")));
  12214. }
  12215. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  12216. }
  12217. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  12218. {
  12219. 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")));
  12220. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  12221. }
  12222. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  12223. {
  12224. 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")));
  12225. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  12226. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  12227. {
  12228. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL) &&
  12229. (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) &&
  12230. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name) != NULL) &&
  12231. (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))
  12232. {
  12233. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  12234. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  12235. if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "NetworkConfigurationPriority") != NULL))
  12236. {
  12237. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]);
  12238. }
  12239. else
  12240. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  12241. }
  12242. }
  12243. }
  12244. }
  12245. }
  12246. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  12247. }
  12248. json_object_put(SetVariables);
  12249. return result;
  12250. }
  12251. int handleTriggerMessageRequest(char *uuid, char *payload)
  12252. {
  12253. mtrace();
  12254. int result = FAIL;
  12255. int connectorIdIsNULL = FALSE;
  12256. int connectorIdInt =0;
  12257. char requestedMessagestr[40]={0};
  12258. json_object *TriggerMessage;
  12259. DEBUG_INFO("handleTriggerMessageRequest\n");
  12260. TriggerMessage = json_tokener_parse(payload);
  12261. if(!is_error(TriggerMessage))
  12262. {
  12263. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  12264. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  12265. // Required data
  12266. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  12267. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  12268. // Optional data
  12269. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  12270. {
  12271. // Required data
  12272. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  12273. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  12274. // Optional data
  12275. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  12276. {
  12277. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  12278. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  12279. }
  12280. else
  12281. connectorIdIsNULL = TRUE;
  12282. }
  12283. }
  12284. json_object_put(TriggerMessage);
  12285. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  12286. {
  12287. if((strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  12288. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  12289. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  12290. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  12291. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  12292. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  12293. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  12294. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  12295. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  12296. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  12297. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  12298. {
  12299. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  12300. sendTriggerMessageConfirmation(uuid);
  12301. return TRUE;
  12302. }
  12303. else
  12304. {
  12305. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  12306. sendTriggerMessageConfirmation(uuid);
  12307. }
  12308. }
  12309. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  12310. {
  12311. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  12312. sendTriggerMessageConfirmation(uuid);
  12313. return TRUE;
  12314. }
  12315. //==========================
  12316. // Trigger message
  12317. //==========================
  12318. if( strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  12319. {
  12320. if((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) &&
  12321. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) &&
  12322. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) &&
  12323. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing) )
  12324. {
  12325. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  12326. }
  12327. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusNotificationStatus]);
  12328. }
  12329. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  12330. {
  12331. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[LogStatusNotificationStatus]);
  12332. }
  12333. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  12334. {
  12335. if(DB_updateBootType(BootReasonEnumType_Triggered))
  12336. server_sign = FALSE;
  12337. }
  12338. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  12339. {
  12340. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval);
  12341. }
  12342. else if (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  12343. {
  12344. if(connectorIdIsNULL == FALSE)
  12345. {
  12346. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12347. {
  12348. //sendMeterValuesRequest((connectorIdInt -1), ReadingContext_Trigger);
  12349. cpinitateMsg.bits[connectorIdInt -1].TriggerMeterValueReq = ON;
  12350. }
  12351. }
  12352. else
  12353. {
  12354. for(int idx=0;idx< gunTotalNumber;idx++)
  12355. {
  12356. //sendMeterValuesRequest(idx, ReadingContext_Trigger);
  12357. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  12358. }
  12359. }
  12360. }
  12361. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  12362. {
  12363. if(connectorIdIsNULL == FALSE)
  12364. {
  12365. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12366. {
  12367. cpinitateMsg.bits[connectorIdInt -1].StatusNotificationReq = ON;
  12368. }
  12369. }
  12370. else
  12371. {
  12372. for(int idx=0;idx< gunTotalNumber;idx++)
  12373. cpinitateMsg.bits[idx].StatusNotificationReq = ON;
  12374. }
  12375. }
  12376. return result;
  12377. }
  12378. int handleUnlockConnectorRequest(char *uuid, char *payload)
  12379. {
  12380. mtrace();
  12381. int result = FAIL;
  12382. int connectorIdInt =0;
  12383. int tempIndex = 0;
  12384. json_object *UnlockConnector;
  12385. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  12386. UnlockConnector = json_tokener_parse(payload);
  12387. if(!is_error(UnlockConnector))
  12388. {
  12389. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  12390. {
  12391. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  12392. }
  12393. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  12394. {
  12395. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  12396. }
  12397. }
  12398. json_object_put(UnlockConnector);
  12399. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  12400. if(gunTotalNumber == 0)
  12401. {
  12402. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12403. goto end;
  12404. }
  12405. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  12406. {
  12407. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12408. goto end;
  12409. }
  12410. else
  12411. {
  12412. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  12413. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  12414. //check Transaction active
  12415. if(gunType[connectorIdInt-1] == 'J')
  12416. {
  12417. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12418. {
  12419. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12420. }
  12421. else
  12422. {
  12423. tempIndex = connectorIdInt -1;
  12424. }
  12425. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12426. {
  12427. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12428. {
  12429. //stop Transaction
  12430. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12431. }
  12432. }
  12433. }
  12434. else if((gunType[connectorIdInt-1] == 'U')||(gunType[connectorIdInt-1] == 'E'))
  12435. {
  12436. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12437. {
  12438. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12439. }
  12440. else
  12441. {
  12442. tempIndex = connectorIdInt -1;
  12443. }
  12444. for (int index = 0; index < CCS_QUANTITY; index++)
  12445. {
  12446. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12447. {
  12448. //stop Transaction
  12449. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12450. }
  12451. }
  12452. }
  12453. else if(gunType[connectorIdInt-1] == 'G')
  12454. {
  12455. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12456. {
  12457. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12458. }
  12459. else
  12460. {
  12461. tempIndex = connectorIdInt -1;
  12462. }
  12463. for (int index = 0; index < GB_QUANTITY; index++)
  12464. {
  12465. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)))
  12466. {
  12467. //stop Transaction
  12468. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12469. }
  12470. }
  12471. }
  12472. else
  12473. {
  12474. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  12475. {
  12476. tempIndex = 2;
  12477. }
  12478. else
  12479. {
  12480. tempIndex = connectorIdInt-1;
  12481. }
  12482. for (int index = 0; index < AC_QUANTITY; index++)
  12483. {
  12484. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12485. {
  12486. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12487. }
  12488. }
  12489. }
  12490. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  12491. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  12492. result = TRUE;
  12493. return result;
  12494. }
  12495. end:
  12496. //json_object_put(obj); --- remove temporally
  12497. sendUnlockConnectorConfirmation(uuid, connectorIdInt-1);
  12498. return result;
  12499. }
  12500. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  12501. {
  12502. mtrace();
  12503. int result = FAIL;
  12504. json_object *UnpublishFirmware;
  12505. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  12506. UnpublishFirmware = json_tokener_parse(payload);
  12507. if(!is_error(UnpublishFirmware))
  12508. {
  12509. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  12510. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  12511. // Required data
  12512. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  12513. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  12514. }
  12515. json_object_put(UnpublishFirmware);
  12516. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  12517. /*
  12518. * TODO:
  12519. * 1. Check unpublished status
  12520. */
  12521. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  12522. sendUnpublishFirmwareConfirmation(uuid);
  12523. return result;
  12524. }
  12525. static char UpdateFirmwarepayloadData[512]={0};
  12526. void *UpdateFirmwareProcess(void *data)
  12527. {
  12528. pthread_detach(pthread_self());
  12529. mtrace();
  12530. int retriesInt =0, retryIntervalInt=0;
  12531. char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
  12532. int port=0;
  12533. char locationstr[160]={0}, retrieveDatestr[30]={0};
  12534. int isSuccess = 0;
  12535. char ftpbuf[200];
  12536. char temp[100];
  12537. char * pch;
  12538. DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
  12539. json_object *UpdateFirmware;
  12540. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  12541. if(!is_error(UpdateFirmware))
  12542. {
  12543. // Required data
  12544. if(json_object_object_get(UpdateFirmware, "location") != NULL)
  12545. sprintf((char*)locationstr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "location")));
  12546. if(json_object_object_get(UpdateFirmware, "retrieveDate") != NULL)
  12547. sprintf((char*)retrieveDatestr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "retrieveDate")));
  12548. // Optional data
  12549. if(json_object_object_get(UpdateFirmware, "retries"))
  12550. {
  12551. retriesInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  12552. }
  12553. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  12554. {
  12555. retryIntervalInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  12556. }
  12557. }
  12558. json_object_put(UpdateFirmware);
  12559. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  12560. memset(path, 0, ARRAY_SIZE(path));
  12561. system("rm -f /mnt/*");
  12562. if(strncmp(locationstr,"http", 4) == 0)
  12563. {
  12564. sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  12565. //sscanf(locationstr,"%[^:]:%*2[/]%[^:]:%[^@]@%[^/]%199[^\n]",
  12566. // protocol, user, password, host, path);
  12567. sprintf(ftppath,"/%s", path);
  12568. DEBUG_INFO("locationstr: %s\n", locationstr);
  12569. DEBUG_INFO("protocol: %s\n",protocol);
  12570. DEBUG_INFO("host: %s\n",host);
  12571. DEBUG_INFO("path: %s\n",path);
  12572. DEBUG_INFO("ftppath: %s\n",ftppath);
  12573. int ftppathlen=strlen(ftppath);
  12574. int i=1;
  12575. char filenametemp[50];
  12576. while(i < ftppathlen)
  12577. {
  12578. int len=ftppathlen-i;
  12579. if(ftppath[len]== 47) // '/' ascll code: 47
  12580. {
  12581. DEBUG_INFO("compare '/' all right\n");
  12582. break;
  12583. }
  12584. i=i+1;
  12585. }
  12586. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12587. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  12588. filenametemp[i+1] = 0;
  12589. do
  12590. {
  12591. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12592. sleep(3);
  12593. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
  12594. if(!isSuccess)
  12595. {
  12596. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12597. sleep(retryIntervalInt);
  12598. }
  12599. else
  12600. {
  12601. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12602. }
  12603. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
  12604. }
  12605. else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
  12606. {
  12607. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12608. memset(temp, 0, ARRAY_SIZE(temp));
  12609. //DEBUG_INFO("locationstr=%s\n",locationstr);
  12610. strcpy(ftpbuf, locationstr/*"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/DemoDC1_2018-07-13_185011_PSULog.zip"*/ );
  12611. int ftppathlen=strlen(ftpbuf);
  12612. int i=1;
  12613. char filenametemp[50];
  12614. while(i < ftppathlen)
  12615. {
  12616. int len=ftppathlen-i;
  12617. if(ftpbuf[len]== 47) // '/' ascll code: 47
  12618. {
  12619. DEBUG_INFO(" compare '/' all right\n");
  12620. break;
  12621. }
  12622. i=i+1;
  12623. }
  12624. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12625. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  12626. filenametemp[i+1] = 0;
  12627. strncpy(temp, ftpbuf, ftppathlen-i+1);
  12628. pch=strchr(temp,'@');
  12629. if(pch==NULL)
  12630. {
  12631. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  12632. protocol, host, &port, path);
  12633. strcpy(user,"anonymous");
  12634. strcpy(password,"");
  12635. }
  12636. else
  12637. {
  12638. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  12639. protocol, user, password, host, &port, path);
  12640. }
  12641. sscanf(host,"%[^/]%s",host1, path1);
  12642. sprintf(ftppath,"%s", path1);
  12643. //DEBUG_INFO("protocol =%s\n",protocol);
  12644. //DEBUG_INFO("user =%s\n",user);
  12645. //DEBUG_INFO("password =%s\n",password);
  12646. //DEBUG_INFO("host1 =%s\n",host1);
  12647. //DEBUG_INFO("port =%d\n",port);
  12648. //DEBUG_INFO("path1 =%s\n",path1);
  12649. //DEBUG_INFO("ftppath=%s\n",ftppath);
  12650. //ftpFile(host, user, password, port, ftppath, fname);
  12651. //download firmware pthred
  12652. if(port == 0)
  12653. {
  12654. port = 21;
  12655. }
  12656. do
  12657. {
  12658. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12659. sleep(3);
  12660. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
  12661. if(!isSuccess)
  12662. {
  12663. //BulldogUtil.sleepMs(interval*1000);
  12664. DEBUG_INFO("Update firmware request and download file fail.\n");
  12665. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12666. sleep(retryIntervalInt);
  12667. }
  12668. else
  12669. {
  12670. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12671. }
  12672. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  12673. }
  12674. else
  12675. {
  12676. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12677. }
  12678. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  12679. pthread_exit(NULL);
  12680. }
  12681. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  12682. {
  12683. mtrace();
  12684. int result = FAIL;
  12685. pthread_t t;
  12686. sendUpdateFirmwareConfirmation(uuid);
  12687. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  12688. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  12689. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  12690. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  12691. ////pthread_join(t, NULL); //
  12692. //pthread_detach(t);
  12693. //sendUpdateFirmwareConfirmation(uuid);
  12694. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  12695. return result;
  12696. }
  12697. //==========================================
  12698. // Handle server response routine
  12699. //==========================================
  12700. void handleAuthorizeResponse(char *payload, int gun_index)
  12701. {
  12702. mtrace();
  12703. DEBUG_INFO("handleAuthorizeResponse...\n");
  12704. json_object *Authorize;
  12705. Authorize = json_tokener_parse(payload);
  12706. if(!is_error(Authorize))
  12707. {
  12708. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  12709. {
  12710. // Required data
  12711. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  12712. // Optional data
  12713. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  12714. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  12715. else
  12716. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  12717. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  12718. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  12719. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  12720. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  12721. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  12722. {
  12723. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  12724. {
  12725. 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));
  12726. }
  12727. }
  12728. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  12729. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  12730. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  12731. {
  12732. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  12733. 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")));
  12734. else
  12735. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  12736. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  12737. 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")));
  12738. }
  12739. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  12740. {
  12741. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  12742. 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")));
  12743. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  12744. 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")));
  12745. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  12746. 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")));
  12747. }
  12748. }
  12749. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  12750. {
  12751. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  12752. }
  12753. }
  12754. json_object_put(Authorize);
  12755. //Update idTag information to authorization cache if supported
  12756. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  12757. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  12758. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  12759. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  12760. {
  12761. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  12762. }
  12763. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  12764. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  12765. authorizeRetryTimes = 0;
  12766. }
  12767. void handleBootNotificationResponse(char *payload, int gun_index)
  12768. {
  12769. mtrace();
  12770. char statusStr[12]={0};
  12771. char currentTimeStr[30]={0};
  12772. int intervalInt = 0;
  12773. struct tm tp;
  12774. char buf[28]={0};
  12775. char timebuf[50]={0};
  12776. DEBUG_INFO("handleBootNotificationResponse...\n");
  12777. json_object *BootNotification;
  12778. BootNotification = json_tokener_parse(payload);
  12779. if(!is_error(BootNotification))
  12780. {
  12781. // Required data
  12782. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  12783. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  12784. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  12785. }
  12786. json_object_put(BootNotification);
  12787. DEBUG_INFO("statusStr: %s\n", statusStr);
  12788. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  12789. BootNotificationInterval = intervalInt;
  12790. HeartBeatWaitTime = intervalInt;
  12791. //write back to ShmOCPP20Data->BootNotification
  12792. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  12793. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  12794. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  12795. {
  12796. server_sign = TRUE;
  12797. server_pending =FALSE;
  12798. DB_updateBootType(BootReasonEnumType_PowerUp);
  12799. }
  12800. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  12801. {
  12802. server_pending = TRUE;
  12803. }
  12804. strptime((const char *)ShmOCPP20Data->BootNotification.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  12805. tp.tm_isdst = -1;
  12806. //time_t utc = mktime(&tp);
  12807. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  12808. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  12809. sprintf(timebuf,"date -s '%s'",buf);
  12810. system(timebuf);
  12811. srand(time(NULL));
  12812. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  12813. //==============================================
  12814. // RTC sync
  12815. //==============================================
  12816. system("/sbin/hwclock -w --systohc");
  12817. SetOcppConnStatus(TRUE);
  12818. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  12819. }
  12820. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  12821. {
  12822. mtrace();
  12823. json_object *ClearedChargingLimit;
  12824. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  12825. ClearedChargingLimit = json_tokener_parse(payload);
  12826. if(!is_error(ClearedChargingLimit))
  12827. {
  12828. // Required data
  12829. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  12830. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  12831. }
  12832. json_object_put(ClearedChargingLimit);
  12833. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitReq = OFF;
  12834. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitConf = ON;
  12835. }
  12836. void handleDataTransferResponse(char *payload, int gun_index)
  12837. {
  12838. mtrace();
  12839. json_object *DataTrans;
  12840. DEBUG_INFO("handleDataTransferResponse...\n");
  12841. DataTrans = json_tokener_parse(payload);
  12842. if(!is_error(DataTrans))
  12843. {
  12844. // Required data
  12845. if(json_object_object_get(DataTrans,"status") != NULL)
  12846. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  12847. // Optional data
  12848. if(json_object_object_get(DataTrans,"data") != NULL)
  12849. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  12850. }
  12851. json_object_put(DataTrans);
  12852. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  12853. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  12854. }
  12855. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  12856. {
  12857. mtrace();
  12858. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  12859. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  12860. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  12861. }
  12862. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  12863. {
  12864. mtrace();
  12865. json_object *Get15118EVCertificate;
  12866. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  12867. Get15118EVCertificate = json_tokener_parse(payload);
  12868. if(!is_error(Get15118EVCertificate))
  12869. {
  12870. // Required data
  12871. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  12872. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  12873. // Optional data
  12874. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  12875. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  12876. }
  12877. json_object_put(Get15118EVCertificate);
  12878. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  12879. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  12880. }
  12881. void hanldeGetCertificateStatusResponse(char *payload, int gun_index)
  12882. {
  12883. mtrace();
  12884. json_object *GetCertificateStatus;
  12885. DEBUG_INFO("hanldeGetCertificateStatusResponse...\n");
  12886. GetCertificateStatus = json_tokener_parse(payload);
  12887. if(!is_error(GetCertificateStatus))
  12888. {
  12889. // Required data
  12890. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  12891. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  12892. // Optional data
  12893. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  12894. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  12895. }
  12896. json_object_put(GetCertificateStatus);
  12897. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  12898. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  12899. }
  12900. void handleHeartbeatResponse(char *payload, int gun_index)
  12901. {
  12902. mtrace();
  12903. struct tm tp;
  12904. char buf[28]={0};
  12905. char timebuf[128]={0};
  12906. DEBUG_INFO("handleHeartbeatResponse...\n");
  12907. json_object *Heartbeat;
  12908. Heartbeat = json_tokener_parse(payload);
  12909. if(!is_error(Heartbeat))
  12910. {
  12911. // Required data
  12912. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  12913. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  12914. }
  12915. json_object_put(Heartbeat);
  12916. if(FirstHeartBeat == OFF)
  12917. {
  12918. FirstHeartBeat = ON;
  12919. DEBUG_INFO("FirstHeartBeat \n");
  12920. }
  12921. HeartBeatWithNOResponse = 0;
  12922. clientTime.Heartbeat=time((time_t*)NULL);
  12923. strptime((const char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  12924. tp.tm_isdst = -1;
  12925. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  12926. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  12927. sprintf(timebuf,"date -s '%s'",buf);
  12928. system(timebuf);
  12929. //==============================================
  12930. // RTC sync
  12931. //==============================================
  12932. system("/sbin/hwclock -w --systohc");
  12933. }
  12934. void hanldeLogStatusNotificationResponse(char *payload, int gun_index)
  12935. {
  12936. mtrace();
  12937. DEBUG_INFO("hanldeLogStatusNotificationResponse...\n");
  12938. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  12939. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  12940. }
  12941. void handleMeterValuesResponse(char *payload, int gun_index)
  12942. {
  12943. mtrace();
  12944. DEBUG_INFO("handleMeterValuesResponse...\n");
  12945. }
  12946. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  12947. {
  12948. mtrace();
  12949. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  12950. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  12951. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  12952. }
  12953. void hanldeNotifyCustomerInformationResponse(char *payload, int gun_index)
  12954. {
  12955. mtrace();
  12956. DEBUG_INFO("hanldeNotifyCustomerInformationResponse...\n");
  12957. }
  12958. void hanldeNotifyDisplayMessagesResponse(char *payload, int gun_index)
  12959. {
  12960. mtrace();
  12961. DEBUG_INFO("hanldeNotifyDisplayMessagesResponse...\n");
  12962. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  12963. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  12964. }
  12965. void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  12966. {
  12967. mtrace();
  12968. json_object *NotifyEVChargingNeeds;
  12969. DEBUG_INFO("hanldeNotifyEVChargingNeedsResponse...\n");
  12970. NotifyEVChargingNeeds = json_tokener_parse(payload);
  12971. if(!is_error(NotifyEVChargingNeeds))
  12972. {
  12973. // Required data
  12974. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  12975. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  12976. }
  12977. json_object_put(NotifyEVChargingNeeds);
  12978. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  12979. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  12980. }
  12981. void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  12982. {
  12983. mtrace();
  12984. json_object *NotifyEVChargingSchedule;
  12985. DEBUG_INFO("hanldeNotifyEVChargingScheduleResponse...\n");
  12986. NotifyEVChargingSchedule = json_tokener_parse(payload);
  12987. if(!is_error(NotifyEVChargingSchedule))
  12988. {
  12989. // Required data
  12990. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  12991. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  12992. }
  12993. json_object_put(NotifyEVChargingSchedule);
  12994. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  12995. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  12996. }
  12997. void hanldeNotifyEventResponse(char *payload, int gun_index)
  12998. {
  12999. mtrace();
  13000. DEBUG_INFO("hanldeNotifyEventResponse...\n");
  13001. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  13002. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  13003. }
  13004. void hanldeNotifyMonitoringReportResponse(char *payload, int gun_index)
  13005. {
  13006. mtrace();
  13007. DEBUG_INFO("hanldeNotifyMonitoringReportResponse...\n");
  13008. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  13009. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  13010. }
  13011. void hanldeNotifyReportResponse(char *payload, int gun_index)
  13012. {
  13013. mtrace();
  13014. DEBUG_INFO("hanldeNotifyReportResponse...\n");
  13015. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  13016. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  13017. }
  13018. void hanldePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  13019. {
  13020. mtrace();
  13021. DEBUG_INFO("hanldePublishFirmwareStatusNotificationResponse...\n");
  13022. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  13023. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  13024. }
  13025. void hanldeReportChargingProfilesResponse(char *payload, int gun_index)
  13026. {
  13027. mtrace();
  13028. DEBUG_INFO("hanldeReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  13029. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  13030. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  13031. }
  13032. void hanldeReservationStatusUpdateResponse(char *payload, int gun_index)
  13033. {
  13034. mtrace();
  13035. DEBUG_INFO("hanldeReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  13036. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  13037. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  13038. }
  13039. void hanldeSecurityEventNotificationResponse(char *payload, int gun_index)
  13040. {
  13041. mtrace();
  13042. DEBUG_INFO("hanldeSecurityEventNotificationResponse...\n");
  13043. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  13044. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  13045. }
  13046. void hanldeSignCertificateResponse(char *payload, int gun_index)
  13047. {
  13048. mtrace();
  13049. json_object *SignCertificate;
  13050. DEBUG_INFO("hanldeSignCertificateResponse...\n");
  13051. SignCertificate = json_tokener_parse(payload);
  13052. if(!is_error(SignCertificate))
  13053. {
  13054. // Required data
  13055. if(json_object_object_get(SignCertificate,"status") != NULL)
  13056. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  13057. }
  13058. json_object_put(SignCertificate);
  13059. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  13060. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  13061. }
  13062. void handleStatusNotificationResponse(char *payload, int gun_index)
  13063. {
  13064. mtrace();
  13065. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  13066. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13067. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  13068. }
  13069. void hanldeTransactionEvenResponse(char *payload, int gun_index)
  13070. {
  13071. mtrace();
  13072. json_object *TransactionEven;
  13073. DEBUG_INFO("hanldeTransactionEvenResponse...\n");
  13074. TransactionEven = json_tokener_parse(payload);
  13075. if(!is_error(TransactionEven))
  13076. {
  13077. // Required data
  13078. // Optional data
  13079. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  13080. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  13081. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  13082. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  13083. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  13084. {
  13085. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  13086. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  13087. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  13088. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  13089. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  13090. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  13091. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  13092. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  13093. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  13094. {
  13095. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  13096. 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")));
  13097. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  13098. 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")));
  13099. }
  13100. }
  13101. }
  13102. json_object_put(TransactionEven);
  13103. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  13104. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  13105. }
  13106. //==========================================
  13107. // Handle Error routine
  13108. //==========================================
  13109. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  13110. {
  13111. mtrace();
  13112. #ifdef SystemLogMessage
  13113. DEBUG_INFO("errorCode: %s\n", errorCode);
  13114. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  13115. DEBUG_INFO("errorDetails: %s\n", payload);
  13116. #endif
  13117. }
  13118. //===============================================
  13119. // Common routine
  13120. //===============================================
  13121. int initialConfigurationTable(void)
  13122. {
  13123. DEBUG_INFO("initialConfigurationTable...\n");
  13124. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  13125. DB_variableIsCreate();
  13126. DB_variableLoadFromDb();
  13127. DB_getNetworkProfileFromDb();
  13128. return 0;
  13129. }
  13130. int TransactionMessageAttemptsGet(void)
  13131. {
  13132. return TransactionMessageAttemptsValue;
  13133. }
  13134. int FirstHeartBeatResponse(void)
  13135. {
  13136. return FirstHeartBeat;
  13137. }
  13138. int TransactionMessageRetryIntervalGet(void)
  13139. {
  13140. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  13141. }
  13142. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  13143. {
  13144. char rmFileCmd[100]={0};
  13145. char FilePath[100]={0};
  13146. char ftpbuf[200];
  13147. int systemresult;
  13148. //DEBUG_INFO("filename=%s\n",filename);
  13149. //DEBUG_INFO("url=%s\n",url);
  13150. sprintf(FilePath,"/mnt/%s",filename);
  13151. system("ping 8.8.8.8 &");
  13152. if((access(FilePath,F_OK))!=-1)
  13153. {
  13154. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13155. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13156. system(rmFileCmd);
  13157. }
  13158. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13159. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13160. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13161. systemresult = system(ftpbuf);
  13162. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13163. if(systemresult != 0)
  13164. {
  13165. DEBUG_INFO("http DownLoad error!\n");
  13166. return FALSE;
  13167. }
  13168. system("pkill ping");
  13169. return TRUE;
  13170. }
  13171. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  13172. {
  13173. char rmFileCmd[100]={0};
  13174. char FilePath[100]={0};
  13175. char ftpbuf[200];
  13176. int systemresult;
  13177. //char temp[100];
  13178. sprintf(FilePath,"/mnt/%s",filename);
  13179. system("ping 8.8.8.8 &");
  13180. if((access(FilePath,F_OK))!=-1)
  13181. {
  13182. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13183. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13184. system(rmFileCmd);
  13185. }
  13186. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13187. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13188. //sprintf(ftpbuf, "ftpget -u %s -p %s %s -P %d %s %s%s",user,password,IPbuffer,port/*21*/,filename,path,filename); --- remove temporally
  13189. //DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13190. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13191. systemresult = system(ftpbuf);
  13192. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13193. if(systemresult != 0)
  13194. {
  13195. printf("wget error!\n");
  13196. return FALSE;
  13197. }
  13198. system("pkill ping");
  13199. return TRUE;
  13200. }
  13201. int httpUploadFile(char *location, char *path, char *filename,char *url)
  13202. {
  13203. char rmFileCmd[100]={0};
  13204. char FilePath[100]={0};
  13205. char ftpbuf[200];
  13206. int systemresult;
  13207. //DEBUG_INFO("filename=%s\n",filename);
  13208. //DEBUG_INFO("url=%s\n",url);
  13209. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  13210. if((access(FilePath,F_OK))!=-1)
  13211. {
  13212. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13213. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13214. system(rmFileCmd);
  13215. }
  13216. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  13217. if(fp == NULL)
  13218. {
  13219. DEBUG_INFO("log is NULL\n");
  13220. return FALSE;
  13221. }
  13222. else
  13223. {
  13224. fprintf(fp, "%s\n", url);
  13225. fprintf(fp, "%s\n", filename);
  13226. fclose(fp);
  13227. }
  13228. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13229. sprintf(ftpbuf, "%s","/bin/php-cgi /var/www/ocpp_upload.php");
  13230. systemresult = system(ftpbuf);
  13231. DEBUG_INFO("systemresult = %d\n",systemresult);
  13232. if(systemresult != 0)
  13233. {
  13234. DEBUG_INFO("http upload error!\n");
  13235. return FALSE;
  13236. }
  13237. return TRUE;
  13238. }
  13239. int ftpUploadFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  13240. {
  13241. struct hostent* server;
  13242. char *IPbuffer;
  13243. char ftpbuf[200];
  13244. int systemresult;
  13245. // To retrieve host information
  13246. server = gethostbyname(location);
  13247. // To convert an Internet network
  13248. // address into ASCII string
  13249. IPbuffer = inet_ntoa(*((struct in_addr*)
  13250. server->h_addr_list[0]));
  13251. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13252. /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
  13253. /* format : ftpput -u username -p passwd IP target source*/
  13254. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
  13255. DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13256. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13257. systemresult = system(ftpbuf);
  13258. DEBUG_INFO("systemresult=%d\n",systemresult);
  13259. if(systemresult != 0)
  13260. {
  13261. DEBUG_INFO("ftpput error!\n");
  13262. return FALSE;
  13263. }
  13264. return TRUE;
  13265. }
  13266. //=========================================
  13267. // Routine
  13268. //=========================================
  13269. int GetOcppServerURL()
  13270. {
  13271. int result = FALSE;
  13272. struct yuarel url;
  13273. char urlStr[512];
  13274. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  13275. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  13276. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  13277. if((ShmSysConfigAndInfo->SysConfig.OcppServerURL != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0) )
  13278. {
  13279. memcpy(urlStr, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  13280. if(yuarel_parse(&url, urlStr) != -1)
  13281. {
  13282. sprintf(OcppProtocol, "%s", url.scheme);
  13283. sprintf(OcppHost, "%s", url.host);
  13284. if(url.path == NULL)
  13285. OcppTempPath[0] = '\0';
  13286. else
  13287. {
  13288. if((url.path[strlen(url.path)-1] != '/') && (strlen(url.path) > 0))
  13289. {
  13290. sprintf(OcppTempPath, "%s/", url.path);
  13291. }
  13292. else
  13293. {
  13294. sprintf(OcppTempPath, "%s", url.path);
  13295. }
  13296. }
  13297. if(url.port == 0)
  13298. {
  13299. if(strcmp(OcppProtocol, "wss") == 0)
  13300. OcppPort = 443;
  13301. else
  13302. OcppPort = 80;
  13303. }
  13304. else
  13305. OcppPort = url.port;
  13306. result = TRUE;
  13307. }
  13308. }
  13309. else if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  13310. {
  13311. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  13312. if(yuarel_parse(&url, urlStr) != -1)
  13313. {
  13314. sprintf(OcppProtocol, "%s", url.scheme);
  13315. sprintf(OcppHost, "%s", url.host);
  13316. if(url.path == NULL)
  13317. OcppTempPath[0] = '\0';
  13318. else
  13319. sprintf(OcppTempPath, "%s", url.path);
  13320. if(url.port == 0)
  13321. {
  13322. if(strcmp(OcppProtocol, "wss") == 0)
  13323. OcppPort = 443;
  13324. else
  13325. OcppPort = 80;
  13326. }
  13327. else
  13328. OcppPort = url.port;
  13329. result = TRUE;
  13330. }
  13331. }
  13332. else
  13333. {
  13334. strcpy(OcppHost,"");
  13335. }
  13336. return result;
  13337. }
  13338. int GetOcppPath()
  13339. {
  13340. int result = FALSE;
  13341. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  13342. {
  13343. if(OcppTempPath == NULL)
  13344. {
  13345. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13346. }
  13347. else
  13348. {
  13349. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13350. }
  13351. result = TRUE;
  13352. }
  13353. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  13354. {
  13355. if(OcppTempPath == NULL)
  13356. {
  13357. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  13358. }
  13359. else
  13360. {
  13361. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  13362. }
  13363. result = TRUE;
  13364. }
  13365. else
  13366. {
  13367. strcpy(OcppPath,"");
  13368. }
  13369. return result;
  13370. }
  13371. int GetOcppPort()
  13372. {
  13373. return OcppPort;
  13374. }
  13375. int GetOcppConnStatus(void)
  13376. {
  13377. return ShmOCPP20Data->OcppConnStatus;
  13378. }
  13379. void SetOcppConnStatus(uint8_t status)
  13380. {
  13381. ShmOCPP20Data->OcppConnStatus = status;
  13382. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  13383. }
  13384. int GetHeartBeatWithNOResponse(void)
  13385. {
  13386. return HeartBeatWithNOResponse;
  13387. }
  13388. void SetHeartBeatWithNOResponse(void)
  13389. {
  13390. HeartBeatWithNOResponse = 0;
  13391. }
  13392. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  13393. void storeTempStopTransaction(int gun_index)
  13394. {
  13395. }
  13396. void checkTempStopTransaction(int gun_index)
  13397. {
  13398. FILE *fptr1;
  13399. char ch;
  13400. char str[QUEUE_MESSAGE_LENGTH]={0};
  13401. char guid[37]={0};
  13402. char tempdata[65]={0};
  13403. char connectorStr[2]={0};
  13404. char TempStopTransaction[256];
  13405. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  13406. fptr1 = fopen(TempStopTransaction, "r");
  13407. if (!fptr1)
  13408. {
  13409. //DEBUG_INFO("TempStopTransaction_%d not found or unable to open the input file!\n", (gun_index+1));
  13410. return ;
  13411. }
  13412. ch=fgetc(fptr1);
  13413. rewind(fptr1);
  13414. if(ch!=EOF)
  13415. {
  13416. // copy all contents to the temporary file except the specific line
  13417. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  13418. {
  13419. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13420. if(str[0]=='\0')
  13421. {
  13422. break;
  13423. }
  13424. //TempStopTransaction格式: 槍號,StopTransaction封包
  13425. strncpy(connectorStr, str, 1);
  13426. if(atoi(connectorStr) != (gun_index+1))
  13427. {
  13428. DEBUG_INFO("atoi(connectorStr) = %d, gun_index = %d\n", atoi(connectorStr), gun_index);
  13429. fclose(fptr1);
  13430. return ;
  13431. }
  13432. //random_uuid(guid);
  13433. strncpy(guid, str+6, 36); //copy guid
  13434. sprintf(tempdata, "StopTransaction,%d", (gun_index));
  13435. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  13436. {
  13437. //DEBUG_INFO("StopTransaction mapitem pass\n");
  13438. }
  13439. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  13440. memset(str,0,ARRAY_SIZE(str));
  13441. }
  13442. }
  13443. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  13444. fclose(fptr1);
  13445. remove(TempStopTransaction); // remove the original file
  13446. }
  13447. int GetWebSocketPingInterval(void)
  13448. {
  13449. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  13450. }
  13451. int GetServerSign(void)
  13452. {
  13453. return server_sign;
  13454. }
  13455. uint8_t GetOcppSecurityProfile()
  13456. {
  13457. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  13458. }
  13459. void GetOcppChargerBoxId(uint8_t *data)
  13460. {
  13461. sprintf((char*)data, "%s", ShmOCPP20Data->ChargeBoxId);
  13462. }
  13463. void GetOcppSecurityPassword(uint8_t *data)
  13464. {
  13465. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  13466. }
  13467. void SetServerSign(int value)
  13468. {
  13469. server_sign = value;
  13470. }
  13471. int GetBootNotificationInterval(void)
  13472. {
  13473. return BootNotificationInterval;
  13474. }
  13475. int GetInternetConn(void)
  13476. {
  13477. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  13478. }
  13479. void InitialSystemValue(void)
  13480. {
  13481. int connectorIndex = 0;
  13482. gunTotalNumber=0;
  13483. SystemInitial = 0;
  13484. localversion=0;
  13485. BootNotificationInterval = 10;
  13486. authorizeRetryTimes = 0;
  13487. GunStatusInterval = 10;
  13488. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  13489. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  13490. //Hear Beat
  13491. HeartBeatWithNOResponse = 0;
  13492. HeartBeatCountPerHour = 0;
  13493. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  13494. FirstHeartBeat = 0;
  13495. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  13496. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  13497. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  13498. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  13499. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  13500. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  13501. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  13502. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  13503. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  13504. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  13505. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  13506. memset(gunType, 0, ARRAY_SIZE(gunType));
  13507. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13508. {
  13509. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O')
  13510. {
  13511. // DO series
  13512. for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
  13513. {
  13514. SystemInitial = SystemInitial + 1;
  13515. gunTotalNumber = gunTotalNumber + 1;
  13516. gunType[connectorIndex] = 'O';
  13517. connectorIndex = connectorIndex + 1;
  13518. }
  13519. }
  13520. else
  13521. {
  13522. // DM, DW, DS series
  13523. //check connector / socket type (index: 8, 9, 10)
  13524. for(int index=7; index <10 ; index++)
  13525. {
  13526. if(index != 8)
  13527. {
  13528. // DC Connector
  13529. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] >= 'A') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= 'Z'))
  13530. {
  13531. SystemInitial = SystemInitial + 1;
  13532. gunTotalNumber = gunTotalNumber + 1;
  13533. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13534. connectorIndex = connectorIndex + 1;
  13535. }
  13536. }
  13537. else
  13538. {
  13539. // AC Connector
  13540. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13541. {
  13542. SystemInitial = SystemInitial + 1;
  13543. gunTotalNumber = gunTotalNumber + 1;
  13544. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13545. connectorIndex = connectorIndex + 1;
  13546. }
  13547. }
  13548. }
  13549. }
  13550. //DEBUG_INFO("DC ...\n");
  13551. }
  13552. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  13553. {
  13554. //check connector / socket type (index: 8, 9, 10)
  13555. for(int index=7; index <10 ; index++)
  13556. {
  13557. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13558. {
  13559. SystemInitial = SystemInitial + 1;
  13560. gunTotalNumber = gunTotalNumber + 1;
  13561. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13562. connectorIndex = connectorIndex + 1;
  13563. //DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
  13564. }
  13565. }
  13566. }
  13567. //Status && ConnectorPlugIn Setting
  13568. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13569. {
  13570. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  13571. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  13572. }
  13573. for (int index = 0; index < CCS_QUANTITY; index++)
  13574. {
  13575. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  13576. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  13577. }
  13578. for (int index = 0; index < GB_QUANTITY; index++)
  13579. {
  13580. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  13581. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  13582. }
  13583. for (int index = 0; index < AC_QUANTITY; index++)
  13584. {
  13585. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  13586. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  13587. }
  13588. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13589. {
  13590. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  13591. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  13592. }
  13593. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  13594. {
  13595. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13596. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  13597. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  13598. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  13599. }
  13600. clientTime.Heartbeat=time((time_t*)NULL);
  13601. sleep(1);
  13602. }
  13603. void LWS_Send(char * str)
  13604. {
  13605. //=====================================================
  13606. // Check InternetConn 0: disconnected, 1: connected
  13607. //====================================================
  13608. if(GetOcppConnStatus() == 0)
  13609. {
  13610. DEBUG_INFO("offline now !!!\n");
  13611. return;
  13612. }
  13613. pthread_mutex_lock(&lock_send);
  13614. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13615. sprintf((char *)SendBuffer, "%s", str);
  13616. SendBufLen = strlen(str);
  13617. pthread_mutex_unlock(&lock_send);
  13618. lws_callback_on_writable(wsi_client);
  13619. //lws_service(context, 0);
  13620. //sleep(1);
  13621. }
  13622. void LWS_SendNow(char * str)
  13623. {
  13624. //=====================================================
  13625. // Check InternetConn 0: disconnected, 1: connected
  13626. //====================================================
  13627. if(GetOcppConnStatus() == 0)
  13628. {
  13629. DEBUG_INFO("offline now !!!\n");
  13630. return;
  13631. }
  13632. pthread_mutex_lock(&lock_send);
  13633. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13634. sprintf((char *)SendBuffer, "%s", str);
  13635. SendBufLen = strlen(str);
  13636. pthread_mutex_unlock(&lock_send);
  13637. lws_callback_on_writable(wsi_client);
  13638. lws_service(context, 0);
  13639. //sleep(1);
  13640. }