MessageHandler.c 736 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988
  1. #include "Module_OcppBackend20.h"
  2. #include "define.h"
  3. static char *APNAuthenticationEnumTypeStr[] = {
  4. MACROSTR(CHAP),
  5. MACROSTR(NONE),
  6. MACROSTR(PAP),
  7. MACROSTR(AUTO)
  8. };
  9. static char *AttributeEnumTypeStr[] = {
  10. MACROSTR(Actual),
  11. MACROSTR(Target),
  12. MACROSTR(MinSet),
  13. MACROSTR(MaxSet)
  14. };
  15. static char *AuthorizationStatusEnumTypeStr[] = {
  16. MACROSTR(Accepted),
  17. MACROSTR(Blocked),
  18. MACROSTR(ConcurrentTx),
  19. MACROSTR(Expired),
  20. MACROSTR(Invalid),
  21. MACROSTR(NoCredit),
  22. MACROSTR(NotAllowedTypeEVSE),
  23. MACROSTR(NotAtThisLocation),
  24. MACROSTR(NotAtThisTime),
  25. MACROSTR(Unknown)
  26. };
  27. static char *AuthorizeCertificateStatusEnumTypeStr[] = {
  28. MACROSTR(Accepted),
  29. MACROSTR(SignatureError),
  30. MACROSTR(CertificateExpired),
  31. MACROSTR(CertificateRevoked),
  32. MACROSTR(NoCertificateAvailable),
  33. MACROSTR(CertChainError),
  34. MACROSTR(ContractCancelled)
  35. };
  36. static char *BootReasonEnumTypeStr[] = {
  37. MACROSTR(ApplicationReset),
  38. MACROSTR(FirmwareUpdate),
  39. MACROSTR(LocalReset),
  40. MACROSTR(PowerUp),
  41. MACROSTR(RemoteReset),
  42. MACROSTR(ScheduledReset),
  43. MACROSTR(Triggered),
  44. MACROSTR(Unknown),
  45. MACROSTR(Watchdog)
  46. };
  47. static char *CancelReservationStatusEnumTypeStr[] = {
  48. MACROSTR(Accepted),
  49. MACROSTR(Rejected)
  50. };
  51. static char *CertificateActionEnumTypeStr[] = {
  52. MACROSTR(Install),
  53. MACROSTR(Update)
  54. };
  55. static char *CertificateSignedStatusEnumTypeStr[] = {
  56. MACROSTR(Accepted),
  57. MACROSTR(Rejected)
  58. };
  59. static char *CertificateSigningUseEnumTypeStr[] = {
  60. MACROSTR(ChargingStationCertificate),
  61. MACROSTR(V2GCertificate)
  62. };
  63. static char *ChangeAvailabilityStatusEnumTypeStr[] = {
  64. MACROSTR(Accepted),
  65. MACROSTR(Rejected),
  66. MACROSTR(Scheduled)
  67. };
  68. static char *ChargingLimitSourceEnumTypeStr[] = {
  69. MACROSTR(EMS),
  70. MACROSTR(Other),
  71. MACROSTR(SO),
  72. MACROSTR(CSO)
  73. };
  74. static char *ChargingProfileKindEnumTypeStr[] = {
  75. MACROSTR(Absolute),
  76. MACROSTR(Recurring),
  77. MACROSTR(Relative)
  78. };
  79. static char *ChargingProfilePurposeEnumTypeStr[] = {
  80. MACROSTR(ChargingStationExternalConstraints),
  81. MACROSTR(ChargingStationMaxProfile),
  82. MACROSTR(TxDefaultProfile),
  83. MACROSTR(TxProfile)
  84. };
  85. static char *ChargingProfileStatusEnumTypeStr[] = {
  86. MACROSTR(Accepted),
  87. MACROSTR(Rejected)
  88. };
  89. static char *ChargingRateUnitEnumTypeStr[] = {
  90. MACROSTR(W),
  91. MACROSTR(A)
  92. };
  93. static char *ChargingStateEnumTypeStr[] = {
  94. MACROSTR(Charging),
  95. MACROSTR(EVConnected),
  96. MACROSTR(SuspendedEV),
  97. MACROSTR(SuspendedEVSE),
  98. MACROSTR(Idle)
  99. };
  100. static char *ClearCacheStatusEnumTypeStr[] = {
  101. MACROSTR(Accepted),
  102. MACROSTR(Rejected)
  103. };
  104. static char *ClearChargingProfileStatusEnumTypeStr[] = {
  105. MACROSTR(Accepted),
  106. MACROSTR(Unknown)
  107. };
  108. static char *ClearMessageStatusEnumTypeStr[] = {
  109. MACROSTR(Accepted),
  110. MACROSTR(Unknown)
  111. };
  112. static char *ClearMonitoringStatusEnumTypeStr[] = {
  113. MACROSTR(Accepted),
  114. MACROSTR(Rejected),
  115. MACROSTR(NotFound)
  116. };
  117. static char *ComponentCriterionEnumTypeStr[] = {
  118. MACROSTR(Active),
  119. MACROSTR(Available),
  120. MACROSTR(Enabled),
  121. MACROSTR(Problem)
  122. };
  123. static char *ConnectorEnumTypeStr[] = {
  124. MACROSTR(cCCS1),
  125. MACROSTR(cCCS2),
  126. MACROSTR(cG105),
  127. MACROSTR(cTesla),
  128. MACROSTR(cType1),
  129. MACROSTR(cType2),
  130. MACROSTR(s309-1P-16A),
  131. MACROSTR(s309-1P-32A),
  132. MACROSTR(s309-3P-16A),
  133. MACROSTR(s309-3P-32A),
  134. MACROSTR(sBS1361),
  135. MACROSTR(sCEE-7-7),
  136. MACROSTR(sType2),
  137. MACROSTR(sType3),
  138. MACROSTR(Other1PhMax16A),
  139. MACROSTR(Other1PhOver16A),
  140. MACROSTR(Other3Ph),
  141. MACROSTR(Pan),
  142. MACROSTR(wInductive),
  143. MACROSTR(wResonant),
  144. MACROSTR(Undetermined),
  145. MACROSTR(Unknown)
  146. };
  147. static char *ConnectorStatusEnumTypeStr[] = {
  148. MACROSTR(Available),
  149. MACROSTR(Occupied),
  150. MACROSTR(Reserved),
  151. MACROSTR(Unavailable),
  152. MACROSTR(Faulted)
  153. };
  154. static char *CostKindEnumTypeStr[] = {
  155. MACROSTR(CarbonDioxideEmission),
  156. MACROSTR(RelativePricePercentage),
  157. MACROSTR(RenewableGenerationPercentage)
  158. };
  159. static char *CustomerInformationStatusEnumTypeStr[] = {
  160. MACROSTR(Accepted),
  161. MACROSTR(Rejected),
  162. MACROSTR(Invalid)
  163. };
  164. static char *DataEnumTypeStr[] = {
  165. MACROSTR(string),
  166. MACROSTR(decimal),
  167. MACROSTR(integer),
  168. MACROSTR(dateTime),
  169. MACROSTR(boolean),
  170. MACROSTR(OptionList),
  171. MACROSTR(SequenceList),
  172. MACROSTR(MemberList)
  173. };
  174. static char *DataTransferStatusEnumTypeStr[] = {
  175. MACROSTR(Accepted),
  176. MACROSTR(Rejected),
  177. MACROSTR(UnknownMessageId),
  178. MACROSTR(UnknownVendorId)
  179. };
  180. static char *DeleteCertificateStatusEnumTypeStr[] = {
  181. MACROSTR(Accepted),
  182. MACROSTR(Failed),
  183. MACROSTR(NotFound)
  184. };
  185. static char *DisplayMessageStatusEnumTypeStr[] = {
  186. MACROSTR(Accepted),
  187. MACROSTR(NotSupportedMessageFormat),
  188. MACROSTR(Rejected),
  189. MACROSTR(NotSupportedPriority),
  190. MACROSTR(NotSupportedState),
  191. MACROSTR(UnknownTransaction)
  192. };
  193. static char *EnergyTransferModeEnumTypeStr[] = {
  194. MACROSTR(DC),
  195. MACROSTR(AC_single_phase),
  196. MACROSTR(AC_two_phase),
  197. MACROSTR(AC_three_phase)
  198. };
  199. static char *EventNotificationEnumTypeStr[] = {
  200. MACROSTR(HardWiredNotification),
  201. MACROSTR(HardWiredMonitor),
  202. MACROSTR(PreconfiguredMonitor),
  203. MACROSTR(CustomMonitor)
  204. };
  205. static char *EventTriggerEnumTypeStr[] = {
  206. MACROSTR(Alerting),
  207. MACROSTR(Delta),
  208. MACROSTR(Periodic)
  209. };
  210. static char *FirmwareStatusEnumTypeStr[] = {
  211. MACROSTR(Downloaded),
  212. MACROSTR(DownloadFailed),
  213. MACROSTR(Downloading),
  214. MACROSTR(DownloadScheduled),
  215. MACROSTR(DownloadPaused),
  216. MACROSTR(Idle),
  217. MACROSTR(InstallationFailed),
  218. MACROSTR(Installing),
  219. MACROSTR(Installed),
  220. MACROSTR(InstallRebooting),
  221. MACROSTR(InstallScheduled),
  222. MACROSTR(InstallVerificationFailed),
  223. MACROSTR(InvalidSignature),
  224. MACROSTR(SignatureVerified)
  225. };
  226. static char *GenericDeviceModelStatusEnumTypeStr[] = {
  227. MACROSTR(Accepted),
  228. MACROSTR(Rejected),
  229. MACROSTR(NotSupported),
  230. MACROSTR(EmptyResultSet)
  231. };
  232. static char *GenericStatusEnumTypeStr[] = {
  233. MACROSTR(Accepted),
  234. MACROSTR(Rejected)
  235. };
  236. static char *GetCertificateIdUseEnumTypeStr[] = {
  237. MACROSTR(V2GRootCertificate),
  238. MACROSTR(MORootCertificate),
  239. MACROSTR(CSMSRootCertificate),
  240. MACROSTR(V2GCertificateChain),
  241. MACROSTR(ManufacturerRootCertificate)
  242. };
  243. static char *GetCertificateStatusEnumTypeStr[] = {
  244. MACROSTR(Accepted),
  245. MACROSTR(Failed)
  246. };
  247. static char *GetChargingProfileStatusEnumTypeStr[] = {
  248. MACROSTR(Accepted),
  249. MACROSTR(NoProfiles)
  250. };
  251. static char *GetDisplayMessagesStatusEnumTypeStr[] = {
  252. MACROSTR(Accepted),
  253. MACROSTR(Unknown)
  254. };
  255. static char *GetInstalledCertificateStatusEnumTypeStr[] = {
  256. MACROSTR(Accepted),
  257. MACROSTR(NotFound)
  258. };
  259. static char *GetVariableStatusEnumTypeStr[] = {
  260. MACROSTR(Accepted),
  261. MACROSTR(Rejected),
  262. MACROSTR(UnknownComponent),
  263. MACROSTR(UnknownVariable),
  264. MACROSTR(NotSupportedAttributeType)
  265. };
  266. static char *HashAlgorithmEnumTypeStr[] = {
  267. MACROSTR(SHA256),
  268. MACROSTR(SHA384),
  269. MACROSTR(SHA512)
  270. };
  271. static char *IdTokenEnumTypeStr[] = {
  272. MACROSTR(Central),
  273. MACROSTR(eMAID),
  274. MACROSTR(ISO14443),
  275. MACROSTR(KeyCode),
  276. MACROSTR(Local),
  277. MACROSTR(NoAuthorization),
  278. MACROSTR(ISO15693)
  279. };
  280. static char *InstallCertificateUseEnumTypeStr[] = {
  281. MACROSTR(V2GRootCertificate),
  282. MACROSTR(MORootCertificate),
  283. MACROSTR(CSMSRootCertificate),
  284. MACROSTR(ManufacturerRootCertificate)
  285. };
  286. static char *InstallCertificateStatusEnumTypeStr[]={
  287. MACROSTR(Accepted),
  288. MACROSTR(Failed),
  289. MACROSTR(Rejected)
  290. };
  291. static char *Iso15118EVCertificateStatusEnumTypeStr[] = {
  292. MACROSTR(Accepted),
  293. MACROSTR(Failed)
  294. };
  295. static char *LocationEnumTypeStr[] = {
  296. MACROSTR(Body),
  297. MACROSTR(Cable),
  298. MACROSTR(EV),
  299. MACROSTR(Inlet),
  300. MACROSTR(Outlet)
  301. };
  302. static char *LogEnumTypeStr[] = {
  303. MACROSTR(DiagnosticsLog),
  304. MACROSTR(SecurityLog)
  305. };
  306. static char *LogStatusEnumTypeStr[] = {
  307. MACROSTR(Accepted),
  308. MACROSTR(Rejected),
  309. MACROSTR(AcceptedCanceled)
  310. };
  311. static char *MeasurandEnumTypeStr[] = {
  312. MACROSTR(Current.Export),
  313. MACROSTR(Current.Import),
  314. MACROSTR(Current.Offered),
  315. MACROSTR(Energy.Active.Export.Register),
  316. MACROSTR(Energy.Active.Import.Register),
  317. MACROSTR(Energy.Reactive.Export.Register),
  318. MACROSTR(Energy.Reactive.Import.Register),
  319. MACROSTR(Energy.Active.Export.Interval),
  320. MACROSTR(Energy.Active.Import.Interval),
  321. MACROSTR(Energy.Active.Net),
  322. MACROSTR(Energy.Reactive.Export.Interval),
  323. MACROSTR(Energy.Reactive.Import.Interval),
  324. MACROSTR(Energy.Reactive.Net),
  325. MACROSTR(Energy.Apparent.Net),
  326. MACROSTR(Energy.Apparent.Import),
  327. MACROSTR(Energy.Apparent.Export),
  328. MACROSTR(Frequency),
  329. MACROSTR(Power.Active.Export),
  330. MACROSTR(Power.Active.Import),
  331. MACROSTR(Power.Factor),
  332. MACROSTR(Power.Offered),
  333. MACROSTR(Power.Reactive.Export),
  334. MACROSTR(Power.Reactive.Import),
  335. MACROSTR(SoC),
  336. MACROSTR(Voltage)
  337. };
  338. static char *MessageFormatEnumTypeStr[] = {
  339. MACROSTR(ASCII),
  340. MACROSTR(HTML),
  341. MACROSTR(URI),
  342. MACROSTR(UTF8)
  343. };
  344. static char *MessagePriorityEnumTypeStr[] = {
  345. MACROSTR(AlwaysFront),
  346. MACROSTR(InFront),
  347. MACROSTR(NormalCycle)
  348. };
  349. static char *MessageStateEnumTypeStr[] = {
  350. MACROSTR(Charging),
  351. MACROSTR(Faulted),
  352. MACROSTR(Idle),
  353. MACROSTR(Unavailable)
  354. };
  355. static char *MessageTriggerEnumTypeStr[] = {
  356. MACROSTR(BootNotification),
  357. MACROSTR(LogStatusNotification),
  358. MACROSTR(FirmwareStatusNotification),
  359. MACROSTR(Heartbeat),
  360. MACROSTR(MeterValues),
  361. MACROSTR(SignChargingStationCertificate),
  362. MACROSTR(SignV2GCertificate),
  363. MACROSTR(StatusNotification),
  364. MACROSTR(TransactionEvent),
  365. MACROSTR(SignCombinedCertificate),
  366. MACROSTR(PublishFirmwareStatusNotification)
  367. };
  368. static char *MonitorEnumTypeStr[] = {
  369. MACROSTR(UpperThreshold),
  370. MACROSTR(LowerThreshold),
  371. MACROSTR(Delta),
  372. MACROSTR(Periodic),
  373. MACROSTR(PeriodicClockAligned)
  374. };
  375. static char *MonitoringBaseEnumTypeStr[] = {
  376. MACROSTR(All),
  377. MACROSTR(FactoryDefault),
  378. MACROSTR(HardWiredOnly)
  379. };
  380. static char *MonitoringCriterionEnumTypeStr[] = {
  381. MACROSTR(ThresholdMonitoring),
  382. MACROSTR(DeltaMonitoring),
  383. MACROSTR(PeriodicMonitoring)
  384. };
  385. static char *MutabilityEnumTypeStr[] = {
  386. MACROSTR(ReadOnly),
  387. MACROSTR(WriteOnly),
  388. MACROSTR(ReadWrite)
  389. };
  390. static char *NotifyEVChargingNeedsStatusEnumTypeStr[] = {
  391. MACROSTR(Accepted),
  392. MACROSTR(Rejected),
  393. MACROSTR(Processing)
  394. };
  395. static char *OCPPInterfaceEnumTypeStr[] = {
  396. MACROSTR(Wired0),
  397. MACROSTR(Wired1),
  398. MACROSTR(Wired2),
  399. MACROSTR(Wired3),
  400. MACROSTR(Wireless0),
  401. MACROSTR(Wireless1),
  402. MACROSTR(Wireless2),
  403. MACROSTR(Wireless3)
  404. };
  405. static char *OCPPTransportEnumTypeStr[] = {
  406. MACROSTR(JSON),
  407. MACROSTR(SOAP)
  408. };
  409. static char *OCPPVersionEnumTypeStr[] = {
  410. MACROSTR(OCPP12),
  411. MACROSTR(OCPP15),
  412. MACROSTR(OCPP16),
  413. MACROSTR(OCPP20)
  414. };
  415. static char *OperationalStatusEnumTypeStr[] = {
  416. MACROSTR(Inoperative),
  417. MACROSTR(Operative)
  418. };
  419. static char *PhaseEnumTypeStr[] = {
  420. MACROSTR(L1),
  421. MACROSTR(L2),
  422. MACROSTR(L3),
  423. MACROSTR(N),
  424. MACROSTR(L1-N),
  425. MACROSTR(L2-N),
  426. MACROSTR(L3-N),
  427. MACROSTR(L1-L2),
  428. MACROSTR(L2-L3),
  429. MACROSTR(L3-L1)
  430. };
  431. static char *PublishFirmwareStatusEnumTypeStr[] = {
  432. MACROSTR(Downloaded),
  433. MACROSTR(DownloadFailed),
  434. MACROSTR(Downloading),
  435. MACROSTR(DownloadScheduled),
  436. MACROSTR(DownloadPaused),
  437. MACROSTR(PublishFailed),
  438. MACROSTR(Published),
  439. MACROSTR(InvalidChecksum),
  440. MACROSTR(ChecksumVerified)
  441. };
  442. static char *ReadingContextEnumTypeStr[] = {
  443. MACROSTR(Interruption.Begin),
  444. MACROSTR(Interruption.End),
  445. MACROSTR(Other),
  446. MACROSTR(Sample.Clock),
  447. MACROSTR(Sample.Periodic),
  448. MACROSTR(Transaction.Begin),
  449. MACROSTR(Transaction.End),
  450. MACROSTR(Trigger)
  451. };
  452. static char *ReasonEnumTypeStr[] = {
  453. MACROSTR(DeAuthorized),
  454. MACROSTR(EmergencyStop),
  455. MACROSTR(EnergyLimitReached),
  456. MACROSTR(EVDisconnected),
  457. MACROSTR(GroundFault),
  458. MACROSTR(ImmediateReset),
  459. MACROSTR(Local),
  460. MACROSTR(LocalOutOfCredit),
  461. MACROSTR(MasterPass),
  462. MACROSTR(Other),
  463. MACROSTR(OvercurrentFault),
  464. MACROSTR(PowerLoss),
  465. MACROSTR(PowerQuality),
  466. MACROSTR(Reboot),
  467. MACROSTR(Remote),
  468. MACROSTR(SOCLimitReached),
  469. MACROSTR(StoppedByEV),
  470. MACROSTR(TimeLimitReached),
  471. MACROSTR(TimeLimitReached)
  472. };
  473. static char *RecurrencyKindEnumTypeStr[] = {
  474. MACROSTR(Daily),
  475. MACROSTR(Weekly)
  476. };
  477. static char *RegistrationStatusEnumTypeStr[] = {
  478. MACROSTR(Accepted),
  479. MACROSTR(Pending),
  480. MACROSTR(Rejected)
  481. };
  482. static char *ReportBaseEnumTypeStr[] = {
  483. MACROSTR(ConfigurationInventory),
  484. MACROSTR(FullInventory),
  485. MACROSTR(SummaryInventory)
  486. };
  487. static char *RequestStartStopStatusEnumTypeStr[] = {
  488. MACROSTR(Accepted),
  489. MACROSTR(Rejected)
  490. };
  491. static char *ReservationUpdateStatusEnumTypeStr[] = {
  492. MACROSTR(Expired),
  493. MACROSTR(Removed)
  494. };
  495. static char *ReserveNowStatusEnumTypeStr[] = {
  496. MACROSTR(Accepted),
  497. MACROSTR(Faulted),
  498. MACROSTR(Occupied),
  499. MACROSTR(Rejected),
  500. MACROSTR(Unavailable)
  501. };
  502. static char *ResetEnumTypeStr[] = {
  503. MACROSTR(Immediate),
  504. MACROSTR(OnIdle)
  505. };
  506. static char *ResetStatusEnumTypeStr[] = {
  507. MACROSTR(Accepted),
  508. MACROSTR(Rejected),
  509. MACROSTR(Scheduled)
  510. };
  511. static char *SetMonitoringStatusEnumTypeStr[] = {
  512. MACROSTR(Accepted),
  513. MACROSTR(UnknownComponent),
  514. MACROSTR(UnknownVariable),
  515. MACROSTR(UnsupportedMonitorType),
  516. MACROSTR(Rejected),
  517. MACROSTR(OutOfRange),
  518. MACROSTR(Duplicate)
  519. };
  520. static char *SetNetworkProfileStatusEnumTypeStr[] = {
  521. MACROSTR(Accepted),
  522. MACROSTR(Rejected),
  523. MACROSTR(Failed)
  524. };
  525. static char *SetVariableStatusEnumTypeStr[] = {
  526. MACROSTR(Accepted),
  527. MACROSTR(Rejected),
  528. MACROSTR(InvalidValue),
  529. MACROSTR(UnknownComponent),
  530. MACROSTR(UnknownVariable),
  531. MACROSTR(NotSupportedAttributeType),
  532. MACROSTR(OutOfRange),
  533. MACROSTR(RebootRequired)
  534. };
  535. static char *TransactionEventEnumTypeStr[] = {
  536. MACROSTR(Ended),
  537. MACROSTR(Started),
  538. MACROSTR(Updated)
  539. };
  540. static char *TriggerMessageStatusEnumTypeStr[] = {
  541. MACROSTR(Accepted),
  542. MACROSTR(Rejected),
  543. MACROSTR(NotImplemented)
  544. };
  545. static char *TriggerReasonEnumTypeStr[] = {
  546. MACROSTR(Authorized),
  547. MACROSTR(CablePluggedIn),
  548. MACROSTR(ChargingRateChanged),
  549. MACROSTR(ChargingStateChanged),
  550. MACROSTR(Deauthorized),
  551. MACROSTR(EnergyLimitReached),
  552. MACROSTR(EVCommunicationLost),
  553. MACROSTR(EVConnectTimeout),
  554. MACROSTR(MeterValueClock),
  555. MACROSTR(MeterValuePeriodic),
  556. MACROSTR(TimeLimitReached),
  557. MACROSTR(Trigger),
  558. MACROSTR(UnlockCommand),
  559. MACROSTR(StopAuthorized),
  560. MACROSTR(EVDeparted),
  561. MACROSTR(EVDetected),
  562. MACROSTR(RemoteStop),
  563. MACROSTR(RemoteStart),
  564. MACROSTR(AbnormalCondition),
  565. MACROSTR(SignedDataReceived),
  566. MACROSTR(ResetCommand)
  567. };
  568. static char *UnlockStatusEnumTypeStr[] = {
  569. MACROSTR(Unlocked),
  570. MACROSTR(UnlockFailed),
  571. MACROSTR(OngoingAuthorizedTransaction),
  572. MACROSTR(UnknownConnector)
  573. };
  574. static char *UnpublishFirmwareStatusEnumTypeStr[] = {
  575. MACROSTR(DownloadOngoing),
  576. MACROSTR(NoFirmware),
  577. MACROSTR(Unpublished)
  578. };
  579. static char *UpdateEnumTypeStr[] = {
  580. MACROSTR(Differential),
  581. MACROSTR(Full)
  582. };
  583. static char *UpdateFirmwareStatusEnumTypeStr[] = {
  584. MACROSTR(Accepted),
  585. MACROSTR(Rejected),
  586. MACROSTR(AcceptedCanceled),
  587. MACROSTR(InvalidCertificate),
  588. MACROSTR(RevokedCertificate)
  589. };
  590. static char *UpdateStatusEnumTypeStr[] = {
  591. MACROSTR(Accepted),
  592. MACROSTR(Failed),
  593. MACROSTR(VersionMismatch)
  594. };
  595. static char *UploadLogStatusEnumTypeStr[] = {
  596. MACROSTR(BadMessage),
  597. MACROSTR(Idle),
  598. MACROSTR(NotSupportedOperation),
  599. MACROSTR(PermissionDenied),
  600. MACROSTR(Uploaded),
  601. MACROSTR(UploadFailure),
  602. MACROSTR(Uploading)
  603. };
  604. static char *VPNEnumTypeStr[] = {
  605. MACROSTR(IKEv2),
  606. MACROSTR(IPSec),
  607. MACROSTR(L2TP),
  608. MACROSTR(PPTP)
  609. };
  610. #if 0
  611. static char *ChargePointErrorCodeEnumTypeStr[] = {
  612. MACROSTR(ConnectorLockFailure),
  613. MACROSTR(EVCommunicationError),
  614. MACROSTR(GroundFailure),
  615. MACROSTR(HighTemperature),
  616. MACROSTR(InternalError),
  617. MACROSTR(LocalListConflict),
  618. MACROSTR(NoError),
  619. MACROSTR(OtherError),
  620. MACROSTR(OverCurrentFailure),
  621. MACROSTR(OverVoltage),
  622. MACROSTR(PowerMeterFailure),
  623. MACROSTR(PowerSwitchFailure),
  624. MACROSTR(ReaderFailure),
  625. MACROSTR(ResetFailure),
  626. MACROSTR(UnderVoltage),
  627. MACROSTR(WeakSignal)
  628. };
  629. #endif
  630. static char *GetCompositeScheduleStatusEnumTypeStr[] = {
  631. MACROSTR(Accepted),
  632. MACROSTR(Rejected)
  633. };
  634. static char *RemoteStartStopStatusEnumTypeStr[] = {
  635. MACROSTR(Accepted),
  636. MACROSTR(Rejected)
  637. };
  638. static char *ReservationStatusEnumTypeStr[] = {
  639. MACROSTR(Accepted),
  640. MACROSTR(Faulted),
  641. MACROSTR(Occupied),
  642. MACROSTR(Rejected),
  643. MACROSTR(Unavailable)
  644. };
  645. #if 0
  646. static char * StopTransactionReasonEnumTypeStr[] = {
  647. MACROSTR(EmergencyStop),
  648. MACROSTR(EVDisconnected),
  649. MACROSTR(HardReset),
  650. MACROSTR(Local),
  651. MACROSTR(Other),
  652. MACROSTR(PowerLoss),
  653. MACROSTR(Reboot),
  654. MACROSTR(Remote),
  655. MACROSTR(SoftReset),
  656. MACROSTR(UnlockCommand),
  657. MACROSTR(DeAuthorized)
  658. };
  659. #endif
  660. //ChargePointMaxProfile
  661. #define ChargePointMaxProfile_JSON "/Storage/OCPP/ChargePointMaxProfile_OCPP20.json"
  662. //TxDefaultProfile
  663. #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0_OCPP20.json"
  664. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  665. struct StatusCodeData *ShmStatusCodeData;
  666. struct PsuData *ShmPsuData ;
  667. struct OCPP20Data *ShmOCPP20Data;
  668. pthread_mutex_t lock_send = PTHREAD_MUTEX_INITIALIZER;
  669. char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
  670. //===============================
  671. // Gun Total Numbers
  672. //===============================
  673. static int gunTotalNumber = 0;
  674. static uint8_t gunType[4] = {0};
  675. //===============================
  676. // Local List Version
  677. //===============================
  678. static int localversion=0;
  679. //===============================
  680. // OCPP sign variable
  681. //===============================
  682. static int server_sign = FALSE;
  683. int server_pending = FALSE;
  684. static int BootNotificationInterval = 0;
  685. static int SystemInitial = 0;//= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; // System Boot UP
  686. //===============================
  687. // OCPP auth variable
  688. //===============================
  689. static int authorizeRetryTimes = 0; //number of Retry times
  690. //===============================
  691. // OCPP other variables
  692. //===============================
  693. static int HeartBeatWaitTime = 10;
  694. static int FirstHeartBeat = 0;
  695. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  696. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  697. static char CurrentChargingProfileScheduleStr[30] = {0};
  698. //========================================
  699. // OCPP status/previous related variables
  700. //========================================
  701. static int GunStatusInterval = 10;
  702. static uint8_t statusModeChage[CONNECTOR_QUANTITY] = {FALSE};
  703. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  704. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  705. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  706. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  707. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  708. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  709. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  710. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  711. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  712. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  713. static int TransactionMessageAttemptsValue = 0;
  714. static int TransactionMessageRetryIntervalValue = 0;
  715. static int TempMeterValueInterval = 0;
  716. static struct AuthorizationData idTagQuery;
  717. //=============================================
  718. // OCPP HeartBeat Response Not Receive Counts
  719. //============================================
  720. static int HeartBeatWithNOResponse = 0;
  721. static int HeartBeatCountPerHour = 0;
  722. sqlite3 *db;
  723. int TransactionMessageAttemptsGet(void);
  724. int TransactionMessageRetryIntervalGet(void);
  725. int GetOcppConnStatus(void);
  726. void SetOcppConnStatus(uint8_t status);
  727. int setKeyValue(char *key, char *value);
  728. void OCPP_get_TableAuthlocalAllData(void);
  729. void processUnkownKey(void);
  730. struct StructOCPPMeterValue
  731. {
  732. unsigned char TimeStamp[28];
  733. struct StructSampledValue SampledValue[10];
  734. };
  735. struct ClientTime
  736. {
  737. unsigned int Heartbeat;
  738. unsigned int StatusNotification[CONNECTOR_QUANTITY];
  739. unsigned int StartTransaction;
  740. unsigned int StopTransaction;
  741. unsigned int MeterValues[CONNECTOR_QUANTITY];
  742. }clientTime;
  743. typedef union
  744. {
  745. //Operations Initiated by Central System
  746. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  747. struct
  748. {
  749. //CsMsgValue[0]
  750. unsigned char StatusNotificationReq:1; //bit 0,
  751. unsigned char StatusNotificationConf:1; //bit 1,
  752. unsigned char TriggerMeterValue:1; //bit 2,
  753. unsigned char :5; //bit 5~7
  754. }bits[CONNECTOR_QUANTITY];
  755. }CpinitiateMsg;
  756. CpinitiateMsg cpinitateMsg;
  757. //=========================================
  758. // Date time related function
  759. //=========================================
  760. void getNowDatetime(uint8_t *data)
  761. {
  762. time_t t = time(NULL);
  763. struct tm tm = *localtime(&t);
  764. 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);
  765. }
  766. //=========================================
  767. // Sqlite3 related function
  768. //=========================================
  769. int DB_Initial()
  770. {
  771. int result = PASS;
  772. char* errMsg = NULL;
  773. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  774. "idToken text UNIQUE,"
  775. "type text,"
  776. "status text,"
  777. "cacheExpiryDateTime text,"
  778. "chargingPriority integer,"
  779. "language1 text,"
  780. "evseId text,"
  781. "language2 text,"
  782. "groupIdToken_idToken text,"
  783. "groupIdToken_type text,"
  784. "personalMessage text);";
  785. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  786. "idToken text UNIQUE,"
  787. "type text,"
  788. "status text,"
  789. "cacheExpiryDateTime text,"
  790. "chargingPriority integer,"
  791. "language1 text,"
  792. "evseId text,"
  793. "language2 text,"
  794. "groupIdToken_idToken text,"
  795. "groupIdToken_type text,"
  796. "personalMessage text,"
  797. "version text);";
  798. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  799. "componentName text NOT NULL ,"
  800. "componentInstance text, "
  801. "variableName text NOT NULL, "
  802. "variableInstance text, "
  803. "variableCharacteristicsDataType integer, "
  804. "variableCharacteristicsUnit text, "
  805. "variableCharacteristicsMaxLimit real,"
  806. "variableAttributesType text, "
  807. "variableAttributesTypeMutability text, "
  808. "variableAttributesTypeValue text, "
  809. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  810. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  811. "type);";
  812. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  813. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  814. {
  815. result = FAIL;
  816. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  817. sqlite3_close(db);
  818. }
  819. else
  820. {
  821. DEBUG_INFO( "OCPP local database open successfully.\n");
  822. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  823. {
  824. result = FAIL;
  825. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  826. }
  827. else
  828. {
  829. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  830. }
  831. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  832. {
  833. result = FAIL;
  834. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  835. }
  836. else
  837. {
  838. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  839. }
  840. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  841. {
  842. result = FAIL;
  843. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  844. }
  845. else
  846. {
  847. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  848. }
  849. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  850. {
  851. result = FAIL;
  852. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  853. }
  854. else
  855. {
  856. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  857. }
  858. //sqlite3_close(db);
  859. }
  860. return result;
  861. }
  862. int versionCallback(void *para, int columnCount, char **columnValue, char **columnName)
  863. {
  864. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  865. return 0;
  866. }
  867. void DB_getListVerion()
  868. {
  869. char sql[256];
  870. char* errMsg = NULL;
  871. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  872. /* Execute SQL statement */
  873. if( sqlite3_exec(db, sql, versionCallback, 0, &errMsg) != SQLITE_OK )
  874. {
  875. DEBUG_INFO("SQL error: %s", errMsg);
  876. }
  877. }
  878. int IdTagCallback(void *para, int columnCount, char **columnValue, char **columnName)
  879. {
  880. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  881. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  882. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  883. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  884. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  885. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  886. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  887. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  888. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  889. return 0;
  890. }
  891. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  892. {
  893. char sql[256];
  894. char* errMsg = NULL;
  895. memset(&idTagQuery, 0, sizeof(idTagQuery));
  896. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  897. if(isQueryFromCache)
  898. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  899. else
  900. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  901. /* Execute SQL statement */
  902. if(sqlite3_exec(db, sql, IdTagCallback, 0, &errMsg) != SQLITE_OK )
  903. {
  904. DEBUG_INFO("SQL error: %s", errMsg);
  905. }
  906. }
  907. int sqlite3_exec_callback(void *para, int columnCount, char **columnValue, char **columnName)
  908. {
  909. for (int i = 0; i < columnCount; i++)
  910. {
  911. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  912. }
  913. return 0;
  914. }
  915. void DB_get_TableAuthlocalAllData(void)
  916. {
  917. char sql[256];
  918. char* errMsg = NULL;
  919. sprintf(sql,"select * from ocpp20_auth_local;");
  920. /* Execute SQL statement */
  921. if(sqlite3_exec(db, sql, &sqlite3_exec_callback, 0,(char **)&errMsg) != SQLITE_OK)
  922. {
  923. DEBUG_INFO("SQL error: %s", errMsg);
  924. }
  925. }
  926. int listCallback(void *para, int columnCount, char **columnValue, char **columnName)
  927. {
  928. for(int i = 0; i<columnCount; i++)
  929. {
  930. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  931. }
  932. return 0;
  933. }
  934. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  935. {
  936. int result = PASS;
  937. char sql[512];
  938. char* errMsg = NULL;
  939. 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;",
  940. data->idToken.idToken,
  941. data->idToken.type,
  942. data->idTokenInfo.status,
  943. data->idTokenInfo.cacheExpiryDateTime,
  944. data->idTokenInfo.chargingPriority,
  945. data->idTokenInfo.language1,
  946. data->idTokenInfo.language2,
  947. data->idTokenInfo.groupIdToken.idToken,
  948. data->idTokenInfo.groupIdToken.type,
  949. listVersion);
  950. //* Execute SQL statement */
  951. if(sqlite3_exec(db, sql, listCallback, 0, &errMsg) != SQLITE_OK)
  952. {
  953. DEBUG_INFO("SQL error: %s\n", errMsg);
  954. result = FAIL;
  955. }
  956. else
  957. {
  958. memset(sql, 0, ARRAY_SIZE(sql));
  959. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  960. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  961. {
  962. DEBUG_INFO("SQL error: %s\n", errMsg);
  963. result = FAIL;
  964. }
  965. }
  966. return result;
  967. }
  968. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  969. {
  970. int result = PASS;
  971. char sql[512];
  972. char* errMsg = NULL;
  973. 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;",
  974. idToken->idToken,
  975. idToken->type,
  976. idTokenInfo->status,
  977. idTokenInfo->cacheExpiryDateTime,
  978. idTokenInfo->chargingPriority,
  979. idTokenInfo->language1,
  980. idTokenInfo->language2,
  981. idTokenInfo->groupIdToken.idToken,
  982. idTokenInfo->groupIdToken.type);
  983. //* Execute SQL statement */
  984. if(sqlite3_exec(db, sql, listCallback, 0, &errMsg) != SQLITE_OK)
  985. {
  986. DEBUG_INFO("SQL error: %s\n", errMsg);
  987. result = FAIL;
  988. }
  989. return result;
  990. }
  991. static int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  992. {
  993. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  994. // printf("localversion=%d\n", localversion);
  995. return 0;
  996. }
  997. void DB_deleteIdTag(char idTag[])
  998. {
  999. char sql[512];
  1000. char* errMsg = NULL;
  1001. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1002. //* Execute SQL statement */
  1003. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1004. {
  1005. DEBUG_INFO("SQL error: %s", errMsg);
  1006. }
  1007. }
  1008. int DB_cleanLocalList()
  1009. {
  1010. int result = PASS;
  1011. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1012. char *errMsg = 0;
  1013. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1014. {
  1015. DEBUG_INFO("%s\n", errMsg);
  1016. result = FAIL;
  1017. }
  1018. return result;
  1019. }
  1020. int DB_cleanLocalCache()
  1021. {
  1022. int result = PASS;
  1023. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1024. char *errMsg = 0;
  1025. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1026. {
  1027. DEBUG_INFO("%s\n", errMsg);
  1028. result = FAIL;
  1029. }
  1030. return result;
  1031. }
  1032. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1033. {
  1034. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1035. return 0;
  1036. }
  1037. void DB_getBooType()
  1038. {
  1039. char sql[256];
  1040. char* errMsg = NULL;
  1041. sprintf(sql,"select * from ocpp20_boot_type;");
  1042. /* Execute SQL statement */
  1043. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1044. {
  1045. DEBUG_INFO("SQL error: %s\n", errMsg);
  1046. }
  1047. }
  1048. int DB_updateBootType(BootReasonEnumType reason)
  1049. {
  1050. int result = PASS;
  1051. char sql[512];
  1052. char* errMsg = NULL;
  1053. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1054. //* Execute SQL statement */
  1055. if(sqlite3_exec(db, sql, listCallback, 0, &errMsg) != SQLITE_OK)
  1056. {
  1057. DEBUG_INFO("SQL error: %s\n", errMsg);
  1058. result = FAIL;
  1059. }
  1060. return result;
  1061. }
  1062. uint8_t DB_variableSaveToDb(struct ReportDataType *variable)
  1063. {
  1064. uint8_t result = FAIL;
  1065. char sql[4096];
  1066. char* errMsg = NULL;
  1067. 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;",
  1068. variable->component.name,
  1069. variable->component.instance,
  1070. variable->variable.name,
  1071. variable->variable.instance,
  1072. variable->variableCharacteristics.dataType,
  1073. variable->variableCharacteristics.unit,
  1074. variable->variableCharacteristics.maxLimit,
  1075. variable->variableAttribute[0].type,
  1076. variable->variableAttribute[0].mutability,
  1077. variable->variableAttribute[0].value);
  1078. //* Execute SQL statement */
  1079. if(sqlite3_exec(db, sql, listCallback, 0, &errMsg) != SQLITE_OK)
  1080. {
  1081. DEBUG_INFO("SQL error: %s\n", errMsg);
  1082. result = FAIL;
  1083. }
  1084. return result;
  1085. }
  1086. int cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1087. {
  1088. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1089. if(atoi(columnValue[0]) == 0)
  1090. {
  1091. DB_updateBootType(BootReasonEnumType_PowerUp);
  1092. // Create variable table content
  1093. /* AlignedDataCtrlr Required item */
  1094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1095. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1100. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1107. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1110. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1113. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1115. else
  1116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1117. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1125. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1132. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1139. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1145. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1147. else
  1148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1149. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1157. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1158. /* AuthCtrlrVariable Required item */
  1159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1165. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1172. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1179. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1186. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1193. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1200. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1204. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1208. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1209. /* AuthCacheCtrlr Variable Required item*/
  1210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1216. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1223. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1231. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1235. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*100);
  1236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1239. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1246. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1247. /* ClockCtrlr Variable Required item */
  1248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1253. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1254. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1261. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1269. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1276. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1283. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1291. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1298. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1305. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1306. /* ChargingStation Required item */
  1307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1313. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1320. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1327. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1328. /* Connector Required item */
  1329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1335. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1340. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1342. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1349. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1350. /* CustomizationCtrlr Required item */
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1357. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1358. /* DeviceDataCtrlr Required item */
  1359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1366. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1369. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1374. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1377. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1382. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1384. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1385. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1390. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1393. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1398. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1401. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1406. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1409. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1414. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1416. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1417. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1422. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1423. /* DisplayMessageCtrlr Required item */
  1424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1425. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1430. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1433. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1437. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1440. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "0");
  1444. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1451. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1458. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1459. /* EVSE Required item */
  1460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1466. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1473. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1480. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1487. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1488. /* LocalAuthListCtrlr Required item */
  1489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1495. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1498. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1502. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1509. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "50");
  1517. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1522. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "2048");
  1525. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1529. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = 1024*1024;
  1530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "5000");
  1533. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1534. /* MonitoringCtrlr Required item */
  1535. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1536. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1541. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1543. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1544. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1548. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1551. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1556. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1559. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1564. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1567. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1572. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1575. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1580. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1583. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1587. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1588. /* OCPPCommCtrlr Required item */
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1590. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1591. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1595. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1598. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1604. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1606. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1607. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1611. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1613. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1614. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1615. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1619. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1621. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1622. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "LAN,WIFI,4G");
  1626. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1633. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1635. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1641. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1643. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1645. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1646. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1648. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1651. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1653. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1654. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1655. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1657. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1658. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1659. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1660. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1661. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "3");
  1666. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1667. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1668. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1673. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1674. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1675. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1676. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1681. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1682. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1683. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1684. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1688. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1690. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1691. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1692. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1693. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1695. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1696. /* ReservationCtrlr Required item */
  1697. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1698. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1699. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1700. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1702. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1703. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1704. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1705. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1706. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1707. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1708. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1710. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1712. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1713. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1714. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1715. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1716. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1717. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1718. /* SampledDataCtrlr Required item */
  1719. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  1720. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  1721. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1722. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1723. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1724. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1725. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  1727. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  1728. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1729. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1730. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1732. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  1734. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  1735. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1737. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1739. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  1741. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1742. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1743. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1744. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1745. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, " ");
  1746. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1749. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1750. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1751. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1752. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1753. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1754. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  1757. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1758. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1759. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  1761. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  1764. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1765. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1766. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1767. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, " ");
  1768. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  1772. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1773. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1774. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1775. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "0");
  1776. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  1777. /* SecurityCtrlr Required item */
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  1779. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  1780. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1781. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  1782. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1783. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1784. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, " ");
  1785. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  1787. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  1788. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1789. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1791. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1792. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "Phihong Technology");
  1793. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  1795. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  1796. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "Phihong");
  1800. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  1801. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  1802. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  1803. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1804. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1805. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  1807. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  1808. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  1809. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  1810. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1811. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1812. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1813. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "0");
  1814. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  1815. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  1816. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  1817. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1819. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1820. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  1821. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  1822. /* SmartChargingCtrlr Required item */
  1823. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  1824. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  1825. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1828. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1829. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  1831. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1833. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1835. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  1836. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  1839. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1842. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  1843. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  1844. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  1845. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1847. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1848. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1849. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "0");
  1850. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  1851. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1854. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1855. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  1857. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  1858. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  1859. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1862. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  1864. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  1865. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  1866. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1869. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1870. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  1871. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  1872. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  1873. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  1874. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1876. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1877. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  1878. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  1879. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  1880. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1882. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1884. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  1885. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  1886. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  1887. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  1888. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1891. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "3");
  1892. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  1893. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  1894. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  1895. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1897. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1898. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  1899. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  1900. /* TariffCostCtrlr Required item */
  1901. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  1902. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  1903. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  1904. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1906. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1907. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  1908. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  1909. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  1911. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  1912. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1913. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1914. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  1916. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  1918. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  1919. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1920. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  1921. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1922. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1923. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  1924. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  1925. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  1926. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  1927. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  1928. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1929. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  1932. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  1933. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  1934. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  1935. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  1936. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1937. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  1940. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  1941. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  1942. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  1943. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1944. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  1945. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1946. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1947. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  1948. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  1949. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  1950. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  1951. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1952. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1954. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1955. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  1956. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  1957. /* TxCtrlr Required item */
  1958. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  1959. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  1960. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1961. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1962. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1963. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  1964. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  1965. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  1966. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  1967. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  1968. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1969. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1970. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1971. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  1972. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  1973. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  1974. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  1975. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1976. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1977. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1978. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1979. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  1980. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  1981. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  1982. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1983. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1984. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1985. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  1986. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  1987. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  1988. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1990. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1991. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1992. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "EVConnected,Authorized,PowerPathClosed");
  1993. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  1994. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  1995. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  1996. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1997. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1998. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1999. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "EVConnected,Authorized,PowerPathClosed");
  2000. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2001. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2002. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2003. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2005. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2007. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "60000");
  2008. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2009. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2010. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2012. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2014. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2015. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2016. }
  2017. else
  2018. {
  2019. // Variable name init
  2020. /* AlignedDataCtrlr Required item */
  2021. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2022. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2023. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2024. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2026. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2027. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2028. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2029. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2030. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2031. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2032. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2034. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2035. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2036. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2037. /* AuthCtrlrVariable Required item */
  2038. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2039. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2040. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2041. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2042. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2043. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2044. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2045. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2046. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2047. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2048. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2049. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2050. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2051. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2052. /* AuthCacheCtrlr Variable Required item */
  2053. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2054. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2055. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2056. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2059. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2062. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2063. /* ClockCtrlr Variable Required item */
  2064. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2065. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2066. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2067. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2068. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2069. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2070. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2071. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2073. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2074. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2076. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2077. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2078. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2080. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2081. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2082. /* ChargingStation Required item */
  2083. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2085. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2086. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2087. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2088. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2089. /* Connector Required item */
  2090. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2091. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2092. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2095. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2096. /* DeviceDataCtrlr Required item */
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2110. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2117. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2119. /* DisplayMessageCtrlr Required item */
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2130. /* EVSE Required item */
  2131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2139. /* LocalAuthListCtrlr Required item */
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2154. /* MonitoringCtrlr Required item */
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2173. /* OCPPCommCtrlr Required item */
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2205. /* ReservationCtrlr Required item */
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2212. /* SampledDataCtrlr Required item */
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2229. /* SecurityCtrlr Required item */
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2242. /* SmartChargingCtrlr Required item */
  2243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2265. /* TariffCostCtrlr Required item */
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2284. /* TxCtrlr Required item */
  2285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2301. }
  2302. return 0;
  2303. }
  2304. void DB_variableIsCreate()
  2305. {
  2306. char sql[512];
  2307. char* errMsg = NULL;
  2308. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2309. /* Execute SQL statement */
  2310. if(sqlite3_exec(db, sql, cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2311. {
  2312. DEBUG_INFO("SQL error: %s\n", errMsg);
  2313. }
  2314. }
  2315. int cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2316. {
  2317. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2318. {
  2319. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) != NULL) &&
  2320. (strlen(columnValue[2])>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) != NULL):TRUE) &&
  2321. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) != NULL) &&
  2322. (strlen(columnValue[4])>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) != NULL):TRUE))
  2323. {
  2324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2326. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2330. }
  2331. }
  2332. return 0;
  2333. }
  2334. void DB_variableLoadFromDb()
  2335. {
  2336. char sql[512];
  2337. char* errMsg = NULL;
  2338. sprintf(sql,"select * from ocpp20_variable;");
  2339. /* Execute SQL statement */
  2340. if(sqlite3_exec(db, sql, cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2341. {
  2342. DEBUG_INFO("SQL error: %s\n", errMsg);
  2343. }
  2344. }
  2345. //==========================================
  2346. // Check time passed since today
  2347. //==========================================
  2348. long long DiffTimebWithNow(struct timeb ST)
  2349. {
  2350. //return milli-second
  2351. struct timeb ET;
  2352. long long StartTime,StopTime;
  2353. ftime(&ET);
  2354. StartTime=(long long)ST.time;
  2355. StopTime=(long long)ET.time;
  2356. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2357. }
  2358. int getTimePassSinceToday()
  2359. {
  2360. int result = -1;
  2361. time_t t;
  2362. struct tm *tmStartToday;
  2363. struct timeb tbStartToday;
  2364. t=time(NULL);
  2365. tmStartToday=localtime(&t);
  2366. tmStartToday->tm_hour = 0;
  2367. tmStartToday->tm_min = 0;
  2368. tmStartToday->tm_sec = 0;
  2369. tbStartToday.time = mktime(tmStartToday);
  2370. tbStartToday.millitm = 0;
  2371. result = DiffTimebWithNow(tbStartToday)/1000;
  2372. return result;
  2373. }
  2374. //==========================================
  2375. // GetCompositeSchedule logic related function
  2376. //==========================================
  2377. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2378. {
  2379. //return milli-second
  2380. unsigned int StartTime,StopTime;
  2381. StartTime=(unsigned int)ST.time;
  2382. StopTime=(unsigned int)ET.time;
  2383. return (StopTime-StartTime);
  2384. }
  2385. int DiffTimebWithNowSec(struct timeb ST)
  2386. {
  2387. //return milli-second
  2388. struct timeb ET;
  2389. unsigned int StartTime,StopTime;
  2390. ftime(&ET);
  2391. StartTime=(unsigned int)ST.time;
  2392. StopTime=(unsigned int)ET.time;
  2393. return (StopTime-StartTime);
  2394. }
  2395. int getStartStop(uint8_t *start, uint8_t *stop)
  2396. {
  2397. int result = -1;
  2398. struct tm tmStart;
  2399. struct timeb tbStart;
  2400. struct tm tmStop;
  2401. struct timeb tbStop;
  2402. 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) &&
  2403. (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))
  2404. {
  2405. //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);
  2406. //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);
  2407. tmStart.tm_year -= 1900;
  2408. tmStart.tm_mon -= 1;
  2409. tbStart.time = mktime(&tmStart);
  2410. tbStart.millitm = 0;
  2411. tmStop.tm_year -= 1900;
  2412. tmStop.tm_mon -= 1;
  2413. tbStop.time = mktime(&tmStop);
  2414. tbStop.millitm = 0;
  2415. result = DiffTimebSec(tbStart, tbStop);
  2416. //DEBUG_INFO("getStartStop(): %d\n", result);
  2417. }
  2418. else
  2419. {
  2420. DEBUG_WARN("Start or stop date parsing error.\r\n");
  2421. }
  2422. return result;
  2423. }
  2424. int isOvertNow(uint8_t *start)
  2425. {
  2426. int result = YES;
  2427. struct tm tmStart;
  2428. struct timeb tbStart;
  2429. 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))
  2430. {
  2431. //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);
  2432. tmStart.tm_year -= 1900;
  2433. tmStart.tm_mon -= 1;
  2434. tbStart.time = mktime(&tmStart);
  2435. tbStart.millitm = 0;
  2436. if(DiffTimebWithNowSec(tbStart) <= 0)
  2437. result = NO;
  2438. }
  2439. else
  2440. {
  2441. DEBUG_WARN("Start date parsing error.\r\n");
  2442. }
  2443. return result;
  2444. }
  2445. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  2446. {
  2447. int result = -1;
  2448. struct tm tmStart;
  2449. struct timeb tbStart;
  2450. struct tm tmStop;
  2451. struct timeb tbStop;
  2452. 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) &&
  2453. (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))
  2454. {
  2455. tmStart.tm_year -= 1900;
  2456. tmStart.tm_mon -= 1;
  2457. tbStart.time = mktime(&tmStart);
  2458. tbStart.millitm = 0;
  2459. tmStop.tm_year -= 1900;
  2460. tmStop.tm_mon -= 1;
  2461. tbStop.time = mktime(&tmStop);
  2462. tbStop.millitm = 0;
  2463. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  2464. }
  2465. return result;
  2466. }
  2467. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *compositeProfile)
  2468. {
  2469. FILE *fp;
  2470. char profileFileName[128];
  2471. char *line = NULL;
  2472. size_t len = 0;
  2473. time_t CurrentTime;
  2474. struct tm *tmComposite;
  2475. struct ChargingProfileType maxProfile;
  2476. struct ChargingProfileType defaultTxProfile;
  2477. struct ChargingProfileType txProfile;
  2478. struct ChargingSchedulePeriodType tmpPeriod;
  2479. uint8_t limitMax=0;
  2480. uint8_t limitDef=0;
  2481. uint8_t limitTx=0;
  2482. int compositePeriodIdx = 0;
  2483. CurrentTime = time(NULL);
  2484. tmComposite=localtime(&CurrentTime);
  2485. 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);
  2486. sprintf((char*)compositeProfile->chargingSchedule[0].chargingRateUnit, "A");
  2487. compositeProfile->chargingSchedule[0].duration = durationReq;
  2488. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2489. {
  2490. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2491. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2492. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2493. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  2494. }
  2495. compositeProfile->id = 0;
  2496. compositeProfile->stackLevel = 99 ;
  2497. sprintf((char*)compositeProfile->chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  2498. maxProfile.id = -1;
  2499. defaultTxProfile.id = -1;
  2500. txProfile.id = -1;
  2501. maxProfile.chargingSchedule[0].duration = -1;
  2502. defaultTxProfile.chargingSchedule[0].duration = -1;
  2503. txProfile.chargingSchedule[0].duration = -1;
  2504. system("yes|rm /tmp/*.json");
  2505. system("cp /Storage/OCPP/*.json /tmp");
  2506. /*
  2507. * Search valid charging profile
  2508. */
  2509. //DEBUG_INFO("====================================\n");
  2510. // Search tx profile
  2511. sprintf(profileFileName, "/tmp/TxProfile_%d.json", connectorId);
  2512. if((access(profileFileName, F_OK))!=-1)
  2513. {
  2514. fp = fopen(profileFileName, "r");
  2515. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2516. {
  2517. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2518. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2519. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2520. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2521. }
  2522. txProfile.id = -1;
  2523. txProfile.stackLevel = -1;
  2524. while(getline(&line, &len, fp) != -1)
  2525. {
  2526. json_object *obj = NULL;
  2527. obj = json_tokener_parse(line);
  2528. if(is_error(obj))
  2529. {
  2530. DEBUG_ERROR("Parse txProfile from file error.\n");
  2531. }
  2532. else
  2533. {
  2534. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != txProfile.id) &&
  2535. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= txProfile.stackLevel)
  2536. )
  2537. {
  2538. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2539. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2540. )
  2541. {
  2542. struct tm tmFrom, tmTo;
  2543. struct timeb tbFrom, tbTo;
  2544. 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) &&
  2545. (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))
  2546. {
  2547. tmFrom.tm_year -= 1900;
  2548. tmFrom.tm_mon -= 1;
  2549. tbFrom.time = mktime(&tmFrom);
  2550. tmTo.tm_year -= 1900;
  2551. tmTo.tm_mon -= 1;
  2552. tbTo.time = mktime(&tmTo);
  2553. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2554. {
  2555. if(txProfile.id == -1)
  2556. DEBUG_INFO("TxProfile found.\n");
  2557. else
  2558. DEBUG_INFO("TxProfile updated.\n");
  2559. // Required item
  2560. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2561. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2562. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2563. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2564. 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++)
  2565. {
  2566. 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"));
  2567. 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")));
  2568. 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?
  2569. 3:
  2570. 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")));
  2571. }
  2572. // Optional item
  2573. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2574. {
  2575. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2576. }
  2577. else
  2578. {
  2579. sprintf((char*)txProfile.validFrom, " ");
  2580. }
  2581. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2582. {
  2583. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2584. }
  2585. else
  2586. {
  2587. sprintf((char*)txProfile.validTo, " ");
  2588. }
  2589. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2590. {
  2591. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2592. }
  2593. else
  2594. {
  2595. sprintf((char*)txProfile.recurrencyKind, " ");
  2596. }
  2597. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2598. {
  2599. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2600. }
  2601. else
  2602. {
  2603. sprintf((char*)txProfile.transactionId, " ");
  2604. }
  2605. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2606. {
  2607. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2608. }
  2609. else
  2610. {
  2611. txProfile.chargingSchedule[0].duration = 86400;
  2612. }
  2613. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2614. {
  2615. 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")));
  2616. }
  2617. else
  2618. {
  2619. 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));
  2620. }
  2621. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2622. {
  2623. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2624. }
  2625. else
  2626. {
  2627. txProfile.chargingSchedule[0].minChargingRate = -1;
  2628. }
  2629. }
  2630. }
  2631. }
  2632. else
  2633. {
  2634. if(txProfile.id == -1)
  2635. DEBUG_INFO("TxProfile found.\n");
  2636. else
  2637. DEBUG_INFO("TxProfile updated.\n");
  2638. // Required item
  2639. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2640. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2641. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2642. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2643. 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++)
  2644. {
  2645. 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"));
  2646. 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")));
  2647. 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?
  2648. 3:
  2649. 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")));
  2650. }
  2651. // Optional item
  2652. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2653. {
  2654. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2655. }
  2656. else
  2657. {
  2658. sprintf((char*)txProfile.validFrom, " ");
  2659. }
  2660. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2661. {
  2662. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2663. }
  2664. else
  2665. {
  2666. sprintf((char*)txProfile.validTo, " ");
  2667. }
  2668. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2669. {
  2670. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2671. }
  2672. else
  2673. {
  2674. sprintf((char*)txProfile.recurrencyKind, " ");
  2675. }
  2676. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2677. {
  2678. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2679. }
  2680. else
  2681. {
  2682. sprintf((char*)txProfile.transactionId, " ");
  2683. }
  2684. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2685. {
  2686. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2687. }
  2688. else
  2689. {
  2690. txProfile.chargingSchedule[0].duration = 86400;
  2691. }
  2692. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2693. {
  2694. 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")));
  2695. }
  2696. else
  2697. {
  2698. 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));
  2699. }
  2700. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2701. {
  2702. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2703. }
  2704. else
  2705. {
  2706. txProfile.chargingSchedule[0].minChargingRate = -1;
  2707. }
  2708. }
  2709. }
  2710. }
  2711. json_object_put(obj);
  2712. }
  2713. fclose(fp);
  2714. /*
  2715. if(txProfile.ChargingProfileId != -1)
  2716. {
  2717. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  2718. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  2719. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  2720. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  2721. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  2722. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  2723. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  2724. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[0].StartSchedule);
  2725. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  2726. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  2727. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  2728. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  2729. {
  2730. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  2731. {
  2732. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  2733. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  2734. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  2735. }
  2736. }
  2737. }
  2738. else
  2739. DEBUG_INFO("TxProfile not found.\n");*/
  2740. }
  2741. // Search default tx profile
  2742. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d.json", connectorId);
  2743. if((access(profileFileName, F_OK))==-1)
  2744. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  2745. if((access(profileFileName, F_OK))!=-1)
  2746. {
  2747. fp = fopen(profileFileName, "r");
  2748. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2749. {
  2750. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2751. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2752. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2753. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2754. }
  2755. defaultTxProfile.id = -1;
  2756. defaultTxProfile.stackLevel = -1;
  2757. while(getline(&line, &len, fp) != -1)
  2758. {
  2759. json_object *obj = NULL;
  2760. obj = json_tokener_parse(line);
  2761. if(is_error(obj))
  2762. {
  2763. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  2764. }
  2765. else
  2766. {
  2767. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != defaultTxProfile.id) &&
  2768. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= defaultTxProfile.stackLevel)
  2769. )
  2770. {
  2771. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2772. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2773. )
  2774. {
  2775. struct tm tmFrom, tmTo;
  2776. struct timeb tbFrom, tbTo;
  2777. 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) &&
  2778. (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))
  2779. {
  2780. tmFrom.tm_year -= 1900;
  2781. tmFrom.tm_mon -= 1;
  2782. tbFrom.time = mktime(&tmFrom);
  2783. tmTo.tm_year -= 1900;
  2784. tmTo.tm_mon -= 1;
  2785. tbTo.time = mktime(&tmTo);
  2786. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2787. {
  2788. if(defaultTxProfile.id == -1)
  2789. DEBUG_INFO("TxDefaultProfile found.\n");
  2790. else
  2791. DEBUG_INFO("TxDefaultProfile updated.\n");
  2792. // Required item
  2793. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2794. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2795. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2796. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  2797. 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++)
  2798. {
  2799. 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"));
  2800. 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")));
  2801. 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?
  2802. 3:
  2803. 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")));
  2804. }
  2805. // Optional item
  2806. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2807. {
  2808. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2809. }
  2810. else
  2811. {
  2812. sprintf((char*)defaultTxProfile.validFrom, " ");
  2813. }
  2814. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2815. {
  2816. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2817. }
  2818. else
  2819. {
  2820. sprintf((char*)defaultTxProfile.validTo, " ");
  2821. }
  2822. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2823. {
  2824. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2825. }
  2826. else
  2827. {
  2828. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  2829. }
  2830. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2831. {
  2832. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2833. }
  2834. else
  2835. {
  2836. sprintf((char*)defaultTxProfile.transactionId, " ");
  2837. }
  2838. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2839. {
  2840. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2841. }
  2842. else
  2843. {
  2844. defaultTxProfile.chargingSchedule[0].duration = 86400;
  2845. }
  2846. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2847. {
  2848. 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")));
  2849. }
  2850. else
  2851. {
  2852. 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));
  2853. }
  2854. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2855. {
  2856. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2857. }
  2858. else
  2859. {
  2860. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  2861. }
  2862. }
  2863. }
  2864. }
  2865. else
  2866. {
  2867. if(defaultTxProfile.id == -1)
  2868. DEBUG_INFO("TxDefaultProfile found.\n");
  2869. else
  2870. DEBUG_INFO("TxDefaultProfile updated.\n");
  2871. // Required item
  2872. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2873. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2874. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2875. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  2876. 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++)
  2877. {
  2878. 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"));
  2879. 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")));
  2880. 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?
  2881. 3:
  2882. 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")));
  2883. }
  2884. // Optional item
  2885. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2886. {
  2887. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2888. }
  2889. else
  2890. {
  2891. sprintf((char*)defaultTxProfile.validFrom, " ");
  2892. }
  2893. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2894. {
  2895. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2896. }
  2897. else
  2898. {
  2899. sprintf((char*)defaultTxProfile.validTo, " ");
  2900. }
  2901. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2902. {
  2903. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2904. }
  2905. else
  2906. {
  2907. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  2908. }
  2909. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2910. {
  2911. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2912. }
  2913. else
  2914. {
  2915. sprintf((char*)defaultTxProfile.transactionId, " ");
  2916. }
  2917. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2918. {
  2919. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2920. }
  2921. else
  2922. {
  2923. defaultTxProfile.chargingSchedule[0].duration = 86400;
  2924. }
  2925. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2926. {
  2927. 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")));
  2928. }
  2929. else
  2930. {
  2931. 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));
  2932. }
  2933. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2934. {
  2935. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2936. }
  2937. else
  2938. {
  2939. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  2940. }
  2941. }
  2942. }
  2943. }
  2944. json_object_put(obj);
  2945. }
  2946. fclose(fp);
  2947. /*
  2948. if(defaultTxProfile.ChargingProfileId != -1)
  2949. {
  2950. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  2951. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  2952. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  2953. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  2954. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  2955. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  2956. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  2957. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[0].StartSchedule);
  2958. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  2959. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  2960. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  2961. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  2962. {
  2963. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  2964. {
  2965. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  2966. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  2967. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  2968. }
  2969. }
  2970. }
  2971. else
  2972. DEBUG_INFO("TxDefaultProfile not found.\n");
  2973. DEBUG_INFO("------------------------------------\n");*/
  2974. }
  2975. // Search max profile
  2976. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  2977. if((access(profileFileName, F_OK))!=-1)
  2978. {
  2979. fp = fopen(profileFileName, "r");
  2980. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2981. {
  2982. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2983. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2984. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2985. }
  2986. maxProfile.id = -1;
  2987. maxProfile.stackLevel = -1;
  2988. while(getline(&line, &len, fp) != -1)
  2989. {
  2990. json_object *obj = NULL;
  2991. obj = json_tokener_parse(line);
  2992. if(is_error(obj))
  2993. {
  2994. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  2995. }
  2996. else
  2997. {
  2998. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != maxProfile.id) &&
  2999. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= maxProfile.stackLevel)
  3000. )
  3001. {
  3002. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3003. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3004. )
  3005. {
  3006. struct tm tmFrom, tmTo;
  3007. struct timeb tbFrom, tbTo;
  3008. 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) &&
  3009. (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))
  3010. {
  3011. tmFrom.tm_year -= 1900;
  3012. tmFrom.tm_mon -= 1;
  3013. tbFrom.time = mktime(&tmFrom);
  3014. tmTo.tm_year -= 1900;
  3015. tmTo.tm_mon -= 1;
  3016. tbTo.time = mktime(&tmTo);
  3017. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3018. {
  3019. if(maxProfile.id == -1)
  3020. DEBUG_INFO("MaxProfile found.\n");
  3021. else
  3022. DEBUG_INFO("MaxProfile updated.\n");
  3023. // Required item
  3024. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3025. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3026. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3027. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3028. 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++)
  3029. {
  3030. 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"));
  3031. 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")));
  3032. 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?
  3033. 3:
  3034. 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")));
  3035. }
  3036. // Optional item
  3037. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3038. {
  3039. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3040. }
  3041. else
  3042. {
  3043. sprintf((char*)maxProfile.validFrom, " ");
  3044. }
  3045. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3046. {
  3047. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3048. }
  3049. else
  3050. {
  3051. sprintf((char*)maxProfile.validTo, " ");
  3052. }
  3053. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3054. {
  3055. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3056. }
  3057. else
  3058. {
  3059. sprintf((char*)maxProfile.recurrencyKind, " ");
  3060. }
  3061. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3062. {
  3063. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3064. }
  3065. else
  3066. {
  3067. sprintf((char*)maxProfile.transactionId, " ");
  3068. }
  3069. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3070. {
  3071. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3072. }
  3073. else
  3074. {
  3075. maxProfile.chargingSchedule[0].duration = 86400;
  3076. }
  3077. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3078. {
  3079. 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")));
  3080. }
  3081. else
  3082. {
  3083. 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));
  3084. }
  3085. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3086. {
  3087. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3088. }
  3089. else
  3090. {
  3091. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3092. }
  3093. }
  3094. }
  3095. }
  3096. else
  3097. {
  3098. if(maxProfile.id == -1)
  3099. DEBUG_INFO("MaxProfile found.\n");
  3100. else
  3101. DEBUG_INFO("MaxProfile updated.\n");
  3102. // Required item
  3103. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3104. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3105. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3106. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3107. 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++)
  3108. {
  3109. 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"));
  3110. 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")));
  3111. 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?
  3112. 3:
  3113. 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")));
  3114. }
  3115. // Optional item
  3116. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3117. {
  3118. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3119. }
  3120. else
  3121. {
  3122. sprintf((char*)maxProfile.validFrom, " ");
  3123. }
  3124. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3125. {
  3126. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3127. }
  3128. else
  3129. {
  3130. sprintf((char*)maxProfile.validTo, " ");
  3131. }
  3132. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3133. {
  3134. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3135. }
  3136. else
  3137. {
  3138. sprintf((char*)maxProfile.recurrencyKind, " ");
  3139. }
  3140. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3141. {
  3142. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3143. }
  3144. else
  3145. {
  3146. sprintf((char*)maxProfile.transactionId, " ");
  3147. }
  3148. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3149. {
  3150. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3151. }
  3152. else
  3153. {
  3154. maxProfile.chargingSchedule[0].duration = 86400;
  3155. }
  3156. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3157. {
  3158. 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")));
  3159. }
  3160. else
  3161. {
  3162. 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));
  3163. }
  3164. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3165. {
  3166. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3167. }
  3168. else
  3169. {
  3170. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3171. }
  3172. }
  3173. }
  3174. }
  3175. json_object_put(obj);
  3176. }
  3177. fclose(fp);
  3178. /*
  3179. if(maxProfile.ChargingProfileId !=-1)
  3180. {
  3181. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3182. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3183. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3184. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3185. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3186. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3187. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3188. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[0].StartSchedule);
  3189. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3190. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3191. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3192. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3193. {
  3194. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3195. {
  3196. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3197. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3198. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3199. }
  3200. }
  3201. }
  3202. else
  3203. DEBUG_INFO("MaxProfile not found.\n");
  3204. DEBUG_INFO("------------------------------------\n");*/
  3205. }
  3206. /*
  3207. * Align found profile start schedule & periods
  3208. */
  3209. //DEBUG_INFO("====================================\n");
  3210. /*
  3211. // For local test usage, force modify found profile start schedule info
  3212. 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);
  3213. 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);
  3214. 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);
  3215. */
  3216. if(txProfile.id != -1)
  3217. {
  3218. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3219. {
  3220. if(txProfile.chargingSchedule[0].duration != -1)
  3221. {
  3222. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3223. 0:
  3224. (txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3225. }
  3226. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3227. {
  3228. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3229. {
  3230. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3231. 0:
  3232. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3233. if(idxPeriod > 0)
  3234. {
  3235. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3236. {
  3237. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3238. }
  3239. }
  3240. }
  3241. }
  3242. }
  3243. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3244. {
  3245. if(txProfile.chargingSchedule[0].duration != -1)
  3246. {
  3247. 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?
  3248. 0:
  3249. (txProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3250. }
  3251. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3252. {
  3253. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3254. {
  3255. 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?
  3256. 0:
  3257. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3258. if(idxPeriod > 0)
  3259. {
  3260. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3261. {
  3262. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3263. }
  3264. }
  3265. }
  3266. }
  3267. }
  3268. else
  3269. {
  3270. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3271. {
  3272. if(txProfile.chargingSchedule[0].duration != -1)
  3273. {
  3274. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3275. 0:
  3276. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3277. }
  3278. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3279. {
  3280. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3281. {
  3282. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3283. 0:
  3284. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3285. if(idxPeriod > 0)
  3286. {
  3287. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3288. {
  3289. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3290. }
  3291. }
  3292. }
  3293. }
  3294. }
  3295. else
  3296. {
  3297. if(txProfile.chargingSchedule[0].duration != -1)
  3298. {
  3299. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3300. 0:
  3301. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3302. }
  3303. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3304. {
  3305. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3306. {
  3307. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3308. 0:
  3309. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3310. if(idxPeriod > 0)
  3311. {
  3312. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3313. {
  3314. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3315. }
  3316. }
  3317. }
  3318. }
  3319. }
  3320. }
  3321. /*
  3322. DEBUG_INFO("txProfile after align.\n");
  3323. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  3324. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3325. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3326. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3327. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3328. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3329. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  3330. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3331. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  3332. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  3333. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  3334. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3335. {
  3336. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3337. {
  3338. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3339. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3340. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3341. }
  3342. }*/
  3343. }
  3344. if(defaultTxProfile.id != -1)
  3345. {
  3346. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3347. {
  3348. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3349. {
  3350. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3351. 0:
  3352. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3353. }
  3354. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3355. {
  3356. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3357. {
  3358. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3359. 0:
  3360. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3361. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3362. {
  3363. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3364. }
  3365. if(idxPeriod > 0)
  3366. {
  3367. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3368. {
  3369. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3370. }
  3371. }
  3372. }
  3373. }
  3374. }
  3375. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3376. {
  3377. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3378. {
  3379. 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?
  3380. 0:
  3381. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3382. }
  3383. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3384. {
  3385. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3386. {
  3387. 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?
  3388. 0:
  3389. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3390. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3391. {
  3392. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3393. }
  3394. if(idxPeriod > 0)
  3395. {
  3396. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3397. {
  3398. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3399. }
  3400. }
  3401. }
  3402. }
  3403. }
  3404. else
  3405. {
  3406. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3407. {
  3408. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3409. {
  3410. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3411. 0:
  3412. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3413. }
  3414. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3415. {
  3416. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3417. {
  3418. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3419. 0:
  3420. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3421. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3422. {
  3423. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3424. }
  3425. if(idxPeriod > 0)
  3426. {
  3427. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3428. {
  3429. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3430. }
  3431. }
  3432. }
  3433. }
  3434. }
  3435. else
  3436. {
  3437. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3438. {
  3439. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3440. 0:
  3441. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3442. }
  3443. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3444. {
  3445. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3446. {
  3447. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3448. 0:
  3449. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3450. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3451. {
  3452. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3453. }
  3454. if(idxPeriod > 0)
  3455. {
  3456. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3457. {
  3458. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3459. }
  3460. }
  3461. }
  3462. }
  3463. }
  3464. }
  3465. /*
  3466. DEBUG_INFO("defaultTxProfile after align.\n");
  3467. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3468. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3469. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3470. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3471. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3472. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3473. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3474. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3475. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3476. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3477. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3478. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3479. {
  3480. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3481. {
  3482. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3483. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3484. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3485. }
  3486. }
  3487. DEBUG_INFO("------------------------------------\n");*/
  3488. }
  3489. if(maxProfile.id != -1)
  3490. {
  3491. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3492. {
  3493. if(maxProfile.chargingSchedule[0].duration != -1)
  3494. {
  3495. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3496. 0:
  3497. (maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3498. }
  3499. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3500. {
  3501. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3502. {
  3503. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3504. 0:
  3505. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3506. if(idxPeriod > 0)
  3507. {
  3508. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3509. {
  3510. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3511. }
  3512. }
  3513. }
  3514. }
  3515. }
  3516. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3517. {
  3518. if(maxProfile.chargingSchedule[0].duration != -1)
  3519. {
  3520. 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?
  3521. 0:
  3522. (maxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[9].startSchedule)));
  3523. }
  3524. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3525. {
  3526. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3527. {
  3528. 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?
  3529. 0:
  3530. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3531. if(idxPeriod > 0)
  3532. {
  3533. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3534. {
  3535. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3536. }
  3537. }
  3538. }
  3539. }
  3540. }
  3541. else
  3542. {
  3543. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3544. {
  3545. if(maxProfile.chargingSchedule[0].duration != -1)
  3546. {
  3547. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3548. 0:
  3549. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3550. }
  3551. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3552. {
  3553. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3554. {
  3555. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3556. 0:
  3557. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3558. if(idxPeriod > 0)
  3559. {
  3560. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3561. {
  3562. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3563. }
  3564. }
  3565. }
  3566. }
  3567. }
  3568. else
  3569. {
  3570. if(maxProfile.chargingSchedule[0].duration != -1)
  3571. {
  3572. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3573. 0:
  3574. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3575. }
  3576. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3577. {
  3578. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3579. {
  3580. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3581. 0:
  3582. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3583. if(idxPeriod > 0)
  3584. {
  3585. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3586. {
  3587. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3588. }
  3589. }
  3590. }
  3591. }
  3592. }
  3593. }
  3594. /*
  3595. DEBUG_INFO("MaxProfile after align.\n");
  3596. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3597. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3598. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3599. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3600. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3601. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3602. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3603. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3604. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3605. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3606. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3607. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3608. {
  3609. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3610. {
  3611. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3612. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3613. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3614. }
  3615. }
  3616. DEBUG_INFO("------------------------------------\n");*/
  3617. }
  3618. /*
  3619. * Merge to conposite schedule
  3620. */
  3621. //DEBUG_INFO("====================================\n");
  3622. // Find each profile period quantity
  3623. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3624. {
  3625. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3626. limitMax = idx+1;
  3627. }
  3628. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3629. {
  3630. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3631. limitDef = idx+1;
  3632. }
  3633. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3634. {
  3635. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3636. limitTx = idx+1;
  3637. }
  3638. // TxProfile found, composite schedule based on it
  3639. if(txProfile.id != -1)
  3640. {
  3641. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  3642. {
  3643. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  3644. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  3645. (txProfile.chargingSchedule[0].duration > 0))
  3646. {
  3647. if(maxProfile.id != -1)
  3648. {
  3649. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3650. {
  3651. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  3652. {
  3653. if((maxProfile.chargingSchedule[0].duration > 0))
  3654. {
  3655. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3656. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3657. 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);
  3658. }
  3659. else
  3660. {
  3661. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3662. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3663. tmpPeriod.limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit;
  3664. }
  3665. }
  3666. if(idxMaxPeriod == (limitMax-1))
  3667. {
  3668. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3669. {
  3670. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3671. {
  3672. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3673. compositePeriodIdx++;
  3674. }
  3675. else
  3676. {
  3677. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3678. }
  3679. }
  3680. }
  3681. }
  3682. }
  3683. else
  3684. {
  3685. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3686. {
  3687. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3688. compositePeriodIdx++;
  3689. }
  3690. else
  3691. {
  3692. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3693. }
  3694. }
  3695. }
  3696. if(idxTxPeriod == (limitTx-1))
  3697. {
  3698. if(defaultTxProfile.id != -1)
  3699. {
  3700. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3701. {
  3702. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  3703. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3704. (defaultTxProfile.chargingSchedule[0].duration>0))
  3705. {
  3706. if(maxProfile.id != -1)
  3707. {
  3708. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3709. {
  3710. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3711. {
  3712. if((maxProfile.chargingSchedule[0].duration > 0))
  3713. {
  3714. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3715. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3716. 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);
  3717. }
  3718. else
  3719. {
  3720. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3721. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3722. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3723. }
  3724. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3725. {
  3726. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3727. {
  3728. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3729. compositePeriodIdx++;
  3730. }
  3731. else
  3732. {
  3733. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3734. }
  3735. }
  3736. break;
  3737. }
  3738. }
  3739. }
  3740. else
  3741. {
  3742. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3743. {
  3744. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3745. compositePeriodIdx++;
  3746. }
  3747. else
  3748. {
  3749. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3750. }
  3751. }
  3752. }
  3753. }
  3754. }
  3755. }
  3756. }
  3757. }
  3758. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  3759. else if(defaultTxProfile.id != -1)
  3760. {
  3761. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3762. {
  3763. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  3764. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3765. (defaultTxProfile.chargingSchedule[0].duration > 0))
  3766. {
  3767. if(maxProfile.id != -1)
  3768. {
  3769. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3770. {
  3771. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3772. {
  3773. if((maxProfile.chargingSchedule[0].duration > 0))
  3774. {
  3775. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3776. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3777. 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);
  3778. }
  3779. else
  3780. {
  3781. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3782. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3783. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3784. }
  3785. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3786. {
  3787. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3788. {
  3789. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3790. compositePeriodIdx++;
  3791. }
  3792. else
  3793. {
  3794. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3795. }
  3796. }
  3797. break;
  3798. }
  3799. }
  3800. }
  3801. else
  3802. {
  3803. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3804. {
  3805. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3806. compositePeriodIdx++;
  3807. }
  3808. else
  3809. {
  3810. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3811. }
  3812. }
  3813. }
  3814. }
  3815. }
  3816. // Fill other period by MaxProfile
  3817. if(maxProfile.id != -1)
  3818. {
  3819. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3820. {
  3821. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3822. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3823. (maxProfile.chargingSchedule[0].duration > 0))
  3824. {
  3825. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod >= compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod) &&
  3826. (maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3827. {
  3828. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod;
  3829. tmpPeriod.numberPhases = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].numberPhases;
  3830. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3831. }
  3832. if((maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3833. {
  3834. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].duration;
  3835. tmpPeriod.numberPhases = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  3836. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3837. }
  3838. if(tmpPeriod.limit != -1)
  3839. {
  3840. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3841. {
  3842. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3843. {
  3844. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3845. compositePeriodIdx++;
  3846. }
  3847. else
  3848. {
  3849. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3850. }
  3851. }
  3852. }
  3853. }
  3854. }
  3855. }
  3856. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  3857. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[0].startSchedule);
  3858. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[0].duration);
  3859. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[0].chargingRateUnit);
  3860. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3861. {
  3862. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  3863. {
  3864. compositeProfile->id = 1;
  3865. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3866. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit);
  3867. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases);
  3868. }
  3869. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit == -1)
  3870. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit =0;
  3871. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  3872. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  3873. }
  3874. if(line)
  3875. free(line);
  3876. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = 1;
  3877. }
  3878. //==========================================
  3879. // Init all share memory
  3880. //==========================================
  3881. int InitShareMemory()
  3882. {
  3883. int result = PASS;
  3884. int MeterSMId;
  3885. //creat ShmSysConfigAndInfo
  3886. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  3887. {
  3888. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  3889. result = FAIL;
  3890. }
  3891. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  3892. {
  3893. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  3894. result = FAIL;
  3895. }
  3896. else
  3897. {}
  3898. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  3899. {
  3900. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  3901. result = FAIL;
  3902. }
  3903. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  3904. {
  3905. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  3906. result = FAIL;
  3907. }
  3908. else
  3909. {}
  3910. //creat ShmPsuData
  3911. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  3912. {
  3913. DEBUG_ERROR("shmget ShmPsuData NG\n");
  3914. result = FAIL;
  3915. }
  3916. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  3917. {
  3918. DEBUG_ERROR("shmat ShmPsuData NG\n");
  3919. result = FAIL;
  3920. }
  3921. else
  3922. {}
  3923. //creat ShmOCPP20Data
  3924. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  3925. {
  3926. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  3927. result = FAIL;
  3928. }
  3929. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  3930. {
  3931. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  3932. result = FAIL;
  3933. }
  3934. else
  3935. {}
  3936. /****************************** For Initial Settings************************************************/
  3937. //offline MeterValue Interval
  3938. TempMeterValueInterval = 0;
  3939. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  3940. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  3941. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  3942. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  3943. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  3944. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  3945. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  3946. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  3947. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  3948. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  3949. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  3950. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  3951. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  3952. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  3953. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  3954. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  3955. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  3956. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  3957. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  3958. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  3959. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  3960. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  3961. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  3962. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  3963. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  3964. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  3965. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  3966. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  3967. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  3968. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  3969. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  3970. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  3971. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  3972. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  3973. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  3974. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  3975. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  3976. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  3977. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  3978. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  3979. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  3980. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  3981. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  3982. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  3983. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  3984. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  3985. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  3986. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  3987. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  3988. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  3989. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  3990. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  3991. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  3992. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  3993. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  3994. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  3995. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  3996. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  3997. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  3998. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  3999. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  4000. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  4001. return result;
  4002. }
  4003. int ProcessShareMemory()
  4004. {
  4005. if(InitShareMemory() == FAIL)
  4006. {
  4007. DEBUG_ERROR("InitShareMemory NG\n");
  4008. if(ShmStatusCodeData!=NULL)
  4009. {
  4010. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  4011. }
  4012. sleep(5);
  4013. return FAIL;
  4014. }
  4015. return PASS;
  4016. }
  4017. //---------------------common routine---------------------------//
  4018. int isOFFline(void)
  4019. {
  4020. if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
  4021. {
  4022. if(TempMeterValueInterval >= 2 )
  4023. {
  4024. TempMeterValueInterval = 0;
  4025. return TRUE;
  4026. }
  4027. else
  4028. {
  4029. TempMeterValueInterval = TempMeterValueInterval+ 1;
  4030. return FALSE;
  4031. }
  4032. }
  4033. else
  4034. {
  4035. return FALSE;
  4036. }
  4037. }
  4038. void CheckSystemValue(void)
  4039. {
  4040. uint8_t reqSampleMeter[CONNECTOR_QUANTITY]={0};
  4041. uint8_t reqClockAlignMeter[CONNECTOR_QUANTITY]={0};
  4042. char filenmae[100]={0};
  4043. char str[100]={0};
  4044. int tempIndex = 0;
  4045. //===============================
  4046. // EVSE operation check
  4047. //===============================
  4048. //===============================
  4049. // Heartbeat check
  4050. //===============================
  4051. if((difftime(time((time_t*)NULL), clientTime.Heartbeat) < 0) || (HeartBeatWaitTime <= 0))
  4052. {
  4053. clientTime.Heartbeat = time((time_t*)NULL);
  4054. if(server_sign == TRUE)
  4055. {
  4056. HeartBeatWaitTime = ShmOCPP20Data->BootNotification.Response_interval;
  4057. }
  4058. else
  4059. {
  4060. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);
  4061. }
  4062. }
  4063. if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= HeartBeatWaitTime))
  4064. {
  4065. //parameter for test
  4066. sendHeartbeatRequest(0);
  4067. //==============================================
  4068. // Reset Waiting Time
  4069. //==============================================
  4070. clientTime.Heartbeat=time((time_t*)NULL);
  4071. HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
  4072. }
  4073. //===============================
  4074. // CSU Trigger Reset Conf
  4075. //===============================
  4076. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->MsMsg.bits.ResetConf == 1))
  4077. {
  4078. sendResetConfirmation((char *)ShmOCPP20Data->Reset.guid);
  4079. }
  4080. //===============================
  4081. // CSU Trigger Authorize Request
  4082. //===============================
  4083. if(isWebsocketSendable &&
  4084. (server_sign == TRUE) &&
  4085. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == 1) &&
  4086. (authorizeRetryTimes < 3))
  4087. {
  4088. sendAuthorizeRequest(0);
  4089. authorizeRetryTimes = authorizeRetryTimes + 1;
  4090. if(authorizeRetryTimes < 3)
  4091. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = 0;
  4092. }
  4093. else if((server_sign == TRUE) &&
  4094. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == 1) &&
  4095. (authorizeRetryTimes >= 3))
  4096. {
  4097. authorizeRetryTimes = 0;
  4098. ShmOCPP20Data->OcppConnStatus = 0; // ocpp off-line
  4099. server_sign = FALSE;
  4100. }
  4101. else if((server_sign == FALSE) &&
  4102. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  4103. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  4104. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  4105. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  4106. {
  4107. sendAuthorizeRequest(0);
  4108. }
  4109. //===============================
  4110. // Each connector operation check
  4111. //===============================
  4112. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  4113. {
  4114. //===============================
  4115. // CSU Trigger Smart Charging Profilw
  4116. //===============================
  4117. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  4118. {
  4119. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index]);
  4120. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  4121. }
  4122. //==============================================
  4123. // Charger start transaction
  4124. //==============================================
  4125. /*
  4126. if((ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq == 1))
  4127. {
  4128. ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq = OFF;
  4129. sendStartTransactionRequest(gun_index);
  4130. clientTime.StartTransaction = time((time_t*)NULL);
  4131. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4132. }*/
  4133. //==============================================
  4134. // Charger stop transaction
  4135. //==============================================
  4136. /*
  4137. if(((ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq == 1)))
  4138. {
  4139. ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq =0;
  4140. sendStopTransactionRequest(gun_index);
  4141. clientTime.StopTransaction = time((time_t*)NULL);
  4142. }*/
  4143. //==============================================
  4144. // Charger status report
  4145. //==============================================
  4146. //--- Check Mode Change ---//
  4147. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  4148. if(gunType[gun_index] == 'J')
  4149. {
  4150. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4151. {
  4152. tempIndex = ((gun_index==2) ? 1: 0);
  4153. }
  4154. else
  4155. {
  4156. tempIndex = gun_index;
  4157. }
  4158. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4159. {
  4160. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4161. {
  4162. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  4163. {
  4164. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  4165. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  4166. cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
  4167. statusModeChage[gun_index] = TRUE;
  4168. }
  4169. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4170. {
  4171. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4172. if((access(filenmae,F_OK))!=-1)
  4173. {
  4174. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4175. sprintf(str,"rm -f %s",filenmae);
  4176. system(str);
  4177. }
  4178. }
  4179. #if 1 // for TempStopTransaction
  4180. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4181. {
  4182. checkTempStopTransaction(gun_index);
  4183. }
  4184. #endif
  4185. }
  4186. }
  4187. }
  4188. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4189. {
  4190. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4191. {
  4192. tempIndex = ((gun_index==2) ? 1: 0);
  4193. }
  4194. else
  4195. {
  4196. tempIndex = gun_index;
  4197. }
  4198. for (int index = 0; index < CCS_QUANTITY; index++)
  4199. {
  4200. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4201. {
  4202. 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]*/ )
  4203. {
  4204. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  4205. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  4206. cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
  4207. statusModeChage[gun_index] = TRUE;
  4208. }
  4209. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4210. {
  4211. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4212. if((access(filenmae,F_OK))!=-1)
  4213. {
  4214. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4215. sprintf(str,"rm -f %s",filenmae);
  4216. system(str);
  4217. }
  4218. }
  4219. #if 1 // for TempStopTransaction
  4220. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4221. {
  4222. checkTempStopTransaction(gun_index);
  4223. }
  4224. #endif
  4225. }
  4226. }
  4227. }
  4228. else if(gunType[gun_index] == 'G')
  4229. {
  4230. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4231. {
  4232. tempIndex = ((gun_index==2) ? 1: 0);
  4233. }
  4234. else
  4235. {
  4236. tempIndex = gun_index;
  4237. }
  4238. for (int index = 0; index < GB_QUANTITY; index++)
  4239. {
  4240. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4241. {
  4242. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  4243. {
  4244. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  4245. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  4246. cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
  4247. statusModeChage[gun_index] = TRUE;
  4248. }
  4249. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4250. {
  4251. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4252. if((access(filenmae,F_OK))!=-1)
  4253. {
  4254. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4255. sprintf(str,"rm -f %s",filenmae);
  4256. system(str);
  4257. }
  4258. }
  4259. #if 1 // for TempStopTransaction
  4260. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4261. {
  4262. checkTempStopTransaction(gun_index);
  4263. }
  4264. #endif
  4265. }
  4266. }
  4267. }
  4268. else if(gunType[gun_index] == 'O')
  4269. {
  4270. tempIndex = gun_index;
  4271. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4272. {
  4273. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4274. {
  4275. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  4276. {
  4277. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  4278. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  4279. cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
  4280. statusModeChage[gun_index] = TRUE;
  4281. }
  4282. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // complete
  4283. {
  4284. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4285. if((access(filenmae,F_OK))!=-1)
  4286. {
  4287. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4288. sprintf(str,"rm -f %s",filenmae);
  4289. system(str);
  4290. }
  4291. }
  4292. #if 1 // for TempStopTransaction
  4293. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == 0))
  4294. {
  4295. checkTempStopTransaction(gun_index);
  4296. }
  4297. #endif
  4298. }
  4299. }
  4300. }
  4301. else
  4302. {
  4303. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4304. {
  4305. tempIndex = 2;
  4306. }
  4307. else
  4308. {
  4309. tempIndex = gun_index;
  4310. }
  4311. for (int index = 0; index < AC_QUANTITY; index++)
  4312. {
  4313. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4314. {
  4315. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  4316. {
  4317. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  4318. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  4319. cpinitateMsg.bits[gun_index].StatusNotificationReq = 1;
  4320. statusModeChage[gun_index] = TRUE;
  4321. }
  4322. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4323. {
  4324. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4325. if((access(filenmae,F_OK))!=-1)
  4326. {
  4327. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4328. sprintf(str,"rm -f %s",filenmae);
  4329. system(str);
  4330. }
  4331. }
  4332. #if 1 // for TempStopTransaction
  4333. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4334. {
  4335. checkTempStopTransaction(gun_index);
  4336. }
  4337. #endif
  4338. }
  4339. }// END
  4340. }
  4341. if(isWebsocketSendable &&
  4342. (((statusModeChage[gun_index] == TRUE) || ((cpinitateMsg.bits[gun_index].StatusNotificationReq == 1) && ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 10)))) )
  4343. {
  4344. if(SystemInitial > 0)
  4345. SystemInitial -= 1;
  4346. sendStatusNotificationRequest(gun_index);
  4347. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  4348. statusModeChage[gun_index] = FALSE;
  4349. }
  4350. //==============================================
  4351. // Meter report
  4352. //==============================================
  4353. if(cpinitateMsg.bits[gun_index].TriggerMeterValue)
  4354. {
  4355. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  4356. cpinitateMsg.bits[gun_index].TriggerMeterValue = 0;
  4357. }
  4358. if(((time((time_t*)NULL) - clientTime.MeterValues[gun_index]) > (atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1)) ||
  4359. ((atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value) > 0)?((getTimePassSinceToday()%(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value)))==0):FALSE))
  4360. {
  4361. //check Transaction active
  4362. if(gunType[gun_index] == 'J')
  4363. {
  4364. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4365. {
  4366. tempIndex = ((gun_index==2) ? 1: 0);
  4367. }
  4368. else
  4369. {
  4370. tempIndex = gun_index;
  4371. }
  4372. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4373. {
  4374. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4375. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4376. {
  4377. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4378. {
  4379. reqSampleMeter[gun_index] = 1;
  4380. }
  4381. else if((atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value) > 0) && ((getTimePassSinceToday()%(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value)))==0))
  4382. {
  4383. reqClockAlignMeter[gun_index] = 1;
  4384. }
  4385. }
  4386. }// End for CHAdeMO
  4387. }
  4388. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4389. {
  4390. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4391. {
  4392. tempIndex = ((gun_index==2) ? 1: 0);
  4393. }
  4394. else
  4395. {
  4396. tempIndex = gun_index;
  4397. }
  4398. for (int index = 0; index < CCS_QUANTITY; index++)
  4399. {
  4400. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4401. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4402. {
  4403. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4404. {
  4405. reqSampleMeter[gun_index] = 1;
  4406. }
  4407. else if((atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value) > 0) && ((getTimePassSinceToday()%(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value)))==0))
  4408. {
  4409. reqClockAlignMeter[gun_index] = 1;
  4410. }
  4411. }
  4412. } // End for CCS
  4413. }
  4414. else if(gunType[gun_index] == 'G')
  4415. {
  4416. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4417. {
  4418. tempIndex = ((gun_index==2) ? 1: 0);
  4419. }
  4420. else
  4421. {
  4422. tempIndex = gun_index;
  4423. }
  4424. for (int index = 0; index < GB_QUANTITY; index++)
  4425. {
  4426. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4427. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4428. {
  4429. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4430. {
  4431. reqSampleMeter[gun_index] = 1;
  4432. }
  4433. else if((atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value) > 0) && ((getTimePassSinceToday()%(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value)))==0))
  4434. {
  4435. reqClockAlignMeter[gun_index] = 1;
  4436. }
  4437. }
  4438. }// End for GB
  4439. }
  4440. else if(gunType[gun_index] == 'O')
  4441. {
  4442. tempIndex = gun_index;
  4443. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4444. {
  4445. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4446. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4447. {
  4448. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  4449. {
  4450. reqSampleMeter[gun_index] = 1;
  4451. }
  4452. else if((atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value) > 0) && ((getTimePassSinceToday()%(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value)))==0))
  4453. {
  4454. reqClockAlignMeter[gun_index] = 1;
  4455. }
  4456. }
  4457. }
  4458. }
  4459. else
  4460. {
  4461. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4462. {
  4463. tempIndex = 2;
  4464. }
  4465. else
  4466. {
  4467. tempIndex = gun_index;
  4468. }
  4469. for (int index = 0; index < AC_QUANTITY; index++)
  4470. {
  4471. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4472. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4473. {
  4474. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4475. {
  4476. reqSampleMeter[gun_index] = 1;
  4477. }
  4478. else if((atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value) > 0) && ((getTimePassSinceToday()%(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value)))==0))
  4479. {
  4480. reqClockAlignMeter[gun_index] = 1;
  4481. }
  4482. }
  4483. }//End for AC
  4484. }
  4485. if(reqSampleMeter[gun_index] == 1)
  4486. {
  4487. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  4488. storeTempStopTransaction(gun_index);
  4489. }
  4490. else if(reqClockAlignMeter[gun_index] == 1)
  4491. {
  4492. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  4493. }
  4494. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4495. sleep(1);
  4496. }
  4497. //==============================================
  4498. // Check Connector reserved
  4499. //==============================================
  4500. //===============================
  4501. // Check if Reserve is expired
  4502. //===============================
  4503. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0) )
  4504. {
  4505. double diff_t;
  4506. struct tm tp;
  4507. // current time
  4508. time_t t = time(NULL);
  4509. strptime((char *)ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime, "%Y-%m-%dT%H:%M:%S", &tp);
  4510. tp.tm_isdst = -1;
  4511. time_t utc = mktime(&tp);
  4512. diff_t = difftime(utc, t);
  4513. if(diff_t <= 0)
  4514. {
  4515. DEBUG_INFO("reserve expired.\n");
  4516. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  4517. }
  4518. }//END OF Check if Reserve is expired
  4519. //==========================================
  4520. // csu trigger FirmwareStatusNotificationReq
  4521. //==========================================
  4522. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  4523. {
  4524. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  4525. }
  4526. //==========================================
  4527. // csu trigger CancelReservationConf
  4528. //==========================================
  4529. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  4530. {
  4531. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  4532. }
  4533. //==========================================
  4534. // csu trigger ChangeAvailabilityConf
  4535. //==========================================
  4536. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  4537. {
  4538. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  4539. }
  4540. //==========================================
  4541. // csu trigger UnlockConnectorConf
  4542. //==========================================
  4543. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  4544. {
  4545. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  4546. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = 0;
  4547. }
  4548. //==========================================
  4549. // csu trigger ReserveNowConf
  4550. //==========================================
  4551. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  4552. {
  4553. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  4554. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = 0;
  4555. }
  4556. //==========================================
  4557. // csu trigger DataTransferReq
  4558. //==========================================
  4559. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  4560. {
  4561. sendDataTransferRequest(gun_index);
  4562. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = 0;
  4563. }
  4564. }
  4565. }
  4566. //==========================================
  4567. // send request routine
  4568. //==========================================
  4569. int sendAuthorizeRequest(int gun_index)
  4570. {
  4571. mtrace();
  4572. int result = FAIL;
  4573. char message[4096]={0};
  4574. char guid[37];
  4575. char tempdata[128]={0};
  4576. json_object *Authorize = json_object_new_object();
  4577. json_object *idToken = json_object_new_object();
  4578. DEBUG_INFO("sendAuthorizeRequest...\n");
  4579. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  4580. //Local Authorize
  4581. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) &&(ShmOCPP20Data->OcppConnStatus == 0))
  4582. {
  4583. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  4584. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4585. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  4586. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  4587. result = PASS;
  4588. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4589. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4590. authorizeRetryTimes = 0;
  4591. return result;
  4592. }
  4593. 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))||
  4594. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  4595. {
  4596. // Query idtag from cache
  4597. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  4598. // Query idtag from list
  4599. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4600. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  4601. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4602. {
  4603. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  4604. {
  4605. DEBUG_INFO("offline Local Authorization Fail !!!!, Card %s is blank!!!!\n", idTagQuery.idToken.idToken);
  4606. }
  4607. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  4608. {
  4609. DEBUG_INFO("offline Local Authorization Fail !!!!, Card %s is not Accepted!!!!\n", idTagQuery.idToken.idToken);
  4610. }
  4611. DEBUG_INFO("offline Local Authorization Fail !!!!\n");
  4612. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4613. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4614. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  4615. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4616. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4617. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4618. authorizeRetryTimes = 0;
  4619. return result;
  4620. }
  4621. else
  4622. {
  4623. DEBUG_INFO("offline Local Authorization get result !!!!\n");
  4624. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  4625. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4626. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  4627. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  4628. else
  4629. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  4630. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4631. result = PASS;
  4632. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4633. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4634. authorizeRetryTimes = 0;
  4635. return result;
  4636. }
  4637. }
  4638. //initialize struct Authorize
  4639. memset(&(ShmOCPP20Data->Authorize), 0 , sizeof(struct StructAuthorize));
  4640. //get data from shared memory
  4641. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4642. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  4643. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  4644. json_object_object_add(Authorize, "idToken", idToken);
  4645. random_uuid(guid);
  4646. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  4647. json_object_put(Authorize);
  4648. LWS_Send(message);
  4649. sprintf(tempdata, "Authorize,%d", gun_index);
  4650. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4651. {
  4652. result = PASS;
  4653. }
  4654. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4655. return result;
  4656. }
  4657. int sendBootNotificationRequest()
  4658. {
  4659. mtrace();
  4660. int result = FAIL;
  4661. char message[4096]={0};
  4662. char guid[37]={0};
  4663. char tempdata[128]={0};
  4664. json_object *BootNotification = json_object_new_object();
  4665. json_object *chargingStation = json_object_new_object();
  4666. json_object *modem = json_object_new_object();
  4667. // Fill BootNotification fields
  4668. DB_getBooType();
  4669. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  4670. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  4671. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  4672. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  4673. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  4674. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  4675. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  4676. {
  4677. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  4678. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  4679. json_object_object_add(chargingStation, "modem", modem);
  4680. }
  4681. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  4682. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  4683. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  4684. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  4685. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  4686. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  4687. random_uuid(guid);
  4688. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  4689. json_object_put(BootNotification);
  4690. LWS_Send(message);
  4691. sprintf(tempdata, "BootNotification,0");
  4692. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4693. {
  4694. result = PASS;
  4695. }
  4696. return result;
  4697. }
  4698. int sendClearedChargingLimitRequest(int gun_index)
  4699. {
  4700. mtrace();
  4701. int result = FAIL;
  4702. char message[4096]={0};
  4703. char guid[37]={0};
  4704. char tempdata[128]={0};
  4705. json_object *ClearedChargingLimit = json_object_new_object();
  4706. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  4707. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  4708. random_uuid(guid);
  4709. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  4710. json_object_put(ClearedChargingLimit);
  4711. LWS_Send(message);
  4712. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  4713. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4714. {
  4715. result = PASS;
  4716. }
  4717. return result;
  4718. }
  4719. int sendDataTransferRequest(int gun_index)
  4720. {
  4721. mtrace();
  4722. char message[1000]={0};
  4723. char guid[37]={0};
  4724. char tempdata[65]={0};
  4725. int result = FAIL;
  4726. random_uuid(guid);
  4727. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  4728. MESSAGE_TYPE_CALL,
  4729. guid,
  4730. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  4731. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  4732. ShmOCPP20Data->DataTransfer[gun_index].data);
  4733. LWS_Send(message);
  4734. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  4735. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4736. {
  4737. result = PASS;
  4738. }
  4739. return result;
  4740. }
  4741. int sendFirmwareStatusNotificationRequest(char *status)
  4742. {
  4743. mtrace();
  4744. int result = FAIL;
  4745. char message[110]={0};
  4746. char guid[37]={0};
  4747. char tempdata[65]={0};
  4748. json_object *FirmwareStatusNotification = json_object_new_object();
  4749. DEBUG_INFO("sendFirmwareStatusNotificationRequest \n");
  4750. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  4751. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  4752. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  4753. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  4754. random_uuid(guid);
  4755. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  4756. json_object_put(FirmwareStatusNotification);
  4757. LWS_SendNow(message);
  4758. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  4759. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4760. {
  4761. result = PASS;
  4762. }
  4763. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = 0;
  4764. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = 0;
  4765. //record status
  4766. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  4767. {
  4768. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  4769. }
  4770. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  4771. {
  4772. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  4773. }
  4774. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  4775. {
  4776. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  4777. }
  4778. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  4779. {
  4780. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  4781. }
  4782. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  4783. {
  4784. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  4785. }
  4786. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  4787. {
  4788. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  4789. }
  4790. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  4791. {
  4792. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  4793. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  4794. }
  4795. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  4796. {
  4797. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  4798. }
  4799. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  4800. {
  4801. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  4802. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  4803. }
  4804. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  4805. {
  4806. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  4807. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  4808. }
  4809. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  4810. {
  4811. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  4812. }
  4813. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  4814. {
  4815. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  4816. }
  4817. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  4818. {
  4819. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  4820. }
  4821. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  4822. {
  4823. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  4824. }
  4825. return result;
  4826. }
  4827. int sendGet15118EVCertificateRequest()
  4828. {
  4829. mtrace();
  4830. int result = FAIL;
  4831. char message[4096]={0};
  4832. char guid[37]={0};
  4833. char tempdata[128]={0};
  4834. json_object *Get15118EVCertificate = json_object_new_object();
  4835. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  4836. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  4837. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  4838. random_uuid(guid);
  4839. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  4840. json_object_put(Get15118EVCertificate);
  4841. LWS_Send(message);
  4842. sprintf(tempdata, "Get15118EVCertificate,0");
  4843. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4844. {
  4845. result = PASS;
  4846. }
  4847. return result;
  4848. }
  4849. int sendGetCertificateStatusRequest()
  4850. {
  4851. mtrace();
  4852. int result = FAIL;
  4853. char message[4096]={0};
  4854. char guid[37]={0};
  4855. char tempdata[128]={0};
  4856. json_object *GetCertificateStatus = json_object_new_object();
  4857. json_object *ocspRequestData = json_object_new_object();
  4858. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  4859. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  4860. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  4861. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  4862. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  4863. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  4864. random_uuid(guid);
  4865. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  4866. json_object_put(GetCertificateStatus);
  4867. LWS_Send(message);
  4868. sprintf(tempdata, "GetCertificateStatus,0");
  4869. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4870. {
  4871. result = PASS;
  4872. }
  4873. return result;
  4874. }
  4875. int sendHeartbeatRequest()
  4876. {
  4877. mtrace();
  4878. int result = FAIL;
  4879. char message[40096]={0};
  4880. char guid[37]={0};
  4881. char tempdata[128]={0};
  4882. random_uuid(guid);
  4883. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  4884. , MESSAGE_TYPE_CALL
  4885. , guid );
  4886. LWS_Send(message);
  4887. sprintf(tempdata, "Heartbeat,%d", 0);
  4888. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4889. {
  4890. result = PASS;
  4891. }
  4892. return result;
  4893. }
  4894. int sendLogStatusNotificationRequest(char *status)
  4895. {
  4896. mtrace();
  4897. int result = FAIL;
  4898. char message[4096]={0};
  4899. char guid[37]={0};
  4900. char tempdata[128]={0};
  4901. json_object *LogStatusNotification = json_object_new_object();
  4902. DEBUG_INFO("sendLogStatusNotificationRequest \n");
  4903. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  4904. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  4905. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  4906. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  4907. random_uuid(guid);
  4908. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  4909. json_object_put(LogStatusNotification);
  4910. LWS_SendNow(message);
  4911. sprintf(tempdata, "LogStatusNotification,%d", 0);
  4912. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4913. {
  4914. result = PASS;
  4915. }
  4916. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  4917. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  4918. //record status
  4919. if(strcmp(status,"BadMessage")==0)
  4920. {
  4921. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  4922. }
  4923. else if(strcmp(status,"Idle")==0)
  4924. {
  4925. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  4926. }
  4927. else if(strcmp(status,"NotSupportedOperation")==0)
  4928. {
  4929. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  4930. }
  4931. else if(strcmp(status,"PermissionDenied")==0)
  4932. {
  4933. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  4934. }
  4935. else if(strcmp(status,"Uploaded")==0)
  4936. {
  4937. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  4938. }
  4939. else if(strcmp(status,"UploadFailure")==0)
  4940. {
  4941. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  4942. }
  4943. else if(strcmp(status,"Uploading")==0)
  4944. {
  4945. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  4946. }
  4947. return result;
  4948. }
  4949. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  4950. {
  4951. mtrace();
  4952. int result = FAIL;
  4953. char guid[37]={0};
  4954. char tempdata[65]={0};
  4955. int tempIndex = 0;
  4956. json_object *MeterValueReq = json_object_new_object();
  4957. json_object *meterValues = json_object_new_array();
  4958. json_object *meterValue = json_object_new_object();
  4959. json_object *sampledValues = json_object_new_array();
  4960. json_object *sampledValue = json_object_new_object();
  4961. json_object *unitOfMeasure = json_object_new_object();
  4962. DEBUG_INFO("sendMeterValuesRequest ...\n");
  4963. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  4964. //set value
  4965. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  4966. //UTC Date time
  4967. struct timeval tmnow;
  4968. struct tm *tm;
  4969. char buf[28];//, usec_buf[6];
  4970. gettimeofday(&tmnow, NULL);
  4971. time_t t;
  4972. t = time(NULL);
  4973. /*UTC time and date*/
  4974. tm = gmtime(&t);
  4975. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  4976. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  4977. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  4978. //idx_sample=0;
  4979. //********************************(1)Current.Import L1************************************************/
  4980. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  4981. if(gunType[gun_index] == 'J')
  4982. {
  4983. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4984. {
  4985. tempIndex = ((gun_index==2) ? 1: 0);
  4986. }
  4987. else
  4988. {
  4989. tempIndex = gun_index;
  4990. }
  4991. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4992. {
  4993. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4994. {
  4995. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent;
  4996. }
  4997. }
  4998. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  4999. }
  5000. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5001. {
  5002. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5003. {
  5004. tempIndex = ((gun_index==2) ? 1: 0);
  5005. }
  5006. else
  5007. {
  5008. tempIndex = gun_index;
  5009. }
  5010. for (int index = 0; index < CCS_QUANTITY; index++)
  5011. {
  5012. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5013. {
  5014. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent;
  5015. }
  5016. }
  5017. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5018. }
  5019. else if(gunType[gun_index] == 'G')
  5020. {
  5021. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5022. {
  5023. tempIndex = ((gun_index==2) ? 1: 0);
  5024. }
  5025. else
  5026. {
  5027. tempIndex = gun_index;
  5028. }
  5029. for (int index = 0; index < GB_QUANTITY; index++)
  5030. {
  5031. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5032. {
  5033. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent;
  5034. }
  5035. }
  5036. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5037. }
  5038. else
  5039. {
  5040. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5041. {
  5042. tempIndex = 2;
  5043. }
  5044. else
  5045. {
  5046. tempIndex = gun_index;
  5047. }
  5048. for (int index = 0; index < AC_QUANTITY; index++)
  5049. {
  5050. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5051. {
  5052. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent;
  5053. }
  5054. }
  5055. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5056. }
  5057. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  5058. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5059. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5060. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  5061. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  5062. //idx_sample=1;
  5063. //********************************(2)Energy.Active.Import.Register ************************************************/
  5064. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5065. if(gunType[gun_index] == 'J')
  5066. {
  5067. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5068. {
  5069. tempIndex = ((gun_index==2) ? 1: 0);
  5070. }
  5071. else
  5072. {
  5073. tempIndex = gun_index;
  5074. }
  5075. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5076. {
  5077. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5078. {
  5079. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  5080. }
  5081. }
  5082. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5083. }
  5084. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5085. {
  5086. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5087. {
  5088. tempIndex = ((gun_index==2) ? 1: 0);
  5089. }
  5090. else
  5091. {
  5092. tempIndex = gun_index;
  5093. }
  5094. for (int index = 0; index < CCS_QUANTITY; index++)
  5095. {
  5096. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5097. {
  5098. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  5099. }
  5100. }
  5101. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5102. }
  5103. else if(gunType[gun_index] == 'G')
  5104. {
  5105. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5106. {
  5107. tempIndex = ((gun_index==2) ? 1: 0);
  5108. }
  5109. else
  5110. {
  5111. tempIndex = gun_index;
  5112. }
  5113. for (int index = 0; index < GB_QUANTITY; index++)
  5114. {
  5115. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5116. {
  5117. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  5118. }
  5119. }
  5120. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5121. }
  5122. else
  5123. {
  5124. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5125. {
  5126. tempIndex = 2;
  5127. }
  5128. else
  5129. {
  5130. tempIndex = gun_index;
  5131. }
  5132. for (int index = 0; index < AC_QUANTITY; index++)
  5133. {
  5134. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5135. {
  5136. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  5137. }
  5138. }
  5139. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5140. }
  5141. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  5142. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  5143. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5144. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  5145. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5146. //idx_sample=2;
  5147. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  5148. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5149. if(gunType[gun_index] == 'J')
  5150. {
  5151. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5152. {
  5153. tempIndex = ((gun_index==2) ? 1: 0);
  5154. }
  5155. else
  5156. {
  5157. tempIndex = gun_index;
  5158. }
  5159. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5160. {
  5161. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5162. {
  5163. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
  5164. }
  5165. } // END OF FOR CHAdeMO_QUANTITY
  5166. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5167. }
  5168. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5169. {
  5170. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5171. {
  5172. tempIndex = ((gun_index==2) ? 1: 0);
  5173. }
  5174. else
  5175. {
  5176. tempIndex = gun_index;
  5177. }
  5178. for (int index = 0; index < CCS_QUANTITY; index++)
  5179. {
  5180. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5181. {
  5182. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
  5183. }
  5184. } // END OF CCS_QUANTITY
  5185. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5186. }
  5187. else if(gunType[gun_index] == 'G')
  5188. {
  5189. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5190. {
  5191. tempIndex = ((gun_index==2) ? 1: 0);
  5192. }
  5193. else
  5194. {
  5195. tempIndex = gun_index;
  5196. }
  5197. for (int index = 0; index < GB_QUANTITY; index++)
  5198. {
  5199. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5200. {
  5201. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
  5202. }
  5203. } // END OF GB_QUANTITY
  5204. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5205. }
  5206. else
  5207. {
  5208. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5209. {
  5210. tempIndex = 2;
  5211. }
  5212. else
  5213. {
  5214. tempIndex = gun_index;
  5215. }
  5216. for (int index = 0; index < AC_QUANTITY; index++)
  5217. {
  5218. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5219. {
  5220. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
  5221. }
  5222. }
  5223. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5224. }
  5225. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  5226. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  5227. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5228. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  5229. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5230. //idx_sample=3;
  5231. //********************************(4)Power.Active.Import************************************************/
  5232. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5233. if(gunType[gun_index] == 'J')
  5234. {
  5235. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5236. {
  5237. tempIndex = ((gun_index==2) ? 1: 0);
  5238. }
  5239. else
  5240. {
  5241. tempIndex = gun_index;
  5242. }
  5243. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5244. {
  5245. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5246. {
  5247. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower;
  5248. }
  5249. } // END OF FOR
  5250. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5251. }
  5252. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5253. {
  5254. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5255. {
  5256. tempIndex = ((gun_index==2) ? 1: 0);
  5257. }
  5258. else
  5259. {
  5260. tempIndex = gun_index;
  5261. }
  5262. for (int index = 0; index < CCS_QUANTITY; index++)
  5263. {
  5264. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5265. {
  5266. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower;
  5267. }
  5268. }
  5269. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5270. }
  5271. else if(gunType[gun_index] == 'G')
  5272. {
  5273. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5274. {
  5275. tempIndex = ((gun_index==2) ? 1: 0);
  5276. }
  5277. else
  5278. {
  5279. tempIndex = gun_index;
  5280. }
  5281. for (int index = 0; index < GB_QUANTITY; index++)
  5282. {
  5283. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5284. {
  5285. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5286. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower;
  5287. }
  5288. }
  5289. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5290. }
  5291. else
  5292. {
  5293. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5294. {
  5295. tempIndex = 2;
  5296. }
  5297. else
  5298. {
  5299. tempIndex = gun_index;
  5300. }
  5301. for (int index = 0; index < AC_QUANTITY; index++)
  5302. {
  5303. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5304. {
  5305. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower;
  5306. }
  5307. }
  5308. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5309. }
  5310. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  5311. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  5312. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5313. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  5314. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  5315. //idx_sample=4;
  5316. //***********************************************(5)VOLTAGE L1******************************************************/
  5317. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5318. if(gunType[gun_index] == 'J')
  5319. {
  5320. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5321. {
  5322. tempIndex = ((gun_index==2) ? 1: 0);
  5323. }
  5324. else
  5325. {
  5326. tempIndex = gun_index;
  5327. }
  5328. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5329. {
  5330. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5331. {
  5332. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage;
  5333. }
  5334. }
  5335. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5336. }
  5337. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5338. {
  5339. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5340. {
  5341. tempIndex = ((gun_index==2) ? 1: 0);
  5342. }
  5343. else
  5344. {
  5345. tempIndex = gun_index;
  5346. }
  5347. for (int index = 0; index < CCS_QUANTITY; index++)
  5348. {
  5349. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5350. {
  5351. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage;
  5352. }
  5353. }
  5354. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5355. }
  5356. else if(gunType[gun_index] == 'G')
  5357. {
  5358. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5359. {
  5360. tempIndex = ((gun_index==2) ? 1: 0);
  5361. }
  5362. else
  5363. {
  5364. tempIndex = gun_index;
  5365. }
  5366. for (int index = 0; index < GB_QUANTITY; index++)
  5367. {
  5368. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5369. {
  5370. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage;
  5371. }
  5372. }
  5373. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5374. }
  5375. else
  5376. {
  5377. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5378. {
  5379. tempIndex = 2;
  5380. }
  5381. else
  5382. {
  5383. tempIndex = gun_index;
  5384. }
  5385. for (int index = 0; index < AC_QUANTITY; index++)
  5386. {
  5387. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5388. {
  5389. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage;
  5390. }
  5391. }
  5392. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5393. }
  5394. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  5395. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5396. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5397. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  5398. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  5399. //***********************************************(6)SOC******************************************************/
  5400. if((gunType[gun_index] == 'J')||(gunType[gun_index] == 'U')||(gunType[gun_index] == 'E')||(gunType[gun_index] == 'G'))
  5401. {
  5402. //idx_sample=5;
  5403. //sampledValue = NULL;
  5404. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5405. {
  5406. tempIndex = ((gun_index==2) ? 1: 0);
  5407. }
  5408. else
  5409. {
  5410. tempIndex = gun_index;
  5411. }
  5412. if(gunType[gun_index] == 'J')
  5413. {
  5414. //tempIndex = ((gun_index==2) ? 1: 0);
  5415. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5416. {
  5417. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5418. {
  5419. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  5420. }
  5421. }
  5422. }
  5423. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5424. {
  5425. //tempIndex = ((gun_index==2) ? 1: 0);
  5426. for (int index = 0; index < CCS_QUANTITY; index++)
  5427. {
  5428. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5429. {
  5430. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  5431. }
  5432. }
  5433. }
  5434. else if(gunType[gun_index] == 'G')
  5435. {
  5436. //tempIndex = ((gun_index==2) ? 1: 0);
  5437. for (int index = 0; index < GB_QUANTITY; index++)
  5438. {
  5439. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5440. {
  5441. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  5442. }
  5443. }
  5444. }
  5445. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  5446. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  5447. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5448. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  5449. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  5450. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  5451. }
  5452. //********************************(7)Current.Import L2************************************************/
  5453. // Only for AC 3 phase
  5454. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5455. {
  5456. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5457. {
  5458. tempIndex = 2;
  5459. }
  5460. else
  5461. {
  5462. tempIndex = gun_index;
  5463. }
  5464. for (int index = 0; index < AC_QUANTITY; index++)
  5465. {
  5466. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5467. {
  5468. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2;
  5469. }
  5470. }
  5471. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5472. }
  5473. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  5474. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5475. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5476. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  5477. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  5478. //********************************(8)Current.Import L3************************************************/
  5479. // Only for AC 3 phase
  5480. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5481. {
  5482. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5483. {
  5484. tempIndex = 2;
  5485. }
  5486. else
  5487. {
  5488. tempIndex = gun_index;
  5489. }
  5490. for (int index = 0; index < AC_QUANTITY; index++)
  5491. {
  5492. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5493. {
  5494. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3;
  5495. }
  5496. }
  5497. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5498. }
  5499. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  5500. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5501. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5502. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  5503. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  5504. //***********************************************(9)VOLTAGE L2******************************************************/
  5505. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5506. {
  5507. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5508. {
  5509. tempIndex = 2;
  5510. }
  5511. else
  5512. {
  5513. tempIndex = gun_index;
  5514. }
  5515. for (int index = 0; index < AC_QUANTITY; index++)
  5516. {
  5517. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5518. {
  5519. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2;
  5520. }
  5521. }
  5522. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5523. }
  5524. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  5525. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5526. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5527. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  5528. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  5529. //***********************************************(10)VOLTAGE L3******************************************************/
  5530. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5531. {
  5532. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5533. {
  5534. tempIndex = 2;
  5535. }
  5536. else
  5537. {
  5538. tempIndex = gun_index;
  5539. }
  5540. for (int index = 0; index < AC_QUANTITY; index++)
  5541. {
  5542. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5543. {
  5544. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3;
  5545. }
  5546. }
  5547. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5548. }
  5549. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  5550. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5551. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5552. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  5553. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  5554. // Message create ====================================================================================================
  5555. random_uuid(guid);
  5556. uint8_t idxMeter = 0;
  5557. while(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp) > 0)
  5558. {
  5559. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  5560. {
  5561. if(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value > 0)
  5562. {
  5563. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  5564. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  5565. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  5566. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  5567. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  5568. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  5569. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  5570. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  5571. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  5572. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  5573. {
  5574. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  5575. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  5576. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  5577. }
  5578. json_object_array_add(sampledValues, sampledValue);
  5579. }
  5580. }
  5581. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  5582. json_object_object_add(meterValue, "sampledValue", sampledValues);
  5583. json_object_array_add(meterValues, meterValue);
  5584. idxMeter++;
  5585. }
  5586. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  5587. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  5588. sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",%s]"
  5589. ,gun_index + 1
  5590. ,MESSAGE_TYPE_CALL
  5591. ,guid
  5592. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  5593. json_object_put(MeterValueReq);
  5594. // Put request guid to hash map
  5595. sprintf(tempdata, "MeterValues,%d", (gun_index));
  5596. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5597. {
  5598. result = PASS;
  5599. }
  5600. if(dataType != ReadingContextEnumType_Trigger)
  5601. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  5602. else
  5603. {
  5604. if(FirstHeartBeat)
  5605. LWS_Send(queuedata +2);
  5606. }
  5607. return result;
  5608. }
  5609. int sendNotifyChargingLimitRequest(int gun_index)
  5610. {
  5611. mtrace();
  5612. int result = FAIL;
  5613. char message[4096]={0};
  5614. char guid[37]={0};
  5615. char tempdata[128]={0};
  5616. json_object *NotifyChargingLimit = json_object_new_object();
  5617. json_object *chargingLimit = json_object_new_object();
  5618. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  5619. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  5620. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  5621. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  5622. random_uuid(guid);
  5623. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  5624. json_object_put(NotifyChargingLimit);
  5625. LWS_Send(message);
  5626. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  5627. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5628. {
  5629. result = PASS;
  5630. }
  5631. return result;
  5632. }
  5633. int sendNotifyCustomerInformationRequest()
  5634. {
  5635. mtrace();
  5636. int result = FAIL;
  5637. char message[4096]={0};
  5638. char guid[37]={0};
  5639. char tempdata[128]={0};
  5640. json_object *NotifyCustomerInformation = json_object_new_object();
  5641. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  5642. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  5643. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  5644. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  5645. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  5646. random_uuid(guid);
  5647. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  5648. json_object_put(NotifyCustomerInformation);
  5649. LWS_Send(message);
  5650. sprintf(tempdata, "NotifyCustomerInformation,0");
  5651. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5652. {
  5653. result = PASS;
  5654. }
  5655. return result;
  5656. }
  5657. int sendNotifyDisplayMessagesRequest()
  5658. {
  5659. mtrace();
  5660. int result = FAIL;
  5661. char message[4096]={0};
  5662. char guid[37]={0};
  5663. char tempdata[128]={0};
  5664. json_object *NotifyDisplayMessages = json_object_new_object();
  5665. json_object *messageInfos = json_object_new_array();
  5666. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  5667. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  5668. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  5669. {
  5670. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  5671. {
  5672. json_object *messageInfo = json_object_new_object();
  5673. json_object *message = json_object_new_object();
  5674. json_object *display = json_object_new_object();
  5675. json_object *evse = json_object_new_object();
  5676. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  5677. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  5678. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  5679. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  5680. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  5681. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  5682. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  5683. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  5684. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  5685. json_object_object_add(messageInfo, "message", message);
  5686. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  5687. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  5688. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  5689. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  5690. json_object_object_add(display, "evse",evse);
  5691. json_object_object_add(messageInfo, "evse", display);
  5692. json_object_array_add(messageInfos, messageInfo);
  5693. }
  5694. }
  5695. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  5696. random_uuid(guid);
  5697. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  5698. json_object_put(NotifyDisplayMessages);
  5699. LWS_Send(message);
  5700. sprintf(tempdata, "NotifyDisplayMessages,0");
  5701. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5702. {
  5703. result = PASS;
  5704. }
  5705. return result;
  5706. }
  5707. int sendNotifyEVChargingNeedsRequest(int gun_index)
  5708. {
  5709. mtrace();
  5710. int result = FAIL;
  5711. char message[4096]={0};
  5712. char guid[37]={0};
  5713. char tempdata[128]={0};
  5714. json_object *NotifyEVChargingNeeds = json_object_new_object();
  5715. json_object *chargingNeeds = json_object_new_object();
  5716. json_object *acChargingParameters = json_object_new_object();
  5717. json_object *dcChargingParameters = json_object_new_object();
  5718. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  5719. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  5720. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  5721. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  5722. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  5723. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  5724. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  5725. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  5726. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  5727. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  5728. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  5729. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  5730. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  5731. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  5732. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  5733. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  5734. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  5735. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  5736. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  5737. random_uuid(guid);
  5738. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  5739. json_object_put(NotifyEVChargingNeeds);
  5740. LWS_Send(message);
  5741. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  5742. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5743. {
  5744. result = PASS;
  5745. }
  5746. return result;
  5747. }
  5748. int sendNotifyEVChargingScheduleRequest(int gun_index)
  5749. {
  5750. mtrace();
  5751. int result = FAIL;
  5752. char message[4096]={0};
  5753. char guid[37]={0};
  5754. char tempdata[128]={0};
  5755. json_object *NotifyEVChargingSchedule = json_object_new_object();
  5756. json_object *chargingSchedule = json_object_new_object();
  5757. json_object *periods = json_object_new_array();
  5758. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  5759. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  5760. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  5761. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  5762. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  5763. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  5764. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  5765. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  5766. {
  5767. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  5768. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  5769. {
  5770. json_object *Period = json_object_new_object();
  5771. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  5772. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  5773. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  5774. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  5775. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  5776. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  5777. json_object_array_add(periods, Period);
  5778. }
  5779. }
  5780. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  5781. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  5782. random_uuid(guid);
  5783. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  5784. json_object_put(NotifyEVChargingSchedule);
  5785. LWS_Send(message);
  5786. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  5787. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5788. {
  5789. result = PASS;
  5790. }
  5791. return result;
  5792. }
  5793. int sendNotifyEventRequest()
  5794. {
  5795. mtrace();
  5796. int result = FAIL;
  5797. char message[4096]={0};
  5798. char guid[37]={0};
  5799. char tempdata[128]={0};
  5800. json_object *NotifyEvent = json_object_new_object();
  5801. json_object *eventDatas = json_object_new_array();
  5802. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  5803. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  5804. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  5805. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  5806. {
  5807. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  5808. {
  5809. json_object *eventData = json_object_new_object();
  5810. json_object *component = json_object_new_object();
  5811. json_object *evse = json_object_new_object();
  5812. json_object *variable = json_object_new_object();
  5813. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  5814. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  5815. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  5816. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  5817. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  5818. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  5819. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  5820. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  5821. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  5822. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  5823. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  5824. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  5825. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  5826. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  5827. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  5828. json_object_object_add(component, "evse",evse);
  5829. json_object_object_add(eventData, "component", component);
  5830. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  5831. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  5832. json_object_object_add(eventData, "variable", variable);
  5833. json_object_array_add(eventDatas, eventData);
  5834. }
  5835. }
  5836. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  5837. random_uuid(guid);
  5838. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  5839. json_object_put(NotifyEvent);
  5840. LWS_Send(message);
  5841. sprintf(tempdata, "NotifyEvent,0");
  5842. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5843. {
  5844. result = PASS;
  5845. }
  5846. return result;
  5847. }
  5848. int sendNotifyMonitoringReportRequest()
  5849. {
  5850. mtrace();
  5851. int result = FAIL;
  5852. char message[4096]={0};
  5853. char guid[37]={0};
  5854. char tempdata[128]={0};
  5855. json_object *NotifyMonitoringReport = json_object_new_object();
  5856. json_object *monitors = json_object_new_array();
  5857. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  5858. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  5859. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  5860. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  5861. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  5862. {
  5863. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  5864. {
  5865. json_object *monitor = json_object_new_object();
  5866. json_object *component = json_object_new_object();
  5867. json_object *evse = json_object_new_object();
  5868. json_object *variable = json_object_new_object();
  5869. json_object *variableMonitorings = json_object_new_array();
  5870. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  5871. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  5872. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  5873. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  5874. json_object_object_add(component, "evse",evse);
  5875. json_object_object_add(monitor, "component", component);
  5876. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  5877. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  5878. json_object_object_add(monitor, "variable", variable);
  5879. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  5880. {
  5881. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  5882. {
  5883. json_object *variableMonitoring = json_object_new_object();
  5884. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  5885. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  5886. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  5887. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  5888. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  5889. json_object_array_add(variableMonitorings, variableMonitoring);
  5890. }
  5891. }
  5892. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  5893. json_object_array_add(monitors, monitor);
  5894. }
  5895. }
  5896. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  5897. random_uuid(guid);
  5898. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  5899. json_object_put(NotifyMonitoringReport);
  5900. LWS_Send(message);
  5901. sprintf(tempdata, "NotifyMonitoringReport,0");
  5902. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5903. {
  5904. result = PASS;
  5905. }
  5906. return result;
  5907. }
  5908. int sendNotifyReportRequest()
  5909. {
  5910. mtrace();
  5911. int result = FAIL;
  5912. char message[4096]={0};
  5913. char guid[37]={0};
  5914. char tempdata[128]={0};
  5915. json_object *NotifyReport = json_object_new_object();
  5916. json_object *reportDatas = json_object_new_array();
  5917. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  5918. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  5919. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  5920. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  5921. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  5922. {
  5923. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  5924. {
  5925. json_object *reportData = json_object_new_object();
  5926. json_object *component = json_object_new_object();
  5927. json_object *evse = json_object_new_object();
  5928. json_object *variable = json_object_new_object();
  5929. json_object *variableAttributes = json_object_new_array();
  5930. json_object *variableCharacteristics = json_object_new_object();
  5931. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  5932. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  5933. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  5934. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  5935. json_object_object_add(component, "evse",evse);
  5936. json_object_object_add(reportData, "component", component);
  5937. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  5938. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  5939. json_object_object_add(reportData, "variable",variable);
  5940. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  5941. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  5942. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  5943. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  5944. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  5945. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  5946. {
  5947. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  5948. {
  5949. json_object *variableAttribute = json_object_new_object();
  5950. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  5951. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  5952. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  5953. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  5954. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  5955. json_object_array_add(variableAttributes, variableAttribute);
  5956. }
  5957. }
  5958. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  5959. json_object_array_add(reportDatas, reportData);
  5960. }
  5961. }
  5962. json_object_object_add(NotifyReport, "reportData", reportDatas);
  5963. random_uuid(guid);
  5964. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  5965. json_object_put(NotifyReport);
  5966. LWS_Send(message);
  5967. sprintf(tempdata, "NotifyReport,0");
  5968. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5969. {
  5970. result = PASS;
  5971. }
  5972. return result;
  5973. }
  5974. int sendPublishFirmwareStatusNotificationRequest()
  5975. {
  5976. mtrace();
  5977. int result = FAIL;
  5978. char message[4096]={0};
  5979. char guid[37]={0};
  5980. char tempdata[128]={0};
  5981. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  5982. json_object *locations = json_object_new_array();
  5983. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  5984. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  5985. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  5986. {
  5987. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  5988. }
  5989. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  5990. random_uuid(guid);
  5991. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  5992. json_object_put(PublishFirmwareStatusNotification);
  5993. LWS_Send(message);
  5994. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  5995. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5996. {
  5997. result = PASS;
  5998. }
  5999. return result;
  6000. }
  6001. int sendReportChargingProfilesRequest(int gun_index)
  6002. {
  6003. mtrace();
  6004. int result = FAIL;
  6005. char message[4096]={0};
  6006. char guid[37]={0};
  6007. char tempdata[128]={0};
  6008. json_object *ReportChargingProfiles = json_object_new_object();
  6009. json_object *chargingProfiles = json_object_new_array();
  6010. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  6011. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  6012. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  6013. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  6014. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  6015. {
  6016. json_object *chargingProfile = json_object_new_object();
  6017. json_object *chargingSchedules = json_object_new_array();
  6018. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  6019. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  6020. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  6021. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  6022. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  6023. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  6024. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  6025. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  6026. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  6027. {
  6028. json_object *chargingSchedule = json_object_new_object();
  6029. json_object *chargingSchedulePeriods = json_object_new_array();
  6030. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  6031. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  6032. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  6033. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  6034. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  6035. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  6036. {
  6037. json_object *chargingSchedulePeriod = json_object_new_object();
  6038. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  6039. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  6040. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  6041. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  6042. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  6043. }
  6044. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  6045. json_object_array_add(chargingSchedules, chargingSchedule);
  6046. }
  6047. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  6048. json_object_array_add(chargingProfiles, chargingProfile);
  6049. }
  6050. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  6051. random_uuid(guid);
  6052. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  6053. json_object_put(ReportChargingProfiles);
  6054. LWS_Send(message);
  6055. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  6056. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6057. {
  6058. result = PASS;
  6059. }
  6060. return result;
  6061. }
  6062. int sendReservationStatusUpdateRequest(int gun_index)
  6063. {
  6064. mtrace();
  6065. int result = FAIL;
  6066. char message[4096]={0};
  6067. char guid[37]={0};
  6068. char tempdata[128]={0};
  6069. json_object *ReservationStatusUpdate = json_object_new_object();
  6070. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  6071. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  6072. random_uuid(guid);
  6073. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  6074. json_object_put(ReservationStatusUpdate);
  6075. LWS_Send(message);
  6076. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  6077. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6078. {
  6079. result = PASS;
  6080. }
  6081. return result;
  6082. }
  6083. int sendSecurityEventNotificationRequest()
  6084. {
  6085. mtrace();
  6086. int result = FAIL;
  6087. char message[4096]={0};
  6088. char guid[37]={0};
  6089. char tempdata[128]={0};
  6090. json_object *SecurityEventNotification = json_object_new_object();
  6091. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  6092. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  6093. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techinfo));
  6094. random_uuid(guid);
  6095. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  6096. json_object_put(SecurityEventNotification);
  6097. LWS_Send(message);
  6098. sprintf(tempdata, "SecurityEventNotification,0");
  6099. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6100. {
  6101. result = PASS;
  6102. }
  6103. return result;
  6104. }
  6105. int sendSignCertificateRequest()
  6106. {
  6107. mtrace();
  6108. int result = FAIL;
  6109. char message[4096]={0};
  6110. char guid[37]={0};
  6111. char tempdata[128]={0};
  6112. json_object *SignCertificate = json_object_new_object();
  6113. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  6114. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  6115. random_uuid(guid);
  6116. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  6117. json_object_put(SignCertificate);
  6118. LWS_Send(message);
  6119. sprintf(tempdata, "SignCertificate,0");
  6120. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6121. {
  6122. result = PASS;
  6123. }
  6124. return result;
  6125. }
  6126. int sendStatusNotificationRequest(int gun_index)
  6127. {
  6128. mtrace();
  6129. int result = FAIL;
  6130. char message[600]={0};
  6131. char guid[37];
  6132. int currentStatus = 0;
  6133. struct timeval tmnow;
  6134. struct tm *tm;
  6135. char buf[28];//, usec_buf[6];
  6136. char tempdata[65]={0};
  6137. int tempIndex = 0;
  6138. gettimeofday(&tmnow, NULL);
  6139. time_t t;
  6140. t = time(NULL);
  6141. /*UTC time and date*/
  6142. tm = gmtime(&t);
  6143. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  6144. #if 0 // remove temporally
  6145. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  6146. strcat(buf,".");
  6147. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  6148. strcat(buf,usec_buf);
  6149. #endif
  6150. printf("%s",buf);
  6151. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  6152. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  6153. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  6154. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  6155. /*
  6156. enum _SYSTEM_STATUS
  6157. {
  6158. S_BOOTING = 0,
  6159. S_IDLE, = 1
  6160. S_AUTHORIZING, =2
  6161. S_REASSIGN_CHECK, =3
  6162. S_REASSIGN, =4
  6163. S_PRECHARGE, =5
  6164. S_PREPARING_FOR_EV, =6
  6165. S_PREPARING_FOR_EVSE, =7
  6166. S_CHARGING, =8
  6167. S_TERMINATING, =9
  6168. S_COMPLETE, =10
  6169. S_ALARM, =11
  6170. S_FAULT =12
  6171. }
  6172. */
  6173. //check Transaction active
  6174. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  6175. if(gunType[gun_index] == 'J')
  6176. {
  6177. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6178. {
  6179. tempIndex = ((gun_index==2) ? 1: 0);
  6180. }
  6181. else
  6182. {
  6183. tempIndex = gun_index;
  6184. }
  6185. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6186. {
  6187. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6188. {
  6189. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6190. {
  6191. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == 1) // //0: unplug, 1: Plug-in
  6192. {
  6193. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6194. }
  6195. else
  6196. {
  6197. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6198. }
  6199. }
  6200. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6201. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6202. ) //S_PRECHARGE
  6203. {
  6204. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6205. }
  6206. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6207. {
  6208. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6209. }
  6210. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6211. {
  6212. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6213. }
  6214. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6215. {
  6216. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6217. }
  6218. 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
  6219. {
  6220. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6221. }
  6222. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6223. {
  6224. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6225. }
  6226. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6227. {
  6228. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6229. }
  6230. } //end of the same index
  6231. }//end of for CHAdeMO_QUANTITY
  6232. }
  6233. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  6234. {
  6235. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6236. {
  6237. tempIndex = ((gun_index==2) ? 1: 0);
  6238. }
  6239. else
  6240. {
  6241. tempIndex = gun_index;
  6242. }
  6243. for (int index = 0; index < CCS_QUANTITY; index++)
  6244. {
  6245. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6246. {
  6247. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6248. {
  6249. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == 1) //0: unplug, 1: Plug-in
  6250. {
  6251. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6252. }
  6253. else
  6254. {
  6255. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6256. }
  6257. }
  6258. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6259. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6260. ) //S_PRECHARGE
  6261. {
  6262. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6263. }
  6264. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6265. {
  6266. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6267. }
  6268. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6269. {
  6270. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6271. }
  6272. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  6273. {
  6274. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6275. }
  6276. 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
  6277. {
  6278. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  6279. }
  6280. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6281. {
  6282. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6283. }
  6284. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6285. {
  6286. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6287. }
  6288. } //end of the same index
  6289. } // end of for CCS_QUANTITY
  6290. }
  6291. else if(gunType[gun_index] == 'G')
  6292. {
  6293. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6294. {
  6295. tempIndex = ((gun_index==2) ? 1: 0);
  6296. }
  6297. else
  6298. {
  6299. tempIndex = gun_index;
  6300. }
  6301. for (int index = 0; index < GB_QUANTITY; index++)
  6302. {
  6303. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6304. {
  6305. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6306. {
  6307. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == 1) // //0: unplug, 1: Plug-in
  6308. {
  6309. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6310. }
  6311. else
  6312. {
  6313. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6314. }
  6315. }
  6316. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6317. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6318. ) //S_PRECHARGE
  6319. {
  6320. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6321. }
  6322. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6323. {
  6324. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6325. }
  6326. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6327. {
  6328. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6329. }
  6330. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6331. {
  6332. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6333. }
  6334. 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
  6335. {
  6336. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6337. }
  6338. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6339. {
  6340. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6341. }
  6342. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6343. {
  6344. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6345. }
  6346. } //end of the same index
  6347. } // end of for GB_QUANTITY
  6348. }
  6349. else
  6350. {
  6351. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6352. {
  6353. tempIndex = 2;
  6354. }
  6355. else
  6356. {
  6357. tempIndex = gun_index;
  6358. }
  6359. for (int index = 0; index < AC_QUANTITY; index++)
  6360. {
  6361. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6362. {
  6363. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  6364. {
  6365. 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))
  6366. {
  6367. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6368. }
  6369. else
  6370. {
  6371. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6372. }
  6373. }
  6374. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  6375. {
  6376. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6377. }
  6378. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  6379. {
  6380. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6381. }
  6382. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  6383. {
  6384. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6385. }
  6386. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6387. {
  6388. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6389. }
  6390. 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
  6391. {
  6392. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6393. }
  6394. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6395. {
  6396. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6397. }
  6398. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6399. {
  6400. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6401. }
  6402. }//end of the same index
  6403. }//end of for AC_QUANTITY
  6404. }
  6405. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  6406. random_uuid(guid);
  6407. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  6408. , MESSAGE_TYPE_CALL
  6409. , guid
  6410. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  6411. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  6412. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  6413. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  6414. if((server_sign == TRUE))
  6415. {
  6416. LWS_Send(message);
  6417. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  6418. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6419. {
  6420. result = PASS;
  6421. }
  6422. }
  6423. else
  6424. {
  6425. result = PASS;
  6426. }
  6427. return result;
  6428. }
  6429. int sendTransactionEventRequest(int gun_index)
  6430. {
  6431. mtrace();
  6432. int result = FAIL;
  6433. char message[4096]={0};
  6434. char guid[37]={0};
  6435. char tempdata[128]={0};
  6436. json_object *TransactionEvent = json_object_new_object();
  6437. json_object *transactionInfo = json_object_new_object();
  6438. json_object *idToken = json_object_new_object();
  6439. json_object *evse = json_object_new_object();
  6440. json_object *meterValues = json_object_new_array();
  6441. DEBUG_INFO("sendTransactionEventRequest...\n");
  6442. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  6443. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  6444. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  6445. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  6446. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  6447. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  6448. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  6449. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  6450. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  6451. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  6452. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  6453. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  6454. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  6455. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  6456. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  6457. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  6458. json_object_object_add(TransactionEvent, "idToken", idToken);
  6459. json_object_object_add(evse, "idToken", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  6460. json_object_object_add(evse, "type", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  6461. json_object_object_add(TransactionEvent, "evse", evse);
  6462. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  6463. {
  6464. json_object *meterValue = json_object_new_object();
  6465. json_object *sampledValues = json_object_new_array();
  6466. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  6467. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  6468. {
  6469. json_object *sampledValue = json_object_new_object();
  6470. json_object *unitOfMeasure = json_object_new_object();
  6471. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  6472. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  6473. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  6474. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  6475. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  6476. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  6477. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  6478. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  6479. json_object_array_add(sampledValues, sampledValue);
  6480. }
  6481. json_object_object_add(meterValue, "sampledValue", sampledValues);
  6482. json_object_array_add(meterValues, meterValue);
  6483. }
  6484. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  6485. random_uuid(guid);
  6486. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  6487. json_object_put(TransactionEvent);
  6488. LWS_Send(message);
  6489. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  6490. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6491. {
  6492. result = PASS;
  6493. }
  6494. return result;
  6495. }
  6496. //==========================================
  6497. // send confirm routine
  6498. //==========================================
  6499. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  6500. {
  6501. mtrace();
  6502. int result = FAIL;
  6503. char message[4096]={0};
  6504. json_object *CancelReservation = json_object_new_object();
  6505. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  6506. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  6507. sprintf(message,"[%d,\"%s\",%s]"
  6508. ,MESSAGE_TYPE_CALLRESULT
  6509. ,uuid
  6510. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  6511. json_object_put(CancelReservation);
  6512. ShmOCPP20Data->CsMsg.bits[0].CancelReservationConf = OFF;
  6513. LWS_Send(message);
  6514. result = TRUE;
  6515. return result;
  6516. }
  6517. int sendCertificateSignedConfirmation(char *uuid)
  6518. {
  6519. mtrace();
  6520. int result = FAIL;
  6521. char message[4096]={0};
  6522. json_object *CertificateSigned = json_object_new_object();
  6523. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  6524. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  6525. sprintf(message,"[%d,\"%s\",%s]"
  6526. ,MESSAGE_TYPE_CALLRESULT
  6527. ,uuid
  6528. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  6529. json_object_put(CertificateSigned);
  6530. LWS_Send(message);
  6531. result = TRUE;
  6532. return result;
  6533. }
  6534. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  6535. {
  6536. mtrace();
  6537. int result = FAIL;
  6538. char message[4096]={0};
  6539. json_object *ChangeAvailability = json_object_new_object();
  6540. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  6541. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  6542. sprintf(message,"[%d,\"%s\",%s]"
  6543. ,MESSAGE_TYPE_CALLRESULT
  6544. ,uuid
  6545. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  6546. json_object_put(ChangeAvailability);
  6547. LWS_Send(message);
  6548. result = TRUE;
  6549. return result;
  6550. }
  6551. int sendClearCacheConfirmation(char *uuid)
  6552. {
  6553. mtrace();
  6554. int result = FAIL;
  6555. char message[4096]={0};
  6556. json_object *ClearCache = json_object_new_object();
  6557. DEBUG_INFO("sendClearCacheConfirmation...\n");
  6558. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  6559. sprintf(message,"[%d,\"%s\",%s]"
  6560. ,MESSAGE_TYPE_CALLRESULT
  6561. ,uuid
  6562. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  6563. json_object_put(ClearCache);
  6564. LWS_Send(message);
  6565. result = TRUE;
  6566. return result;
  6567. }
  6568. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  6569. {
  6570. mtrace();
  6571. int result = FAIL;
  6572. char message[500]={0};
  6573. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  6574. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  6575. LWS_Send(message);
  6576. return result;
  6577. }
  6578. int sendClearDisplayMessageConfirmation(char *uuid)
  6579. {
  6580. mtrace();
  6581. int result = FAIL;
  6582. char message[4096]={0};
  6583. json_object *ClearDisplayMessage = json_object_new_object();
  6584. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  6585. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  6586. sprintf(message,"[%d,\"%s\",%s]"
  6587. ,MESSAGE_TYPE_CALLRESULT
  6588. ,uuid
  6589. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  6590. json_object_put(ClearDisplayMessage);
  6591. LWS_Send(message);
  6592. result = TRUE;
  6593. return result;
  6594. }
  6595. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  6596. {
  6597. mtrace();
  6598. int result = FAIL;
  6599. char message[4096]={0};
  6600. json_object *ClearVariableMonitoring = json_object_new_object();
  6601. json_object *clearMonitoringResults = json_object_new_array();
  6602. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  6603. for(int idx=0;idx<variableQuantity;idx++)
  6604. {
  6605. json_object *clearMonitoringResult = json_object_new_object();
  6606. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  6607. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  6608. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  6609. }
  6610. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  6611. sprintf(message,"[%d,\"%s\",%s]"
  6612. ,MESSAGE_TYPE_CALLRESULT
  6613. ,uuid
  6614. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  6615. json_object_put(ClearVariableMonitoring);
  6616. LWS_Send(message);
  6617. result = TRUE;
  6618. return result;
  6619. }
  6620. int sendCostUpdatedConfirmation(char *uuid)
  6621. {
  6622. mtrace();
  6623. int result = FAIL;
  6624. char message[4096]={0};
  6625. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  6626. sprintf(message,"[%d,\"%s\",{}]"
  6627. ,MESSAGE_TYPE_CALLRESULT
  6628. ,uuid);
  6629. LWS_Send(message);
  6630. result = TRUE;
  6631. return result;
  6632. }
  6633. int sendCustomerInformationConfirmation(char *uuid)
  6634. {
  6635. mtrace();
  6636. int result = FAIL;
  6637. char message[4096]={0};
  6638. json_object *CustomerInformation = json_object_new_object();
  6639. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  6640. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  6641. sprintf(message,"[%d,\"%s\",%s]"
  6642. ,MESSAGE_TYPE_CALLRESULT
  6643. ,uuid
  6644. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  6645. json_object_put(CustomerInformation);
  6646. LWS_Send(message);
  6647. result = TRUE;
  6648. return result;
  6649. }
  6650. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  6651. {
  6652. mtrace();
  6653. int result = FAIL;
  6654. char message[4096]={0};
  6655. json_object *DataTransfer = json_object_new_object();
  6656. DEBUG_INFO("sendDataTransferConfirmation...\n");
  6657. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  6658. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  6659. sprintf(message,"[%d,\"%s\",%s]"
  6660. ,MESSAGE_TYPE_CALLRESULT
  6661. ,uuid
  6662. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  6663. json_object_put(DataTransfer);
  6664. LWS_Send(message);
  6665. result = TRUE;
  6666. return result;
  6667. }
  6668. int sendDeleteCertificateConfirmation(char *uuid)
  6669. {
  6670. mtrace();
  6671. int result = FAIL;
  6672. char message[4096]={0};
  6673. json_object *DeleteCertificate = json_object_new_object();
  6674. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  6675. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  6676. sprintf(message,"[%d,\"%s\",%s]"
  6677. ,MESSAGE_TYPE_CALLRESULT
  6678. ,uuid
  6679. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  6680. json_object_put(DeleteCertificate);
  6681. LWS_Send(message);
  6682. result = TRUE;
  6683. return result;
  6684. }
  6685. int sendGetBaseReportConfirmation(char *uuid)
  6686. {
  6687. mtrace();
  6688. int result = FAIL;
  6689. char message[4096]={0};
  6690. json_object *GetBaseReport = json_object_new_object();
  6691. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  6692. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  6693. sprintf(message,"[%d,\"%s\",%s]"
  6694. ,MESSAGE_TYPE_CALLRESULT
  6695. ,uuid
  6696. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  6697. json_object_put(GetBaseReport);
  6698. LWS_Send(message);
  6699. result = TRUE;
  6700. return result;
  6701. }
  6702. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  6703. {
  6704. mtrace();
  6705. int result = FAIL;
  6706. char message[4096]={0};
  6707. json_object *GetChargingProfiles = json_object_new_object();
  6708. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  6709. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  6710. sprintf(message,"[%d,\"%s\",%s]"
  6711. ,MESSAGE_TYPE_CALLRESULT
  6712. ,uuid
  6713. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  6714. json_object_put(GetChargingProfiles);
  6715. LWS_Send(message);
  6716. result = TRUE;
  6717. return result;
  6718. }
  6719. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  6720. {
  6721. mtrace();
  6722. int result = FAIL;
  6723. char message[4096]={0};
  6724. int CompositeScheduleIndex = 0;
  6725. json_object *GetCompositeSchedule = json_object_new_object();
  6726. json_object *schedule = json_object_new_object();
  6727. json_object *chargingSchedule = json_object_new_object();
  6728. json_object *chargingSchedulePeriod = json_object_new_array();
  6729. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  6730. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  6731. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  6732. if(nPeriod == 0)
  6733. {
  6734. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  6735. {
  6736. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  6737. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  6738. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  6739. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  6740. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  6741. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  6742. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  6743. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  6744. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  6745. {
  6746. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  6747. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  6748. {
  6749. json_object *Period = json_object_new_object();
  6750. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  6751. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  6752. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  6753. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  6754. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  6755. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  6756. json_object_array_add(chargingSchedulePeriod, Period);
  6757. }
  6758. }
  6759. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  6760. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  6761. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  6762. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  6763. }
  6764. }
  6765. else
  6766. {
  6767. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  6768. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  6769. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  6770. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  6771. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  6772. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  6773. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  6774. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  6775. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  6776. {
  6777. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  6778. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  6779. {
  6780. json_object *Period = json_object_new_object();
  6781. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  6782. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  6783. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  6784. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  6785. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  6786. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  6787. json_object_array_add(chargingSchedulePeriod, Period);
  6788. }
  6789. }
  6790. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  6791. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  6792. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  6793. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  6794. }
  6795. sprintf(message,"[%d,\"%s\",%s]"
  6796. ,MESSAGE_TYPE_CALLRESULT
  6797. ,uuid
  6798. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  6799. json_object_put(GetCompositeSchedule);
  6800. LWS_Send(message);
  6801. result = TRUE;
  6802. return result;
  6803. }
  6804. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  6805. {
  6806. mtrace();
  6807. int result = FAIL;
  6808. char message[4096]={0};
  6809. json_object *GetGetDisplayMessages = json_object_new_object();
  6810. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  6811. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  6812. sprintf(message,"[%d,\"%s\",%s]"
  6813. ,MESSAGE_TYPE_CALLRESULT
  6814. ,uuid
  6815. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  6816. json_object_put(GetGetDisplayMessages);
  6817. LWS_Send(message);
  6818. result = TRUE;
  6819. return result;
  6820. }
  6821. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  6822. {
  6823. mtrace();
  6824. int result = FAIL;
  6825. char message[4096]={0};
  6826. json_object *GetInstalledCertificateIds = json_object_new_object();
  6827. json_object *certificateHashDataChains = json_object_new_array();
  6828. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  6829. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  6830. for(int idx=0;idx<certQuantity;idx++)
  6831. {
  6832. json_object *cert = json_object_new_object();
  6833. json_object *certificateHashData = json_object_new_object();
  6834. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  6835. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  6836. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  6837. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  6838. json_object_object_add(cert, "certificateHashData", certificateHashData);
  6839. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  6840. json_object_array_add(certificateHashDataChains, cert);
  6841. }
  6842. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  6843. sprintf(message,"[%d,\"%s\",%s]"
  6844. ,MESSAGE_TYPE_CALLRESULT
  6845. ,uuid
  6846. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  6847. json_object_put(GetInstalledCertificateIds);
  6848. LWS_Send(message);
  6849. result = TRUE;
  6850. return result;
  6851. }
  6852. int sendGetLocalListVersionConfirmation(char *uuid)
  6853. {
  6854. mtrace();
  6855. int result = FAIL;
  6856. char message[4096]={0};
  6857. json_object *GetLocalListVersion = json_object_new_object();
  6858. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  6859. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  6860. sprintf(message,"[%d,\"%s\",%s]"
  6861. ,MESSAGE_TYPE_CALLRESULT
  6862. ,uuid
  6863. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  6864. json_object_put(GetLocalListVersion);
  6865. LWS_Send(message);
  6866. result = TRUE;
  6867. return result;
  6868. }
  6869. int sendGetLogConfirmation(char *uuid)
  6870. {
  6871. mtrace();
  6872. int result = FAIL;
  6873. char message[4096]={0};
  6874. json_object *GetLog = json_object_new_object();
  6875. DEBUG_INFO("sendGetLogConfirmation...\n");
  6876. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  6877. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  6878. sprintf(message,"[%d,\"%s\",%s]"
  6879. ,MESSAGE_TYPE_CALLRESULT
  6880. ,uuid
  6881. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  6882. json_object_put(GetLog);
  6883. LWS_Send(message);
  6884. result = TRUE;
  6885. return result;
  6886. }
  6887. int sendGetMonitoringReportConfirmation(char *uuid)
  6888. {
  6889. mtrace();
  6890. int result = FAIL;
  6891. char message[4096]={0};
  6892. json_object *GetMonitoringReport = json_object_new_object();
  6893. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  6894. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  6895. sprintf(message,"[%d,\"%s\",%s]"
  6896. ,MESSAGE_TYPE_CALLRESULT
  6897. ,uuid
  6898. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  6899. json_object_put(GetMonitoringReport);
  6900. LWS_Send(message);
  6901. result = TRUE;
  6902. return result;
  6903. }
  6904. int sendGetReportConfirmation(char *uuid)
  6905. {
  6906. mtrace();
  6907. int result = FAIL;
  6908. char message[4096]={0};
  6909. json_object *GetReport = json_object_new_object();
  6910. DEBUG_INFO("sendGetReportConfirmation...\n");
  6911. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  6912. sprintf(message,"[%d,\"%s\",%s]"
  6913. ,MESSAGE_TYPE_CALLRESULT
  6914. ,uuid
  6915. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  6916. json_object_put(GetReport);
  6917. LWS_Send(message);
  6918. result = TRUE;
  6919. return result;
  6920. }
  6921. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  6922. {
  6923. mtrace();
  6924. int result = FAIL;
  6925. char message[4096]={0};
  6926. json_object *GetTransactionStatus = json_object_new_object();
  6927. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  6928. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  6929. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  6930. sprintf(message,"[%d,\"%s\",%s]"
  6931. ,MESSAGE_TYPE_CALLRESULT
  6932. ,uuid
  6933. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  6934. json_object_put(GetTransactionStatus);
  6935. LWS_Send(message);
  6936. result = TRUE;
  6937. return result;
  6938. }
  6939. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  6940. {
  6941. mtrace();
  6942. int result = FAIL;
  6943. char message[4096]={0};
  6944. json_object *GetVariables = json_object_new_object();
  6945. json_object *getVariableResults = json_object_new_array();
  6946. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  6947. for(int idx=0;idx<variableQuantity;idx++)
  6948. {
  6949. json_object *variableResult = json_object_new_object();
  6950. json_object *component = json_object_new_object();
  6951. json_object *variable = json_object_new_object();
  6952. json_object *evse = json_object_new_object();
  6953. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  6954. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  6955. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  6956. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  6957. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  6958. json_object_object_add(component, "component", evse);
  6959. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  6960. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  6961. json_object_object_add(variableResult, "component", component);
  6962. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  6963. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  6964. json_object_object_add(variableResult, "variable", variable);
  6965. json_object_array_add(getVariableResults, variableResult);
  6966. }
  6967. json_object_object_add(GetVariables , "setVariableResult", getVariableResults);
  6968. sprintf(message,"[%d,\"%s\",%s]"
  6969. ,MESSAGE_TYPE_CALLRESULT
  6970. ,uuid
  6971. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  6972. json_object_put(GetVariables);
  6973. LWS_Send(message);
  6974. result = TRUE;
  6975. return result;
  6976. }
  6977. int sendInstallCertificateConfirmation(char *uuid)
  6978. {
  6979. mtrace();
  6980. int result = FAIL;
  6981. char message[4096]={0};
  6982. json_object *InstallCertificate = json_object_new_object();
  6983. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  6984. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  6985. sprintf(message,"[%d,\"%s\",%s]"
  6986. ,MESSAGE_TYPE_CALLRESULT
  6987. ,uuid
  6988. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  6989. json_object_put(InstallCertificate);
  6990. LWS_Send(message);
  6991. result = TRUE;
  6992. return result;
  6993. }
  6994. int sendPublishFirmwareConfirmation(char *uuid)
  6995. {
  6996. mtrace();
  6997. int result = FAIL;
  6998. char message[4096]={0};
  6999. json_object *PublishFirmware = json_object_new_object();
  7000. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  7001. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  7002. sprintf(message,"[%d,\"%s\",%s]"
  7003. ,MESSAGE_TYPE_CALLRESULT
  7004. ,uuid
  7005. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  7006. json_object_put(PublishFirmware);
  7007. LWS_Send(message);
  7008. result = TRUE;
  7009. return result;
  7010. }
  7011. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  7012. {
  7013. mtrace();
  7014. int result = FAIL;
  7015. char message[4096]={0};
  7016. json_object *RemoteStartTransaction = json_object_new_object();
  7017. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  7018. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  7019. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  7020. sprintf(message,"[%d,\"%s\",%s]"
  7021. ,MESSAGE_TYPE_CALLRESULT
  7022. ,uuid
  7023. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  7024. json_object_put(RemoteStartTransaction);
  7025. LWS_Send(message);
  7026. result = TRUE;
  7027. return result;
  7028. }
  7029. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  7030. {
  7031. mtrace();
  7032. int result = FAIL;
  7033. char message[4096]={0};
  7034. json_object *RemoteStopTransaction = json_object_new_object();
  7035. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  7036. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  7037. sprintf(message,"[%d,\"%s\",%s]"
  7038. ,MESSAGE_TYPE_CALLRESULT
  7039. ,uuid
  7040. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  7041. json_object_put(RemoteStopTransaction);
  7042. LWS_Send(message);
  7043. result = TRUE;
  7044. return result;
  7045. }
  7046. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  7047. {
  7048. mtrace();
  7049. int result = FAIL;
  7050. char message[4096]={0};
  7051. json_object *ReserveNow = json_object_new_object();
  7052. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  7053. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  7054. sprintf(message,"[%d,\"%s\",%s]"
  7055. ,MESSAGE_TYPE_CALLRESULT
  7056. ,uuid
  7057. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  7058. json_object_put(ReserveNow);
  7059. LWS_Send(message);
  7060. result = TRUE;
  7061. return result;
  7062. }
  7063. int sendResetConfirmation(char *uuid)
  7064. {
  7065. mtrace();
  7066. int result = FAIL;
  7067. char message[4096]={0};
  7068. json_object *Reset = json_object_new_object();
  7069. ShmOCPP20Data->MsMsg.bits.ResetConf = 0;
  7070. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  7071. sprintf(message,"[%d,\"%s\",%s]"
  7072. ,MESSAGE_TYPE_CALLRESULT
  7073. ,uuid
  7074. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  7075. json_object_put(Reset);
  7076. LWS_Send(message);
  7077. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  7078. {
  7079. DB_updateBootType(BootReasonEnumType_RemoteReset);
  7080. }
  7081. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  7082. {
  7083. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  7084. }
  7085. result = TRUE;
  7086. return result;
  7087. }
  7088. int sendSendLocalListConfirmation(char *uuid)
  7089. {
  7090. mtrace();
  7091. int result = FAIL;
  7092. char message[4096]={0};
  7093. json_object *SendLocalList = json_object_new_object();
  7094. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  7095. sprintf(message,"[%d,\"%s\",%s]"
  7096. ,MESSAGE_TYPE_CALLRESULT
  7097. ,uuid
  7098. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  7099. json_object_put(SendLocalList);
  7100. LWS_Send(message);
  7101. result = TRUE;
  7102. return result;
  7103. }
  7104. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  7105. {
  7106. mtrace();
  7107. int result = FAIL;
  7108. char message[4096]={0};
  7109. json_object *SetChargingProfile = json_object_new_object();
  7110. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  7111. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  7112. sprintf(message,"[%d,\"%s\",%s]"
  7113. ,MESSAGE_TYPE_CALLRESULT
  7114. ,uuid
  7115. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  7116. json_object_put(SetChargingProfile);
  7117. LWS_Send(message);
  7118. result = TRUE;
  7119. return result;
  7120. }
  7121. int sendSetDisplayMessageConfirmation(char *uuid)
  7122. {
  7123. mtrace();
  7124. int result = FAIL;
  7125. char message[4096]={0};
  7126. json_object *SetDisplayMessage = json_object_new_object();
  7127. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  7128. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  7129. sprintf(message,"[%d,\"%s\",%s]"
  7130. ,MESSAGE_TYPE_CALLRESULT
  7131. ,uuid
  7132. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  7133. json_object_put(SetDisplayMessage);
  7134. LWS_Send(message);
  7135. result = TRUE;
  7136. return result;
  7137. }
  7138. int sendSetMonitoringBaseConfirmation(char *uuid)
  7139. {
  7140. mtrace();
  7141. int result = FAIL;
  7142. char message[4096]={0};
  7143. json_object *SetMonitoringBase = json_object_new_object();
  7144. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  7145. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  7146. sprintf(message,"[%d,\"%s\",%s]"
  7147. ,MESSAGE_TYPE_CALLRESULT
  7148. ,uuid
  7149. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  7150. json_object_put(SetMonitoringBase);
  7151. LWS_Send(message);
  7152. result = TRUE;
  7153. return result;
  7154. }
  7155. int sendSetMonitoringLevelConfirmation(char *uuid)
  7156. {
  7157. mtrace();
  7158. int result = FAIL;
  7159. char message[4096]={0};
  7160. json_object *SetMonitoringLevel = json_object_new_object();
  7161. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  7162. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  7163. sprintf(message,"[%d,\"%s\",%s]"
  7164. ,MESSAGE_TYPE_CALLRESULT
  7165. ,uuid
  7166. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  7167. json_object_put(SetMonitoringLevel);
  7168. LWS_Send(message);
  7169. result = TRUE;
  7170. return result;
  7171. }
  7172. int sendSetNetworkProfileConfirmation(char *uuid)
  7173. {
  7174. mtrace();
  7175. int result = FAIL;
  7176. char message[4096]={0};
  7177. json_object *SetNetworkProfile = json_object_new_object();
  7178. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  7179. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  7180. sprintf(message,"[%d,\"%s\",%s]"
  7181. ,MESSAGE_TYPE_CALLRESULT
  7182. ,uuid
  7183. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  7184. json_object_put(SetNetworkProfile);
  7185. LWS_Send(message);
  7186. result = TRUE;
  7187. return result;
  7188. }
  7189. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  7190. {
  7191. mtrace();
  7192. int result = FAIL;
  7193. char message[4096]={0};
  7194. json_object *SetVariableMonitoring = json_object_new_object();
  7195. json_object *setMonitoringResults = json_object_new_array();
  7196. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  7197. for(int idx=0;idx<variableQuantity;idx++)
  7198. {
  7199. json_object *variableMonitorResult = json_object_new_object();
  7200. json_object *component = json_object_new_object();
  7201. json_object *variable = json_object_new_object();
  7202. json_object *evse = json_object_new_object();
  7203. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  7204. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  7205. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  7206. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  7207. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  7208. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  7209. json_object_object_add(component, "component", evse);
  7210. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  7211. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  7212. json_object_object_add(variableMonitorResult, "component", component);
  7213. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  7214. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  7215. json_object_object_add(variableMonitorResult, "variable", variable);
  7216. json_object_array_add(setMonitoringResults, variableMonitorResult);
  7217. }
  7218. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  7219. sprintf(message,"[%d,\"%s\",%s]"
  7220. ,MESSAGE_TYPE_CALLRESULT
  7221. ,uuid
  7222. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  7223. json_object_put(SetVariableMonitoring);
  7224. LWS_Send(message);
  7225. result = TRUE;
  7226. return result;
  7227. }
  7228. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  7229. {
  7230. mtrace();
  7231. int result = FAIL;
  7232. char message[4096]={0};
  7233. json_object *SetVariable = json_object_new_object();
  7234. json_object *setVariableResults = json_object_new_array();
  7235. DEBUG_INFO("sendSetVariableConfirmation...\n");
  7236. for(int idx=0;idx<variableQuantity;idx++)
  7237. {
  7238. json_object *variableResult = json_object_new_object();
  7239. json_object *component = json_object_new_object();
  7240. json_object *variable = json_object_new_object();
  7241. json_object *evse = json_object_new_object();
  7242. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  7243. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  7244. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  7245. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  7246. json_object_object_add(component, "component", evse);
  7247. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  7248. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  7249. json_object_object_add(variableResult, "component", component);
  7250. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  7251. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  7252. json_object_object_add(variableResult, "variable", variable);
  7253. json_object_array_add(setVariableResults, variableResult);
  7254. }
  7255. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  7256. sprintf(message,"[%d,\"%s\",%s]"
  7257. ,MESSAGE_TYPE_CALLRESULT
  7258. ,uuid
  7259. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  7260. json_object_put(SetVariable);
  7261. LWS_Send(message);
  7262. result = TRUE;
  7263. return result;
  7264. }
  7265. int sendTriggerMessageConfirmation(char *uuid)
  7266. {
  7267. mtrace();
  7268. int result = FAIL;
  7269. char message[4096]={0};
  7270. json_object *TriggerMessage = json_object_new_object();
  7271. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  7272. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  7273. sprintf(message,"[%d,\"%s\",%s]",
  7274. MESSAGE_TYPE_CALLRESULT,
  7275. uuid,
  7276. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  7277. json_object_put(TriggerMessage);
  7278. LWS_Send(message);
  7279. result = TRUE;
  7280. return result;
  7281. }
  7282. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  7283. {
  7284. mtrace();
  7285. int result = FAIL;
  7286. char message[4096]={0};
  7287. json_object *UnlockConnector = json_object_new_object();
  7288. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  7289. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  7290. sprintf(message,"[%d,\"%s\",%s]",
  7291. MESSAGE_TYPE_CALLRESULT,
  7292. uuid,
  7293. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  7294. json_object_put(UnlockConnector);
  7295. LWS_Send(message);
  7296. result = TRUE;
  7297. return result;
  7298. }
  7299. int sendUnpublishFirmwareConfirmation(char *uuid)
  7300. {
  7301. mtrace();
  7302. int result = FAIL;
  7303. char message[4096]={0};
  7304. json_object *UnpublishFirmware = json_object_new_object();
  7305. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  7306. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  7307. sprintf(message,"[%d,\"%s\",%s]"
  7308. ,MESSAGE_TYPE_CALLRESULT
  7309. ,uuid
  7310. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  7311. json_object_put(UnpublishFirmware);
  7312. LWS_Send(message);
  7313. result = TRUE;
  7314. return result;
  7315. }
  7316. int sendUpdateFirmwareConfirmation(char *uuid)
  7317. {
  7318. mtrace();
  7319. int result = FAIL;
  7320. char message[4096]={0};
  7321. json_object *UpdateFirmware = json_object_new_object();
  7322. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  7323. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  7324. sprintf(message,"[%d,\"%s\",%s]"
  7325. ,MESSAGE_TYPE_CALLRESULT
  7326. ,uuid
  7327. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  7328. json_object_put(UpdateFirmware);
  7329. LWS_Send(message);
  7330. result = TRUE;
  7331. return result;
  7332. }
  7333. //==========================================
  7334. // send CallError routine
  7335. //==========================================
  7336. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  7337. {
  7338. mtrace();
  7339. char message[220]={0};
  7340. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  7341. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  7342. LWS_Send(message);
  7343. }
  7344. //==========================================
  7345. // Handle server request routine Start
  7346. //==========================================
  7347. int handleCancelReservationRequest(char *uuid, char *payload)
  7348. {
  7349. mtrace();
  7350. int result = FAIL;
  7351. int gunNO = 0;
  7352. int reservationIdInt = -1;
  7353. DEBUG_INFO("handleCancelReservationRequest...\n");
  7354. json_object *CancelReservation;
  7355. CancelReservation = json_tokener_parse(payload);
  7356. if(!is_error(CancelReservation))
  7357. {
  7358. // Required data
  7359. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  7360. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  7361. }
  7362. json_object_put(CancelReservation);
  7363. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  7364. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  7365. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  7366. if(reservationIdInt != -1)
  7367. {
  7368. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  7369. //check Transaction active
  7370. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  7371. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7372. {
  7373. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  7374. {
  7375. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  7376. if(gunType[2] == 'J')
  7377. {
  7378. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  7379. }
  7380. else
  7381. {
  7382. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  7383. }
  7384. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  7385. goto end;
  7386. }
  7387. }
  7388. for (int index = 0; index < CCS_QUANTITY; index++)
  7389. {
  7390. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  7391. {
  7392. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  7393. if((gunType[2] == 'U') || (gunType[2] == 'E'))
  7394. {
  7395. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  7396. }
  7397. else
  7398. {
  7399. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  7400. }
  7401. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = 1;
  7402. goto end;
  7403. }
  7404. }
  7405. for (int index = 0; index < GB_QUANTITY; index++)
  7406. {
  7407. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  7408. {
  7409. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  7410. if(gunType[2] == 'G')
  7411. {
  7412. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  7413. }
  7414. else
  7415. {
  7416. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  7417. }
  7418. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = 1;
  7419. goto end;
  7420. }
  7421. }
  7422. for (int index = 0; index < AC_QUANTITY; index++)
  7423. {
  7424. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  7425. {
  7426. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  7427. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7428. {
  7429. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  7430. }
  7431. else
  7432. {
  7433. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  7434. }
  7435. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  7436. goto end;
  7437. }
  7438. }
  7439. }
  7440. //The reservationId does NOT match the reservationId
  7441. sendCancelReservationConfirmation(uuid, gunNO);
  7442. end:
  7443. // Fill in ocpp packet uuid
  7444. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  7445. return result;
  7446. }
  7447. int handleCertificateSignedRequest(char *uuid, char *payload)
  7448. {
  7449. mtrace();
  7450. int result = FAIL;
  7451. json_object *CertificateSigned;
  7452. DEBUG_INFO("handleCertificateSignedRequest...\n");
  7453. CertificateSigned = json_tokener_parse(payload);
  7454. if(!is_error(CertificateSigned))
  7455. {
  7456. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  7457. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  7458. // Required data
  7459. if(json_object_array_length(json_object_object_get(CertificateSigned, "certificate")) <= ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.certificate))
  7460. {
  7461. for(int idx=0;idx<json_object_array_length(json_object_object_get(CertificateSigned, "certificate"));idx++)
  7462. {
  7463. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificate[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(CertificateSigned, "certificateType"), idx)));
  7464. /*
  7465. * TODO:
  7466. * 1. Certificate install response
  7467. */
  7468. }
  7469. }
  7470. // Optional data
  7471. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  7472. {
  7473. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  7474. }
  7475. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  7476. }
  7477. else
  7478. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  7479. json_object_put(CertificateSigned);
  7480. sendCertificateSignedConfirmation(uuid);
  7481. return result;
  7482. }
  7483. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  7484. {
  7485. mtrace();
  7486. int result = FAIL;
  7487. int evseId = 0, gunIndex = 0;
  7488. char operationalStatus[16]={0};
  7489. char comfirmstr[20];
  7490. int specificId = FALSE;
  7491. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  7492. json_object *ChangeAvailability;
  7493. ChangeAvailability = json_tokener_parse(payload);
  7494. if(!is_error(ChangeAvailability))
  7495. {
  7496. // Required data
  7497. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  7498. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  7499. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  7500. {
  7501. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  7502. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  7503. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  7504. }
  7505. }
  7506. json_object_put(ChangeAvailability);
  7507. if((evseId != 0) && (evseId <= gunTotalNumber))
  7508. {
  7509. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  7510. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  7511. }
  7512. else if(evseId == 0)
  7513. {
  7514. for(int i=0; i < gunTotalNumber; i++)
  7515. {
  7516. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  7517. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  7518. }
  7519. }
  7520. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  7521. {
  7522. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  7523. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  7524. }
  7525. else if(gunIndex == 0)
  7526. {
  7527. for(int i=0; i < gunTotalNumber; i++)
  7528. {
  7529. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  7530. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  7531. }
  7532. }
  7533. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  7534. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7535. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  7536. {
  7537. specificId = TRUE;
  7538. }
  7539. if(specificId == FALSE)
  7540. goto end;
  7541. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  7542. {
  7543. //----------------------gunIndex is 0 ------------------------------------------------//
  7544. if(gunIndex == 0)
  7545. {
  7546. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  7547. {
  7548. for(int i=0; i < gunTotalNumber; i++)
  7549. {
  7550. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7551. {
  7552. if ((gunType[i] == 'J')&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  7553. {
  7554. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  7555. {
  7556. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7557. goto end;
  7558. }
  7559. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  7560. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  7561. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  7562. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  7563. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  7564. {
  7565. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  7566. goto end;
  7567. }
  7568. }
  7569. }//END FOR CHAdeMO_QUANTITY
  7570. for (int index = 0; index < CCS_QUANTITY; index++)
  7571. {
  7572. if (((gunType[i] == 'U')||(gunType[i] == 'E'))&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  7573. {
  7574. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  7575. {
  7576. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7577. goto end;
  7578. }
  7579. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  7580. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  7581. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  7582. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  7583. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  7584. {
  7585. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  7586. goto end;
  7587. }
  7588. }
  7589. }//END FOR CCS_QUANTITY
  7590. for (int index = 0; index < GB_QUANTITY; index++)
  7591. {
  7592. if ((gunType[i] == 'G')&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  7593. {
  7594. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  7595. {
  7596. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7597. goto end;
  7598. }
  7599. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  7600. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  7601. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  7602. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  7603. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  7604. {
  7605. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  7606. goto end;
  7607. }
  7608. }
  7609. }// END FOR GB_QUANTITY
  7610. for (int index = 0; index < AC_QUANTITY; index++)
  7611. {
  7612. if (((gunType[i] > '0')&&(gunType[i] <= '9'))&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  7613. {
  7614. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  7615. {
  7616. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7617. goto end;
  7618. }
  7619. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  7620. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  7621. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  7622. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  7623. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  7624. {
  7625. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  7626. goto end;
  7627. }
  7628. }
  7629. }//END FOR AC_QUANTITY
  7630. }// END FOR gunTotalNumber
  7631. }
  7632. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  7633. {
  7634. for(int i=0; i < gunTotalNumber; i++)
  7635. {
  7636. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  7637. {
  7638. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7639. goto end;
  7640. }
  7641. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  7642. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  7643. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  7644. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  7645. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  7646. {
  7647. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  7648. goto end;
  7649. }
  7650. }
  7651. }
  7652. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  7653. goto end;
  7654. }
  7655. //----------------------gunIndex is not 0 ------------------------------------------------//
  7656. //check Transaction active
  7657. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7658. {
  7659. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J'))
  7660. {
  7661. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  7662. {
  7663. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7664. goto end;
  7665. }
  7666. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  7667. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  7668. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  7669. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  7670. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  7671. {
  7672. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  7673. goto end;
  7674. }
  7675. else
  7676. {
  7677. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  7678. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  7679. goto end;
  7680. }
  7681. }
  7682. }//END FOR CHAdeMO_QUANTITY
  7683. for (int index = 0; index < CCS_QUANTITY; index++)
  7684. {
  7685. if ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E')))
  7686. {
  7687. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  7688. {
  7689. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7690. goto end;
  7691. }
  7692. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  7693. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  7694. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  7695. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  7696. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  7697. {
  7698. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  7699. goto end;
  7700. }
  7701. else
  7702. {
  7703. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  7704. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  7705. goto end;
  7706. }
  7707. }
  7708. }//END FOR CCS_QUANTITY
  7709. for (int index = 0; index < GB_QUANTITY; index++)
  7710. {
  7711. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))
  7712. {
  7713. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  7714. {
  7715. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7716. goto end;
  7717. }
  7718. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  7719. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  7720. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  7721. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  7722. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  7723. {
  7724. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  7725. goto end;
  7726. }
  7727. else
  7728. {
  7729. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  7730. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  7731. goto end;
  7732. }
  7733. }
  7734. }// END FOR GB_QUANTITY
  7735. for (int index = 0; index < AC_QUANTITY; index++)
  7736. {
  7737. if ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))
  7738. {
  7739. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  7740. {
  7741. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7742. goto end;
  7743. }
  7744. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  7745. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  7746. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  7747. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  7748. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  7749. {
  7750. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  7751. goto end;
  7752. }
  7753. else
  7754. {
  7755. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  7756. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  7757. goto end;
  7758. }
  7759. }
  7760. }//END FOR AC_QUANTITY
  7761. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  7762. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  7763. {
  7764. //----------------------gunIndex is 0 ------------------------------------------------//
  7765. if(gunIndex == 0)
  7766. {
  7767. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  7768. {
  7769. for(int i=0; i < gunTotalNumber; i++)
  7770. {
  7771. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7772. {
  7773. 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
  7774. {
  7775. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7776. goto end;
  7777. }
  7778. }//END FOR CHAdeMO_QUANTITY
  7779. for (int index = 0; index < CCS_QUANTITY; index++)
  7780. {
  7781. 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
  7782. {
  7783. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7784. goto end;
  7785. }
  7786. }//END FOR CCS_QUANTITY
  7787. for (int index = 0; index < GB_QUANTITY; index++)
  7788. {
  7789. 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
  7790. {
  7791. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = 1;
  7792. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7793. goto end;
  7794. }
  7795. }// END FOR GB_QUANTITY
  7796. for (int index = 0; index < AC_QUANTITY; index++)
  7797. {
  7798. 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
  7799. {
  7800. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7801. goto end;
  7802. }
  7803. }//END FOR CHAdeMO_QUANTITY
  7804. }// END FOR gunTotalNumber
  7805. }
  7806. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  7807. {
  7808. for(int i=0; i < gunTotalNumber; i++)
  7809. {
  7810. for (int index = 0; index < AC_QUANTITY; index++)
  7811. {
  7812. 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
  7813. {
  7814. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  7815. goto end;
  7816. }
  7817. }//END FOR CHAdeMO_QUANTITY
  7818. } // END FOR gunTotalNumber
  7819. }
  7820. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  7821. goto end;
  7822. }
  7823. //----------------------gunIndex is not 0 ------------------------------------------------//
  7824. //check Transaction active
  7825. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  7826. {
  7827. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'J') ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  7828. {
  7829. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  7830. goto end;
  7831. }
  7832. }//END FOR CHAdeMO_QUANTITY
  7833. for (int index = 0; index < CCS_QUANTITY; index++)
  7834. {
  7835. if ((((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  7836. {
  7837. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  7838. goto end;
  7839. }
  7840. }//END FOR CCS_QUANTITY
  7841. for (int index = 0; index < GB_QUANTITY; index++)
  7842. {
  7843. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  7844. {
  7845. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  7846. goto end;
  7847. }
  7848. }// END FOR GB_QUANTITY
  7849. for (int index = 0; index < AC_QUANTITY; index++)
  7850. {
  7851. if (((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9'))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  7852. {
  7853. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  7854. goto end;
  7855. }
  7856. }//END FOR AC_QUANTITY
  7857. }//END FOR AvailabilityEnumTypeStr[Operative]
  7858. end:
  7859. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  7860. {
  7861. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  7862. }
  7863. else
  7864. {
  7865. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  7866. }
  7867. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  7868. {
  7869. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  7870. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  7871. }
  7872. else if(gunIndex == 0)
  7873. {
  7874. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  7875. {
  7876. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  7877. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  7878. }
  7879. }
  7880. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  7881. return result;
  7882. }
  7883. int handleClearCacheRequest(char *uuid, char *payload)
  7884. {
  7885. mtrace();
  7886. int result = FAIL;
  7887. char rmFileCmd[100]={0};
  7888. struct stat stats;
  7889. DEBUG_INFO("handleClearCacheRequest...\n");
  7890. stat("/Storage/OCPP", &stats);
  7891. // Check for directory existence
  7892. if (S_ISDIR(stats.st_mode) == 1)
  7893. {}
  7894. else
  7895. {
  7896. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  7897. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  7898. system(rmFileCmd);
  7899. }
  7900. /*
  7901. * TODO:
  7902. * 1. Clear cache from sqlite db
  7903. */
  7904. if(1)
  7905. {
  7906. DEBUG_INFO("open AuthorizationCache file failed\n");
  7907. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  7908. }
  7909. else
  7910. {
  7911. DEBUG_INFO("open AuthorizationCache file successful\n");
  7912. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  7913. }
  7914. sendClearCacheConfirmation(uuid);
  7915. return result;
  7916. }
  7917. int handleClearChargingProfileRequest(char *uuid, char *payload)
  7918. {
  7919. mtrace();
  7920. int result = FAIL;
  7921. int resultRename;
  7922. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  7923. char chargingProfilePurposeStr[26]={0};
  7924. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  7925. char tempchargingProfilePurposeStr[26]={0};
  7926. char sstr[160]={0};
  7927. char str[100]={0};
  7928. int c = 0;
  7929. char *loc;
  7930. char fname[200]={0};
  7931. char comfirmstr[20]={0};
  7932. char word[1600]={0};
  7933. int clearflag = FALSE;
  7934. int chargingProfileIdIsNULL = FALSE;
  7935. int connectorIsNULL = FALSE;
  7936. int chargingProfilePurposeIsNULL = FALSE;
  7937. int stackLevelIsNULL = FALSE;
  7938. //int GotoEnd = FALSE;
  7939. FILE *fptr1, *fptr2;
  7940. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  7941. int n_chargingProfile=0;
  7942. int isEmptyFile = FALSE;
  7943. char sLineWord[1600]={0};
  7944. char chargingProfiles[10][100]={0};
  7945. int ChargeProfileCount = 0;
  7946. int ch;
  7947. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  7948. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  7949. json_object *ClearChargingProfile;
  7950. ClearChargingProfile = json_tokener_parse(payload);
  7951. if(!is_error(ClearChargingProfile))
  7952. {
  7953. // Optional data
  7954. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  7955. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  7956. else
  7957. chargingProfileIdIsNULL = TRUE;
  7958. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  7959. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  7960. else
  7961. connectorIsNULL = TRUE;
  7962. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  7963. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  7964. else
  7965. chargingProfilePurposeIsNULL = TRUE;
  7966. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  7967. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  7968. else
  7969. stackLevelIsNULL = TRUE;
  7970. }
  7971. json_object_put(ClearChargingProfile);
  7972. if(connectorIsNULL == FALSE)
  7973. {
  7974. switch(connectorIdInt)
  7975. {
  7976. case 0:
  7977. if(chargingProfilePurposeIsNULL == TRUE)
  7978. {
  7979. int l = 0;
  7980. strcpy(fname, ChargePointMaxProfile_JSON);
  7981. if((access(fname,F_OK))!=-1)
  7982. {
  7983. strcpy(chargingProfiles[l], fname);
  7984. l = l + 1;
  7985. }
  7986. strcpy(fname, TxDefaultProfile_0_JSON);
  7987. if((access(fname,F_OK))!=-1)
  7988. {
  7989. strcpy(chargingProfiles[l], fname);
  7990. l = l + 1;
  7991. }
  7992. ChargeProfileCount = l;
  7993. }
  7994. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  7995. {
  7996. strcpy(fname, ChargePointMaxProfile_JSON);
  7997. if((access(fname,F_OK))!=-1)
  7998. {
  7999. strcpy(chargingProfiles[0], fname);
  8000. ChargeProfileCount = 1;
  8001. }
  8002. }
  8003. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  8004. {
  8005. strcpy(fname, TxDefaultProfile_0_JSON);
  8006. if((access(fname,F_OK))!=-1)
  8007. {
  8008. strcpy(chargingProfiles[0], fname);
  8009. ChargeProfileCount = 1;
  8010. }
  8011. }
  8012. break;
  8013. default:
  8014. if(chargingProfilePurposeIsNULL == TRUE)
  8015. {
  8016. int m = 0;
  8017. memset(fname, 0, ARRAY_SIZE(fname));
  8018. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  8019. if((access(fname,F_OK))!=-1)
  8020. {
  8021. strcpy(chargingProfiles[m], fname);
  8022. m = m + 1;
  8023. }
  8024. memset(fname, 0, ARRAY_SIZE(fname));
  8025. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  8026. if((access(fname,F_OK))!=-1)
  8027. {
  8028. strcpy(chargingProfiles[m], fname);
  8029. m = m + 1;
  8030. }
  8031. ChargeProfileCount = m;
  8032. }
  8033. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  8034. {
  8035. //strcpy(fname, TxDefaultProfile_1_JSON);
  8036. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  8037. if((access(fname,F_OK))!=-1)
  8038. {
  8039. strcpy(chargingProfiles[0], fname);
  8040. ChargeProfileCount = 1;
  8041. }
  8042. }
  8043. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  8044. {
  8045. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  8046. if((access(fname,F_OK))!=-1)
  8047. {
  8048. strcpy(chargingProfiles[0], fname);
  8049. ChargeProfileCount = 1;
  8050. }
  8051. }
  8052. //strcpy(fname, ChargePointMaxProfile_JSON );
  8053. break;
  8054. }
  8055. }
  8056. else // Check all Charging Profiles
  8057. {
  8058. int i = 0;
  8059. char fnametemp[200]={0};
  8060. ChargeProfileCount = 0;
  8061. //Check ChargePointMaxProfile.json exit
  8062. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  8063. {
  8064. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  8065. i = i + 1;
  8066. }
  8067. //Check TxDefaultProfile_0.json exit
  8068. if((access("/Storage/OCPP/TxDefaultProfile_0.json",F_OK))!=-1)
  8069. {
  8070. strcpy(chargingProfiles[i], "/Storage/OCPP/TxDefaultProfile_0.json");
  8071. i = i + 1;
  8072. }
  8073. //Check TxDefaultProfile_%d.json
  8074. for(int j=1; j <= gunTotalNumber; j++)
  8075. {
  8076. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  8077. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d.json", j);
  8078. if((access(fnametemp,F_OK))!=-1)
  8079. {
  8080. strcpy(chargingProfiles[i], fnametemp);
  8081. i = i + 1;
  8082. }
  8083. }
  8084. //Check TxProfile_%d.json
  8085. for(int j=1; j <= gunTotalNumber; j++)
  8086. {
  8087. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  8088. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d.json", j);
  8089. if((access(fnametemp,F_OK))!=-1)
  8090. {
  8091. strcpy(chargingProfiles[i], fnametemp);
  8092. i = i + 1;
  8093. }
  8094. }
  8095. ChargeProfileCount = i;
  8096. }// End connectorIsNULL is TRUE
  8097. if(ChargeProfileCount == 0)
  8098. {
  8099. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  8100. goto end;
  8101. }
  8102. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  8103. {
  8104. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  8105. goto end;
  8106. }
  8107. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  8108. {
  8109. memset(str, 0, ARRAY_SIZE(str));
  8110. // clear temp file
  8111. sprintf(str,"rm -f %s",temp);
  8112. system(str);
  8113. for(int k=0; k < ChargeProfileCount; k++)
  8114. {
  8115. memset(str, 0, ARRAY_SIZE(str));
  8116. //clear file in C
  8117. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8118. system(str);
  8119. }
  8120. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8121. goto end;
  8122. }
  8123. else if(connectorIsNULL == TRUE)
  8124. {
  8125. for(int k=0; k < ChargeProfileCount; k++)
  8126. {
  8127. fptr1 = fopen(chargingProfiles[k], "r");
  8128. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  8129. //Check Charging Profile Count
  8130. while(fscanf(fptr1, "%s", word) != EOF)
  8131. {
  8132. //DEBUG_INFO("word=%s\n",word);
  8133. if(strstr(word, "chargingProfileId")!= NULL)
  8134. {
  8135. //DEBUG_INFO("test chargingProfileId \n");
  8136. n_chargingProfile = n_chargingProfile + 1;
  8137. //DEBUG_INFO("chargingProfileId Found\n");
  8138. }
  8139. }
  8140. rewind(fptr1);
  8141. //search Charging Profile Element
  8142. //int i= 0;
  8143. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  8144. {
  8145. //------------------------tempconnectorIdInt------------------------//
  8146. loc = strstr(sLineWord, "connectorId");
  8147. c = 0;
  8148. memset(sstr ,0, sizeof(sstr) );
  8149. while (loc[strlen("connectorId")+2+c] != ',')
  8150. {
  8151. sstr[c] = loc[strlen("connectorId")+2+c];
  8152. c++;
  8153. }
  8154. sstr[c] = '\0';
  8155. tempconnectorIdInt = atoi(sstr);
  8156. printf("file's gun number is %d\n", tempconnectorIdInt);
  8157. //--------------------------chargingProfileId--------------------//
  8158. c = 0;
  8159. loc = strstr(sLineWord, "chargingProfileId");
  8160. memset(sstr ,0, ARRAY_SIZE(sstr));
  8161. while (loc[strlen("chargingProfileId")+2+c] != ',')
  8162. {
  8163. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  8164. //printf("i=%d sstr=%c\n",c, sstr[c]);
  8165. c++;
  8166. }
  8167. sstr[c] = '\0';
  8168. tempchargingProfileIdInt = atoi(sstr);
  8169. //stackLevel
  8170. c = 0;
  8171. loc = strstr(sLineWord, "stackLevel");
  8172. memset(sstr ,0, ARRAY_SIZE(sstr));
  8173. while (loc[strlen("stackLevel")+2+c] != ',')
  8174. {
  8175. sstr[c] = loc[strlen("stackLevel")+2+c];
  8176. //printf("i=%d sstr=%c\n",c, sstr[c]);
  8177. c++;
  8178. }
  8179. sstr[c] = '\0';
  8180. tempstackLevelInt = atoi(sstr);
  8181. c = 0;
  8182. loc = strstr(sLineWord, "chargingProfilePurpose");
  8183. memset(sstr ,0, ARRAY_SIZE(sstr));
  8184. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  8185. {
  8186. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  8187. c++;
  8188. }
  8189. sstr[c] = '\0';
  8190. strcpy(tempchargingProfilePurposeStr, sstr);
  8191. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  8192. {
  8193. //------- not write to fptr2-------//
  8194. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8195. //clearflag = TRUE;
  8196. }
  8197. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  8198. {
  8199. //------- not write to fptr2-------//
  8200. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8201. }
  8202. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  8203. {
  8204. //------- not write to fptr2-------//
  8205. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8206. }
  8207. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  8208. {
  8209. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8210. }
  8211. else
  8212. {
  8213. fprintf(fptr2, sLineWord);//writing data into file
  8214. }
  8215. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  8216. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  8217. if(clearflag == TRUE)
  8218. {
  8219. fclose(fptr1);
  8220. fclose(fptr2);
  8221. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8222. system(str);
  8223. // clear temp file
  8224. sprintf(str,"rm -f %s",temp);
  8225. system(str);
  8226. }
  8227. else
  8228. {
  8229. fclose(fptr1);
  8230. fclose(fptr2);
  8231. memset(str, 0, ARRAY_SIZE(str));
  8232. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8233. system(str);
  8234. resultRename = rename(temp, chargingProfiles[k]);
  8235. if(resultRename == 0)
  8236. {
  8237. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  8238. }
  8239. else
  8240. {
  8241. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  8242. }
  8243. if(comfirmstr[0]== 0)
  8244. {
  8245. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  8246. }
  8247. //Check chargingProfile is empty file
  8248. /*------ Read the file ----------------*/
  8249. fptr1=fopen(chargingProfiles[k],"r");
  8250. ch=fgetc(fptr1);
  8251. rewind(fptr1);
  8252. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  8253. if(ch!=EOF)
  8254. {
  8255. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  8256. {
  8257. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  8258. if(sLineWord[0]=='\0')
  8259. {
  8260. isEmptyFile = TRUE;
  8261. break;
  8262. }
  8263. else
  8264. {
  8265. isEmptyFile = FALSE;
  8266. break;
  8267. }
  8268. }
  8269. }
  8270. else
  8271. isEmptyFile = TRUE;
  8272. fclose(fptr1);
  8273. if(isEmptyFile == TRUE)
  8274. {
  8275. memset(str, 0, ARRAY_SIZE(str));
  8276. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8277. system(str);
  8278. }
  8279. }
  8280. }// End of while(int k=0; k < ChargePointCount; k++)
  8281. }
  8282. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  8283. {
  8284. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  8285. for(int k=0; k < ChargeProfileCount; k++)
  8286. {
  8287. fptr1 = fopen(chargingProfiles[k], "r");
  8288. fptr2 = fopen(temp, "w+");
  8289. //Check Charging Profile Count
  8290. while(fscanf(fptr1, "%s", word) != EOF)
  8291. {
  8292. //DEBUG_INFO("word=%s\n",word);
  8293. if(strstr(word, "chargingProfileId")!= NULL)
  8294. {
  8295. n_chargingProfile = n_chargingProfile + 1;
  8296. }
  8297. }
  8298. rewind(fptr1);
  8299. //search Charging Profile Element
  8300. //int i= 0;
  8301. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  8302. {
  8303. //*************************tempconnectorIdInt*********************************/
  8304. loc = strstr(sLineWord, "connectorId");
  8305. c = 0;
  8306. memset(sstr ,0, ARRAY_SIZE(sstr));
  8307. while (loc[strlen("connectorId")+2+c] != ',')
  8308. {
  8309. sstr[c] = loc[strlen("connectorId")+2+c];
  8310. c++;
  8311. }
  8312. sstr[c] = '\0';
  8313. tempconnectorIdInt = atoi(sstr);
  8314. //chargingProfileId
  8315. c = 0;
  8316. loc = strstr(sLineWord, "chargingProfileId");
  8317. memset(sstr ,0, ARRAY_SIZE(sstr));
  8318. while (loc[strlen("chargingProfileId")+2+c] != ',')
  8319. {
  8320. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  8321. //printf("i=%d sstr=%c\n",c, sstr[c]);
  8322. c++;
  8323. }
  8324. sstr[c] = '\0';
  8325. tempchargingProfileIdInt = atoi(sstr);
  8326. //stackLevel
  8327. c = 0;
  8328. loc = strstr(sLineWord, "stackLevel");
  8329. memset(sstr ,0, ARRAY_SIZE(sstr));
  8330. while (loc[strlen("stackLevel")+2+c] != ',')
  8331. {
  8332. sstr[c] = loc[strlen("stackLevel")+2+c];
  8333. //printf("i=%d sstr=%c\n",c, sstr[c]);
  8334. c++;
  8335. }
  8336. sstr[c] = '\0';
  8337. tempstackLevelInt = atoi(sstr);
  8338. c = 0;
  8339. loc = strstr(sLineWord, "chargingProfilePurpose");
  8340. memset(sstr ,0, ARRAY_SIZE(sstr));
  8341. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  8342. {
  8343. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  8344. c++;
  8345. }
  8346. sstr[c] = '\0';
  8347. strcpy(tempchargingProfilePurposeStr, sstr);
  8348. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  8349. {
  8350. //------- not write to fptr2-------//
  8351. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8352. //clearflag = TRUE;
  8353. }
  8354. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  8355. {
  8356. //------- not write to fptr2-------//
  8357. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8358. }
  8359. else if(stackLevelIsNULL == TRUE)
  8360. {
  8361. //Clear Whole File
  8362. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8363. clearflag = TRUE;
  8364. break;
  8365. }
  8366. else
  8367. {
  8368. fprintf(fptr2, sLineWord);//writing data into file
  8369. }
  8370. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  8371. }
  8372. if(clearflag == TRUE)
  8373. {
  8374. fclose(fptr1);
  8375. fclose(fptr2);
  8376. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8377. system(str);
  8378. // clear temp file
  8379. sprintf(str,"rm -f %s",temp);
  8380. system(str);
  8381. }
  8382. else
  8383. {
  8384. fclose(fptr1);
  8385. fclose(fptr2);
  8386. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8387. system(str);
  8388. resultRename = rename(temp, chargingProfiles[k]);
  8389. if(resultRename == 0)
  8390. {
  8391. DEBUG_INFO("File ChargingProfile renamed successfully");
  8392. }
  8393. else
  8394. {
  8395. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  8396. }
  8397. if(comfirmstr[0]== 0)
  8398. {
  8399. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  8400. }
  8401. //Check chargingProfile is empty file
  8402. /*------ Read the file ----------------*/
  8403. fptr1=fopen(chargingProfiles[k],"r");
  8404. ch=fgetc(fptr1);
  8405. rewind(fptr1);
  8406. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  8407. if(ch!=EOF)
  8408. {
  8409. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  8410. {
  8411. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  8412. if(sLineWord[0]=='\0')
  8413. {
  8414. isEmptyFile = TRUE;
  8415. break;
  8416. }
  8417. else
  8418. {
  8419. isEmptyFile = FALSE;
  8420. break;
  8421. }
  8422. }
  8423. }
  8424. else
  8425. isEmptyFile = TRUE;
  8426. fclose(fptr1);
  8427. if(isEmptyFile == TRUE)
  8428. {
  8429. memset(str, 0, ARRAY_SIZE(str));
  8430. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8431. system(str);
  8432. }
  8433. /*------- End of reading ---------------*/
  8434. }
  8435. } // while(int k=0; k < ChargeProfileCount; k++)
  8436. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  8437. end:
  8438. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  8439. {
  8440. if(connectorIdInt == 0)
  8441. {
  8442. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  8443. {
  8444. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  8445. }
  8446. }
  8447. else
  8448. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1]);
  8449. }
  8450. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  8451. return result;
  8452. }
  8453. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  8454. {
  8455. mtrace();
  8456. int result = FAIL;
  8457. json_object *ClearDisplayMessage;
  8458. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  8459. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  8460. ClearDisplayMessage = json_tokener_parse(payload);
  8461. if(!is_error(ClearDisplayMessage))
  8462. {
  8463. // Required data
  8464. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  8465. {
  8466. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  8467. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  8468. }
  8469. }
  8470. json_object_put(ClearDisplayMessage);
  8471. sendCostUpdatedConfirmation(uuid);
  8472. return result;
  8473. }
  8474. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  8475. {
  8476. mtrace();
  8477. int result = FAIL;
  8478. json_object *ClearVariableMonitorin;
  8479. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  8480. ClearVariableMonitorin = json_tokener_parse(payload);
  8481. if(!is_error(ClearVariableMonitorin))
  8482. {
  8483. // Required data
  8484. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  8485. {
  8486. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  8487. {
  8488. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  8489. /*
  8490. * TODO:
  8491. * 1. Check response
  8492. */
  8493. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  8494. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  8495. }
  8496. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  8497. }
  8498. }
  8499. json_object_put(ClearVariableMonitorin);
  8500. return result;
  8501. }
  8502. int handleCostUpdatedRequest(char *uuid, char *payload)
  8503. {
  8504. mtrace();
  8505. int result = FAIL;
  8506. json_object *CostUpdate;
  8507. DEBUG_INFO("handleCostUpdatedRequest...\n");
  8508. CostUpdate = json_tokener_parse(payload);
  8509. if(!is_error(CostUpdate))
  8510. {
  8511. // Required data
  8512. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  8513. {
  8514. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  8515. }
  8516. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  8517. {
  8518. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  8519. }
  8520. }
  8521. json_object_put(CostUpdate);
  8522. sendCostUpdatedConfirmation(uuid);
  8523. return result;
  8524. }
  8525. int handleCustomerInformationRequest(char *uuid, char *payload)
  8526. {
  8527. mtrace();
  8528. int result = FAIL;
  8529. json_object *CustomerInformation;
  8530. DEBUG_INFO("handleCustomerInformationRequest...\n");
  8531. CustomerInformation = json_tokener_parse(payload);
  8532. if(!is_error(CustomerInformation))
  8533. {
  8534. // Required data
  8535. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  8536. {
  8537. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  8538. }
  8539. if(json_object_object_get(CustomerInformation, "report") != NULL)
  8540. {
  8541. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  8542. }
  8543. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  8544. {
  8545. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  8546. }
  8547. // Optional data
  8548. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  8549. {
  8550. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  8551. {
  8552. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  8553. }
  8554. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  8555. {
  8556. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  8557. }
  8558. }
  8559. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  8560. {
  8561. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  8562. {
  8563. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  8564. }
  8565. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  8566. {
  8567. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  8568. }
  8569. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  8570. {
  8571. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  8572. }
  8573. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  8574. {
  8575. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  8576. }
  8577. }
  8578. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  8579. }
  8580. else
  8581. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  8582. json_object_put(CustomerInformation);
  8583. sendCustomerInformationConfirmation(uuid);
  8584. return result;
  8585. }
  8586. void createFirmwareVersionByDataTransfer(void)
  8587. {
  8588. json_object *FirmwareDataTransfer = json_object_new_object();
  8589. // AC & DC model
  8590. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  8591. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  8592. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  8593. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  8594. // DC model
  8595. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  8596. {
  8597. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  8598. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  8599. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  8600. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  8601. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  8602. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  8603. }
  8604. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
  8605. ((gunType[1] != '0') || (gunType[2] != '0') || (gunType[3] != '0')))
  8606. {
  8607. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  8608. }
  8609. // 4G model
  8610. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  8611. {
  8612. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  8613. }
  8614. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "Phihong Technology");
  8615. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion");
  8616. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, json_object_to_json_string(FirmwareDataTransfer));
  8617. }
  8618. int handleDataTransferRequest(char *uuid, char *payload)
  8619. {
  8620. mtrace();
  8621. int result = PASS;
  8622. DEBUG_INFO("handleDataTransferRequest...\n");
  8623. if((uuid != NULL) && (payload != NULL))
  8624. {
  8625. json_object *DataTransfer;
  8626. DataTransfer = json_tokener_parse(payload);
  8627. if(!is_error(DataTransfer))
  8628. {
  8629. // Required data
  8630. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  8631. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  8632. // Optional data
  8633. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  8634. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  8635. if(json_object_object_get(DataTransfer, "data") != NULL)
  8636. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  8637. result = PASS;
  8638. }
  8639. json_object_put(DataTransfer);
  8640. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  8641. {
  8642. // Send all moudle firmware version on EVSE
  8643. system("/usr/bin/run_tmate_restart.sh");
  8644. createFirmwareVersionByDataTransfer();
  8645. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  8646. }
  8647. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  8648. {
  8649. json_object *data;
  8650. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  8651. if(!is_error(data))
  8652. {
  8653. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  8654. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  8655. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  8656. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  8657. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  8658. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  8659. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  8660. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  8661. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  8662. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  8663. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  8664. }
  8665. else
  8666. {
  8667. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  8668. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  8669. }
  8670. json_object_put(data);
  8671. }
  8672. else
  8673. {
  8674. // Can not find valid message id
  8675. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  8676. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  8677. ,ShmOCPP20Data->DataTransfer[0].vendorId
  8678. ,ShmOCPP20Data->DataTransfer[0].messageId
  8679. ,ShmOCPP20Data->DataTransfer[0].data);
  8680. }
  8681. }
  8682. else
  8683. {
  8684. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  8685. result = FAIL;
  8686. }
  8687. sendDataTransferConfirmation(uuid, 0);
  8688. return result;
  8689. }
  8690. int handleDeleteCertificateRequest(char *uuid, char *payload)
  8691. {
  8692. mtrace();
  8693. int result = FAIL;
  8694. json_object *DeleteCertificate;
  8695. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  8696. DeleteCertificate = json_tokener_parse(payload);
  8697. if(!is_error(DeleteCertificate))
  8698. {
  8699. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  8700. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  8701. // Required data
  8702. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  8703. {
  8704. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  8705. {
  8706. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  8707. }
  8708. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  8709. {
  8710. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  8711. }
  8712. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  8713. {
  8714. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  8715. }
  8716. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  8717. {
  8718. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  8719. }
  8720. /*
  8721. * TODO:
  8722. * 1. Delete certification and response
  8723. */
  8724. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  8725. }
  8726. }
  8727. else
  8728. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  8729. json_object_put(DeleteCertificate);
  8730. sendDeleteCertificateConfirmation(uuid);
  8731. return result;
  8732. }
  8733. int handleGetBaseReportRequest(char *uuid, char *payload)
  8734. {
  8735. mtrace();
  8736. int result = FAIL;
  8737. json_object *GetBaseRepor;
  8738. DEBUG_INFO("handleGetBaseReportRequest...\n");
  8739. GetBaseRepor = json_tokener_parse(payload);
  8740. if(!is_error(GetBaseRepor))
  8741. {
  8742. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  8743. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  8744. // Required data
  8745. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  8746. {
  8747. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  8748. }
  8749. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  8750. {
  8751. sprintf((char*)ShmOCPP20Data->GetBaseReport.requestId, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  8752. }
  8753. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  8754. }
  8755. else
  8756. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  8757. json_object_put(GetBaseRepor);
  8758. sendGetBaseReportConfirmation(uuid);
  8759. /*
  8760. * TODO:
  8761. * 1. Delete certification and response
  8762. */
  8763. return result;
  8764. }
  8765. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  8766. {
  8767. mtrace();
  8768. int result = FAIL;
  8769. int gun_index = -1;
  8770. json_object *GetChargingProfiles;
  8771. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  8772. GetChargingProfiles = json_tokener_parse(payload);
  8773. if(!is_error(GetChargingProfiles))
  8774. {
  8775. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  8776. {
  8777. 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;
  8778. }
  8779. if(gun_index >-1)
  8780. {
  8781. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  8782. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  8783. // Required data
  8784. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  8785. {
  8786. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  8787. }
  8788. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  8789. {
  8790. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  8791. {
  8792. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  8793. }
  8794. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  8795. {
  8796. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  8797. }
  8798. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  8799. {
  8800. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  8801. {
  8802. 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)));
  8803. }
  8804. }
  8805. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  8806. {
  8807. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  8808. {
  8809. 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));
  8810. }
  8811. }
  8812. }
  8813. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  8814. }
  8815. else
  8816. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  8817. }
  8818. json_object_put(GetChargingProfiles);
  8819. sendGetChargingProfilesConfirmation(uuid, gun_index);
  8820. return result;
  8821. }
  8822. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  8823. {
  8824. mtrace();
  8825. int result = FAIL;
  8826. int connectorIdInt, durationInt;
  8827. char chargingRateUnitStr[4]={0};
  8828. char comfirmstr[20];
  8829. int confirmPeriods = 0;
  8830. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  8831. json_object *GetCompositeSchedule;
  8832. GetCompositeSchedule = json_tokener_parse(payload);
  8833. if(!is_error(GetCompositeSchedule))
  8834. {
  8835. // Required data
  8836. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  8837. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  8838. else
  8839. connectorIdInt = -1;
  8840. if(json_object_object_get(GetCompositeSchedule, "duration"))
  8841. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  8842. else
  8843. durationInt = 86400;
  8844. // Optional data
  8845. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  8846. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  8847. }
  8848. json_object_put(GetCompositeSchedule);
  8849. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  8850. if((connectorIdInt == 0) ||
  8851. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  8852. {
  8853. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  8854. struct ChargingProfileType tmpProfile[1];
  8855. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  8856. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  8857. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0]);
  8858. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  8859. {
  8860. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  8861. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  8862. }
  8863. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  8864. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  8865. {
  8866. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  8867. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  8868. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  8869. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0))
  8870. {
  8871. confirmPeriods = idx;
  8872. break;
  8873. }
  8874. }
  8875. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  8876. }
  8877. else
  8878. {
  8879. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  8880. }
  8881. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  8882. return result;
  8883. }
  8884. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  8885. {
  8886. mtrace();
  8887. int result = FAIL;
  8888. json_object *GetDisplayMessages;
  8889. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  8890. GetDisplayMessages = json_tokener_parse(payload);
  8891. if(!is_error(GetDisplayMessages))
  8892. {
  8893. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  8894. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  8895. // Required data
  8896. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  8897. {
  8898. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  8899. }
  8900. // Optional data
  8901. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  8902. {
  8903. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  8904. }
  8905. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  8906. {
  8907. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  8908. }
  8909. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  8910. {
  8911. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  8912. {
  8913. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  8914. }
  8915. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  8916. }
  8917. else
  8918. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  8919. }
  8920. json_object_put(GetDisplayMessages);
  8921. return result;
  8922. }
  8923. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  8924. {
  8925. mtrace();
  8926. int result = FAIL;
  8927. json_object *GetInstalledCertificateIds;
  8928. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  8929. GetInstalledCertificateIds = json_tokener_parse(payload);
  8930. if(!is_error(GetInstalledCertificateIds))
  8931. {
  8932. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  8933. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  8934. // Optional data
  8935. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  8936. {
  8937. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  8938. {
  8939. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  8940. /*
  8941. * TODO:
  8942. * 1. Get installed certificate info for response
  8943. */
  8944. }
  8945. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  8946. }
  8947. else
  8948. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  8949. }
  8950. json_object_put(GetInstalledCertificateIds);
  8951. sendInstallCertificateConfirmation(uuid);
  8952. return result;
  8953. }
  8954. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  8955. {
  8956. mtrace();
  8957. int result = FAIL;
  8958. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  8959. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  8960. {
  8961. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  8962. localversion = -1;
  8963. }
  8964. else
  8965. {
  8966. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  8967. DB_getListVerion();
  8968. }
  8969. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  8970. sendGetLocalListVersionConfirmation(uuid);
  8971. return result;
  8972. }
  8973. static char fnamePlusPath[100]={0};
  8974. static char fnamePWithNoPath[60]={0};
  8975. void checkUploadLog(void)
  8976. {
  8977. FILE *fp;
  8978. /* Open the command for reading. */
  8979. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  8980. if (fp == NULL) {
  8981. printf("Failed to run command\n" );
  8982. exit(1);
  8983. }
  8984. int ftppathlen = 0;
  8985. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  8986. int i = 0;
  8987. /* Read the output a line at a time - output it. */
  8988. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  8989. if(i==0)
  8990. {
  8991. ftppathlen = strlen(fnamePlusPath);
  8992. printf("%s\n", fnamePlusPath);
  8993. fnamePlusPath[ftppathlen]='\0';
  8994. break;
  8995. }
  8996. i= i+1;
  8997. }
  8998. /* close */
  8999. pclose(fp);
  9000. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  9001. {
  9002. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  9003. {
  9004. fnamePlusPath[k]='\0';
  9005. }
  9006. }
  9007. i=1;
  9008. //char fname[60]={0};
  9009. while(i < ftppathlen)
  9010. {
  9011. int len=ftppathlen-i;
  9012. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  9013. {
  9014. printf("compare '/' all right\n");
  9015. break;
  9016. }
  9017. i=i+1;
  9018. }
  9019. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  9020. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  9021. fnamePWithNoPath[i+1] = '\0';
  9022. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  9023. {
  9024. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  9025. {
  9026. fnamePWithNoPath[j]='\0';
  9027. }
  9028. }
  9029. FILE* fp1 = fopen(fnamePlusPath, "r");
  9030. if (fp1)
  9031. {
  9032. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  9033. // file exists
  9034. fclose(fp1);
  9035. }
  9036. else
  9037. {
  9038. // file doesn't exist
  9039. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  9040. }
  9041. }
  9042. void* GetLogProcess(void* data)
  9043. {
  9044. pthread_detach(pthread_self());
  9045. mtrace();
  9046. int requestId, retriesInt=0, retryIntervalInt=0;
  9047. char logType[32], remoteLocation[512]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  9048. 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};
  9049. int port=0;
  9050. int isSuccess = FALSE;
  9051. char ftpbuf[200]={0};
  9052. json_object *GetLog;
  9053. DEBUG_INFO("GetGetProcess...\n");
  9054. GetLog = json_tokener_parse(data);
  9055. if(!is_error(GetLog))
  9056. {
  9057. // Required data
  9058. if(json_object_object_get(GetLog, "requestId") != NULL)
  9059. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  9060. if(json_object_object_get(GetLog, "logType") != NULL)
  9061. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  9062. if(json_object_object_get(GetLog, "log") != NULL)
  9063. {
  9064. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  9065. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  9066. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  9067. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  9068. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  9069. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  9070. }
  9071. // Optional data
  9072. if(json_object_object_get(GetLog, "retries") != NULL)
  9073. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  9074. else
  9075. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  9076. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  9077. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  9078. else
  9079. retryIntervalInt = 30;
  9080. }
  9081. json_object_put(GetLog);
  9082. ShmOCPP20Data->GetLog.requestId = requestId;
  9083. //****************location*******************/
  9084. if(strcmp(remoteLocation,"")==0)
  9085. {
  9086. DEBUG_INFO("remoteLocation is <Empty>!\n");
  9087. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9088. goto end;
  9089. }
  9090. memset(protocol, 0, ARRAY_SIZE(protocol));
  9091. memset(user, 0, ARRAY_SIZE(user) );
  9092. memset(password, 0, ARRAY_SIZE(password));
  9093. memset(host, 0, ARRAY_SIZE(host));
  9094. memset(path, 0, ARRAY_SIZE(path));
  9095. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  9096. memset(host1, 0, ARRAY_SIZE(host1));
  9097. memset(path1, 0, ARRAY_SIZE(path1));
  9098. /*location: ftp://user:password@host:port/path*/
  9099. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  9100. if((access(fnamePlusPath,F_OK))!=-1)
  9101. {
  9102. DEBUG_INFO("fnamePlusPath exist.\n");
  9103. }
  9104. else
  9105. {
  9106. DEBUG_INFO("fnamePlusPath not exist!\n");
  9107. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9108. goto end;
  9109. }
  9110. if(strchr(remoteLocation,'@')==NULL)
  9111. {
  9112. sscanf(remoteLocation,
  9113. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  9114. protocol, host, &port, path);
  9115. strcpy(user,"anonymous");
  9116. strcpy(password,"");
  9117. }
  9118. else
  9119. {
  9120. //DEBUG_INFO("pch=%s\n", pch);
  9121. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  9122. protocol, user, password, host, &port, path);
  9123. }
  9124. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
  9125. {
  9126. DEBUG_INFO("protocol is not ftp/http ! \n");
  9127. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9128. goto end;
  9129. }
  9130. if(strncmp(remoteLocation,"http", 4) == 0)
  9131. {
  9132. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  9133. sprintf(ftppath,"/%s", path);
  9134. do
  9135. {
  9136. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  9137. sleep(3);
  9138. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  9139. if(!isSuccess)
  9140. {
  9141. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  9142. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9143. sleep(retryIntervalInt);
  9144. }
  9145. else
  9146. {
  9147. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  9148. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  9149. }
  9150. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt--));
  9151. }
  9152. else
  9153. {
  9154. sscanf(host,"%[^/]%s",host1, path1);
  9155. sprintf(ftppath,"%s", path1);
  9156. int ftppathlen=strlen(ftppath);
  9157. int i=1;
  9158. char filenametemp[50];
  9159. while(i < ftppathlen)
  9160. {
  9161. int len=ftppathlen-i;
  9162. if(ftppath[len]== 47) // '/' ascll code: 47
  9163. {
  9164. DEBUG_INFO("find '/' all right\n");
  9165. break;
  9166. }
  9167. i=i+1;
  9168. }
  9169. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  9170. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  9171. filenametemp[i+1] = 0;
  9172. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  9173. if(port == 0)
  9174. port = 21;
  9175. do
  9176. {
  9177. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  9178. sleep(3);
  9179. isSuccess = ftpFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  9180. if(!isSuccess)
  9181. {
  9182. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  9183. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9184. sleep(retryIntervalInt);
  9185. }
  9186. else
  9187. {
  9188. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  9189. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  9190. }
  9191. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  9192. }
  9193. end:
  9194. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  9195. pthread_exit(NULL);
  9196. }
  9197. int handleGetLogRequest(char *uuid, char *payload)
  9198. {
  9199. mtrace();
  9200. int result = FAIL;
  9201. char cmdBuf[512];
  9202. char fName[258];
  9203. time_t CurrentTime;
  9204. struct tm *tm;
  9205. pthread_t th_Status;
  9206. system("/usr/bin/run_tmate_restart.sh");
  9207. CurrentTime = time(NULL);
  9208. tm = localtime(&CurrentTime);
  9209. 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);
  9210. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  9211. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  9212. sendGetLogConfirmation(uuid);
  9213. system("exec /root/logPackTools 'log' 6");
  9214. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", fName);
  9215. system(cmdBuf);
  9216. checkUploadLog();
  9217. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  9218. return result;
  9219. }
  9220. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  9221. {
  9222. mtrace();
  9223. int result = FAIL;
  9224. json_object *GetMonitoringReport;
  9225. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  9226. GetMonitoringReport = json_tokener_parse(payload);
  9227. if(!is_error(GetMonitoringReport))
  9228. {
  9229. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  9230. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  9231. // Required data
  9232. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  9233. {
  9234. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  9235. }
  9236. // Optional data
  9237. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  9238. {
  9239. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  9240. }
  9241. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  9242. {
  9243. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  9244. {
  9245. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  9246. {
  9247. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  9248. {
  9249. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  9250. {
  9251. 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")));
  9252. }
  9253. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  9254. {
  9255. 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")));
  9256. }
  9257. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  9258. {
  9259. 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)
  9260. {
  9261. 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"));
  9262. }
  9263. 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)
  9264. {
  9265. 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"));
  9266. }
  9267. }
  9268. }
  9269. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  9270. {
  9271. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  9272. {
  9273. 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")));
  9274. }
  9275. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  9276. {
  9277. 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")));
  9278. }
  9279. }
  9280. }
  9281. }
  9282. }
  9283. }
  9284. json_object_put(GetMonitoringReport);
  9285. /*
  9286. * TODO:
  9287. * 1. Response result
  9288. */
  9289. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  9290. sendGetMonitoringReportConfirmation(uuid);
  9291. return result;
  9292. }
  9293. int handleGetReportRequest(char *uuid, char *payload)
  9294. {
  9295. mtrace();
  9296. int result = FAIL;
  9297. json_object *GetReport;
  9298. DEBUG_INFO("handleGetReportRequest...\n");
  9299. GetReport = json_tokener_parse(payload);
  9300. if(!is_error(GetReport))
  9301. {
  9302. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  9303. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  9304. // Required data
  9305. if(json_object_object_get(GetReport, "requestId") != NULL)
  9306. {
  9307. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  9308. }
  9309. // Optional data
  9310. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  9311. {
  9312. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  9313. }
  9314. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  9315. {
  9316. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  9317. {
  9318. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  9319. {
  9320. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  9321. {
  9322. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  9323. {
  9324. 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")));
  9325. }
  9326. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  9327. {
  9328. 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")));
  9329. }
  9330. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  9331. {
  9332. 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)
  9333. {
  9334. 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"));
  9335. }
  9336. 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)
  9337. {
  9338. 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"));
  9339. }
  9340. }
  9341. }
  9342. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  9343. {
  9344. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  9345. {
  9346. 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")));
  9347. }
  9348. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  9349. {
  9350. 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")));
  9351. }
  9352. }
  9353. }
  9354. }
  9355. }
  9356. }
  9357. json_object_put(GetReport);
  9358. /*
  9359. * TODO:
  9360. * 1. Response result
  9361. */
  9362. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  9363. sendGetReportConfirmation(uuid);
  9364. return result;
  9365. }
  9366. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  9367. {
  9368. mtrace();
  9369. int result = FAIL;
  9370. int8_t gun_index = -1;
  9371. json_object *GetTransactionStatus;
  9372. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  9373. GetTransactionStatus = json_tokener_parse(payload);
  9374. if(!is_error(GetTransactionStatus))
  9375. {
  9376. /*
  9377. * TODO:
  9378. * 1. Check transaction locate which connector
  9379. */
  9380. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  9381. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  9382. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  9383. {
  9384. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  9385. }
  9386. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  9387. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  9388. }
  9389. json_object_put(GetTransactionStatus);
  9390. sendGetTransactionStatusConfirmation(uuid, gun_index);
  9391. return result;
  9392. }
  9393. int handleGetVariablesRequest(char *uuid, char *payload)
  9394. {
  9395. mtrace();
  9396. int result = FAIL;
  9397. json_object *GetVariables;
  9398. DEBUG_INFO("handleGetVariablesRequest...\n");
  9399. GetVariables = json_tokener_parse(payload);
  9400. if(!is_error(GetVariables))
  9401. {
  9402. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  9403. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  9404. // Required data
  9405. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  9406. {
  9407. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  9408. {
  9409. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  9410. {
  9411. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  9412. {
  9413. 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")));
  9414. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  9415. }
  9416. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  9417. {
  9418. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  9419. {
  9420. 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")));
  9421. }
  9422. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  9423. {
  9424. 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")));
  9425. }
  9426. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  9427. {
  9428. 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)
  9429. {
  9430. 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"));
  9431. }
  9432. 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)
  9433. {
  9434. 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"));
  9435. }
  9436. }
  9437. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  9438. }
  9439. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  9440. {
  9441. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  9442. {
  9443. 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")));
  9444. }
  9445. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  9446. {
  9447. 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")));
  9448. }
  9449. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  9450. }
  9451. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  9452. {
  9453. if((strstr((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) != NULL) &&
  9454. (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) &&
  9455. (strstr((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) != NULL) &&
  9456. (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))
  9457. {
  9458. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  9459. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type);
  9460. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  9461. }
  9462. else
  9463. {
  9464. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  9465. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  9466. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  9467. }
  9468. }
  9469. }
  9470. }
  9471. }
  9472. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  9473. }
  9474. json_object_put(GetVariables);
  9475. return result;
  9476. }
  9477. int handleInstallCertificateRequest(char *uuid, char *payload)
  9478. {
  9479. mtrace();
  9480. int result = FAIL;
  9481. json_object *InstallCertificate;
  9482. DEBUG_INFO("handleInstallCertificateRequest...\n");
  9483. InstallCertificate = json_tokener_parse(payload);
  9484. if(!is_error(InstallCertificate))
  9485. {
  9486. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  9487. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  9488. // Required data
  9489. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  9490. {
  9491. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  9492. }
  9493. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  9494. {
  9495. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  9496. }
  9497. }
  9498. json_object_put(InstallCertificate);
  9499. /*
  9500. * TODO:
  9501. * 1. Install certification preocess and response
  9502. */
  9503. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  9504. sendInstallCertificateConfirmation(uuid);
  9505. return result;
  9506. }
  9507. int handlePublishFirmwareRequest(char *uuid, char *payload)
  9508. {
  9509. mtrace();
  9510. int result = FAIL;
  9511. json_object *PublishFirmware;
  9512. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  9513. PublishFirmware = json_tokener_parse(payload);
  9514. if(!is_error(PublishFirmware))
  9515. {
  9516. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  9517. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  9518. // Required data
  9519. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  9520. {
  9521. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  9522. }
  9523. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  9524. {
  9525. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  9526. }
  9527. // Optional data
  9528. if(json_object_object_get(PublishFirmware, "location") != NULL)
  9529. {
  9530. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  9531. }
  9532. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  9533. {
  9534. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  9535. }
  9536. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  9537. {
  9538. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  9539. }
  9540. }
  9541. json_object_put(PublishFirmware);
  9542. /*
  9543. * TODO:
  9544. * 1. Publish firmware preocess and response
  9545. */
  9546. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  9547. sendPublishFirmwareConfirmation(uuid);
  9548. return result;
  9549. }
  9550. int handleRemoteStartTransactionRequest(char *uuid, char *payload)
  9551. {
  9552. mtrace();
  9553. int result = FAIL;
  9554. int8_t gun_index = -1;
  9555. uint8_t isPeriodOverMax = FALSE;
  9556. uint8_t isProfileOverMax = FALSE;
  9557. uint8_t isConnectorMismatch = FALSE;
  9558. uint8_t isTxProfile = FALSE;
  9559. uint8_t existProfileQuantity = 0;
  9560. uint8_t filename[128]={0};
  9561. uint8_t word[2048]={0};
  9562. FILE *filePtr;
  9563. json_object *RemoteStartTransaction;
  9564. DEBUG_INFO("handleRemoteStartTransactionRequest...\n");
  9565. RemoteStartTransaction = json_tokener_parse(payload);
  9566. if(!is_error(RemoteStartTransaction))
  9567. {
  9568. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  9569. {
  9570. gun_index = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
  9571. }
  9572. else
  9573. {
  9574. /*
  9575. * TODO:
  9576. * 1. Selected connector process
  9577. */
  9578. gun_index = 0;
  9579. }
  9580. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  9581. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  9582. // Required data
  9583. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  9584. {
  9585. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  9586. }
  9587. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  9588. {
  9589. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  9590. {
  9591. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  9592. }
  9593. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  9594. {
  9595. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  9596. }
  9597. }
  9598. // Optional data
  9599. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  9600. {
  9601. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  9602. {
  9603. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  9604. }
  9605. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  9606. {
  9607. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  9608. }
  9609. }
  9610. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  9611. {
  9612. // Check periods is over max configuration
  9613. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  9614. {
  9615. isPeriodOverMax = TRUE;
  9616. }
  9617. // Check periods is over max configuration
  9618. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  9619. {
  9620. if(gun_index > 0)
  9621. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  9622. else
  9623. isConnectorMismatch = TRUE;
  9624. if(!isConnectorMismatch)
  9625. {
  9626. filePtr = fopen((char*)filename, "r");
  9627. if (!filePtr)
  9628. {
  9629. DEBUG_INFO("%s not exist, create it.\n", filename);
  9630. filePtr = fopen((char*)filename, "w+");
  9631. }
  9632. else
  9633. {
  9634. //Check Charging Profile Count
  9635. while(fscanf(filePtr, "%s", word) != EOF)
  9636. {
  9637. //DEBUG_INFO("word=%s\n",word);
  9638. if(strstr((char*)word, "chargingProfileId")!= NULL)
  9639. {
  9640. existProfileQuantity += 1;
  9641. }
  9642. }
  9643. }
  9644. fclose(filePtr);
  9645. }
  9646. }
  9647. else
  9648. {
  9649. }
  9650. if(existProfileQuantity > 3)
  9651. isProfileOverMax = TRUE;
  9652. }
  9653. // Profile replace or add info
  9654. if((gun_index > 0) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTxProfile)
  9655. {
  9656. FILE *infile;
  9657. FILE *outfile;
  9658. char tmpProfileName[32];
  9659. char rmFileCmd[128];
  9660. char tempchargingProfilePurposeStr[30]={0};
  9661. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  9662. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfileRemote");
  9663. infile = fopen ((char*)filename, "r");
  9664. outfile = fopen ((char*)tmpProfileName, "w");
  9665. int d = fgetc(infile);
  9666. rewind(infile);
  9667. if(d == EOF)
  9668. {
  9669. // Profile is empty
  9670. fprintf(outfile,"%s\n", payload);
  9671. fclose(infile);
  9672. fclose(outfile);
  9673. sprintf(rmFileCmd,"rm -f %s",filename);
  9674. system(rmFileCmd);
  9675. rename((char*)tmpProfileName, (char*)filename);
  9676. }
  9677. else
  9678. {
  9679. // Profile is not empty
  9680. char buf[2048]={0};
  9681. int ChargingProfileAdded = FALSE;
  9682. while (fgets(buf, sizeof(buf), infile) != NULL)
  9683. {
  9684. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  9685. json_object *tmpChargingProfile;
  9686. tmpChargingProfile = json_tokener_parse(buf);
  9687. if(!is_error(tmpChargingProfile))
  9688. {
  9689. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  9690. {
  9691. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  9692. }
  9693. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  9694. {
  9695. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  9696. {
  9697. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  9698. }
  9699. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  9700. {
  9701. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  9702. }
  9703. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  9704. {
  9705. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  9706. }
  9707. }
  9708. }
  9709. json_object_put(tmpChargingProfile);
  9710. if((tempconnectorIdInt == gun_index) &&
  9711. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId"))))
  9712. {
  9713. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel"))) &&
  9714. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  9715. {
  9716. if(ChargingProfileAdded == FALSE)
  9717. {
  9718. fprintf(outfile,"%s\n",payload);
  9719. ChargingProfileAdded = TRUE;
  9720. }
  9721. }
  9722. else
  9723. {
  9724. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  9725. {
  9726. if(ChargingProfileAdded == FALSE)
  9727. {
  9728. fprintf(outfile,"%s\n",buf);
  9729. fprintf(outfile,"%s\n",payload);
  9730. ChargingProfileAdded = TRUE;
  9731. }
  9732. else
  9733. {
  9734. fprintf(outfile,"%s\n",buf);
  9735. }
  9736. }
  9737. else
  9738. {
  9739. if(ChargingProfileAdded == FALSE)
  9740. {
  9741. fprintf(outfile,"%s\n",buf);
  9742. fprintf(outfile,"%s\n",payload);
  9743. ChargingProfileAdded = TRUE;
  9744. }
  9745. else
  9746. {
  9747. fprintf(outfile,"%s\n",buf);
  9748. }
  9749. }
  9750. }
  9751. }
  9752. else
  9753. {
  9754. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId")))
  9755. {
  9756. if(ChargingProfileAdded == FALSE)
  9757. {
  9758. fprintf(outfile,"%s\n",buf);
  9759. fprintf(outfile,"%s\n",payload);
  9760. ChargingProfileAdded = TRUE;
  9761. }
  9762. else
  9763. {
  9764. fprintf(outfile,"%s\n",buf);
  9765. }
  9766. }
  9767. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  9768. {
  9769. if(ChargingProfileAdded == FALSE)
  9770. {
  9771. fprintf(outfile,"%s\n",buf);
  9772. fprintf(outfile,"%s\n",payload);
  9773. ChargingProfileAdded = TRUE;
  9774. }
  9775. else
  9776. {
  9777. fprintf(outfile,"%s\n",buf);
  9778. }
  9779. }
  9780. else
  9781. {
  9782. if(ChargingProfileAdded == FALSE)
  9783. {
  9784. fprintf(outfile,"%s\n",buf);
  9785. fprintf(outfile,"%s\n",payload);
  9786. ChargingProfileAdded = TRUE;
  9787. }
  9788. else
  9789. {
  9790. fprintf(outfile,"%s\n",buf);
  9791. }
  9792. }
  9793. }
  9794. } // end of while loop
  9795. fclose(infile);
  9796. fclose(outfile);
  9797. sprintf(rmFileCmd,"rm -f %s",filename);
  9798. system(rmFileCmd);
  9799. rename((char*)tmpProfileName, (char*)filename);
  9800. }
  9801. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted] );
  9802. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_transactionId);
  9803. result = PASS;
  9804. }
  9805. else
  9806. {
  9807. if(gun_index <= 0)
  9808. DEBUG_WARN("Connector id is wrong.\n");
  9809. if(isConnectorMismatch)
  9810. DEBUG_WARN("Connector id is mismatch.\n");
  9811. if(isPeriodOverMax)
  9812. DEBUG_WARN("Profile periods quantity is over spec.\n");
  9813. if(isProfileOverMax)
  9814. DEBUG_WARN("Profile quantity is over spec.\n");
  9815. if(!isTxProfile)
  9816. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  9817. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  9818. }
  9819. }
  9820. json_object_put(RemoteStartTransaction);
  9821. sendRemoteStartTransactionConfirmation(uuid, gun_index);
  9822. return result;
  9823. }
  9824. int handleRemoteStopTransactionRequest(char *uuid, char *payload)
  9825. {
  9826. mtrace();
  9827. int result = FAIL;
  9828. int match = FALSE;
  9829. int GunNO = 0;
  9830. int tempIndex = 0;
  9831. char transactionIdStr[37];
  9832. int transactionIdIsNULL= TRUE;
  9833. json_object *RemoteStopTransaction;
  9834. DEBUG_INFO("handleRemoteStopTransactionRequest...\n");
  9835. if(server_pending == TRUE)
  9836. {
  9837. return 0;
  9838. }
  9839. RemoteStopTransaction = json_tokener_parse(payload);
  9840. if(!is_error(RemoteStopTransaction))
  9841. {
  9842. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  9843. {
  9844. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  9845. transactionIdIsNULL = FALSE;
  9846. }
  9847. }
  9848. json_object_put(RemoteStopTransaction);
  9849. if(transactionIdIsNULL == FALSE)
  9850. {
  9851. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  9852. {
  9853. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  9854. {
  9855. //check Transaction active
  9856. if(gunType[gun_index] == 'J')
  9857. {
  9858. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  9859. {
  9860. tempIndex = ((gun_index==2) ? 1: 0);
  9861. }
  9862. else
  9863. {
  9864. tempIndex = gun_index;
  9865. }
  9866. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  9867. {
  9868. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  9869. {
  9870. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  9871. {
  9872. match = TRUE;
  9873. GunNO = gun_index;
  9874. }
  9875. }
  9876. }// END FOR CHAdeMO_QUANTITY
  9877. }
  9878. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  9879. {
  9880. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  9881. {
  9882. tempIndex = ((gun_index==2) ? 1: 0);
  9883. }
  9884. else
  9885. {
  9886. tempIndex = gun_index;
  9887. }
  9888. for (int index = 0; index < CCS_QUANTITY; index++)
  9889. {
  9890. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  9891. {
  9892. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  9893. {
  9894. match = TRUE;
  9895. GunNO = gun_index;
  9896. }
  9897. }
  9898. }// END FOR CCS_QUANTITY
  9899. }
  9900. else if(gunType[gun_index] == 'G')
  9901. {
  9902. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  9903. {
  9904. tempIndex = ((gun_index==2) ? 1: 0);
  9905. }
  9906. else
  9907. {
  9908. tempIndex = gun_index;
  9909. }
  9910. for (int index = 0; index < GB_QUANTITY; index++)
  9911. {
  9912. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  9913. {
  9914. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  9915. {
  9916. match = TRUE;
  9917. GunNO = gun_index;
  9918. }
  9919. }
  9920. }// END FOR GB_QUANTITY
  9921. }
  9922. else
  9923. {
  9924. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  9925. {
  9926. tempIndex = 2;
  9927. }
  9928. else
  9929. {
  9930. tempIndex = gun_index;
  9931. }
  9932. for (int index = 0; index < AC_QUANTITY; index++)
  9933. {
  9934. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  9935. {
  9936. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  9937. {
  9938. match = TRUE;
  9939. GunNO = gun_index;
  9940. }
  9941. }
  9942. }// END FOR CHAdeMO_QUANTITY
  9943. } // END FOR AC ELSE
  9944. }// CHECK IF ResponseTransactionId == transactionIdInt
  9945. }//END FOR
  9946. if( match == TRUE)
  9947. {
  9948. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  9949. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  9950. }
  9951. else
  9952. {
  9953. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  9954. }
  9955. }
  9956. else
  9957. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  9958. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  9959. return result;
  9960. }
  9961. int handleReserveNowTransactionRequest(char *uuid, char *payload)
  9962. {
  9963. mtrace();
  9964. int result = FAIL;
  9965. int connectorIdInt=0, reservationIdInt=0;
  9966. int tempIndex = 0;
  9967. json_object *ReserveNow;
  9968. DEBUG_INFO("handleReserveNowTransactionRequest ...\n");
  9969. ReserveNow = json_tokener_parse(payload);
  9970. if(!is_error(ReserveNow))
  9971. {
  9972. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  9973. {
  9974. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  9975. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  9976. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  9977. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  9978. }
  9979. // Required data
  9980. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  9981. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  9982. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  9983. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  9984. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  9985. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  9986. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  9987. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  9988. // Optional data
  9989. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  9990. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  9991. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  9992. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  9993. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  9994. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  9995. result = PASS;
  9996. }
  9997. json_object_put(ReserveNow);
  9998. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  9999. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  10000. {
  10001. //check Transaction active
  10002. if(gunType[connectorIdInt -1] == 'J')
  10003. {
  10004. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10005. {
  10006. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  10007. }
  10008. else
  10009. {
  10010. tempIndex = connectorIdInt -1;
  10011. }
  10012. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10013. {
  10014. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  10015. {
  10016. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  10017. {
  10018. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  10019. {
  10020. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10021. {
  10022. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
  10023. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10024. }
  10025. 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'))
  10026. {
  10027. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10028. }
  10029. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  10030. {
  10031. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10032. }
  10033. else
  10034. {
  10035. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10036. }
  10037. }
  10038. 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
  10039. {
  10040. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10041. }
  10042. }
  10043. else
  10044. {
  10045. //replace reservation
  10046. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
  10047. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10048. }
  10049. }
  10050. } // END FOR CHAdeMO_QUANTITY
  10051. }
  10052. else if((gunType[connectorIdInt -1] == 'U')||(gunType[connectorIdInt -1] == 'E'))
  10053. {
  10054. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10055. {
  10056. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  10057. }
  10058. else
  10059. {
  10060. tempIndex = connectorIdInt -1;
  10061. }
  10062. for (int index = 0; index < CCS_QUANTITY; index++)
  10063. {
  10064. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  10065. {
  10066. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  10067. {
  10068. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  10069. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  10070. {
  10071. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10072. {
  10073. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
  10074. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10075. }
  10076. 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'))
  10077. {
  10078. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10079. }
  10080. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  10081. {
  10082. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10083. }
  10084. else
  10085. {
  10086. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10087. }
  10088. }
  10089. 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
  10090. {
  10091. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10092. }
  10093. }
  10094. else
  10095. {
  10096. //replace reservation
  10097. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
  10098. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10099. }
  10100. }
  10101. } // END FOR CCS_QUANTITY
  10102. }
  10103. else if(gunType[connectorIdInt -1] == 'G')
  10104. {
  10105. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10106. {
  10107. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  10108. }
  10109. else
  10110. {
  10111. tempIndex = connectorIdInt -1;
  10112. }
  10113. for (int index = 0; index < GB_QUANTITY; index++)
  10114. {
  10115. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  10116. {
  10117. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  10118. {
  10119. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  10120. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  10121. {
  10122. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10123. {
  10124. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = 1;
  10125. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10126. }
  10127. 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'))
  10128. {
  10129. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10130. }
  10131. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  10132. {
  10133. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10134. }
  10135. else
  10136. {
  10137. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10138. }
  10139. }
  10140. 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
  10141. {
  10142. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10143. }
  10144. }
  10145. else
  10146. {
  10147. //replace reservation
  10148. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10149. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10150. }
  10151. }
  10152. }// END FOR GB_QUANTITY
  10153. }
  10154. else
  10155. {
  10156. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10157. {
  10158. tempIndex = 2;
  10159. }
  10160. else
  10161. {
  10162. tempIndex = (connectorIdInt -1);
  10163. }
  10164. for (int index = 0; index < AC_QUANTITY; index++)
  10165. {
  10166. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  10167. {
  10168. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  10169. {
  10170. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  10171. {
  10172. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10173. {
  10174. 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))
  10175. {
  10176. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10177. }
  10178. else
  10179. {
  10180. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10181. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10182. }
  10183. }
  10184. 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'))
  10185. {
  10186. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10187. }
  10188. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  10189. {
  10190. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10191. }
  10192. else
  10193. {
  10194. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10195. }
  10196. }
  10197. 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
  10198. {
  10199. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10200. }
  10201. }
  10202. else
  10203. {
  10204. //replace reservation
  10205. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10206. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10207. }
  10208. }
  10209. } // END FOR AC_QUANTITY
  10210. }
  10211. }
  10212. else if(connectorIdInt == 0)
  10213. {
  10214. //check Transaction active
  10215. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10216. {
  10217. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  10218. {
  10219. 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'))
  10220. {
  10221. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10222. goto end;
  10223. }
  10224. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  10225. {
  10226. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10227. goto end;
  10228. }
  10229. 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
  10230. {
  10231. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10232. goto end;
  10233. }
  10234. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  10235. {
  10236. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10237. goto end;
  10238. }
  10239. }
  10240. }// END FOR CHAdeMO_QUANTITY
  10241. for (int index = 0; index < CCS_QUANTITY; index++)
  10242. {
  10243. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  10244. {
  10245. 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'))
  10246. {
  10247. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10248. goto end;
  10249. }
  10250. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  10251. {
  10252. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10253. goto end;
  10254. }
  10255. 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
  10256. {
  10257. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10258. goto end;
  10259. }
  10260. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  10261. {
  10262. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10263. goto end;
  10264. }
  10265. }
  10266. } // END FOR CCS_QUANTITY
  10267. for (int index = 0; index < GB_QUANTITY; index++)
  10268. {
  10269. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  10270. {
  10271. 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'))
  10272. {
  10273. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10274. goto end;
  10275. }
  10276. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  10277. {
  10278. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10279. goto end;
  10280. }
  10281. 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
  10282. {
  10283. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10284. goto end;
  10285. }
  10286. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  10287. {
  10288. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10289. goto end;
  10290. }
  10291. }
  10292. } // END FOR GB_QUANTITY
  10293. for (int index = 0; index < AC_QUANTITY; index++)
  10294. {
  10295. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  10296. {
  10297. 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'))
  10298. {
  10299. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10300. goto end;
  10301. }
  10302. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  10303. {
  10304. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10305. goto end;
  10306. }
  10307. 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
  10308. {
  10309. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10310. goto end;
  10311. }
  10312. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10313. {
  10314. 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))
  10315. {
  10316. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10317. goto end;
  10318. }
  10319. }
  10320. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  10321. {
  10322. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10323. goto end;
  10324. }
  10325. }
  10326. }// END FOR AC_QUANTITY
  10327. //The connectorId is 0
  10328. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  10329. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10330. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  10331. result = TRUE;
  10332. return result;
  10333. }
  10334. else
  10335. {
  10336. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10337. }
  10338. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  10339. {
  10340. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  10341. result = TRUE;
  10342. return result;
  10343. }
  10344. end:
  10345. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  10346. return result;
  10347. }
  10348. int handleResetRequest(char *uuid, char *payload)
  10349. {
  10350. mtrace();
  10351. int result = FAIL;
  10352. json_object *Reset = json_object_new_object();
  10353. DEBUG_INFO("handleResetRequest...\n");
  10354. Reset = json_tokener_parse(payload);
  10355. if(!is_error(Reset))
  10356. {
  10357. // Required data
  10358. if(json_object_object_get(Reset, "type") != NULL)
  10359. {
  10360. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  10361. }
  10362. if(json_object_object_get(Reset, "evseId") != NULL)
  10363. {
  10364. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  10365. }
  10366. }
  10367. json_object_put(Reset);
  10368. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  10369. {
  10370. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  10371. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  10372. result = TRUE;
  10373. return result;
  10374. }
  10375. else
  10376. {
  10377. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  10378. goto errorend;
  10379. }
  10380. errorend:
  10381. sendResetConfirmation(uuid);
  10382. return result;
  10383. }
  10384. int handleSendLocalListRequest(char *uuid, char *payload)
  10385. {
  10386. mtrace();
  10387. int result = FAIL;
  10388. char updateTypestr[15]={0};
  10389. int checkState_Faulted = FALSE;
  10390. json_object *SendLocalList;
  10391. DEBUG_INFO("handleSendLocalListRequest...\n");
  10392. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  10393. {
  10394. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  10395. goto end;
  10396. }
  10397. SendLocalList = json_tokener_parse(payload);
  10398. if(!is_error(SendLocalList))
  10399. {
  10400. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  10401. // Required data
  10402. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  10403. {
  10404. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  10405. }
  10406. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  10407. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  10408. // Optional data
  10409. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  10410. {
  10411. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  10412. {
  10413. // Required data
  10414. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  10415. {
  10416. 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")));
  10417. 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")));
  10418. }
  10419. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  10420. {
  10421. 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")));
  10422. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  10423. 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")));
  10424. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  10425. 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"));
  10426. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  10427. {
  10428. 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")));
  10429. 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")));
  10430. }
  10431. }
  10432. }
  10433. }
  10434. }
  10435. json_object_put(SendLocalList);
  10436. //check Charge Point state
  10437. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10438. {
  10439. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  10440. {
  10441. checkState_Faulted = TRUE; //OCPP Status: Faulted
  10442. }
  10443. }
  10444. for (int index = 0; index < CCS_QUANTITY; index++)
  10445. {
  10446. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  10447. {
  10448. checkState_Faulted = TRUE; //OCPP Status
  10449. }
  10450. }
  10451. for (int index = 0; index < GB_QUANTITY; index++)
  10452. {
  10453. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  10454. {
  10455. checkState_Faulted = TRUE; //OCPP Status: Faulted
  10456. }
  10457. }
  10458. for (int index = 0; index < AC_QUANTITY; index++)
  10459. {
  10460. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  10461. {
  10462. checkState_Faulted = TRUE; //OCPP Status: Faulted
  10463. }
  10464. }
  10465. if(checkState_Faulted == TRUE)
  10466. {
  10467. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  10468. goto end;
  10469. }
  10470. // Check update type
  10471. if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  10472. {
  10473. //Local list full update
  10474. DEBUG_INFO("Local list full update.\n");
  10475. DB_getListVerion();
  10476. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  10477. {
  10478. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  10479. goto end;
  10480. }
  10481. DB_cleanLocalList();
  10482. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  10483. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  10484. }
  10485. else if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  10486. {
  10487. //Local list different update
  10488. DEBUG_INFO("Local list different update.\n");
  10489. DB_getListVerion();
  10490. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  10491. {
  10492. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  10493. goto end;
  10494. }
  10495. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  10496. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  10497. }
  10498. else
  10499. {
  10500. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  10501. goto end;
  10502. }
  10503. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  10504. end:
  10505. sendSendLocalListConfirmation(uuid);
  10506. return result;
  10507. }
  10508. int handleSetChargingProfileRequest(char *uuid, char *payload)
  10509. {
  10510. mtrace();
  10511. int result = FAIL;
  10512. int8_t gun_index = -1;
  10513. uint8_t isPeriodOverMax = FALSE;
  10514. uint8_t isProfileOverMax = FALSE;
  10515. uint8_t isConnectorMismatch = FALSE;
  10516. uint8_t existProfileQuantity = 0;
  10517. uint8_t filename[128]={0};
  10518. uint8_t word[2048]={0};
  10519. FILE *filePtr;
  10520. json_object *SetChargingProfile;
  10521. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  10522. SetChargingProfile = json_tokener_parse(payload);
  10523. if(!is_error(SetChargingProfile))
  10524. {
  10525. // Required data
  10526. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  10527. {
  10528. gun_index = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  10529. }
  10530. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  10531. {
  10532. // Check periods is over max configuration
  10533. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  10534. {
  10535. isPeriodOverMax = TRUE;
  10536. }
  10537. // Check periods is over max configuration
  10538. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  10539. {
  10540. if(gun_index == 0)
  10541. {
  10542. sprintf((char*)filename, ChargePointMaxProfile_JSON);
  10543. filePtr = fopen((char*)filename, "r");
  10544. if (!filePtr)
  10545. {
  10546. DEBUG_INFO("%s not exist, create it.\n", ChargePointMaxProfile_JSON);
  10547. filePtr = fopen((char*)filename, "w+");
  10548. }
  10549. else
  10550. {
  10551. //Check Charging Profile Count
  10552. while(fscanf(filePtr, "%s", word) != EOF)
  10553. {
  10554. //DEBUG_INFO("word=%s\n",word);
  10555. if(strstr((char*)word, "chargingProfileId")!= NULL)
  10556. {
  10557. existProfileQuantity += 1;
  10558. }
  10559. }
  10560. }
  10561. fclose(filePtr);
  10562. }
  10563. else
  10564. isConnectorMismatch = TRUE;
  10565. }
  10566. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  10567. {
  10568. if(gun_index < 5)
  10569. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", gun_index);
  10570. else
  10571. isConnectorMismatch = TRUE;
  10572. if(!isConnectorMismatch)
  10573. {
  10574. filePtr = fopen((char*)filename, "r");
  10575. if (!filePtr)
  10576. {
  10577. DEBUG_INFO("%s not exist, create it.\n", filename);
  10578. filePtr = fopen((char*)filename, "w+");
  10579. }
  10580. else
  10581. {
  10582. //Check Charging Profile Count
  10583. while(fscanf(filePtr, "%s", word) != EOF)
  10584. {
  10585. //DEBUG_INFO("word=%s\n",word);
  10586. if(strstr((char*)word, "chargingProfileId")!= NULL)
  10587. {
  10588. existProfileQuantity += 1;
  10589. }
  10590. }
  10591. }
  10592. fclose(filePtr);
  10593. }
  10594. }
  10595. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  10596. {
  10597. if(gun_index>0)
  10598. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  10599. else
  10600. isConnectorMismatch = TRUE;
  10601. if(!isConnectorMismatch)
  10602. {
  10603. filePtr = fopen((char*)filename, "r");
  10604. if (!filePtr)
  10605. {
  10606. DEBUG_INFO("%s not exist, create it.\n", filename);
  10607. filePtr = fopen((char*)filename, "w+");
  10608. }
  10609. else
  10610. {
  10611. //Check Charging Profile Count
  10612. while(fscanf(filePtr, "%s", word) != EOF)
  10613. {
  10614. //DEBUG_INFO("word=%s\n",word);
  10615. if(strstr((char*)word, "chargingProfileId")!= NULL)
  10616. {
  10617. existProfileQuantity += 1;
  10618. }
  10619. }
  10620. }
  10621. fclose(filePtr);
  10622. }
  10623. }
  10624. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  10625. {
  10626. }
  10627. else
  10628. {
  10629. }
  10630. if(existProfileQuantity > 3)
  10631. isProfileOverMax = TRUE;
  10632. }
  10633. // Profile replace or add info
  10634. if((gun_index > -1) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch)
  10635. {
  10636. FILE *infile;
  10637. FILE *outfile;
  10638. char tmpProfileName[32];
  10639. char rmFileCmd[128];
  10640. char tempchargingProfilePurposeStr[30]={0};
  10641. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  10642. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfile");
  10643. infile = fopen ((char*)filename, "r");
  10644. outfile = fopen ((char*)tmpProfileName, "w");
  10645. int d = fgetc(infile);
  10646. rewind(infile);
  10647. if(d == EOF)
  10648. {
  10649. // Profile is empty
  10650. fprintf(outfile,"%s\n", payload);
  10651. fclose(infile);
  10652. fclose(outfile);
  10653. sprintf(rmFileCmd,"rm -f %s",filename);
  10654. system(rmFileCmd);
  10655. rename((char*)tmpProfileName, (char*)filename);
  10656. }
  10657. else
  10658. {
  10659. // Profile is not empty
  10660. char buf[2048]={0};
  10661. int ChargingProfileAdded = FALSE;
  10662. while (fgets(buf, sizeof(buf), infile) != NULL)
  10663. {
  10664. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  10665. json_object *tmpChargingProfile;
  10666. tmpChargingProfile = json_tokener_parse(buf);
  10667. if(!is_error(tmpChargingProfile))
  10668. {
  10669. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  10670. {
  10671. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  10672. }
  10673. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  10674. {
  10675. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  10676. {
  10677. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  10678. }
  10679. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  10680. {
  10681. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  10682. }
  10683. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  10684. {
  10685. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  10686. }
  10687. }
  10688. }
  10689. json_object_put(tmpChargingProfile);
  10690. if((tempconnectorIdInt == gun_index) &&
  10691. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId"))))
  10692. {
  10693. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel"))) &&
  10694. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  10695. {
  10696. //DEBUG_INFO("update set chargingProfile to file -0\n");
  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(SetChargingProfile, "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(SetChargingProfile, "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(SetChargingProfile, "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->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  10783. result = PASS;
  10784. }
  10785. else
  10786. {
  10787. if(gun_index == -1)
  10788. DEBUG_WARN("Connector id is wrong.\n");
  10789. if(isConnectorMismatch)
  10790. DEBUG_WARN("Connector id is mismatch.\n");
  10791. if(isPeriodOverMax)
  10792. DEBUG_WARN("Profile periods quantity is over spec.\n");
  10793. if(isProfileOverMax)
  10794. DEBUG_WARN("Profile quantity is over spec.\n");
  10795. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  10796. }
  10797. }
  10798. json_object_put(SetChargingProfile);
  10799. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  10800. {
  10801. if(gun_index == 0)
  10802. {
  10803. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  10804. {
  10805. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  10806. }
  10807. }
  10808. else
  10809. checkCompositeSchedule(gun_index, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index-1]);
  10810. }
  10811. sendSetChargingProfileConfirmation(uuid, (gun_index==0?gun_index:gun_index-1));
  10812. return result;
  10813. }
  10814. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  10815. {
  10816. mtrace();
  10817. int result = FAIL;
  10818. json_object *SetDisplayMessage;
  10819. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  10820. SetDisplayMessage = json_tokener_parse(payload);
  10821. if(!is_error(SetDisplayMessage))
  10822. {
  10823. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  10824. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  10825. // Required data
  10826. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  10827. {
  10828. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  10829. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  10830. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  10831. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  10832. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  10833. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  10834. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  10835. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  10836. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  10837. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  10838. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  10839. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  10840. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  10841. {
  10842. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  10843. 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")));
  10844. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  10845. 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")));
  10846. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  10847. 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")));
  10848. }
  10849. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  10850. {
  10851. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  10852. 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")));
  10853. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  10854. 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")));
  10855. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  10856. {
  10857. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  10858. 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"));
  10859. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  10860. 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"));
  10861. }
  10862. }
  10863. }
  10864. }
  10865. json_object_put(SetDisplayMessage);
  10866. /*
  10867. * TODO:
  10868. * 1. Configure display message and response
  10869. */
  10870. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  10871. sendSetMonitoringBaseConfirmation(uuid);
  10872. return result;
  10873. }
  10874. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  10875. {
  10876. mtrace();
  10877. int result = FAIL;
  10878. json_object *SetMonitoringBase;
  10879. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  10880. SetMonitoringBase = json_tokener_parse(payload);
  10881. if(!is_error(SetMonitoringBase))
  10882. {
  10883. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  10884. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  10885. // Required data
  10886. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  10887. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  10888. }
  10889. json_object_put(SetMonitoringBase);
  10890. /*
  10891. * TODO:
  10892. * 1. Configure monitor base and response
  10893. */
  10894. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10895. sendSetMonitoringBaseConfirmation(uuid);
  10896. return result;
  10897. }
  10898. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  10899. {
  10900. mtrace();
  10901. int result = FAIL;
  10902. json_object *SetMonitoringLevel;
  10903. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  10904. SetMonitoringLevel = json_tokener_parse(payload);
  10905. if(!is_error(SetMonitoringLevel))
  10906. {
  10907. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  10908. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  10909. // Required data
  10910. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  10911. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  10912. }
  10913. json_object_put(SetMonitoringLevel);
  10914. /*
  10915. * TODO:
  10916. * Configure monitor status and response
  10917. */
  10918. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10919. sendSetMonitoringLevelConfirmation(uuid);
  10920. return result;
  10921. }
  10922. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  10923. {
  10924. mtrace();
  10925. int result = FAIL;
  10926. json_object *SetNetworkProfile;
  10927. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  10928. SetNetworkProfile = json_tokener_parse(payload);
  10929. if(!is_error(SetNetworkProfile))
  10930. {
  10931. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  10932. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  10933. // Required data
  10934. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  10935. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  10936. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  10937. {
  10938. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  10939. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  10940. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  10941. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  10942. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  10943. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  10944. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  10945. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  10946. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  10947. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  10948. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  10949. {
  10950. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  10951. 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")));
  10952. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  10953. 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")));
  10954. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  10955. 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")));
  10956. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  10957. 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")));
  10958. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  10959. 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")));
  10960. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  10961. 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")));
  10962. }
  10963. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  10964. {
  10965. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  10966. {
  10967. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  10968. 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")));
  10969. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  10970. }
  10971. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  10972. {
  10973. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  10974. 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")));
  10975. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  10976. }
  10977. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  10978. {
  10979. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  10980. 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")));
  10981. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  10982. }
  10983. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  10984. 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"));
  10985. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  10986. 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")));
  10987. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  10988. 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"));
  10989. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  10990. 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")));
  10991. }
  10992. }
  10993. }
  10994. json_object_put(SetNetworkProfile);
  10995. /*
  10996. * TODO:
  10997. * 1. Process network configuration and response
  10998. */
  10999. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  11000. {
  11001. }
  11002. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  11003. {
  11004. }
  11005. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  11006. {
  11007. }
  11008. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  11009. {
  11010. }
  11011. else
  11012. {
  11013. }
  11014. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  11015. {
  11016. }
  11017. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  11018. {
  11019. }
  11020. else
  11021. {
  11022. }
  11023. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  11024. {
  11025. }
  11026. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  11027. {
  11028. }
  11029. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  11030. {
  11031. }
  11032. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  11033. {
  11034. }
  11035. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  11036. {
  11037. }
  11038. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  11039. {
  11040. }
  11041. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  11042. {
  11043. }
  11044. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  11045. {
  11046. }
  11047. else
  11048. {
  11049. }
  11050. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  11051. {
  11052. }
  11053. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  11054. {
  11055. }
  11056. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  11057. {
  11058. }
  11059. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  11060. {
  11061. }
  11062. else
  11063. {
  11064. }
  11065. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  11066. {
  11067. }
  11068. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  11069. {
  11070. }
  11071. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  11072. {
  11073. }
  11074. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  11075. {
  11076. }
  11077. else
  11078. {
  11079. }
  11080. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  11081. sendSetNetworkProfileConfirmation(uuid);
  11082. return result;
  11083. }
  11084. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  11085. {
  11086. mtrace();
  11087. int result = FAIL;
  11088. json_object *SetVariableMonitoring;
  11089. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  11090. SetVariableMonitoring = json_tokener_parse(payload);
  11091. if(!is_error(SetVariableMonitoring))
  11092. {
  11093. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  11094. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  11095. // Required data
  11096. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  11097. {
  11098. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  11099. {
  11100. 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"));
  11101. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  11102. }
  11103. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  11104. {
  11105. 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"));
  11106. /*
  11107. * TODO:
  11108. * 1. Check monitor value status
  11109. */
  11110. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, MonitorEnumTypeStr[MonitorEnumType_Delta]);
  11111. }
  11112. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  11113. {
  11114. 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")));
  11115. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  11116. }
  11117. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  11118. {
  11119. 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"));
  11120. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  11121. }
  11122. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  11123. {
  11124. 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"));
  11125. }
  11126. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component") != NULL)
  11127. {
  11128. 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)
  11129. {
  11130. 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")));
  11131. }
  11132. 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)
  11133. {
  11134. 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")));
  11135. }
  11136. 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)
  11137. {
  11138. 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)
  11139. {
  11140. 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"));
  11141. }
  11142. 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)
  11143. {
  11144. 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"));
  11145. }
  11146. }
  11147. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  11148. }
  11149. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable") != NULL)
  11150. {
  11151. 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)
  11152. {
  11153. 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")));
  11154. }
  11155. 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)
  11156. {
  11157. 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")));
  11158. }
  11159. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  11160. }
  11161. }
  11162. }
  11163. json_object_put(SetVariableMonitoring);
  11164. return result;
  11165. }
  11166. int handleSetVariablesRequest(char *uuid, char *payload)
  11167. {
  11168. mtrace();
  11169. int result = FAIL;
  11170. json_object *SetVariables;
  11171. DEBUG_INFO("handleSetVariablesRequest...\n");
  11172. SetVariables = json_tokener_parse(payload);
  11173. if(!is_error(SetVariables))
  11174. {
  11175. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  11176. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  11177. // Required data
  11178. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  11179. {
  11180. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  11181. {
  11182. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  11183. {
  11184. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  11185. {
  11186. 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")));
  11187. }
  11188. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  11189. {
  11190. 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")));
  11191. }
  11192. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  11193. {
  11194. 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)
  11195. {
  11196. 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"));
  11197. }
  11198. 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)
  11199. {
  11200. 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"));
  11201. }
  11202. }
  11203. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  11204. }
  11205. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  11206. {
  11207. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  11208. {
  11209. 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")));
  11210. }
  11211. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  11212. {
  11213. 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")));
  11214. }
  11215. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  11216. }
  11217. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  11218. {
  11219. 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")));
  11220. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  11221. }
  11222. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  11223. {
  11224. 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")));
  11225. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  11226. {
  11227. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) != NULL) &&
  11228. (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) &&
  11229. (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) != NULL) &&
  11230. (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))
  11231. {
  11232. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  11233. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  11234. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  11235. }
  11236. else
  11237. {
  11238. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  11239. }
  11240. }
  11241. }
  11242. }
  11243. }
  11244. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  11245. }
  11246. json_object_put(SetVariables);
  11247. return result;
  11248. }
  11249. int handleTriggerMessageRequest(char *uuid, char *payload)
  11250. {
  11251. mtrace();
  11252. int result = FAIL;
  11253. int connectorIdIsNULL = FALSE;
  11254. int connectorIdInt =0;
  11255. char requestedMessagestr[40]={0};
  11256. json_object *TriggerMessage;
  11257. DEBUG_INFO("handleTriggerMessageRequest\n");
  11258. TriggerMessage = json_tokener_parse(payload);
  11259. if(!is_error(TriggerMessage))
  11260. {
  11261. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  11262. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  11263. // Required data
  11264. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  11265. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  11266. // Optional data
  11267. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  11268. {
  11269. // Required data
  11270. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  11271. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  11272. // Optional data
  11273. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  11274. {
  11275. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  11276. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  11277. }
  11278. else
  11279. connectorIdIsNULL = TRUE;
  11280. }
  11281. }
  11282. json_object_put(TriggerMessage);
  11283. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  11284. {
  11285. if((strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  11286. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  11287. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  11288. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  11289. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  11290. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  11291. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  11292. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  11293. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  11294. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  11295. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  11296. {
  11297. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  11298. sendTriggerMessageConfirmation(uuid);
  11299. return TRUE;
  11300. }
  11301. else
  11302. {
  11303. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  11304. sendTriggerMessageConfirmation(uuid);
  11305. }
  11306. }
  11307. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  11308. {
  11309. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  11310. sendTriggerMessageConfirmation(uuid);
  11311. return TRUE;
  11312. }
  11313. //==========================
  11314. // Trigger message
  11315. //==========================
  11316. if( strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  11317. {
  11318. if((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) &&
  11319. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) &&
  11320. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) &&
  11321. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing) )
  11322. {
  11323. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  11324. }
  11325. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusNotificationStatus]);
  11326. }
  11327. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  11328. {
  11329. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[LogStatusNotificationStatus]);
  11330. }
  11331. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  11332. {
  11333. if(DB_updateBootType(BootReasonEnumType_Triggered))
  11334. server_sign = FALSE;
  11335. }
  11336. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  11337. {
  11338. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval);
  11339. }
  11340. else if (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  11341. {
  11342. if(connectorIdIsNULL == FALSE)
  11343. {
  11344. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  11345. {
  11346. //sendMeterValuesRequest((connectorIdInt -1), ReadingContext_Trigger);
  11347. cpinitateMsg.bits[connectorIdInt -1].TriggerMeterValue = 1;
  11348. }
  11349. }
  11350. else
  11351. {
  11352. for(int idx=0;idx< gunTotalNumber;idx++)
  11353. {
  11354. //sendMeterValuesRequest(idx, ReadingContext_Trigger);
  11355. cpinitateMsg.bits[idx].TriggerMeterValue = 1;
  11356. }
  11357. }
  11358. }
  11359. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  11360. {
  11361. if(connectorIdIsNULL == FALSE)
  11362. {
  11363. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  11364. {
  11365. cpinitateMsg.bits[connectorIdInt -1].StatusNotificationReq = 1;
  11366. }
  11367. }
  11368. else
  11369. {
  11370. for(int idx=0;idx< gunTotalNumber;idx++)
  11371. cpinitateMsg.bits[idx].StatusNotificationReq = 1;
  11372. }
  11373. }
  11374. return result;
  11375. }
  11376. int handleUnlockConnectorRequest(char *uuid, char *payload)
  11377. {
  11378. mtrace();
  11379. int result = FAIL;
  11380. int connectorIdInt =0;
  11381. int tempIndex = 0;
  11382. json_object *UnlockConnector;
  11383. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  11384. UnlockConnector = json_tokener_parse(payload);
  11385. if(!is_error(UnlockConnector))
  11386. {
  11387. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  11388. {
  11389. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  11390. }
  11391. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  11392. {
  11393. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  11394. }
  11395. }
  11396. json_object_put(UnlockConnector);
  11397. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  11398. if(gunTotalNumber == 0)
  11399. {
  11400. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  11401. goto end;
  11402. }
  11403. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  11404. {
  11405. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  11406. goto end;
  11407. }
  11408. else
  11409. {
  11410. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  11411. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  11412. //check Transaction active
  11413. if(gunType[connectorIdInt-1] == 'J')
  11414. {
  11415. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11416. {
  11417. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11418. }
  11419. else
  11420. {
  11421. tempIndex = connectorIdInt -1;
  11422. }
  11423. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11424. {
  11425. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  11426. {
  11427. //stop Transaction
  11428. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = 1;
  11429. }
  11430. }
  11431. }
  11432. else if((gunType[connectorIdInt-1] == 'U')||(gunType[connectorIdInt-1] == 'E'))
  11433. {
  11434. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11435. {
  11436. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11437. }
  11438. else
  11439. {
  11440. tempIndex = connectorIdInt -1;
  11441. }
  11442. for (int index = 0; index < CCS_QUANTITY; index++)
  11443. {
  11444. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  11445. {
  11446. //stop Transaction
  11447. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = 1;
  11448. }
  11449. }
  11450. }
  11451. else if(gunType[connectorIdInt-1] == 'G')
  11452. {
  11453. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11454. {
  11455. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11456. }
  11457. else
  11458. {
  11459. tempIndex = connectorIdInt -1;
  11460. }
  11461. for (int index = 0; index < GB_QUANTITY; index++)
  11462. {
  11463. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)))
  11464. {
  11465. //stop Transaction
  11466. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = 1;
  11467. }
  11468. }
  11469. }
  11470. else
  11471. {
  11472. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  11473. {
  11474. tempIndex = 2;
  11475. }
  11476. else
  11477. {
  11478. tempIndex = connectorIdInt-1;
  11479. }
  11480. for (int index = 0; index < AC_QUANTITY; index++)
  11481. {
  11482. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  11483. {
  11484. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = 1;
  11485. }
  11486. }
  11487. }
  11488. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  11489. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  11490. result = TRUE;
  11491. return result;
  11492. }
  11493. end:
  11494. //json_object_put(obj); --- remove temporally
  11495. sendUnlockConnectorConfirmation(uuid, connectorIdInt-1);
  11496. return result;
  11497. }
  11498. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  11499. {
  11500. mtrace();
  11501. int result = FAIL;
  11502. json_object *UnpublishFirmware;
  11503. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  11504. UnpublishFirmware = json_tokener_parse(payload);
  11505. if(!is_error(UnpublishFirmware))
  11506. {
  11507. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  11508. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  11509. // Required data
  11510. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  11511. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  11512. }
  11513. json_object_put(UnpublishFirmware);
  11514. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  11515. /*
  11516. * TODO:
  11517. * 1. Check unpublished status
  11518. */
  11519. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  11520. sendUnpublishFirmwareConfirmation(uuid);
  11521. return result;
  11522. }
  11523. static char UpdateFirmwarepayloadData[512]={0};
  11524. void *UpdateFirmwareProcess(void *data)
  11525. {
  11526. pthread_detach(pthread_self());
  11527. mtrace();
  11528. int retriesInt =0, retryIntervalInt=0;
  11529. char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
  11530. int port=0;
  11531. char locationstr[160]={0}, retrieveDatestr[30]={0};
  11532. int isSuccess = 0;
  11533. char ftpbuf[200];
  11534. char temp[100];
  11535. char * pch;
  11536. DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
  11537. json_object *UpdateFirmware;
  11538. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  11539. if(!is_error(UpdateFirmware))
  11540. {
  11541. // Required data
  11542. if(json_object_object_get(UpdateFirmware, "location") != NULL)
  11543. sprintf((char*)locationstr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "location")));
  11544. if(json_object_object_get(UpdateFirmware, "retrieveDate") != NULL)
  11545. sprintf((char*)retrieveDatestr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "retrieveDate")));
  11546. // Optional data
  11547. if(json_object_object_get(UpdateFirmware, "retries"))
  11548. {
  11549. retriesInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  11550. }
  11551. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  11552. {
  11553. retryIntervalInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  11554. }
  11555. }
  11556. json_object_put(UpdateFirmware);
  11557. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  11558. memset(path, 0, ARRAY_SIZE(path));
  11559. system("rm -f /mnt/*");
  11560. if(strncmp(locationstr,"http", 4) == 0)
  11561. {
  11562. sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  11563. //sscanf(locationstr,"%[^:]:%*2[/]%[^:]:%[^@]@%[^/]%199[^\n]",
  11564. // protocol, user, password, host, path);
  11565. sprintf(ftppath,"/%s", path);
  11566. DEBUG_INFO("locationstr: %s\n", locationstr);
  11567. DEBUG_INFO("protocol: %s\n",protocol);
  11568. DEBUG_INFO("host: %s\n",host);
  11569. DEBUG_INFO("path: %s\n",path);
  11570. DEBUG_INFO("ftppath: %s\n",ftppath);
  11571. int ftppathlen=strlen(ftppath);
  11572. int i=1;
  11573. char filenametemp[50];
  11574. while(i < ftppathlen)
  11575. {
  11576. int len=ftppathlen-i;
  11577. if(ftppath[len]== 47) // '/' ascll code: 47
  11578. {
  11579. DEBUG_INFO("compare '/' all right\n");
  11580. break;
  11581. }
  11582. i=i+1;
  11583. }
  11584. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  11585. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  11586. filenametemp[i+1] = 0;
  11587. do
  11588. {
  11589. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  11590. sleep(3);
  11591. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
  11592. if(!isSuccess)
  11593. {
  11594. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  11595. sleep(retryIntervalInt);
  11596. }
  11597. else
  11598. {
  11599. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  11600. }
  11601. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
  11602. }
  11603. else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
  11604. {
  11605. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  11606. memset(temp, 0, ARRAY_SIZE(temp));
  11607. //DEBUG_INFO("locationstr=%s\n",locationstr);
  11608. strcpy(ftpbuf, locationstr/*"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/DemoDC1_2018-07-13_185011_PSULog.zip"*/ );
  11609. int ftppathlen=strlen(ftpbuf);
  11610. int i=1;
  11611. char filenametemp[50];
  11612. while(i < ftppathlen)
  11613. {
  11614. int len=ftppathlen-i;
  11615. if(ftpbuf[len]== 47) // '/' ascll code: 47
  11616. {
  11617. DEBUG_INFO(" compare '/' all right\n");
  11618. break;
  11619. }
  11620. i=i+1;
  11621. }
  11622. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  11623. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  11624. filenametemp[i+1] = 0;
  11625. strncpy(temp, ftpbuf, ftppathlen-i+1);
  11626. pch=strchr(temp,'@');
  11627. if(pch==NULL)
  11628. {
  11629. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  11630. protocol, host, &port, path);
  11631. strcpy(user,"anonymous");
  11632. strcpy(password,"");
  11633. }
  11634. else
  11635. {
  11636. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  11637. protocol, user, password, host, &port, path);
  11638. }
  11639. sscanf(host,"%[^/]%s",host1, path1);
  11640. sprintf(ftppath,"%s", path1);
  11641. //DEBUG_INFO("protocol =%s\n",protocol);
  11642. //DEBUG_INFO("user =%s\n",user);
  11643. //DEBUG_INFO("password =%s\n",password);
  11644. //DEBUG_INFO("host1 =%s\n",host1);
  11645. //DEBUG_INFO("port =%d\n",port);
  11646. //DEBUG_INFO("path1 =%s\n",path1);
  11647. //DEBUG_INFO("ftppath=%s\n",ftppath);
  11648. //ftpFile(host, user, password, port, ftppath, fname);
  11649. //download firmware pthred
  11650. if(port == 0)
  11651. {
  11652. port = 21;
  11653. }
  11654. do
  11655. {
  11656. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  11657. sleep(3);
  11658. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
  11659. if(!isSuccess)
  11660. {
  11661. //BulldogUtil.sleepMs(interval*1000);
  11662. DEBUG_INFO("Update firmware request and download file fail.\n");
  11663. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  11664. sleep(retryIntervalInt);
  11665. }
  11666. else
  11667. {
  11668. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  11669. }
  11670. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  11671. }
  11672. else
  11673. {
  11674. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  11675. }
  11676. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = 1;
  11677. pthread_exit(NULL);
  11678. }
  11679. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  11680. {
  11681. mtrace();
  11682. int result = FAIL;
  11683. pthread_t t;
  11684. sendUpdateFirmwareConfirmation(uuid);
  11685. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  11686. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  11687. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  11688. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  11689. ////pthread_join(t, NULL); //
  11690. //pthread_detach(t);
  11691. //sendUpdateFirmwareConfirmation(uuid);
  11692. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  11693. return result;
  11694. }
  11695. //==========================================
  11696. // Handle server response routine
  11697. //==========================================
  11698. void handleAuthorizeResponse(char *payload, int gun_index)
  11699. {
  11700. mtrace();
  11701. DEBUG_INFO("handleAuthorizeResponse...\n");
  11702. json_object *Authorize;
  11703. Authorize = json_tokener_parse(payload);
  11704. if(!is_error(Authorize))
  11705. {
  11706. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  11707. {
  11708. // Required data
  11709. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  11710. // Optional data
  11711. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  11712. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  11713. else
  11714. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  11715. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  11716. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  11717. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  11718. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  11719. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  11720. {
  11721. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  11722. {
  11723. 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));
  11724. }
  11725. }
  11726. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  11727. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  11728. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  11729. {
  11730. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  11731. 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")));
  11732. else
  11733. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  11734. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  11735. 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")));
  11736. }
  11737. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  11738. {
  11739. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  11740. 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")));
  11741. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  11742. 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")));
  11743. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  11744. 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")));
  11745. }
  11746. }
  11747. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  11748. {
  11749. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  11750. }
  11751. }
  11752. json_object_put(Authorize);
  11753. //Update idTag information to authorization cache if supported
  11754. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  11755. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  11756. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  11757. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  11758. {
  11759. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  11760. }
  11761. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  11762. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  11763. authorizeRetryTimes = 0;
  11764. }
  11765. void handleBootNotificationResponse(char *payload, int gun_index)
  11766. {
  11767. mtrace();
  11768. char statusStr[12]={0};
  11769. char currentTimeStr[30]={0};
  11770. int intervalInt = 0;
  11771. struct tm tp;
  11772. char buf[28]={0};
  11773. char timebuf[50]={0};
  11774. DEBUG_INFO("handleBootNotificationResponse...\n");
  11775. json_object *BootNotification;
  11776. BootNotification = json_tokener_parse(payload);
  11777. if(!is_error(BootNotification))
  11778. {
  11779. // Required data
  11780. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  11781. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  11782. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  11783. }
  11784. json_object_put(BootNotification);
  11785. DEBUG_INFO("statusStr: %s\n", statusStr);
  11786. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  11787. BootNotificationInterval = intervalInt;
  11788. HeartBeatWaitTime = intervalInt;
  11789. //write back to ShmOCPP20Data->BootNotification
  11790. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  11791. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  11792. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  11793. {
  11794. server_sign = TRUE;
  11795. server_pending =FALSE;
  11796. DB_updateBootType(BootReasonEnumType_PowerUp);
  11797. }
  11798. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  11799. {
  11800. server_pending = TRUE;
  11801. }
  11802. strptime((const char *)ShmOCPP20Data->BootNotification.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  11803. tp.tm_isdst = -1;
  11804. //time_t utc = mktime(&tp);
  11805. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  11806. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  11807. sprintf(timebuf,"date -s '%s'",buf);
  11808. system(timebuf);
  11809. srand(time(NULL));
  11810. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  11811. //==============================================
  11812. // RTC sync
  11813. //==============================================
  11814. system("/sbin/hwclock -w --systohc");
  11815. ShmOCPP20Data->OcppConnStatus = ON; ////0: disconnected, 1: connected
  11816. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  11817. }
  11818. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  11819. {
  11820. mtrace();
  11821. json_object *ClearedChargingLimit;
  11822. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  11823. ClearedChargingLimit = json_tokener_parse(payload);
  11824. if(!is_error(ClearedChargingLimit))
  11825. {
  11826. // Required data
  11827. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  11828. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  11829. }
  11830. json_object_put(ClearedChargingLimit);
  11831. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitReq = OFF;
  11832. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitConf = ON;
  11833. }
  11834. void handleDataTransferResponse(char *payload, int gun_index)
  11835. {
  11836. mtrace();
  11837. json_object *DataTrans;
  11838. DEBUG_INFO("handleDataTransferResponse...\n");
  11839. DataTrans = json_tokener_parse(payload);
  11840. if(!is_error(DataTrans))
  11841. {
  11842. // Required data
  11843. if(json_object_object_get(DataTrans,"status") != NULL)
  11844. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  11845. // Optional data
  11846. if(json_object_object_get(DataTrans,"data") != NULL)
  11847. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  11848. }
  11849. json_object_put(DataTrans);
  11850. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  11851. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  11852. }
  11853. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  11854. {
  11855. mtrace();
  11856. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  11857. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  11858. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  11859. }
  11860. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  11861. {
  11862. mtrace();
  11863. json_object *Get15118EVCertificate;
  11864. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  11865. Get15118EVCertificate = json_tokener_parse(payload);
  11866. if(!is_error(Get15118EVCertificate))
  11867. {
  11868. // Required data
  11869. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  11870. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  11871. // Optional data
  11872. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  11873. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  11874. }
  11875. json_object_put(Get15118EVCertificate);
  11876. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  11877. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  11878. }
  11879. void hanldeGetCertificateStatusResponse(char *payload, int gun_index)
  11880. {
  11881. mtrace();
  11882. json_object *GetCertificateStatus;
  11883. DEBUG_INFO("hanldeGetCertificateStatusResponse...\n");
  11884. GetCertificateStatus = json_tokener_parse(payload);
  11885. if(!is_error(GetCertificateStatus))
  11886. {
  11887. // Required data
  11888. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  11889. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  11890. // Optional data
  11891. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  11892. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  11893. }
  11894. json_object_put(GetCertificateStatus);
  11895. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  11896. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  11897. }
  11898. void handleHeartbeatResponse(char *payload, int gun_index)
  11899. {
  11900. mtrace();
  11901. struct tm tp;
  11902. char buf[28]={0};
  11903. char timebuf[128]={0};
  11904. DEBUG_INFO("handleHeartbeatResponse...\n");
  11905. json_object *Heartbeat;
  11906. Heartbeat = json_tokener_parse(payload);
  11907. if(!is_error(Heartbeat))
  11908. {
  11909. // Required data
  11910. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  11911. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  11912. }
  11913. json_object_put(Heartbeat);
  11914. if(FirstHeartBeat == OFF)
  11915. {
  11916. FirstHeartBeat = ON;
  11917. DEBUG_INFO("FirstHeartBeat \n");
  11918. }
  11919. HeartBeatWithNOResponse = 0;
  11920. strptime((const char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  11921. tp.tm_isdst = -1;
  11922. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  11923. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  11924. sprintf(timebuf,"date -s '%s'",buf);
  11925. system(timebuf);
  11926. //==============================================
  11927. // RTC sync
  11928. //==============================================
  11929. system("/sbin/hwclock -w --systohc");
  11930. //===============================================
  11931. //Print Out HeartBeat log
  11932. //===============================================
  11933. {
  11934. double diff_t;
  11935. struct tm tp,tp1;
  11936. // BootNotification Receive Time
  11937. strptime((const char *)ShmOCPP20Data->BootNotification.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  11938. tp.tm_isdst = -1;
  11939. time_t BootNotificationReceiveTime = mktime(&tp);
  11940. //HeartBeat Receive Time
  11941. strptime((const char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp1);
  11942. tp1.tm_isdst = -1;
  11943. time_t HeartBeatReceiveTime = mktime(&tp1);
  11944. diff_t = difftime(HeartBeatReceiveTime, BootNotificationReceiveTime);
  11945. DEBUG_INFO("Differnt time= %f..\n",diff_t);
  11946. if(((int)diff_t / 3600) > HeartBeatCountPerHour)
  11947. {
  11948. HeartBeatCountPerHour = (int)diff_t / 3600;
  11949. DEBUG_INFO("handleHeartbeatResponse ...\n");
  11950. DEBUG_INFO("After 1 hour, It will print out Heartbeat.\n");
  11951. }
  11952. }
  11953. }
  11954. void hanldeLogStatusNotificationResponse(char *payload, int gun_index)
  11955. {
  11956. mtrace();
  11957. DEBUG_INFO("hanldeLogStatusNotificationResponse...\n");
  11958. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  11959. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  11960. }
  11961. void handleMeterValuesResponse(char *payload, int gun_index)
  11962. {
  11963. mtrace();
  11964. DEBUG_INFO("handleMeterValuesResponse...\n");
  11965. }
  11966. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  11967. {
  11968. mtrace();
  11969. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  11970. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  11971. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  11972. }
  11973. void hanldeNotifyCustomerInformationResponse(char *payload, int gun_index)
  11974. {
  11975. mtrace();
  11976. DEBUG_INFO("hanldeNotifyCustomerInformationResponse...\n");
  11977. }
  11978. void hanldeNotifyDisplayMessagesResponse(char *payload, int gun_index)
  11979. {
  11980. mtrace();
  11981. DEBUG_INFO("hanldeNotifyDisplayMessagesResponse...\n");
  11982. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  11983. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  11984. }
  11985. void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  11986. {
  11987. mtrace();
  11988. json_object *NotifyEVChargingNeeds;
  11989. DEBUG_INFO("hanldeNotifyEVChargingNeedsResponse...\n");
  11990. NotifyEVChargingNeeds = json_tokener_parse(payload);
  11991. if(!is_error(NotifyEVChargingNeeds))
  11992. {
  11993. // Required data
  11994. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  11995. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  11996. }
  11997. json_object_put(NotifyEVChargingNeeds);
  11998. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  11999. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  12000. }
  12001. void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  12002. {
  12003. mtrace();
  12004. json_object *NotifyEVChargingSchedule;
  12005. DEBUG_INFO("hanldeNotifyEVChargingScheduleResponse...\n");
  12006. NotifyEVChargingSchedule = json_tokener_parse(payload);
  12007. if(!is_error(NotifyEVChargingSchedule))
  12008. {
  12009. // Required data
  12010. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  12011. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  12012. }
  12013. json_object_put(NotifyEVChargingSchedule);
  12014. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  12015. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  12016. }
  12017. void hanldeNotifyEventResponse(char *payload, int gun_index)
  12018. {
  12019. mtrace();
  12020. DEBUG_INFO("hanldeNotifyEventResponse...\n");
  12021. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  12022. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  12023. }
  12024. void hanldeNotifyMonitoringReportResponse(char *payload, int gun_index)
  12025. {
  12026. mtrace();
  12027. DEBUG_INFO("hanldeNotifyMonitoringReportResponse...\n");
  12028. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  12029. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  12030. }
  12031. void hanldeNotifyReportResponse(char *payload, int gun_index)
  12032. {
  12033. mtrace();
  12034. DEBUG_INFO("hanldeNotifyReportResponse...\n");
  12035. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  12036. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  12037. }
  12038. void hanldePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  12039. {
  12040. mtrace();
  12041. DEBUG_INFO("hanldePublishFirmwareStatusNotificationResponse...\n");
  12042. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  12043. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  12044. }
  12045. void hanldeReportChargingProfilesResponse(char *payload, int gun_index)
  12046. {
  12047. mtrace();
  12048. DEBUG_INFO("hanldeReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  12049. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  12050. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  12051. }
  12052. void hanldeReservationStatusUpdateResponse(char *payload, int gun_index)
  12053. {
  12054. mtrace();
  12055. DEBUG_INFO("hanldeReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  12056. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  12057. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  12058. }
  12059. void hanldeSecurityEventNotificationResponse(char *payload, int gun_index)
  12060. {
  12061. mtrace();
  12062. DEBUG_INFO("hanldeSecurityEventNotificationResponse...\n");
  12063. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  12064. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  12065. }
  12066. void hanldeSignCertificateResponse(char *payload, int gun_index)
  12067. {
  12068. mtrace();
  12069. json_object *SignCertificate;
  12070. DEBUG_INFO("hanldeSignCertificateResponse...\n");
  12071. SignCertificate = json_tokener_parse(payload);
  12072. if(!is_error(SignCertificate))
  12073. {
  12074. // Required data
  12075. if(json_object_object_get(SignCertificate,"status") != NULL)
  12076. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  12077. }
  12078. json_object_put(SignCertificate);
  12079. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  12080. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  12081. }
  12082. void handleStatusNotificationResponse(char *payload, int gun_index)
  12083. {
  12084. mtrace();
  12085. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  12086. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  12087. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  12088. }
  12089. void hanldeTransactionEvenResponse(char *payload, int gun_index)
  12090. {
  12091. mtrace();
  12092. json_object *TransactionEven;
  12093. DEBUG_INFO("hanldeTransactionEvenResponse...\n");
  12094. TransactionEven = json_tokener_parse(payload);
  12095. if(!is_error(TransactionEven))
  12096. {
  12097. // Required data
  12098. // Optional data
  12099. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  12100. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  12101. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  12102. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  12103. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  12104. {
  12105. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  12106. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  12107. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  12108. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  12109. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  12110. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  12111. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  12112. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  12113. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  12114. {
  12115. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  12116. 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")));
  12117. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  12118. 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")));
  12119. }
  12120. }
  12121. }
  12122. json_object_put(TransactionEven);
  12123. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  12124. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  12125. }
  12126. //==========================================
  12127. // Handle Error routine
  12128. //==========================================
  12129. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  12130. {
  12131. mtrace();
  12132. #ifdef SystemLogMessage
  12133. DEBUG_INFO("errorCode: %s\n", errorCode);
  12134. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  12135. DEBUG_INFO("errorDetails: %s\n", payload);
  12136. #endif
  12137. }
  12138. //===============================================
  12139. // Common routine
  12140. //===============================================
  12141. int initialConfigurationTable(void)
  12142. {
  12143. DEBUG_INFO("initialConfigurationTable...\n");
  12144. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  12145. DB_variableIsCreate();
  12146. DB_variableLoadFromDb();
  12147. return 0;
  12148. }
  12149. int TransactionMessageAttemptsGet(void)
  12150. {
  12151. return TransactionMessageAttemptsValue;
  12152. }
  12153. int FirstHeartBeatResponse(void)
  12154. {
  12155. return FirstHeartBeat;
  12156. }
  12157. int TransactionMessageRetryIntervalGet(void)
  12158. {
  12159. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  12160. }
  12161. int ReadHttpStatus(int sock)
  12162. {
  12163. //char c;
  12164. char buff[1024]="",*ptr=buff+1;
  12165. int bytes_received, status;
  12166. DEBUG_INFO("Begin Response ..\n");
  12167. while((bytes_received = recv(sock, ptr, 1, 0))){
  12168. if(bytes_received==-1){
  12169. perror("ReadHttpStatus");
  12170. exit(1);
  12171. }
  12172. if((ptr[-1]=='\r') && (*ptr=='\n' )) break;
  12173. ptr++;
  12174. }
  12175. *ptr=0;
  12176. ptr=buff+1;
  12177. sscanf(ptr,"%*s %d ", &status);
  12178. DEBUG_INFO("%s\n",ptr);
  12179. DEBUG_INFO("status=%d\n",status);
  12180. DEBUG_INFO("End Response ..\n");
  12181. return (bytes_received>0)?status:0;
  12182. }
  12183. //the only filed that it parsed is 'Content-Length'
  12184. int ParseHeader(int sock)
  12185. {
  12186. //char c;
  12187. char buff[1024]="",*ptr=buff+4;
  12188. int bytes_received;
  12189. DEBUG_INFO("Begin HEADER ..\n");
  12190. while((bytes_received = recv(sock, ptr, 1, 0))){
  12191. if(bytes_received==-1){
  12192. perror("Parse Header");
  12193. exit(1);
  12194. }
  12195. if(
  12196. (ptr[-3]=='\r') && (ptr[-2]=='\n' ) &&
  12197. (ptr[-1]=='\r') && (*ptr=='\n' )
  12198. ) break;
  12199. ptr++;
  12200. }
  12201. *ptr=0;
  12202. ptr=buff+4;
  12203. //printf("%s",ptr);
  12204. if(bytes_received){
  12205. ptr=strstr(ptr,"Content-Length:");
  12206. if(ptr){
  12207. sscanf(ptr,"%*s %d",&bytes_received);
  12208. }else
  12209. bytes_received=-1; //unknown size
  12210. DEBUG_INFO("Content-Length: %d\n",bytes_received);
  12211. }
  12212. DEBUG_INFO("End HEADER ..\n");
  12213. return bytes_received ;
  12214. }
  12215. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  12216. {
  12217. char rmFileCmd[100]={0};
  12218. char FilePath[100]={0};
  12219. char ftpbuf[200];
  12220. int systemresult;
  12221. //DEBUG_INFO("filename=%s\n",filename);
  12222. //DEBUG_INFO("url=%s\n",url);
  12223. sprintf(FilePath,"/mnt/%s",filename);
  12224. if((access(FilePath,F_OK))!=-1)
  12225. {
  12226. DEBUG_INFO("filename=%s exist.\n",FilePath);
  12227. sprintf(rmFileCmd,"rm -f %s",FilePath);
  12228. system(rmFileCmd);
  12229. }
  12230. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12231. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  12232. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  12233. systemresult = system(ftpbuf);
  12234. //DEBUG_INFO("systemresult=%d\n",systemresult);
  12235. if(systemresult != 0)
  12236. {
  12237. DEBUG_INFO("http DownLoad error!\n");
  12238. return FALSE;
  12239. }
  12240. return TRUE;
  12241. }
  12242. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  12243. {
  12244. char rmFileCmd[100]={0};
  12245. char FilePath[100]={0};
  12246. char ftpbuf[200];
  12247. int systemresult;
  12248. //char temp[100];
  12249. sprintf(FilePath,"/mnt/%s",filename);
  12250. if((access(FilePath,F_OK))!=-1)
  12251. {
  12252. DEBUG_INFO("filename=%s exist.\n",FilePath);
  12253. sprintf(rmFileCmd,"rm -f %s",FilePath);
  12254. system(rmFileCmd);
  12255. }
  12256. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12257. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  12258. //sprintf(ftpbuf, "ftpget -u %s -p %s %s -P %d %s %s%s",user,password,IPbuffer,port/*21*/,filename,path,filename); --- remove temporally
  12259. //DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  12260. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  12261. systemresult = system(ftpbuf);
  12262. //DEBUG_INFO("systemresult=%d\n",systemresult);
  12263. if(systemresult != 0)
  12264. {
  12265. printf("wget error!\n");
  12266. return FALSE;
  12267. }
  12268. return TRUE;
  12269. }
  12270. int httpUploadFile(char *location, char *path, char *filename,char *url)
  12271. {
  12272. char rmFileCmd[100]={0};
  12273. char FilePath[100]={0};
  12274. char ftpbuf[200];
  12275. int systemresult;
  12276. //DEBUG_INFO("filename=%s\n",filename);
  12277. //DEBUG_INFO("url=%s\n",url);
  12278. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  12279. if((access(FilePath,F_OK))!=-1)
  12280. {
  12281. DEBUG_INFO("filename=%s exist.\n",FilePath);
  12282. sprintf(rmFileCmd,"rm -f %s",FilePath);
  12283. system(rmFileCmd);
  12284. }
  12285. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  12286. if(fp == NULL)
  12287. {
  12288. DEBUG_INFO("log is NULL\n");
  12289. return FALSE;
  12290. }
  12291. else
  12292. {
  12293. fprintf(fp, "%s\n", url);
  12294. fprintf(fp, "%s\n", filename);
  12295. fclose(fp);
  12296. }
  12297. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12298. sprintf(ftpbuf, "%s","/bin/php-cgi /var/www/ocpp_upload.php");
  12299. systemresult = system(ftpbuf);
  12300. DEBUG_INFO("systemresult = %d\n",systemresult);
  12301. if(systemresult != 0)
  12302. {
  12303. DEBUG_INFO("http upload error!\n");
  12304. return FALSE;
  12305. }
  12306. return TRUE;
  12307. }
  12308. int ftpFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  12309. {
  12310. struct hostent* server;
  12311. char *IPbuffer;
  12312. char ftpbuf[200];
  12313. int systemresult;
  12314. // To retrieve host information
  12315. server = gethostbyname(location);
  12316. // To convert an Internet network
  12317. // address into ASCII string
  12318. IPbuffer = inet_ntoa(*((struct in_addr*)
  12319. server->h_addr_list[0]));
  12320. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12321. /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
  12322. /* format : ftpput -u username -p passwd IP target source*/
  12323. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
  12324. DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  12325. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  12326. systemresult = system(ftpbuf);
  12327. DEBUG_INFO("systemresult=%d\n",systemresult);
  12328. if(systemresult != 0)
  12329. {
  12330. DEBUG_INFO("ftpput error!\n");
  12331. return FALSE;
  12332. }
  12333. return TRUE;
  12334. }
  12335. int get_file_contents(const char* filename, char** outbuffer) {
  12336. FILE* file = NULL;
  12337. long filesize;
  12338. const int blocksize = 1;
  12339. size_t readsize;
  12340. char* filebuffer;
  12341. // Open the file
  12342. file = fopen(filename, "r");
  12343. if (NULL == file)
  12344. {
  12345. printf("'%s' not opened\n", filename);
  12346. exit(EXIT_FAILURE);
  12347. }
  12348. // Determine the file size
  12349. fseek(file, 0, SEEK_END);
  12350. filesize = ftell(file);
  12351. rewind (file);
  12352. // Allocate memory for the file contents
  12353. filebuffer = (char*) malloc(sizeof(char) * filesize);
  12354. *outbuffer = filebuffer;
  12355. if (filebuffer == NULL)
  12356. {
  12357. fputs ("malloc out-of-memory", stderr);
  12358. exit(EXIT_FAILURE);
  12359. }
  12360. // Read in the file
  12361. readsize = fread(filebuffer, blocksize, filesize, file);
  12362. if (readsize != filesize)
  12363. {
  12364. fputs ("didn't read file completely",stderr);
  12365. exit(EXIT_FAILURE);
  12366. }
  12367. // Clean exit
  12368. fclose(file);
  12369. return EXIT_SUCCESS;
  12370. }
  12371. //=========================================
  12372. // Routine
  12373. //=========================================
  12374. int GetOcppServerURL()
  12375. {
  12376. int result = FALSE;
  12377. struct yuarel url;
  12378. char urlStr[512];
  12379. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  12380. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  12381. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  12382. if((ShmSysConfigAndInfo->SysConfig.OcppServerURL != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0) )
  12383. {
  12384. memcpy(urlStr, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  12385. if(yuarel_parse(&url, urlStr) != -1)
  12386. {
  12387. sprintf(OcppProtocol, "%s", url.scheme);
  12388. sprintf(OcppHost, "%s", url.host);
  12389. if(url.path == NULL)
  12390. OcppTempPath[0] = '\0';
  12391. else
  12392. sprintf(OcppTempPath, "%s", url.path);
  12393. if(url.port == 0)
  12394. {
  12395. if(strcmp(OcppProtocol, "wss") == 0)
  12396. OcppPort = 443;
  12397. else
  12398. OcppPort = 80;
  12399. }
  12400. else
  12401. OcppPort = url.port;
  12402. result = TRUE;
  12403. }
  12404. }
  12405. else if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  12406. {
  12407. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  12408. if(yuarel_parse(&url, urlStr) != -1)
  12409. {
  12410. sprintf(OcppProtocol, "%s", url.scheme);
  12411. sprintf(OcppHost, "%s", url.host);
  12412. if(url.path == NULL)
  12413. OcppTempPath[0] = '\0';
  12414. else
  12415. sprintf(OcppTempPath, "%s", url.path);
  12416. if(url.port == 0)
  12417. {
  12418. if(strcmp(OcppProtocol, "wss") == 0)
  12419. OcppPort = 443;
  12420. else
  12421. OcppPort = 80;
  12422. }
  12423. else
  12424. OcppPort = url.port;
  12425. result = TRUE;
  12426. }
  12427. }
  12428. else
  12429. {
  12430. strcpy(OcppHost,"");
  12431. }
  12432. return result;
  12433. }
  12434. int GetOcppPath()
  12435. {
  12436. int result = FALSE;
  12437. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  12438. {
  12439. if(OcppTempPath == NULL)
  12440. {
  12441. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  12442. }
  12443. else
  12444. {
  12445. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  12446. }
  12447. result = TRUE;
  12448. goto End;
  12449. }
  12450. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  12451. {
  12452. if(OcppTempPath == NULL)
  12453. {
  12454. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  12455. }
  12456. else
  12457. {
  12458. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  12459. }
  12460. result = TRUE;
  12461. goto End;
  12462. }
  12463. else
  12464. {
  12465. strcpy(OcppPath,"");
  12466. }
  12467. End:
  12468. return result;
  12469. }
  12470. int GetOcppPort()
  12471. {
  12472. return OcppPort;
  12473. }
  12474. int GetOcppConnStatus(void)
  12475. {
  12476. return ShmOCPP20Data->OcppConnStatus;
  12477. }
  12478. void SetOcppConnStatus(uint8_t status)
  12479. {
  12480. ShmOCPP20Data->OcppConnStatus = status;
  12481. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  12482. }
  12483. int GetHeartBeatWithNOResponse(void)
  12484. {
  12485. return HeartBeatWithNOResponse;
  12486. }
  12487. void SetHeartBeatWithNOResponse(void)
  12488. {
  12489. HeartBeatWithNOResponse = 0;
  12490. }
  12491. void GetStartTransactionIdTag(int gun_index)
  12492. {
  12493. memset(StartTransactionIdTagTemp, 0 ,ARRAY_SIZE(StartTransactionIdTagTemp));
  12494. strcpy((char *)StartTransactionIdTagTemp, (const char *)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken);
  12495. }
  12496. int GetTransactionId(int gunindex, unsigned char idTag[], uint8_t isStopTransaction)
  12497. {
  12498. char ch;
  12499. FILE *fptr1;
  12500. int temptransactionId;
  12501. char str[100]={0};
  12502. temptransactionId = 0;
  12503. if((strcmp((const char*)idTag, "")==0)||(idTag[0]=='\0'))
  12504. {
  12505. DEBUG_INFO("IdTag is empty.\n");
  12506. return temptransactionId;
  12507. }
  12508. /*------ Read the file ----------------*/
  12509. fptr1=fopen("/Storage/OCPP/QueueTransactionId","r");
  12510. if (!fptr1)
  12511. {
  12512. DEBUG_INFO("QueueTransactionId file open error.\n");
  12513. //printf(" File not found or unable to open the input file!!\n");
  12514. return temptransactionId;
  12515. }
  12516. ch=fgetc(fptr1);
  12517. //printf(" Now the content of the file %s is : \n","/Storage/OCPP/QueueTransactionId");
  12518. rewind(fptr1);
  12519. if(ch!=EOF)
  12520. {
  12521. // printf("%c",ch);
  12522. while (fgets(str, 100, fptr1) != NULL)
  12523. {
  12524. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  12525. if(str[0]=='\0')
  12526. {
  12527. break;
  12528. }
  12529. char *revbuf[8] = {0}; // Variable store string split
  12530. int num = 0;// Quantity after string split
  12531. DEBUG_INFO("Transaction queue data= %s\n", str);
  12532. splitstring(str,",",revbuf,&num); // String split
  12533. DEBUG_INFO(" revbuf[0]= %s\n", revbuf[0]);
  12534. DEBUG_INFO(" revbuf[1]= %s\n", revbuf[1]);
  12535. DEBUG_INFO(" revbuf[2]= %s\n", revbuf[2]);
  12536. if((revbuf[1][0] != '\0')&&(revbuf[2][0] != '\0'))
  12537. {
  12538. if(isStopTransaction)
  12539. {
  12540. if((atoi(revbuf[0])==gunindex) && (strcmp(revbuf[1],(const char *)idTag)==0))
  12541. {
  12542. temptransactionId = atoi(revbuf[2]);
  12543. break;
  12544. }
  12545. }
  12546. else
  12547. {
  12548. if((atoi(revbuf[0])==gunindex) || (strcmp(revbuf[1],(const char *)idTag)==0))
  12549. {
  12550. temptransactionId = atoi(revbuf[2]);
  12551. break;
  12552. }
  12553. }
  12554. }
  12555. }
  12556. }
  12557. else
  12558. DEBUG_INFO("EOF\n");
  12559. fclose(fptr1);
  12560. /*------- End of reading ---------------*/
  12561. return temptransactionId;
  12562. }
  12563. void SetTransactionIdZero(int transactionId)
  12564. {
  12565. char ch;
  12566. FILE *fptr1, *fptr2;
  12567. int temptransactionId = 0;
  12568. char str[100]={0}, strtemp[100]={0}, temp[] = "/Storage/OCPP/QueueTransactionIdtemp.json";
  12569. fptr1 = fopen("/Storage/OCPP/QueueTransactionId", "r");
  12570. if (!fptr1)
  12571. {
  12572. //printf(" File not found or unable to open the input file!!\n");
  12573. return ;
  12574. }
  12575. fptr2 = fopen(temp, "w"); // open the temporary file in write mode
  12576. if (!fptr2)
  12577. {
  12578. DEBUG_INFO("Unable to open a temporary file to write!!\n");
  12579. fclose(fptr1);
  12580. return ;
  12581. }
  12582. ch=fgetc(fptr1);
  12583. rewind(fptr1);
  12584. if(ch!=EOF)
  12585. {
  12586. // copy all contents to the temporary file except the specific line
  12587. while (fgets(str, 100, fptr1) != NULL)
  12588. {
  12589. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  12590. if(str[0]=='\0')
  12591. {
  12592. break;
  12593. }
  12594. char *revbuf[8] = {0};
  12595. int num = 0;
  12596. strcpy(strtemp, str);
  12597. splitstring(str,",",revbuf,&num);
  12598. if(revbuf[2][0] != '\0')
  12599. {
  12600. temptransactionId = atoi(revbuf[2]);
  12601. if(transactionId != temptransactionId)
  12602. {
  12603. fprintf(fptr2, "%s\n", strtemp);
  12604. }
  12605. }
  12606. }
  12607. }
  12608. fclose(fptr1);
  12609. fclose(fptr2);
  12610. remove("/Storage/OCPP/QueueTransactionId"); // remove the original file
  12611. rename(temp, "/Storage/OCPP/QueueTransactionId"); // rename the temporary file to original name
  12612. /*------ Read the file ----------------*/
  12613. }
  12614. int InternetDisconnect(void)
  12615. {
  12616. return (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi && ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet && ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi );
  12617. }
  12618. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  12619. void storeTempStopTransaction(int gun_index)
  12620. {
  12621. }
  12622. void checkTempStopTransaction(int gun_index)
  12623. {
  12624. FILE *fptr1;
  12625. char ch;
  12626. char str[QUEUE_MESSAGE_LENGTH]={0};
  12627. char guid[37]={0};
  12628. char tempdata[65]={0};
  12629. char connectorStr[2]={0};
  12630. char TempStopTransaction[256];
  12631. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  12632. fptr1 = fopen(TempStopTransaction, "r");
  12633. //TempStopTransaction格式: 槍號,StopTransaction封包
  12634. if (!fptr1)
  12635. {
  12636. //printf(" File not found or unable to open the input file!!\n");
  12637. return ;
  12638. }
  12639. ch=fgetc(fptr1);
  12640. //printf(" Now the content of the file %s is : \n",fname);
  12641. rewind(fptr1);
  12642. if(ch!=EOF)
  12643. {
  12644. // copy all contents to the temporary file except the specific line
  12645. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  12646. {
  12647. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  12648. if(str[0]=='\0')
  12649. {
  12650. break;
  12651. }
  12652. //TempStopTransaction格式: 槍號,StopTransaction封包
  12653. strncpy(connectorStr, str, 1);
  12654. if(atoi(connectorStr) != (gun_index+1))
  12655. {
  12656. DEBUG_INFO("atoi(connectorStr) = %d, gun_index = %d\n", atoi(connectorStr), gun_index);
  12657. fclose(fptr1);
  12658. return ;
  12659. }
  12660. //random_uuid(guid);
  12661. strncpy(guid, str+6, 36); //copy guid
  12662. sprintf(tempdata, "StopTransaction,%d", (gun_index));
  12663. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  12664. {
  12665. //DEBUG_INFO("StopTransaction mapitem pass\n");
  12666. }
  12667. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  12668. memset(str,0,ARRAY_SIZE(str));
  12669. }
  12670. }
  12671. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  12672. fclose(fptr1);
  12673. remove(TempStopTransaction); // remove the original file
  12674. }
  12675. void FillStartTransaction(int ConnectorId, unsigned char IdTag[], int MeterStart,int ReservationId,unsigned char Timestamp[])
  12676. {
  12677. ShmOCPP20Data->TransactionEvent[ConnectorId-1].evse.connectorId = ConnectorId;
  12678. ShmOCPP20Data->TransactionEvent[ConnectorId-1].reservationId = ReservationId;
  12679. //ShmOCPP20Data->TransactionEvent[ConnectorId-1].MeterStart = MeterStart;
  12680. strcpy((char *)ShmOCPP20Data->TransactionEvent[ConnectorId-1].idToken.idToken, (char *)IdTag);
  12681. strcpy((char *)ShmOCPP20Data->TransactionEvent[ConnectorId-1].timestamp,(char *) Timestamp);
  12682. }
  12683. int GetWebSocketPingInterval(void)
  12684. {
  12685. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  12686. }
  12687. int GetServerSign(void)
  12688. {
  12689. return server_sign;
  12690. }
  12691. uint8_t GetOcppSecurityProfile()
  12692. {
  12693. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  12694. }
  12695. void GetOcppChargerBoxId(uint8_t *data)
  12696. {
  12697. sprintf((char*)data, "%s", ShmOCPP20Data->ChargeBoxId);
  12698. }
  12699. void GetOcppSecurityPassword(uint8_t *data)
  12700. {
  12701. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  12702. }
  12703. void SetServerSign(int value)
  12704. {
  12705. server_sign = value;
  12706. }
  12707. int GetBootNotificationInterval(void)
  12708. {
  12709. return BootNotificationInterval;
  12710. }
  12711. int GetInternetConn(void)
  12712. {
  12713. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  12714. }
  12715. void InitialSystemValue(void)
  12716. {
  12717. int connectorIndex = 0;
  12718. gunTotalNumber=0;
  12719. SystemInitial = 0;
  12720. localversion=0;
  12721. BootNotificationInterval = 0;
  12722. authorizeRetryTimes = 0;
  12723. GunStatusInterval = 10;
  12724. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  12725. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  12726. //Hear Beat
  12727. HeartBeatWithNOResponse = 0;
  12728. HeartBeatCountPerHour = 0;
  12729. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  12730. FirstHeartBeat = 0;
  12731. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  12732. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  12733. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  12734. memset(statusModeChage, 0, ARRAY_SIZE(statusModeChage));
  12735. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  12736. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  12737. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  12738. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  12739. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  12740. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  12741. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  12742. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  12743. memset(gunType, 0, ARRAY_SIZE(gunType));
  12744. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  12745. {
  12746. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O')
  12747. {
  12748. // DO series
  12749. for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
  12750. {
  12751. SystemInitial = SystemInitial + 1;
  12752. gunTotalNumber = gunTotalNumber + 1;
  12753. gunType[connectorIndex] = 'O';
  12754. connectorIndex = connectorIndex + 1;
  12755. }
  12756. }
  12757. else
  12758. {
  12759. // DM, DW, DS series
  12760. //check connector / socket type (index: 8, 9, 10)
  12761. for(int index=7; index <10 ; index++)
  12762. {
  12763. if(index != 8)
  12764. {
  12765. // DC Connector
  12766. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] >= 'A') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= 'Z'))
  12767. {
  12768. SystemInitial = SystemInitial + 1;
  12769. gunTotalNumber = gunTotalNumber + 1;
  12770. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  12771. connectorIndex = connectorIndex + 1;
  12772. }
  12773. }
  12774. else
  12775. {
  12776. // AC Connector
  12777. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  12778. {
  12779. SystemInitial = SystemInitial + 1;
  12780. gunTotalNumber = gunTotalNumber + 1;
  12781. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  12782. connectorIndex = connectorIndex + 1;
  12783. }
  12784. }
  12785. }
  12786. }
  12787. //DEBUG_INFO("DC ...\n");
  12788. }
  12789. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  12790. {
  12791. //check connector / socket type (index: 8, 9, 10)
  12792. for(int index=7; index <10 ; index++)
  12793. {
  12794. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  12795. {
  12796. SystemInitial = SystemInitial + 1;
  12797. gunTotalNumber = gunTotalNumber + 1;
  12798. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  12799. connectorIndex = connectorIndex + 1;
  12800. //DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
  12801. }
  12802. }
  12803. }
  12804. //Status && ConnectorPlugIn Setting
  12805. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12806. {
  12807. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  12808. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  12809. }
  12810. for (int index = 0; index < CCS_QUANTITY; index++)
  12811. {
  12812. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  12813. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  12814. }
  12815. for (int index = 0; index < GB_QUANTITY; index++)
  12816. {
  12817. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  12818. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  12819. }
  12820. for (int index = 0; index < AC_QUANTITY; index++)
  12821. {
  12822. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  12823. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  12824. }
  12825. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  12826. {
  12827. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  12828. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  12829. }
  12830. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  12831. {
  12832. cpinitateMsg.bits[gun_index].StatusNotificationReq = 0;
  12833. cpinitateMsg.bits[gun_index].StatusNotificationConf = 0;
  12834. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  12835. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  12836. }
  12837. clientTime.Heartbeat=time((time_t*)NULL);
  12838. sleep(1);
  12839. }
  12840. void LWS_Send(char * str)
  12841. {
  12842. //=====================================================
  12843. // Check InternetConn 0: disconnected, 1: connected
  12844. //====================================================
  12845. if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
  12846. {
  12847. DEBUG_INFO("offline now !!!\n");
  12848. return;
  12849. }
  12850. pthread_mutex_lock(&lock_send);
  12851. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  12852. sprintf((char *)SendBuffer, "%s", str);
  12853. SendBufLen = strlen(str);
  12854. pthread_mutex_unlock(&lock_send);
  12855. lws_callback_on_writable(wsi_client);
  12856. //lws_service(context, 0);
  12857. //sleep(1);
  12858. }
  12859. void LWS_SendNow(char * str)
  12860. {
  12861. //=====================================================
  12862. // Check InternetConn 0: disconnected, 1: connected
  12863. //====================================================
  12864. if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
  12865. {
  12866. DEBUG_INFO("offline now !!!\n");
  12867. return;
  12868. }
  12869. pthread_mutex_lock(&lock_send);
  12870. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  12871. sprintf((char *)SendBuffer, "%s", str);
  12872. SendBufLen = strlen(str);
  12873. pthread_mutex_unlock(&lock_send);
  12874. lws_callback_on_writable(wsi_client);
  12875. lws_service(context, 0);
  12876. //sleep(1);
  12877. }