MessageHandler.c 801 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913
  1. #include "Module_OcppBackend20.h"
  2. #include "define.h"
  3. static char *APNAuthenticationEnumTypeStr[] = {
  4. MACROSTR(CHAP),
  5. MACROSTR(NONE),
  6. MACROSTR(PAP),
  7. MACROSTR(AUTO)
  8. };
  9. static char *AttributeEnumTypeStr[] = {
  10. MACROSTR(Actual),
  11. MACROSTR(Target),
  12. MACROSTR(MinSet),
  13. MACROSTR(MaxSet)
  14. };
  15. static char *AuthorizationStatusEnumTypeStr[] = {
  16. MACROSTR(Accepted),
  17. MACROSTR(Blocked),
  18. MACROSTR(ConcurrentTx),
  19. MACROSTR(Expired),
  20. MACROSTR(Invalid),
  21. MACROSTR(NoCredit),
  22. MACROSTR(NotAllowedTypeEVSE),
  23. MACROSTR(NotAtThisLocation),
  24. MACROSTR(NotAtThisTime),
  25. MACROSTR(Unknown)
  26. };
  27. #if 0
  28. static char *AuthorizeCertificateStatusEnumTypeStr[] = {
  29. MACROSTR(Accepted),
  30. MACROSTR(SignatureError),
  31. MACROSTR(CertificateExpired),
  32. MACROSTR(CertificateRevoked),
  33. MACROSTR(NoCertificateAvailable),
  34. MACROSTR(CertChainError),
  35. MACROSTR(ContractCancelled)
  36. };
  37. #endif
  38. static char *BootReasonEnumTypeStr[] = {
  39. MACROSTR(ApplicationReset),
  40. MACROSTR(FirmwareUpdate),
  41. MACROSTR(LocalReset),
  42. MACROSTR(PowerUp),
  43. MACROSTR(RemoteReset),
  44. MACROSTR(ScheduledReset),
  45. MACROSTR(Triggered),
  46. MACROSTR(Unknown),
  47. MACROSTR(Watchdog)
  48. };
  49. static char *CancelReservationStatusEnumTypeStr[] = {
  50. MACROSTR(Accepted),
  51. MACROSTR(Rejected)
  52. };
  53. static char *CertificateActionEnumTypeStr[] = {
  54. MACROSTR(Install),
  55. MACROSTR(Update)
  56. };
  57. static char *CertificateSignedStatusEnumTypeStr[] = {
  58. MACROSTR(Accepted),
  59. MACROSTR(Rejected)
  60. };
  61. static char *CertificateSigningUseEnumTypeStr[] = {
  62. MACROSTR(ChargingStationCertificate),
  63. MACROSTR(V2GCertificate)
  64. };
  65. static char *ChangeAvailabilityStatusEnumTypeStr[] = {
  66. MACROSTR(Accepted),
  67. MACROSTR(Rejected),
  68. MACROSTR(Scheduled)
  69. };
  70. static char *ChargingLimitSourceEnumTypeStr[] = {
  71. MACROSTR(EMS),
  72. MACROSTR(Other),
  73. MACROSTR(SO),
  74. MACROSTR(CSO)
  75. };
  76. static char *ChargingProfileKindEnumTypeStr[] = {
  77. MACROSTR(Absolute),
  78. MACROSTR(Recurring),
  79. MACROSTR(Relative)
  80. };
  81. static char *ChargingProfilePurposeEnumTypeStr[] = {
  82. MACROSTR(ChargingStationExternalConstraints),
  83. MACROSTR(ChargingStationMaxProfile),
  84. MACROSTR(TxDefaultProfile),
  85. MACROSTR(TxProfile)
  86. };
  87. static char *ChargingProfileStatusEnumTypeStr[] = {
  88. MACROSTR(Accepted),
  89. MACROSTR(Rejected)
  90. };
  91. static char *ChargingRateUnitEnumTypeStr[] = {
  92. MACROSTR(W),
  93. MACROSTR(A)
  94. };
  95. static char *ChargingStateEnumTypeStr[] = {
  96. MACROSTR(Charging),
  97. MACROSTR(EVConnected),
  98. MACROSTR(SuspendedEV),
  99. MACROSTR(SuspendedEVSE),
  100. MACROSTR(Idle)
  101. };
  102. static char *ClearCacheStatusEnumTypeStr[] = {
  103. MACROSTR(Accepted),
  104. MACROSTR(Rejected)
  105. };
  106. static char *ClearChargingProfileStatusEnumTypeStr[] = {
  107. MACROSTR(Accepted),
  108. MACROSTR(Unknown)
  109. };
  110. static char *ClearMessageStatusEnumTypeStr[] = {
  111. MACROSTR(Accepted),
  112. MACROSTR(Unknown)
  113. };
  114. static char *ClearMonitoringStatusEnumTypeStr[] = {
  115. MACROSTR(Accepted),
  116. MACROSTR(Rejected),
  117. MACROSTR(NotFound)
  118. };
  119. static char *ComponentCriterionEnumTypeStr[] = {
  120. MACROSTR(Active),
  121. MACROSTR(Available),
  122. MACROSTR(Enabled),
  123. MACROSTR(Problem)
  124. };
  125. static char *ConnectorEnumTypeStr[] = {
  126. MACROSTR(cCCS1),
  127. MACROSTR(cCCS2),
  128. MACROSTR(cG105),
  129. MACROSTR(cTesla),
  130. MACROSTR(cType1),
  131. MACROSTR(cType2),
  132. MACROSTR(s309-1P-16A),
  133. MACROSTR(s309-1P-32A),
  134. MACROSTR(s309-3P-16A),
  135. MACROSTR(s309-3P-32A),
  136. MACROSTR(sBS1361),
  137. MACROSTR(sCEE-7-7),
  138. MACROSTR(sType2),
  139. MACROSTR(sType3),
  140. MACROSTR(Other1PhMax16A),
  141. MACROSTR(Other1PhOver16A),
  142. MACROSTR(Other3Ph),
  143. MACROSTR(Pan),
  144. MACROSTR(wInductive),
  145. MACROSTR(wResonant),
  146. MACROSTR(Undetermined),
  147. MACROSTR(Unknown)
  148. };
  149. static char *ConnectorStatusEnumTypeStr[] = {
  150. MACROSTR(Available),
  151. MACROSTR(Occupied),
  152. MACROSTR(Reserved),
  153. MACROSTR(Unavailable),
  154. MACROSTR(Faulted)
  155. };
  156. static char *CostKindEnumTypeStr[] = {
  157. MACROSTR(CarbonDioxideEmission),
  158. MACROSTR(RelativePricePercentage),
  159. MACROSTR(RenewableGenerationPercentage)
  160. };
  161. static char *CustomerInformationStatusEnumTypeStr[] = {
  162. MACROSTR(Accepted),
  163. MACROSTR(Rejected),
  164. MACROSTR(Invalid)
  165. };
  166. static char *DataEnumTypeStr[] = {
  167. MACROSTR(string),
  168. MACROSTR(decimal),
  169. MACROSTR(integer),
  170. MACROSTR(dateTime),
  171. MACROSTR(boolean),
  172. MACROSTR(OptionList),
  173. MACROSTR(SequenceList),
  174. MACROSTR(MemberList)
  175. };
  176. static char *DataTransferStatusEnumTypeStr[] = {
  177. MACROSTR(Accepted),
  178. MACROSTR(Rejected),
  179. MACROSTR(UnknownMessageId),
  180. MACROSTR(UnknownVendorId)
  181. };
  182. static char *DeleteCertificateStatusEnumTypeStr[] = {
  183. MACROSTR(Accepted),
  184. MACROSTR(Failed),
  185. MACROSTR(NotFound)
  186. };
  187. static char *DisplayMessageStatusEnumTypeStr[] = {
  188. MACROSTR(Accepted),
  189. MACROSTR(NotSupportedMessageFormat),
  190. MACROSTR(Rejected),
  191. MACROSTR(NotSupportedPriority),
  192. MACROSTR(NotSupportedState),
  193. MACROSTR(UnknownTransaction)
  194. };
  195. static char *EnergyTransferModeEnumTypeStr[] = {
  196. MACROSTR(DC),
  197. MACROSTR(AC_single_phase),
  198. MACROSTR(AC_two_phase),
  199. MACROSTR(AC_three_phase)
  200. };
  201. static char *EventNotificationEnumTypeStr[] = {
  202. MACROSTR(HardWiredNotification),
  203. MACROSTR(HardWiredMonitor),
  204. MACROSTR(PreconfiguredMonitor),
  205. MACROSTR(CustomMonitor)
  206. };
  207. static char *EventTriggerEnumTypeStr[] = {
  208. MACROSTR(Alerting),
  209. MACROSTR(Delta),
  210. MACROSTR(Periodic)
  211. };
  212. static char *FirmwareStatusEnumTypeStr[] = {
  213. MACROSTR(Downloaded),
  214. MACROSTR(DownloadFailed),
  215. MACROSTR(Downloading),
  216. MACROSTR(DownloadScheduled),
  217. MACROSTR(DownloadPaused),
  218. MACROSTR(Idle),
  219. MACROSTR(InstallationFailed),
  220. MACROSTR(Installing),
  221. MACROSTR(Installed),
  222. MACROSTR(InstallRebooting),
  223. MACROSTR(InstallScheduled),
  224. MACROSTR(InstallVerificationFailed),
  225. MACROSTR(InvalidSignature),
  226. MACROSTR(SignatureVerified)
  227. };
  228. static char *GenericDeviceModelStatusEnumTypeStr[] = {
  229. MACROSTR(Accepted),
  230. MACROSTR(Rejected),
  231. MACROSTR(NotSupported),
  232. MACROSTR(EmptyResultSet)
  233. };
  234. static char *GenericStatusEnumTypeStr[] = {
  235. MACROSTR(Accepted),
  236. MACROSTR(Rejected)
  237. };
  238. static char *GetCertificateIdUseEnumTypeStr[] = {
  239. MACROSTR(V2GRootCertificate),
  240. MACROSTR(MORootCertificate),
  241. MACROSTR(CSMSRootCertificate),
  242. MACROSTR(V2GCertificateChain),
  243. MACROSTR(ManufacturerRootCertificate)
  244. };
  245. static char *GetCertificateStatusEnumTypeStr[] = {
  246. MACROSTR(Accepted),
  247. MACROSTR(Failed)
  248. };
  249. static char *GetChargingProfileStatusEnumTypeStr[] = {
  250. MACROSTR(Accepted),
  251. MACROSTR(NoProfiles)
  252. };
  253. static char *GetDisplayMessagesStatusEnumTypeStr[] = {
  254. MACROSTR(Accepted),
  255. MACROSTR(Unknown)
  256. };
  257. static char *GetInstalledCertificateStatusEnumTypeStr[] = {
  258. MACROSTR(Accepted),
  259. MACROSTR(NotFound)
  260. };
  261. static char *GetVariableStatusEnumTypeStr[] = {
  262. MACROSTR(Accepted),
  263. MACROSTR(Rejected),
  264. MACROSTR(UnknownComponent),
  265. MACROSTR(UnknownVariable),
  266. MACROSTR(NotSupportedAttributeType)
  267. };
  268. static char *HashAlgorithmEnumTypeStr[] = {
  269. MACROSTR(SHA256),
  270. MACROSTR(SHA384),
  271. MACROSTR(SHA512)
  272. };
  273. static char *IdTokenEnumTypeStr[] = {
  274. MACROSTR(Central),
  275. MACROSTR(eMAID),
  276. MACROSTR(ISO14443),
  277. MACROSTR(KeyCode),
  278. MACROSTR(Local),
  279. MACROSTR(NoAuthorization),
  280. MACROSTR(ISO15693)
  281. };
  282. static char *InstallCertificateUseEnumTypeStr[] = {
  283. MACROSTR(V2GRootCertificate),
  284. MACROSTR(MORootCertificate),
  285. MACROSTR(CSMSRootCertificate),
  286. MACROSTR(ManufacturerRootCertificate)
  287. };
  288. static char *InstallCertificateStatusEnumTypeStr[]={
  289. MACROSTR(Accepted),
  290. MACROSTR(Failed),
  291. MACROSTR(Rejected)
  292. };
  293. static char *Iso15118EVCertificateStatusEnumTypeStr[] = {
  294. MACROSTR(Accepted),
  295. MACROSTR(Failed)
  296. };
  297. static char *LocationEnumTypeStr[] = {
  298. MACROSTR(Body),
  299. MACROSTR(Cable),
  300. MACROSTR(EV),
  301. MACROSTR(Inlet),
  302. MACROSTR(Outlet)
  303. };
  304. static char *LogEnumTypeStr[] = {
  305. MACROSTR(DiagnosticsLog),
  306. MACROSTR(SecurityLog)
  307. };
  308. static char *LogStatusEnumTypeStr[] = {
  309. MACROSTR(Accepted),
  310. MACROSTR(Rejected),
  311. MACROSTR(AcceptedCanceled)
  312. };
  313. static char *MeasurandEnumTypeStr[] = {
  314. MACROSTR(Current.Export),
  315. MACROSTR(Current.Import),
  316. MACROSTR(Current.Offered),
  317. MACROSTR(Energy.Active.Export.Register),
  318. MACROSTR(Energy.Active.Import.Register),
  319. MACROSTR(Energy.Reactive.Export.Register),
  320. MACROSTR(Energy.Reactive.Import.Register),
  321. MACROSTR(Energy.Active.Export.Interval),
  322. MACROSTR(Energy.Active.Import.Interval),
  323. MACROSTR(Energy.Active.Net),
  324. MACROSTR(Energy.Reactive.Export.Interval),
  325. MACROSTR(Energy.Reactive.Import.Interval),
  326. MACROSTR(Energy.Reactive.Net),
  327. MACROSTR(Energy.Apparent.Net),
  328. MACROSTR(Energy.Apparent.Import),
  329. MACROSTR(Energy.Apparent.Export),
  330. MACROSTR(Frequency),
  331. MACROSTR(Power.Active.Export),
  332. MACROSTR(Power.Active.Import),
  333. MACROSTR(Power.Factor),
  334. MACROSTR(Power.Offered),
  335. MACROSTR(Power.Reactive.Export),
  336. MACROSTR(Power.Reactive.Import),
  337. MACROSTR(SoC),
  338. MACROSTR(Voltage)
  339. };
  340. static char *MessageFormatEnumTypeStr[] = {
  341. MACROSTR(ASCII),
  342. MACROSTR(HTML),
  343. MACROSTR(URI),
  344. MACROSTR(UTF8)
  345. };
  346. static char *MessagePriorityEnumTypeStr[] = {
  347. MACROSTR(AlwaysFront),
  348. MACROSTR(InFront),
  349. MACROSTR(NormalCycle)
  350. };
  351. static char *MessageStateEnumTypeStr[] = {
  352. MACROSTR(Charging),
  353. MACROSTR(Faulted),
  354. MACROSTR(Idle),
  355. MACROSTR(Unavailable)
  356. };
  357. static char *MessageTriggerEnumTypeStr[] = {
  358. MACROSTR(BootNotification),
  359. MACROSTR(LogStatusNotification),
  360. MACROSTR(FirmwareStatusNotification),
  361. MACROSTR(Heartbeat),
  362. MACROSTR(MeterValues),
  363. MACROSTR(SignChargingStationCertificate),
  364. MACROSTR(SignV2GCertificate),
  365. MACROSTR(StatusNotification),
  366. MACROSTR(TransactionEvent),
  367. MACROSTR(SignCombinedCertificate),
  368. MACROSTR(PublishFirmwareStatusNotification)
  369. };
  370. static char *MonitorEnumTypeStr[] = {
  371. MACROSTR(UpperThreshold),
  372. MACROSTR(LowerThreshold),
  373. MACROSTR(Delta),
  374. MACROSTR(Periodic),
  375. MACROSTR(PeriodicClockAligned)
  376. };
  377. static char *MonitoringBaseEnumTypeStr[] = {
  378. MACROSTR(All),
  379. MACROSTR(FactoryDefault),
  380. MACROSTR(HardWiredOnly)
  381. };
  382. static char *MonitoringCriterionEnumTypeStr[] = {
  383. MACROSTR(ThresholdMonitoring),
  384. MACROSTR(DeltaMonitoring),
  385. MACROSTR(PeriodicMonitoring)
  386. };
  387. static char *MutabilityEnumTypeStr[] = {
  388. MACROSTR(ReadOnly),
  389. MACROSTR(WriteOnly),
  390. MACROSTR(ReadWrite)
  391. };
  392. static char *NotifyEVChargingNeedsStatusEnumTypeStr[] = {
  393. MACROSTR(Accepted),
  394. MACROSTR(Rejected),
  395. MACROSTR(Processing)
  396. };
  397. static char *OCPPInterfaceEnumTypeStr[] = {
  398. MACROSTR(Wired0),
  399. MACROSTR(Wired1),
  400. MACROSTR(Wired2),
  401. MACROSTR(Wired3),
  402. MACROSTR(Wireless0),
  403. MACROSTR(Wireless1),
  404. MACROSTR(Wireless2),
  405. MACROSTR(Wireless3)
  406. };
  407. static char *OCPPTransportEnumTypeStr[] = {
  408. MACROSTR(JSON),
  409. MACROSTR(SOAP)
  410. };
  411. static char *OCPPVersionEnumTypeStr[] = {
  412. MACROSTR(OCPP12),
  413. MACROSTR(OCPP15),
  414. MACROSTR(OCPP16),
  415. MACROSTR(OCPP20)
  416. };
  417. static char *OperationalStatusEnumTypeStr[] = {
  418. MACROSTR(Inoperative),
  419. MACROSTR(Operative)
  420. };
  421. static char *PhaseEnumTypeStr[] = {
  422. MACROSTR(L1),
  423. MACROSTR(L2),
  424. MACROSTR(L3),
  425. MACROSTR(N),
  426. MACROSTR(L1-N),
  427. MACROSTR(L2-N),
  428. MACROSTR(L3-N),
  429. MACROSTR(L1-L2),
  430. MACROSTR(L2-L3),
  431. MACROSTR(L3-L1)
  432. };
  433. static char *PublishFirmwareStatusEnumTypeStr[] = {
  434. MACROSTR(Downloaded),
  435. MACROSTR(DownloadFailed),
  436. MACROSTR(Downloading),
  437. MACROSTR(DownloadScheduled),
  438. MACROSTR(DownloadPaused),
  439. MACROSTR(PublishFailed),
  440. MACROSTR(Published),
  441. MACROSTR(InvalidChecksum),
  442. MACROSTR(ChecksumVerified)
  443. };
  444. static char *ReadingContextEnumTypeStr[] = {
  445. MACROSTR(Interruption.Begin),
  446. MACROSTR(Interruption.End),
  447. MACROSTR(Other),
  448. MACROSTR(Sample.Clock),
  449. MACROSTR(Sample.Periodic),
  450. MACROSTR(Transaction.Begin),
  451. MACROSTR(Transaction.End),
  452. MACROSTR(Trigger)
  453. };
  454. #if 0
  455. static char *ReasonEnumTypeStr[] = {
  456. MACROSTR(DeAuthorized),
  457. MACROSTR(EmergencyStop),
  458. MACROSTR(EnergyLimitReached),
  459. MACROSTR(EVDisconnected),
  460. MACROSTR(GroundFault),
  461. MACROSTR(ImmediateReset),
  462. MACROSTR(Local),
  463. MACROSTR(LocalOutOfCredit),
  464. MACROSTR(MasterPass),
  465. MACROSTR(Other),
  466. MACROSTR(OvercurrentFault),
  467. MACROSTR(PowerLoss),
  468. MACROSTR(PowerQuality),
  469. MACROSTR(Reboot),
  470. MACROSTR(Remote),
  471. MACROSTR(SOCLimitReached),
  472. MACROSTR(StoppedByEV),
  473. MACROSTR(TimeLimitReached),
  474. MACROSTR(TimeLimitReached)
  475. };
  476. #endif
  477. static char *RecurrencyKindEnumTypeStr[] = {
  478. MACROSTR(Daily),
  479. MACROSTR(Weekly)
  480. };
  481. static char *RegistrationStatusEnumTypeStr[] = {
  482. MACROSTR(Accepted),
  483. MACROSTR(Pending),
  484. MACROSTR(Rejected)
  485. };
  486. static char *ReportBaseEnumTypeStr[] = {
  487. MACROSTR(ConfigurationInventory),
  488. MACROSTR(FullInventory),
  489. MACROSTR(SummaryInventory)
  490. };
  491. static char *RequestStartStopStatusEnumTypeStr[] = {
  492. MACROSTR(Accepted),
  493. MACROSTR(Rejected)
  494. };
  495. static char *ReservationUpdateStatusEnumTypeStr[] = {
  496. MACROSTR(Expired),
  497. MACROSTR(Removed)
  498. };
  499. static char *ReserveNowStatusEnumTypeStr[] = {
  500. MACROSTR(Accepted),
  501. MACROSTR(Faulted),
  502. MACROSTR(Occupied),
  503. MACROSTR(Rejected),
  504. MACROSTR(Unavailable)
  505. };
  506. static char *ResetEnumTypeStr[] = {
  507. MACROSTR(Immediate),
  508. MACROSTR(OnIdle)
  509. };
  510. static char *ResetStatusEnumTypeStr[] = {
  511. MACROSTR(Accepted),
  512. MACROSTR(Rejected),
  513. MACROSTR(Scheduled)
  514. };
  515. static char *SetMonitoringStatusEnumTypeStr[] = {
  516. MACROSTR(Accepted),
  517. MACROSTR(UnknownComponent),
  518. MACROSTR(UnknownVariable),
  519. MACROSTR(UnsupportedMonitorType),
  520. MACROSTR(Rejected),
  521. MACROSTR(OutOfRange),
  522. MACROSTR(Duplicate)
  523. };
  524. static char *SetNetworkProfileStatusEnumTypeStr[] = {
  525. MACROSTR(Accepted),
  526. MACROSTR(Rejected),
  527. MACROSTR(Failed)
  528. };
  529. static char *SetVariableStatusEnumTypeStr[] = {
  530. MACROSTR(Accepted),
  531. MACROSTR(Rejected),
  532. MACROSTR(InvalidValue),
  533. MACROSTR(UnknownComponent),
  534. MACROSTR(UnknownVariable),
  535. MACROSTR(NotSupportedAttributeType),
  536. MACROSTR(OutOfRange),
  537. MACROSTR(RebootRequired)
  538. };
  539. static char *TransactionEventEnumTypeStr[] = {
  540. MACROSTR(Ended),
  541. MACROSTR(Started),
  542. MACROSTR(Updated)
  543. };
  544. static char *TriggerMessageStatusEnumTypeStr[] = {
  545. MACROSTR(Accepted),
  546. MACROSTR(Rejected),
  547. MACROSTR(NotImplemented)
  548. };
  549. static char *TriggerReasonEnumTypeStr[] = {
  550. MACROSTR(Authorized),
  551. MACROSTR(CablePluggedIn),
  552. MACROSTR(ChargingRateChanged),
  553. MACROSTR(ChargingStateChanged),
  554. MACROSTR(Deauthorized),
  555. MACROSTR(EnergyLimitReached),
  556. MACROSTR(EVCommunicationLost),
  557. MACROSTR(EVConnectTimeout),
  558. MACROSTR(MeterValueClock),
  559. MACROSTR(MeterValuePeriodic),
  560. MACROSTR(TimeLimitReached),
  561. MACROSTR(Trigger),
  562. MACROSTR(UnlockCommand),
  563. MACROSTR(StopAuthorized),
  564. MACROSTR(EVDeparted),
  565. MACROSTR(EVDetected),
  566. MACROSTR(RemoteStop),
  567. MACROSTR(RemoteStart),
  568. MACROSTR(AbnormalCondition),
  569. MACROSTR(SignedDataReceived),
  570. MACROSTR(ResetCommand)
  571. };
  572. static char *UnlockStatusEnumTypeStr[] = {
  573. MACROSTR(Unlocked),
  574. MACROSTR(UnlockFailed),
  575. MACROSTR(OngoingAuthorizedTransaction),
  576. MACROSTR(UnknownConnector)
  577. };
  578. static char *UnpublishFirmwareStatusEnumTypeStr[] = {
  579. MACROSTR(DownloadOngoing),
  580. MACROSTR(NoFirmware),
  581. MACROSTR(Unpublished)
  582. };
  583. static char *UpdateEnumTypeStr[] = {
  584. MACROSTR(Differential),
  585. MACROSTR(Full)
  586. };
  587. static char *UpdateFirmwareStatusEnumTypeStr[] = {
  588. MACROSTR(Accepted),
  589. MACROSTR(Rejected),
  590. MACROSTR(AcceptedCanceled),
  591. MACROSTR(InvalidCertificate),
  592. MACROSTR(RevokedCertificate)
  593. };
  594. static char *UpdateStatusEnumTypeStr[] = {
  595. MACROSTR(Accepted),
  596. MACROSTR(Failed),
  597. MACROSTR(VersionMismatch)
  598. };
  599. static char *UploadLogStatusEnumTypeStr[] = {
  600. MACROSTR(BadMessage),
  601. MACROSTR(Idle),
  602. MACROSTR(NotSupportedOperation),
  603. MACROSTR(PermissionDenied),
  604. MACROSTR(Uploaded),
  605. MACROSTR(UploadFailure),
  606. MACROSTR(Uploading)
  607. };
  608. static char *VPNEnumTypeStr[] = {
  609. MACROSTR(IKEv2),
  610. MACROSTR(IPSec),
  611. MACROSTR(L2TP),
  612. MACROSTR(PPTP)
  613. };
  614. #if 0
  615. static char *ChargePointErrorCodeEnumTypeStr[] = {
  616. MACROSTR(ConnectorLockFailure),
  617. MACROSTR(EVCommunicationError),
  618. MACROSTR(GroundFailure),
  619. MACROSTR(HighTemperature),
  620. MACROSTR(InternalError),
  621. MACROSTR(LocalListConflict),
  622. MACROSTR(NoError),
  623. MACROSTR(OtherError),
  624. MACROSTR(OverCurrentFailure),
  625. MACROSTR(OverVoltage),
  626. MACROSTR(PowerMeterFailure),
  627. MACROSTR(PowerSwitchFailure),
  628. MACROSTR(ReaderFailure),
  629. MACROSTR(ResetFailure),
  630. MACROSTR(UnderVoltage),
  631. MACROSTR(WeakSignal)
  632. };
  633. #endif
  634. static char *GetCompositeScheduleStatusEnumTypeStr[] = {
  635. MACROSTR(Accepted),
  636. MACROSTR(Rejected)
  637. };
  638. static char *RemoteStartStopStatusEnumTypeStr[] = {
  639. MACROSTR(Accepted),
  640. MACROSTR(Rejected)
  641. };
  642. #if 0
  643. static char * StopTransactionReasonEnumTypeStr[] = {
  644. MACROSTR(EmergencyStop),
  645. MACROSTR(EVDisconnected),
  646. MACROSTR(HardReset),
  647. MACROSTR(Local),
  648. MACROSTR(Other),
  649. MACROSTR(PowerLoss),
  650. MACROSTR(Reboot),
  651. MACROSTR(Remote),
  652. MACROSTR(SoftReset),
  653. MACROSTR(UnlockCommand),
  654. MACROSTR(DeAuthorized)
  655. };
  656. #endif
  657. //ChargePointMaxProfile
  658. #define ChargePointMaxProfile_JSON "/Storage/OCPP/ChargePointMaxProfile_OCPP20.json"
  659. //TxDefaultProfile
  660. #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0_OCPP20.json"
  661. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  662. struct StatusCodeData *ShmStatusCodeData;
  663. struct PsuData *ShmPsuData ;
  664. struct OCPP20Data *ShmOCPP20Data;
  665. pthread_mutex_t lock_send = PTHREAD_MUTEX_INITIALIZER;
  666. char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
  667. //===============================
  668. // Gun Total Numbers
  669. //===============================
  670. static int gunTotalNumber = 0;
  671. static uint8_t gunType[4] = {0};
  672. //===============================
  673. // Local List Version
  674. //===============================
  675. static int localversion=0;
  676. //===============================
  677. // OCPP sign variable
  678. //===============================
  679. static int server_sign = FALSE;
  680. int server_pending = FALSE;
  681. static int BootNotificationInterval = 10;
  682. static int SystemInitial = 0;//= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; // System Boot UP
  683. //===============================
  684. // OCPP auth variable
  685. //===============================
  686. static int authorizeRetryTimes = 0; //number of Retry times
  687. //===============================
  688. // OCPP other variables
  689. //===============================
  690. static int HeartBeatWaitTime = 10;
  691. static int FirstHeartBeat = 0;
  692. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  693. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  694. static char CurrentChargingProfileScheduleStr[30] = {0};
  695. //========================================
  696. // OCPP status/previous related variables
  697. //========================================
  698. static int GunStatusInterval = 10;
  699. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  700. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  701. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  702. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  703. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  704. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  705. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  706. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  707. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  708. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  709. static int TransactionMessageAttemptsValue = 0;
  710. static int TransactionMessageRetryIntervalValue = 0;
  711. static int TempMeterValueInterval = 0;
  712. static struct AuthorizationData idTagQuery;
  713. //=============================================
  714. // OCPP HeartBeat Response Not Receive Counts
  715. //============================================
  716. static int HeartBeatWithNOResponse = 0;
  717. static int HeartBeatCountPerHour = 0;
  718. sqlite3 *db;
  719. int TransactionMessageAttemptsGet(void);
  720. int TransactionMessageRetryIntervalGet(void);
  721. int GetOcppConnStatus(void);
  722. void SetOcppConnStatus(uint8_t status);
  723. int setKeyValue(char *key, char *value);
  724. void OCPP_get_TableAuthlocalAllData(void);
  725. void processUnkownKey(void);
  726. struct StructOCPPMeterValue
  727. {
  728. unsigned char TimeStamp[28];
  729. struct StructSampledValue SampledValue[10];
  730. };
  731. struct ClientTime
  732. {
  733. unsigned int Heartbeat;
  734. unsigned int StatusNotification[CONNECTOR_QUANTITY];
  735. unsigned int StartTransaction;
  736. unsigned int StopTransaction;
  737. unsigned int MeterValues[CONNECTOR_QUANTITY];
  738. }clientTime;
  739. typedef union
  740. {
  741. //Operations Initiated by Central System
  742. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  743. struct
  744. {
  745. //CsMsgValue[0]
  746. unsigned char StatusNotificationReq:1; //bit 0,
  747. unsigned char StatusNotificationConf:1; //bit 1,
  748. unsigned char TriggerMeterValueReq:1; //bit 2,
  749. unsigned char TransactionEventReq:1; //bit 3,
  750. unsigned char SampleMeterReq:1; //bit 4,
  751. unsigned char ClockAlignMeterReq:1; //bit 5,
  752. unsigned char :2;
  753. }bits[CONNECTOR_QUANTITY];
  754. }CpinitiateMsg;
  755. CpinitiateMsg cpinitateMsg;
  756. //=========================================
  757. // Date time related function
  758. //=========================================
  759. void getNowDatetime(uint8_t *data)
  760. {
  761. time_t t = time(NULL);
  762. struct tm tm = *localtime(&t);
  763. sprintf((char*)data, "%04d-%02d-%02dT%02d:%02d:%02dZ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  764. }
  765. //=========================================
  766. // Sqlite3 related function
  767. //=========================================
  768. int DB_Initial()
  769. {
  770. int result = PASS;
  771. char* errMsg = NULL;
  772. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  773. "idToken text UNIQUE,"
  774. "type text,"
  775. "status text,"
  776. "cacheExpiryDateTime text,"
  777. "chargingPriority integer,"
  778. "language1 text,"
  779. "evseId text,"
  780. "language2 text,"
  781. "groupIdToken_idToken text,"
  782. "groupIdToken_type text,"
  783. "personalMessage text);";
  784. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  785. "idToken text UNIQUE,"
  786. "type text,"
  787. "status text,"
  788. "cacheExpiryDateTime text,"
  789. "chargingPriority integer,"
  790. "language1 text,"
  791. "evseId text,"
  792. "language2 text,"
  793. "groupIdToken_idToken text,"
  794. "groupIdToken_type text,"
  795. "personalMessage text,"
  796. "version text);";
  797. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  798. "componentName text NOT NULL ,"
  799. "componentInstance text, "
  800. "variableName text NOT NULL, "
  801. "variableInstance text, "
  802. "variableCharacteristicsDataType integer, "
  803. "variableCharacteristicsUnit text, "
  804. "variableCharacteristicsMaxLimit real,"
  805. "variableAttributesType text, "
  806. "variableAttributesTypeMutability text, "
  807. "variableAttributesTypeValue text, "
  808. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  809. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  810. "type text);";
  811. char *sqlNetworkProfile = "create table if not exists ocpp20_networkprofile (idx integer primary key,"
  812. "slot integer UNIQUE, connectionData text);";
  813. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  814. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  815. {
  816. result = FAIL;
  817. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  818. sqlite3_close(db);
  819. }
  820. else
  821. {
  822. DEBUG_INFO( "OCPP local database open successfully.\n");
  823. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  824. {
  825. result = FAIL;
  826. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  827. }
  828. else
  829. {
  830. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  831. }
  832. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  833. {
  834. result = FAIL;
  835. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  836. }
  837. else
  838. {
  839. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  840. }
  841. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  842. {
  843. result = FAIL;
  844. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  845. }
  846. else
  847. {
  848. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  849. }
  850. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  851. {
  852. result = FAIL;
  853. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  854. }
  855. else
  856. {
  857. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  858. }
  859. if (sqlite3_exec(db, sqlNetworkProfile, 0, 0, &errMsg) != SQLITE_OK)
  860. {
  861. result = FAIL;
  862. DEBUG_ERROR( "Create OCPP 2.0 ocpp20_networkprofile table error message: %s\n", errMsg);
  863. }
  864. else
  865. {
  866. DEBUG_INFO( "Create OCPP 2.0 ocpp20_networkprofile table successfully\n");
  867. }
  868. //sqlite3_close(db);
  869. }
  870. return result;
  871. }
  872. int DB_cbGetVersion(void *para, int columnCount, char **columnValue, char **columnName)
  873. {
  874. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  875. return 0;
  876. }
  877. void DB_getListVerion()
  878. {
  879. char sql[256];
  880. char* errMsg = NULL;
  881. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  882. /* Execute SQL statement */
  883. if( sqlite3_exec(db, sql, DB_cbGetVersion, 0, &errMsg) != SQLITE_OK )
  884. {
  885. DEBUG_INFO("SQL error: %s", errMsg);
  886. }
  887. }
  888. int DB_cbGetIdTag(void *para, int columnCount, char **columnValue, char **columnName)
  889. {
  890. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  891. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  892. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  893. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  894. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  895. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  896. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  897. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  898. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  899. return 0;
  900. }
  901. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  902. {
  903. char sql[256];
  904. char* errMsg = NULL;
  905. memset(&idTagQuery, 0, sizeof(idTagQuery));
  906. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  907. if(isQueryFromCache)
  908. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  909. else
  910. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  911. /* Execute SQL statement */
  912. if(sqlite3_exec(db, sql, DB_cbGetIdTag, 0, &errMsg) != SQLITE_OK )
  913. {
  914. DEBUG_INFO("SQL error: %s", errMsg);
  915. }
  916. }
  917. int DB_cbTableAuthlocalAllData(void *para, int columnCount, char **columnValue, char **columnName)
  918. {
  919. for (int i = 0; i < columnCount; i++)
  920. {
  921. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  922. }
  923. return 0;
  924. }
  925. void DB_get_TableAuthlocalAllData(void)
  926. {
  927. char sql[256];
  928. char* errMsg = NULL;
  929. sprintf(sql,"select * from ocpp20_auth_local;");
  930. /* Execute SQL statement */
  931. if(sqlite3_exec(db, sql, DB_cbTableAuthlocalAllData, 0,&errMsg) != SQLITE_OK)
  932. {
  933. DEBUG_INFO("SQL error: %s", errMsg);
  934. }
  935. }
  936. int DB_cbAddLocalListCache(void *para, int columnCount, char **columnValue, char **columnName)
  937. {
  938. for(int i = 0; i<columnCount; i++)
  939. {
  940. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  941. }
  942. return 0;
  943. }
  944. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  945. {
  946. int result = PASS;
  947. char sql[512];
  948. char* errMsg = NULL;
  949. sprintf(sql,"insert or replace into ocpp20_auth_local (idToken, type, status, cacheExpiryDateTime, chargingPriority, language1, language2, groupIdToken_idToken, groupIdToken_type, version) VALUES('%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', %d ); SELECT * from ocpp20_auth_local;",
  950. data->idToken.idToken,
  951. data->idToken.type,
  952. data->idTokenInfo.status,
  953. data->idTokenInfo.cacheExpiryDateTime,
  954. data->idTokenInfo.chargingPriority,
  955. data->idTokenInfo.language1,
  956. data->idTokenInfo.language2,
  957. data->idTokenInfo.groupIdToken.idToken,
  958. data->idTokenInfo.groupIdToken.type,
  959. listVersion);
  960. //* Execute SQL statement */
  961. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  962. {
  963. DEBUG_INFO("SQL error: %s\n", errMsg);
  964. result = FAIL;
  965. }
  966. else
  967. {
  968. memset(sql, 0, ARRAY_SIZE(sql));
  969. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  970. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  971. {
  972. DEBUG_INFO("SQL error: %s\n", errMsg);
  973. result = FAIL;
  974. }
  975. }
  976. return result;
  977. }
  978. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  979. {
  980. int result = PASS;
  981. char sql[512];
  982. char* errMsg = NULL;
  983. sprintf(sql,"insert or replace into ocpp20_auth_cache (idToken, type, status, cacheExpiryDateTime, chargingPriority, language1, language2, groupIdToken_idToken, groupIdToken_type) VALUES('%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s'); SELECT * from ocpp20_auth_cache;",
  984. idToken->idToken,
  985. idToken->type,
  986. idTokenInfo->status,
  987. idTokenInfo->cacheExpiryDateTime,
  988. idTokenInfo->chargingPriority,
  989. idTokenInfo->language1,
  990. idTokenInfo->language2,
  991. idTokenInfo->groupIdToken.idToken,
  992. idTokenInfo->groupIdToken.type);
  993. //* Execute SQL statement */
  994. if(sqlite3_exec(db, sql, DB_cbAddLocalListCache, 0, &errMsg) != SQLITE_OK)
  995. {
  996. DEBUG_INFO("SQL error: %s\n", errMsg);
  997. result = FAIL;
  998. }
  999. return result;
  1000. }
  1001. int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  1002. {
  1003. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  1004. // printf("localversion=%d\n", localversion);
  1005. return 0;
  1006. }
  1007. void DB_deleteIdTag(char idTag[])
  1008. {
  1009. char sql[512];
  1010. char* errMsg = NULL;
  1011. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1012. //* Execute SQL statement */
  1013. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1014. {
  1015. DEBUG_INFO("SQL error: %s", errMsg);
  1016. }
  1017. }
  1018. int DB_cleanLocalList()
  1019. {
  1020. int result = PASS;
  1021. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1022. char *errMsg = 0;
  1023. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1024. {
  1025. DEBUG_INFO("%s\n", errMsg);
  1026. result = FAIL;
  1027. }
  1028. return result;
  1029. }
  1030. int DB_cleanLocalCache()
  1031. {
  1032. int result = PASS;
  1033. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1034. char *errMsg = 0;
  1035. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1036. {
  1037. DEBUG_INFO("%s\n", errMsg);
  1038. result = FAIL;
  1039. }
  1040. return result;
  1041. }
  1042. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1043. {
  1044. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1045. return 0;
  1046. }
  1047. void DB_getBooType()
  1048. {
  1049. char sql[256];
  1050. char* errMsg = NULL;
  1051. sprintf(sql,"select * from ocpp20_boot_type;");
  1052. /* Execute SQL statement */
  1053. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1054. {
  1055. DEBUG_INFO("SQL error: %s\n", errMsg);
  1056. }
  1057. }
  1058. int DB_cbUpdateBootType(void *para, int columnCount, char **columnValue, char **columnName)
  1059. {
  1060. for(int i = 0; i<columnCount; i++)
  1061. {
  1062. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1063. }
  1064. return 0;
  1065. }
  1066. int DB_updateBootType(BootReasonEnumType reason)
  1067. {
  1068. int result = PASS;
  1069. char sql[512];
  1070. char* errMsg = NULL;
  1071. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1072. //* Execute SQL statement */
  1073. if(sqlite3_exec(db, sql, DB_cbUpdateBootType, 0, &errMsg) != SQLITE_OK)
  1074. {
  1075. DEBUG_INFO("SQL error: %s\n", errMsg);
  1076. result = FAIL;
  1077. }
  1078. return result;
  1079. }
  1080. int DB_cbVariableSaveToDb(void *para, int columnCount, char **columnValue, char **columnName)
  1081. {
  1082. for(int i = 0; i<columnCount; i++)
  1083. {
  1084. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  1085. }
  1086. return 0;
  1087. }
  1088. int DB_variableSaveToDb(struct ReportDataType *variable)
  1089. {
  1090. int result = FAIL;
  1091. char sql[4096];
  1092. char* errMsg = NULL;
  1093. sprintf(sql,"insert or replace into ocpp20_variable (componentName, componentInstance, variableName, variableInstance, variableCharacteristicsDataType, variableCharacteristicsUnit, variableCharacteristicsMaxLimit, variableAttributesType, variableAttributesTypeMutability, variableAttributesTypeValue) VALUES('%s', '%s', '%s', '%s', '%s', '%s', %f, '%s', '%s', '%s'); SELECT * from ocpp20_variable;",
  1094. variable->component.name,
  1095. variable->component.instance,
  1096. variable->variable.name,
  1097. variable->variable.instance,
  1098. variable->variableCharacteristics.dataType,
  1099. variable->variableCharacteristics.unit,
  1100. variable->variableCharacteristics.maxLimit,
  1101. variable->variableAttribute[0].type,
  1102. variable->variableAttribute[0].mutability,
  1103. variable->variableAttribute[0].value);
  1104. //* Execute SQL statement */
  1105. if(sqlite3_exec(db, sql, DB_cbVariableSaveToDb, 0, &errMsg) != SQLITE_OK)
  1106. {
  1107. DEBUG_INFO("SQL error: %s\n", errMsg);
  1108. result = FAIL;
  1109. }
  1110. return result;
  1111. }
  1112. int DB_cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1113. {
  1114. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1115. if(atoi(columnValue[0]) == 0)
  1116. {
  1117. DB_updateBootType(BootReasonEnumType_PowerUp);
  1118. // Create variable table content
  1119. /* AlignedDataCtrlr Required item */
  1120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1126. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1133. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1139. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1141. else
  1142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1143. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1148. ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.minLimit = 10;
  1149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1152. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1159. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1166. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1172. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1174. else
  1175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1176. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1184. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1185. /* AuthCtrlrVariable Required item */
  1186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1192. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1199. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1206. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1213. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1220. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1227. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1231. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1235. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1236. /* AuthCacheCtrlr Variable Required item*/
  1237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1243. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1250. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1258. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1262. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*100);
  1263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1266. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1273. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1274. /* ClockCtrlr Variable Required item */
  1275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1280. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1281. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1288. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1296. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1303. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1310. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1318. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1325. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1332. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1333. /* ChargingStation Required item */
  1334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1338. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1340. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1345. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1347. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1354. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1355. /* Connector Required item */
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1360. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1361. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1362. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1369. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1376. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1377. /* CustomizationCtrlr Required item */
  1378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1384. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1385. /* DeviceDataCtrlr Required item */
  1386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1393. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1396. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1401. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1404. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1409. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1416. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1417. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1420. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1425. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1426. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1428. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1433. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1440. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1441. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1447. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1449. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1450. /* DisplayMessageCtrlr Required item */
  1451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1454. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1457. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1461. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1462. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1464. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1469. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "0");
  1471. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1476. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1478. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1483. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1485. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1486. /* EVSE Required item */
  1487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1490. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1491. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1493. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1498. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1500. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1505. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1507. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1512. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1514. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1515. /* LocalAuthListCtrlr Required item */
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1520. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1522. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1528. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1529. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1532. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1535. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1536. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1537. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1543. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "50");
  1544. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1551. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "2048");
  1552. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1556. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = 1024*1024;
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1559. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "5000");
  1560. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1561. /* MonitoringCtrlr Required item */
  1562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1567. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1568. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1575. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1580. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1583. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1590. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1591. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1598. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1599. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1606. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1607. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1613. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1614. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1615. /* OCPPCommCtrlr Required item */
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1621. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1622. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1629. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1631. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1635. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1636. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1638. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1643. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1644. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1645. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1646. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1651. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "[0]");
  1653. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1654. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1655. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1657. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1658. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1659. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1660. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1661. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1666. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1667. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1668. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1669. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1673. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1674. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1675. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1676. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1682. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1683. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1684. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1688. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1690. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1691. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1692. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "3");
  1693. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1695. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1696. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1697. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1698. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1699. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1700. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1702. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1704. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1705. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1706. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1707. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1708. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1710. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1712. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1713. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1714. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1715. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1716. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1717. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1719. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1720. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1721. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1722. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1723. /* ReservationCtrlr Required item */
  1724. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1725. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1727. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1728. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1729. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1730. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1732. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1734. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1735. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1737. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1739. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1741. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1742. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1743. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1744. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1745. /* SampledDataCtrlr Required item */
  1746. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1749. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1750. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1751. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1752. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  1753. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  1754. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1757. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1758. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1759. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  1761. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1764. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1765. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1766. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  1767. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  1768. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1771. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1772. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, " ");
  1773. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  1774. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  1775. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1776. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1779. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1780. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1781. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  1782. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  1783. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  1784. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1787. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  1788. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  1789. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  1791. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1792. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1793. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, " ");
  1795. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  1796. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1800. ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.minLimit = 10;
  1801. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1802. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1803. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "30");
  1804. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  1805. /* SecurityCtrlr Required item */
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  1807. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  1808. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1809. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  1810. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1811. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1812. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, " ");
  1813. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  1814. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  1815. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  1816. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1817. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1819. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1820. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "Phihong Technology");
  1821. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  1822. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  1823. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  1824. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1825. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "Phihong");
  1828. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  1829. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  1831. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1832. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1833. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  1835. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  1836. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1839. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "0");
  1842. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  1843. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  1844. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  1845. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1846. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1847. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1848. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  1849. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  1850. /* SmartChargingCtrlr Required item */
  1851. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  1853. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1854. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1855. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1857. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  1858. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  1859. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  1860. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1862. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  1864. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  1865. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  1866. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  1867. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1869. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1870. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  1871. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  1872. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  1873. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  1874. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1876. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1877. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "0");
  1878. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  1879. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  1880. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  1881. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1882. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1884. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  1885. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  1886. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  1887. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  1888. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1891. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  1892. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  1893. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  1894. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  1895. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1897. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1898. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  1899. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  1900. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  1901. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  1902. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1903. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1904. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  1906. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  1907. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  1908. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  1909. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1911. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1912. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  1913. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  1914. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  1916. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1918. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1919. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "3");
  1920. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  1921. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  1922. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  1923. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1925. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1926. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  1927. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  1928. /* TariffCostCtrlr Required item */
  1929. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1933. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1934. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1935. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  1936. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  1937. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  1940. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1941. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1942. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1943. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  1944. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  1945. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  1946. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  1947. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1948. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  1949. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1950. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1951. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  1952. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  1954. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  1955. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  1956. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1957. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1958. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1959. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  1960. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  1961. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  1962. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  1963. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  1964. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1965. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1966. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1967. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  1968. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  1969. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  1970. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  1971. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1972. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  1973. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1974. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1975. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  1976. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  1977. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  1978. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  1979. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1980. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  1981. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1982. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1983. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  1984. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  1985. /* TxCtrlr Required item */
  1986. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  1987. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  1988. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1989. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1990. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1991. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  1992. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  1993. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  1994. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  1995. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  1996. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1997. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1998. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1999. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  2000. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  2001. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2002. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2003. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2005. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  2007. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  2008. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2009. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2010. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2011. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2012. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  2014. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  2015. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2016. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2017. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2018. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2019. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2020. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "PowerPathClosed");
  2021. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  2022. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2023. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2024. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2026. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2027. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "PowerPathClosed");
  2028. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2029. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2030. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2031. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2032. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2034. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2035. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "60000");
  2036. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2037. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2038. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2039. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2040. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2041. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2042. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2043. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2044. }
  2045. else
  2046. {
  2047. // Variable name init
  2048. /* AlignedDataCtrlr Required item */
  2049. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2050. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2051. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2052. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2053. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2054. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2055. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2056. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2059. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2062. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2063. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2064. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2065. /* AuthCtrlrVariable Required item */
  2066. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2067. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2068. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2069. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2070. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2071. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2073. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2074. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2076. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2077. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2078. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2080. /* AuthCacheCtrlr Variable Required item */
  2081. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2082. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2083. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2085. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2086. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2087. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2088. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2089. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2090. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2091. /* ClockCtrlr Variable Required item */
  2092. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2095. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2110. /* ChargingStation Required item */
  2111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2117. /* Connector Required item */
  2118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2124. /* DeviceDataCtrlr Required item */
  2125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2142. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2147. /* DisplayMessageCtrlr Required item */
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2158. /* EVSE Required item */
  2159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2167. /* LocalAuthListCtrlr Required item */
  2168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2182. /* MonitoringCtrlr Required item */
  2183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2201. /* OCPPCommCtrlr Required item */
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2233. /* ReservationCtrlr Required item */
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2240. /* SampledDataCtrlr Required item */
  2241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2257. /* SecurityCtrlr Required item */
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2270. /* SmartChargingCtrlr Required item */
  2271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2293. /* TariffCostCtrlr Required item */
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2308. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2309. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2312. /* TxCtrlr Required item */
  2313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2316. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2323. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2329. }
  2330. return 0;
  2331. }
  2332. void DB_variableIsCreate()
  2333. {
  2334. char sql[512];
  2335. char* errMsg = NULL;
  2336. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2337. /* Execute SQL statement */
  2338. if(sqlite3_exec(db, sql, DB_cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2339. {
  2340. DEBUG_INFO("SQL error: %s\n", errMsg);
  2341. }
  2342. }
  2343. int DB_cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2344. {
  2345. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2346. {
  2347. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) != NULL) &&
  2348. (strlen(columnValue[2])>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) != NULL):TRUE) &&
  2349. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) != NULL) &&
  2350. (strlen(columnValue[4])>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) != NULL):TRUE))
  2351. {
  2352. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2353. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2354. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2358. }
  2359. }
  2360. return 0;
  2361. }
  2362. void DB_variableLoadFromDb()
  2363. {
  2364. char sql[512];
  2365. char* errMsg = NULL;
  2366. sprintf(sql,"select * from ocpp20_variable;");
  2367. /* Execute SQL statement */
  2368. if(sqlite3_exec(db, sql, DB_cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2369. {
  2370. DEBUG_INFO("SQL error: %s\n", errMsg);
  2371. }
  2372. }
  2373. int DB_cbGetNetworkProfileFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2374. {
  2375. memset(&ShmOCPP20Data->NetworkConnectionProfile[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile));
  2376. if(columnCount > 0)
  2377. {
  2378. for(int idx=0;idx<columnCount;idx++)
  2379. {
  2380. json_object *SetNetworkProfile;
  2381. SetNetworkProfile = json_tokener_parse(columnValue[2]);
  2382. if(!is_error(SetNetworkProfile))
  2383. {
  2384. // Required data
  2385. if(json_object_object_get(SetNetworkProfile, "ocppVersion") != NULL)
  2386. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppVersion")));
  2387. if(json_object_object_get(SetNetworkProfile, "ocppTransport") != NULL)
  2388. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppTransport")));
  2389. if(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl") != NULL)
  2390. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppCsmsUrl")));
  2391. if(json_object_object_get(SetNetworkProfile, "messageTimeout") != NULL)
  2392. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.messageTimeout = json_object_get_int(json_object_object_get(SetNetworkProfile, "messageTimeout"));
  2393. if(json_object_object_get(SetNetworkProfile, "ocppInterface") != NULL)
  2394. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(SetNetworkProfile, "ocppInterface")));
  2395. if(json_object_object_get(SetNetworkProfile, "vpn") != NULL)
  2396. {
  2397. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server") != NULL)
  2398. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.server, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "server")));
  2399. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user") != NULL)
  2400. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.user, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "user")));
  2401. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group") != NULL)
  2402. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.group, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "group")));
  2403. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password") != NULL)
  2404. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.password, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "password")));
  2405. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key") != NULL)
  2406. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.key, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "key")));
  2407. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type") != NULL)
  2408. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.vpn.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "vpn"), "type")));
  2409. }
  2410. if(json_object_object_get(SetNetworkProfile, "apn") != NULL)
  2411. {
  2412. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn") != NULL)
  2413. {
  2414. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn));
  2415. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apn, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apn")));
  2416. }
  2417. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName") != NULL)
  2418. {
  2419. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName));
  2420. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnUserName, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnUserName")));
  2421. }
  2422. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword") != NULL)
  2423. {
  2424. memset(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword));
  2425. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnPassword, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnPassword")));
  2426. }
  2427. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin") != NULL)
  2428. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.simPin = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "simPin"));
  2429. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork") != NULL)
  2430. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.preferredNetwork, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "preferredNetwork")));
  2431. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork") != NULL)
  2432. ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.useOnlyPreferredNetwork = json_object_get_boolean(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "useOnlyPreferredNetwork"));
  2433. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication") != NULL)
  2434. sprintf((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.apn.apnAuthentication, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "apn"), "apnAuthentication")));
  2435. }
  2436. }
  2437. json_object_put(SetNetworkProfile);
  2438. ShmOCPP20Data->NetworkConnectionProfile[idx].slot = atoi(columnValue[1]);
  2439. }
  2440. }
  2441. return 0;
  2442. }
  2443. void DB_getNetworkProfileFromDb()
  2444. {
  2445. char sql[512];
  2446. char* errMsg = NULL;
  2447. sprintf(sql,"select * from ocpp20_networkprofile order by slot;");
  2448. /* Execute SQL statement */
  2449. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2450. {
  2451. DEBUG_INFO("SQL error: %s\n", errMsg);
  2452. }
  2453. }
  2454. int DB_addNetworkProfile(int slot, char *data)
  2455. {
  2456. int result = PASS;
  2457. char sql[512];
  2458. char* errMsg = NULL;
  2459. sprintf(sql,"insert or replace into ocpp20_networkprofile (slot, connectionData) VALUES('%d', '%s'); SELECT * from ocpp20_networkprofile order by slot;",
  2460. slot,
  2461. data);
  2462. //* Execute SQL statement */
  2463. if(sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK)
  2464. {
  2465. DEBUG_INFO("SQL error: %s\n", errMsg);
  2466. result = FAIL;
  2467. }
  2468. return result;
  2469. }
  2470. int DB_deleteNetworkProfile(int slot)
  2471. {
  2472. int result = PASS;
  2473. char sql[512];
  2474. char* errMsg = NULL;
  2475. sprintf(sql,"DELETE from ocpp20_networkprofile where slot=%d; SELECT * from ocpp20_networkprofile order by slot;", slot);
  2476. //* Execute SQL statement */
  2477. if( sqlite3_exec(db, sql, DB_cbGetNetworkProfileFromDb, 0, &errMsg) != SQLITE_OK )
  2478. {
  2479. DEBUG_INFO("SQL error: %s", errMsg);
  2480. result = FAIL;
  2481. }
  2482. return result;
  2483. }
  2484. //==========================================
  2485. // Check time passed since today
  2486. //==========================================
  2487. long long DiffTimebWithNow(struct timeb ST)
  2488. {
  2489. //return milli-second
  2490. struct timeb ET;
  2491. long long StartTime,StopTime;
  2492. ftime(&ET);
  2493. StartTime=(long long)ST.time;
  2494. StopTime=(long long)ET.time;
  2495. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2496. }
  2497. int getTimePassSinceToday()
  2498. {
  2499. int result = -1;
  2500. time_t t;
  2501. struct tm *tmStartToday;
  2502. struct timeb tbStartToday;
  2503. t=time(NULL);
  2504. tmStartToday=localtime(&t);
  2505. tmStartToday->tm_hour = 0;
  2506. tmStartToday->tm_min = 0;
  2507. tmStartToday->tm_sec = 0;
  2508. tbStartToday.time = mktime(tmStartToday);
  2509. tbStartToday.millitm = 0;
  2510. result = DiffTimebWithNow(tbStartToday)/1000;
  2511. return result;
  2512. }
  2513. //==========================================
  2514. // GetCompositeSchedule logic related function
  2515. //==========================================
  2516. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2517. {
  2518. //return milli-second
  2519. unsigned int StartTime,StopTime;
  2520. StartTime=(unsigned int)ST.time;
  2521. StopTime=(unsigned int)ET.time;
  2522. return (StopTime-StartTime);
  2523. }
  2524. int DiffTimebWithNowSec(struct timeb ST)
  2525. {
  2526. //return milli-second
  2527. struct timeb ET;
  2528. unsigned int StartTime,StopTime;
  2529. ftime(&ET);
  2530. StartTime=(unsigned int)ST.time;
  2531. StopTime=(unsigned int)ET.time;
  2532. return (StopTime-StartTime);
  2533. }
  2534. int getStartStop(uint8_t *start, uint8_t *stop)
  2535. {
  2536. int result = -1;
  2537. struct tm tmStart;
  2538. struct timeb tbStart;
  2539. struct tm tmStop;
  2540. struct timeb tbStop;
  2541. 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) &&
  2542. (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))
  2543. {
  2544. //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);
  2545. //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);
  2546. tmStart.tm_year -= 1900;
  2547. tmStart.tm_mon -= 1;
  2548. tbStart.time = mktime(&tmStart);
  2549. tbStart.millitm = 0;
  2550. tmStop.tm_year -= 1900;
  2551. tmStop.tm_mon -= 1;
  2552. tbStop.time = mktime(&tmStop);
  2553. tbStop.millitm = 0;
  2554. result = DiffTimebSec(tbStart, tbStop);
  2555. //DEBUG_INFO("getStartStop(): %d\n", result);
  2556. }
  2557. else
  2558. {
  2559. DEBUG_WARN("Start or stop date parsing error.\r\n");
  2560. }
  2561. return result;
  2562. }
  2563. int isOvertNow(uint8_t *start)
  2564. {
  2565. int result = YES;
  2566. struct tm tmStart;
  2567. struct timeb tbStart;
  2568. 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))
  2569. {
  2570. //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);
  2571. tmStart.tm_year -= 1900;
  2572. tmStart.tm_mon -= 1;
  2573. tbStart.time = mktime(&tmStart);
  2574. tbStart.millitm = 0;
  2575. if(DiffTimebWithNowSec(tbStart) <= 0)
  2576. result = NO;
  2577. }
  2578. else
  2579. {
  2580. DEBUG_WARN("Start date parsing error.\r\n");
  2581. }
  2582. return result;
  2583. }
  2584. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  2585. {
  2586. int result = -1;
  2587. struct tm tmStart;
  2588. struct timeb tbStart;
  2589. struct tm tmStop;
  2590. struct timeb tbStop;
  2591. 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) &&
  2592. (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))
  2593. {
  2594. tmStart.tm_year -= 1900;
  2595. tmStart.tm_mon -= 1;
  2596. tbStart.time = mktime(&tmStart);
  2597. tbStart.millitm = 0;
  2598. tmStop.tm_year -= 1900;
  2599. tmStop.tm_mon -= 1;
  2600. tbStop.time = mktime(&tmStop);
  2601. tbStop.millitm = 0;
  2602. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  2603. }
  2604. return result;
  2605. }
  2606. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *compositeProfile)
  2607. {
  2608. FILE *fp;
  2609. char profileFileName[128];
  2610. char *line = NULL;
  2611. size_t len = 0;
  2612. time_t CurrentTime;
  2613. struct tm *tmComposite;
  2614. struct ChargingProfileType maxProfile;
  2615. struct ChargingProfileType defaultTxProfile;
  2616. struct ChargingProfileType txProfile;
  2617. struct ChargingSchedulePeriodType tmpPeriod;
  2618. uint8_t limitMax=0;
  2619. uint8_t limitDef=0;
  2620. uint8_t limitTx=0;
  2621. int compositePeriodIdx = 0;
  2622. CurrentTime = time(NULL);
  2623. tmComposite=localtime(&CurrentTime);
  2624. 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);
  2625. sprintf((char*)compositeProfile->chargingSchedule[0].chargingRateUnit, "A");
  2626. compositeProfile->chargingSchedule[0].duration = durationReq;
  2627. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2628. {
  2629. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2630. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2631. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2632. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  2633. }
  2634. compositeProfile->id = 0;
  2635. compositeProfile->stackLevel = 99 ;
  2636. sprintf((char*)compositeProfile->chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  2637. maxProfile.id = -1;
  2638. defaultTxProfile.id = -1;
  2639. txProfile.id = -1;
  2640. maxProfile.chargingSchedule[0].duration = -1;
  2641. defaultTxProfile.chargingSchedule[0].duration = -1;
  2642. txProfile.chargingSchedule[0].duration = -1;
  2643. system("yes|rm /tmp/*.json");
  2644. system("cp /Storage/OCPP/*.json /tmp");
  2645. /*
  2646. * Search valid charging profile
  2647. */
  2648. //DEBUG_INFO("====================================\n");
  2649. // Search tx profile
  2650. sprintf(profileFileName, "/tmp/TxProfile_%d.json", connectorId);
  2651. if((access(profileFileName, F_OK))!=-1)
  2652. {
  2653. fp = fopen(profileFileName, "r");
  2654. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2655. {
  2656. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2657. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2658. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2659. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2660. }
  2661. txProfile.id = -1;
  2662. txProfile.stackLevel = -1;
  2663. while(getline(&line, &len, fp) != -1)
  2664. {
  2665. json_object *obj = NULL;
  2666. obj = json_tokener_parse(line);
  2667. if(is_error(obj))
  2668. {
  2669. DEBUG_ERROR("Parse txProfile from file error.\n");
  2670. }
  2671. else
  2672. {
  2673. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != txProfile.id) &&
  2674. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= txProfile.stackLevel)
  2675. )
  2676. {
  2677. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2678. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2679. )
  2680. {
  2681. struct tm tmFrom, tmTo;
  2682. struct timeb tbFrom, tbTo;
  2683. 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) &&
  2684. (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))
  2685. {
  2686. tmFrom.tm_year -= 1900;
  2687. tmFrom.tm_mon -= 1;
  2688. tbFrom.time = mktime(&tmFrom);
  2689. tmTo.tm_year -= 1900;
  2690. tmTo.tm_mon -= 1;
  2691. tbTo.time = mktime(&tmTo);
  2692. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2693. {
  2694. if(txProfile.id == -1)
  2695. DEBUG_INFO("TxProfile found.\n");
  2696. else
  2697. DEBUG_INFO("TxProfile updated.\n");
  2698. // Required item
  2699. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2700. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2701. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2702. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2703. 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++)
  2704. {
  2705. 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"));
  2706. 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")));
  2707. 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?
  2708. 3:
  2709. 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")));
  2710. }
  2711. // Optional item
  2712. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2713. {
  2714. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2715. }
  2716. else
  2717. {
  2718. sprintf((char*)txProfile.validFrom, " ");
  2719. }
  2720. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2721. {
  2722. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2723. }
  2724. else
  2725. {
  2726. sprintf((char*)txProfile.validTo, " ");
  2727. }
  2728. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2729. {
  2730. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2731. }
  2732. else
  2733. {
  2734. sprintf((char*)txProfile.recurrencyKind, " ");
  2735. }
  2736. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2737. {
  2738. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2739. }
  2740. else
  2741. {
  2742. sprintf((char*)txProfile.transactionId, " ");
  2743. }
  2744. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2745. {
  2746. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2747. }
  2748. else
  2749. {
  2750. txProfile.chargingSchedule[0].duration = 86400;
  2751. }
  2752. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2753. {
  2754. 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")));
  2755. }
  2756. else
  2757. {
  2758. 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));
  2759. }
  2760. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2761. {
  2762. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2763. }
  2764. else
  2765. {
  2766. txProfile.chargingSchedule[0].minChargingRate = -1;
  2767. }
  2768. }
  2769. }
  2770. }
  2771. else
  2772. {
  2773. if(txProfile.id == -1)
  2774. DEBUG_INFO("TxProfile found.\n");
  2775. else
  2776. DEBUG_INFO("TxProfile updated.\n");
  2777. // Required item
  2778. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2779. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2780. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2781. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2782. 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++)
  2783. {
  2784. 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"));
  2785. 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")));
  2786. 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?
  2787. 3:
  2788. 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")));
  2789. }
  2790. // Optional item
  2791. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2792. {
  2793. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2794. }
  2795. else
  2796. {
  2797. sprintf((char*)txProfile.validFrom, " ");
  2798. }
  2799. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2800. {
  2801. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2802. }
  2803. else
  2804. {
  2805. sprintf((char*)txProfile.validTo, " ");
  2806. }
  2807. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2808. {
  2809. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2810. }
  2811. else
  2812. {
  2813. sprintf((char*)txProfile.recurrencyKind, " ");
  2814. }
  2815. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2816. {
  2817. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2818. }
  2819. else
  2820. {
  2821. sprintf((char*)txProfile.transactionId, " ");
  2822. }
  2823. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2824. {
  2825. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2826. }
  2827. else
  2828. {
  2829. txProfile.chargingSchedule[0].duration = 86400;
  2830. }
  2831. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2832. {
  2833. 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")));
  2834. }
  2835. else
  2836. {
  2837. 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));
  2838. }
  2839. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2840. {
  2841. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2842. }
  2843. else
  2844. {
  2845. txProfile.chargingSchedule[0].minChargingRate = -1;
  2846. }
  2847. }
  2848. }
  2849. }
  2850. json_object_put(obj);
  2851. }
  2852. fclose(fp);
  2853. /*
  2854. if(txProfile.ChargingProfileId != -1)
  2855. {
  2856. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  2857. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  2858. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  2859. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  2860. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  2861. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  2862. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  2863. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[0].StartSchedule);
  2864. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  2865. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  2866. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  2867. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  2868. {
  2869. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  2870. {
  2871. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  2872. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  2873. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  2874. }
  2875. }
  2876. }
  2877. else
  2878. DEBUG_INFO("TxProfile not found.\n");*/
  2879. }
  2880. // Search default tx profile
  2881. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d.json", connectorId);
  2882. if((access(profileFileName, F_OK))==-1)
  2883. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  2884. if((access(profileFileName, F_OK))!=-1)
  2885. {
  2886. fp = fopen(profileFileName, "r");
  2887. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2888. {
  2889. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2890. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2891. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2892. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2893. }
  2894. defaultTxProfile.id = -1;
  2895. defaultTxProfile.stackLevel = -1;
  2896. while(getline(&line, &len, fp) != -1)
  2897. {
  2898. json_object *obj = NULL;
  2899. obj = json_tokener_parse(line);
  2900. if(is_error(obj))
  2901. {
  2902. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  2903. }
  2904. else
  2905. {
  2906. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != defaultTxProfile.id) &&
  2907. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= defaultTxProfile.stackLevel)
  2908. )
  2909. {
  2910. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2911. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2912. )
  2913. {
  2914. struct tm tmFrom, tmTo;
  2915. struct timeb tbFrom, tbTo;
  2916. 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) &&
  2917. (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))
  2918. {
  2919. tmFrom.tm_year -= 1900;
  2920. tmFrom.tm_mon -= 1;
  2921. tbFrom.time = mktime(&tmFrom);
  2922. tmTo.tm_year -= 1900;
  2923. tmTo.tm_mon -= 1;
  2924. tbTo.time = mktime(&tmTo);
  2925. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2926. {
  2927. if(defaultTxProfile.id == -1)
  2928. DEBUG_INFO("TxDefaultProfile found.\n");
  2929. else
  2930. DEBUG_INFO("TxDefaultProfile updated.\n");
  2931. // Required item
  2932. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2933. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2934. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2935. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  2936. 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++)
  2937. {
  2938. 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"));
  2939. 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")));
  2940. 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?
  2941. 3:
  2942. 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")));
  2943. }
  2944. // Optional item
  2945. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2946. {
  2947. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2948. }
  2949. else
  2950. {
  2951. sprintf((char*)defaultTxProfile.validFrom, " ");
  2952. }
  2953. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2954. {
  2955. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2956. }
  2957. else
  2958. {
  2959. sprintf((char*)defaultTxProfile.validTo, " ");
  2960. }
  2961. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2962. {
  2963. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2964. }
  2965. else
  2966. {
  2967. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  2968. }
  2969. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2970. {
  2971. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2972. }
  2973. else
  2974. {
  2975. sprintf((char*)defaultTxProfile.transactionId, " ");
  2976. }
  2977. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2978. {
  2979. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2980. }
  2981. else
  2982. {
  2983. defaultTxProfile.chargingSchedule[0].duration = 86400;
  2984. }
  2985. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2986. {
  2987. 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")));
  2988. }
  2989. else
  2990. {
  2991. 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));
  2992. }
  2993. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2994. {
  2995. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2996. }
  2997. else
  2998. {
  2999. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  3000. }
  3001. }
  3002. }
  3003. }
  3004. else
  3005. {
  3006. if(defaultTxProfile.id == -1)
  3007. DEBUG_INFO("TxDefaultProfile found.\n");
  3008. else
  3009. DEBUG_INFO("TxDefaultProfile updated.\n");
  3010. // Required item
  3011. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3012. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3013. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3014. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3015. 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++)
  3016. {
  3017. 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"));
  3018. 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")));
  3019. 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?
  3020. 3:
  3021. 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")));
  3022. }
  3023. // Optional item
  3024. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3025. {
  3026. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3027. }
  3028. else
  3029. {
  3030. sprintf((char*)defaultTxProfile.validFrom, " ");
  3031. }
  3032. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3033. {
  3034. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3035. }
  3036. else
  3037. {
  3038. sprintf((char*)defaultTxProfile.validTo, " ");
  3039. }
  3040. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3041. {
  3042. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3043. }
  3044. else
  3045. {
  3046. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  3047. }
  3048. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3049. {
  3050. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3051. }
  3052. else
  3053. {
  3054. sprintf((char*)defaultTxProfile.transactionId, " ");
  3055. }
  3056. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3057. {
  3058. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3059. }
  3060. else
  3061. {
  3062. defaultTxProfile.chargingSchedule[0].duration = 86400;
  3063. }
  3064. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3065. {
  3066. 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")));
  3067. }
  3068. else
  3069. {
  3070. 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));
  3071. }
  3072. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3073. {
  3074. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3075. }
  3076. else
  3077. {
  3078. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  3079. }
  3080. }
  3081. }
  3082. }
  3083. json_object_put(obj);
  3084. }
  3085. fclose(fp);
  3086. /*
  3087. if(defaultTxProfile.ChargingProfileId != -1)
  3088. {
  3089. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3090. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3091. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3092. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3093. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3094. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3095. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3096. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[0].StartSchedule);
  3097. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3098. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3099. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3100. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3101. {
  3102. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3103. {
  3104. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3105. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3106. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3107. }
  3108. }
  3109. }
  3110. else
  3111. DEBUG_INFO("TxDefaultProfile not found.\n");
  3112. DEBUG_INFO("------------------------------------\n");*/
  3113. }
  3114. // Search max profile
  3115. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  3116. if((access(profileFileName, F_OK))!=-1)
  3117. {
  3118. fp = fopen(profileFileName, "r");
  3119. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3120. {
  3121. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  3122. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  3123. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  3124. }
  3125. maxProfile.id = -1;
  3126. maxProfile.stackLevel = -1;
  3127. while(getline(&line, &len, fp) != -1)
  3128. {
  3129. json_object *obj = NULL;
  3130. obj = json_tokener_parse(line);
  3131. if(is_error(obj))
  3132. {
  3133. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  3134. }
  3135. else
  3136. {
  3137. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != maxProfile.id) &&
  3138. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= maxProfile.stackLevel)
  3139. )
  3140. {
  3141. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3142. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3143. )
  3144. {
  3145. struct tm tmFrom, tmTo;
  3146. struct timeb tbFrom, tbTo;
  3147. 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) &&
  3148. (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))
  3149. {
  3150. tmFrom.tm_year -= 1900;
  3151. tmFrom.tm_mon -= 1;
  3152. tbFrom.time = mktime(&tmFrom);
  3153. tmTo.tm_year -= 1900;
  3154. tmTo.tm_mon -= 1;
  3155. tbTo.time = mktime(&tmTo);
  3156. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3157. {
  3158. if(maxProfile.id == -1)
  3159. DEBUG_INFO("MaxProfile found.\n");
  3160. else
  3161. DEBUG_INFO("MaxProfile updated.\n");
  3162. // Required item
  3163. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3164. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3165. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3166. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3167. 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++)
  3168. {
  3169. 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"));
  3170. 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")));
  3171. 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?
  3172. 3:
  3173. 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")));
  3174. }
  3175. // Optional item
  3176. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3177. {
  3178. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3179. }
  3180. else
  3181. {
  3182. sprintf((char*)maxProfile.validFrom, " ");
  3183. }
  3184. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3185. {
  3186. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3187. }
  3188. else
  3189. {
  3190. sprintf((char*)maxProfile.validTo, " ");
  3191. }
  3192. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3193. {
  3194. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3195. }
  3196. else
  3197. {
  3198. sprintf((char*)maxProfile.recurrencyKind, " ");
  3199. }
  3200. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3201. {
  3202. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3203. }
  3204. else
  3205. {
  3206. sprintf((char*)maxProfile.transactionId, " ");
  3207. }
  3208. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3209. {
  3210. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3211. }
  3212. else
  3213. {
  3214. maxProfile.chargingSchedule[0].duration = 86400;
  3215. }
  3216. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3217. {
  3218. 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")));
  3219. }
  3220. else
  3221. {
  3222. 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));
  3223. }
  3224. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3225. {
  3226. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3227. }
  3228. else
  3229. {
  3230. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3231. }
  3232. }
  3233. }
  3234. }
  3235. else
  3236. {
  3237. if(maxProfile.id == -1)
  3238. DEBUG_INFO("MaxProfile found.\n");
  3239. else
  3240. DEBUG_INFO("MaxProfile updated.\n");
  3241. // Required item
  3242. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3243. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3244. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3245. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3246. 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++)
  3247. {
  3248. 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"));
  3249. 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")));
  3250. 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?
  3251. 3:
  3252. 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")));
  3253. }
  3254. // Optional item
  3255. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3256. {
  3257. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3258. }
  3259. else
  3260. {
  3261. sprintf((char*)maxProfile.validFrom, " ");
  3262. }
  3263. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3264. {
  3265. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3266. }
  3267. else
  3268. {
  3269. sprintf((char*)maxProfile.validTo, " ");
  3270. }
  3271. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3272. {
  3273. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3274. }
  3275. else
  3276. {
  3277. sprintf((char*)maxProfile.recurrencyKind, " ");
  3278. }
  3279. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3280. {
  3281. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3282. }
  3283. else
  3284. {
  3285. sprintf((char*)maxProfile.transactionId, " ");
  3286. }
  3287. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3288. {
  3289. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3290. }
  3291. else
  3292. {
  3293. maxProfile.chargingSchedule[0].duration = 86400;
  3294. }
  3295. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3296. {
  3297. 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")));
  3298. }
  3299. else
  3300. {
  3301. 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));
  3302. }
  3303. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3304. {
  3305. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3306. }
  3307. else
  3308. {
  3309. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3310. }
  3311. }
  3312. }
  3313. }
  3314. json_object_put(obj);
  3315. }
  3316. fclose(fp);
  3317. /*
  3318. if(maxProfile.ChargingProfileId !=-1)
  3319. {
  3320. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3321. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3322. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3323. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3324. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3325. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3326. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3327. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[0].StartSchedule);
  3328. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3329. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3330. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3331. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3332. {
  3333. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3334. {
  3335. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3336. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3337. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3338. }
  3339. }
  3340. }
  3341. else
  3342. DEBUG_INFO("MaxProfile not found.\n");
  3343. DEBUG_INFO("------------------------------------\n");*/
  3344. }
  3345. /*
  3346. * Align found profile start schedule & periods
  3347. */
  3348. //DEBUG_INFO("====================================\n");
  3349. /*
  3350. // For local test usage, force modify found profile start schedule info
  3351. 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);
  3352. 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);
  3353. 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);
  3354. */
  3355. if(txProfile.id != -1)
  3356. {
  3357. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3358. {
  3359. if(txProfile.chargingSchedule[0].duration != -1)
  3360. {
  3361. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3362. 0:
  3363. (txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3364. }
  3365. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3366. {
  3367. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3368. {
  3369. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3370. 0:
  3371. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3372. if(idxPeriod > 0)
  3373. {
  3374. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3375. {
  3376. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3377. }
  3378. }
  3379. }
  3380. }
  3381. }
  3382. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3383. {
  3384. if(txProfile.chargingSchedule[0].duration != -1)
  3385. {
  3386. 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?
  3387. 0:
  3388. (txProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3389. }
  3390. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3391. {
  3392. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3393. {
  3394. 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?
  3395. 0:
  3396. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3397. if(idxPeriod > 0)
  3398. {
  3399. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3400. {
  3401. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3402. }
  3403. }
  3404. }
  3405. }
  3406. }
  3407. else
  3408. {
  3409. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3410. {
  3411. if(txProfile.chargingSchedule[0].duration != -1)
  3412. {
  3413. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3414. 0:
  3415. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3416. }
  3417. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3418. {
  3419. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3420. {
  3421. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3422. 0:
  3423. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3424. if(idxPeriod > 0)
  3425. {
  3426. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3427. {
  3428. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3429. }
  3430. }
  3431. }
  3432. }
  3433. }
  3434. else
  3435. {
  3436. if(txProfile.chargingSchedule[0].duration != -1)
  3437. {
  3438. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3439. 0:
  3440. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3441. }
  3442. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3443. {
  3444. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3445. {
  3446. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3447. 0:
  3448. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3449. if(idxPeriod > 0)
  3450. {
  3451. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3452. {
  3453. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3454. }
  3455. }
  3456. }
  3457. }
  3458. }
  3459. }
  3460. /*
  3461. DEBUG_INFO("txProfile after align.\n");
  3462. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  3463. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3464. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3465. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3466. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3467. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3468. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  3469. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3470. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  3471. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  3472. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  3473. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3474. {
  3475. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3476. {
  3477. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3478. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3479. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3480. }
  3481. }*/
  3482. }
  3483. if(defaultTxProfile.id != -1)
  3484. {
  3485. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3486. {
  3487. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3488. {
  3489. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3490. 0:
  3491. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3492. }
  3493. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3494. {
  3495. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3496. {
  3497. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3498. 0:
  3499. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3500. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3501. {
  3502. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3503. }
  3504. if(idxPeriod > 0)
  3505. {
  3506. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3507. {
  3508. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3509. }
  3510. }
  3511. }
  3512. }
  3513. }
  3514. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3515. {
  3516. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3517. {
  3518. 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?
  3519. 0:
  3520. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3521. }
  3522. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3523. {
  3524. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3525. {
  3526. 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?
  3527. 0:
  3528. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3529. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3530. {
  3531. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3532. }
  3533. if(idxPeriod > 0)
  3534. {
  3535. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3536. {
  3537. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3538. }
  3539. }
  3540. }
  3541. }
  3542. }
  3543. else
  3544. {
  3545. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3546. {
  3547. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3548. {
  3549. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3550. 0:
  3551. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3552. }
  3553. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3554. {
  3555. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3556. {
  3557. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3558. 0:
  3559. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3560. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3561. {
  3562. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3563. }
  3564. if(idxPeriod > 0)
  3565. {
  3566. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3567. {
  3568. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3569. }
  3570. }
  3571. }
  3572. }
  3573. }
  3574. else
  3575. {
  3576. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3577. {
  3578. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3579. 0:
  3580. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3581. }
  3582. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3583. {
  3584. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3585. {
  3586. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3587. 0:
  3588. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3589. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3590. {
  3591. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3592. }
  3593. if(idxPeriod > 0)
  3594. {
  3595. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3596. {
  3597. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3598. }
  3599. }
  3600. }
  3601. }
  3602. }
  3603. }
  3604. /*
  3605. DEBUG_INFO("defaultTxProfile after align.\n");
  3606. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3607. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3608. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3609. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3610. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3611. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3612. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3613. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3614. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3615. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3616. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3617. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3618. {
  3619. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3620. {
  3621. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3622. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3623. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3624. }
  3625. }
  3626. DEBUG_INFO("------------------------------------\n");*/
  3627. }
  3628. if(maxProfile.id != -1)
  3629. {
  3630. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3631. {
  3632. if(maxProfile.chargingSchedule[0].duration != -1)
  3633. {
  3634. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3635. 0:
  3636. (maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3637. }
  3638. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3639. {
  3640. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3641. {
  3642. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3643. 0:
  3644. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3645. if(idxPeriod > 0)
  3646. {
  3647. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3648. {
  3649. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3650. }
  3651. }
  3652. }
  3653. }
  3654. }
  3655. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3656. {
  3657. if(maxProfile.chargingSchedule[0].duration != -1)
  3658. {
  3659. 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?
  3660. 0:
  3661. (maxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[9].startSchedule)));
  3662. }
  3663. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3664. {
  3665. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3666. {
  3667. 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?
  3668. 0:
  3669. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3670. if(idxPeriod > 0)
  3671. {
  3672. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3673. {
  3674. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3675. }
  3676. }
  3677. }
  3678. }
  3679. }
  3680. else
  3681. {
  3682. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3683. {
  3684. if(maxProfile.chargingSchedule[0].duration != -1)
  3685. {
  3686. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3687. 0:
  3688. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3689. }
  3690. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3691. {
  3692. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3693. {
  3694. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3695. 0:
  3696. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3697. if(idxPeriod > 0)
  3698. {
  3699. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3700. {
  3701. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3702. }
  3703. }
  3704. }
  3705. }
  3706. }
  3707. else
  3708. {
  3709. if(maxProfile.chargingSchedule[0].duration != -1)
  3710. {
  3711. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3712. 0:
  3713. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3714. }
  3715. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3716. {
  3717. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3718. {
  3719. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3720. 0:
  3721. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3722. if(idxPeriod > 0)
  3723. {
  3724. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3725. {
  3726. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3727. }
  3728. }
  3729. }
  3730. }
  3731. }
  3732. }
  3733. /*
  3734. DEBUG_INFO("MaxProfile after align.\n");
  3735. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3736. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3737. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3738. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3739. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3740. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3741. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3742. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3743. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3744. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3745. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3746. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3747. {
  3748. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3749. {
  3750. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3751. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3752. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3753. }
  3754. }
  3755. DEBUG_INFO("------------------------------------\n");*/
  3756. }
  3757. /*
  3758. * Merge to conposite schedule
  3759. */
  3760. //DEBUG_INFO("====================================\n");
  3761. // Find each profile period quantity
  3762. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3763. {
  3764. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3765. limitMax = idx+1;
  3766. }
  3767. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3768. {
  3769. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3770. limitDef = idx+1;
  3771. }
  3772. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3773. {
  3774. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3775. limitTx = idx+1;
  3776. }
  3777. // TxProfile found, composite schedule based on it
  3778. if(txProfile.id != -1)
  3779. {
  3780. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  3781. {
  3782. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  3783. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  3784. (txProfile.chargingSchedule[0].duration > 0))
  3785. {
  3786. if(maxProfile.id != -1)
  3787. {
  3788. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3789. {
  3790. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  3791. {
  3792. if((maxProfile.chargingSchedule[0].duration > 0))
  3793. {
  3794. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3795. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3796. 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);
  3797. }
  3798. else
  3799. {
  3800. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3801. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3802. tmpPeriod.limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit;
  3803. }
  3804. }
  3805. if(idxMaxPeriod == (limitMax-1))
  3806. {
  3807. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3808. {
  3809. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3810. {
  3811. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3812. compositePeriodIdx++;
  3813. }
  3814. else
  3815. {
  3816. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3817. }
  3818. }
  3819. }
  3820. }
  3821. }
  3822. else
  3823. {
  3824. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3825. {
  3826. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3827. compositePeriodIdx++;
  3828. }
  3829. else
  3830. {
  3831. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3832. }
  3833. }
  3834. }
  3835. if(idxTxPeriod == (limitTx-1))
  3836. {
  3837. if(defaultTxProfile.id != -1)
  3838. {
  3839. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3840. {
  3841. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  3842. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3843. (defaultTxProfile.chargingSchedule[0].duration>0))
  3844. {
  3845. if(maxProfile.id != -1)
  3846. {
  3847. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3848. {
  3849. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3850. {
  3851. if((maxProfile.chargingSchedule[0].duration > 0))
  3852. {
  3853. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3854. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3855. 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);
  3856. }
  3857. else
  3858. {
  3859. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3860. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3861. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3862. }
  3863. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3864. {
  3865. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3866. {
  3867. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3868. compositePeriodIdx++;
  3869. }
  3870. else
  3871. {
  3872. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3873. }
  3874. }
  3875. break;
  3876. }
  3877. }
  3878. }
  3879. else
  3880. {
  3881. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3882. {
  3883. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3884. compositePeriodIdx++;
  3885. }
  3886. else
  3887. {
  3888. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3889. }
  3890. }
  3891. }
  3892. }
  3893. }
  3894. }
  3895. }
  3896. }
  3897. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  3898. else if(defaultTxProfile.id != -1)
  3899. {
  3900. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3901. {
  3902. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  3903. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3904. (defaultTxProfile.chargingSchedule[0].duration > 0))
  3905. {
  3906. if(maxProfile.id != -1)
  3907. {
  3908. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3909. {
  3910. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3911. {
  3912. if((maxProfile.chargingSchedule[0].duration > 0))
  3913. {
  3914. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3915. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3916. 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);
  3917. }
  3918. else
  3919. {
  3920. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3921. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3922. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3923. }
  3924. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3925. {
  3926. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3927. {
  3928. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3929. compositePeriodIdx++;
  3930. }
  3931. else
  3932. {
  3933. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3934. }
  3935. }
  3936. break;
  3937. }
  3938. }
  3939. }
  3940. else
  3941. {
  3942. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3943. {
  3944. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3945. compositePeriodIdx++;
  3946. }
  3947. else
  3948. {
  3949. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3950. }
  3951. }
  3952. }
  3953. }
  3954. }
  3955. // Fill other period by MaxProfile
  3956. if(maxProfile.id != -1)
  3957. {
  3958. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3959. {
  3960. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3961. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3962. (maxProfile.chargingSchedule[0].duration > 0))
  3963. {
  3964. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod >= compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod) &&
  3965. (maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3966. {
  3967. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod;
  3968. tmpPeriod.numberPhases = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].numberPhases;
  3969. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3970. }
  3971. if((maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3972. {
  3973. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].duration;
  3974. tmpPeriod.numberPhases = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  3975. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3976. }
  3977. if(tmpPeriod.limit != -1)
  3978. {
  3979. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3980. {
  3981. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3982. {
  3983. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3984. compositePeriodIdx++;
  3985. }
  3986. else
  3987. {
  3988. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3989. }
  3990. }
  3991. }
  3992. }
  3993. }
  3994. }
  3995. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  3996. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[0].startSchedule);
  3997. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[0].duration);
  3998. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[0].chargingRateUnit);
  3999. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  4000. {
  4001. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  4002. {
  4003. compositeProfile->id = 1;
  4004. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  4005. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit);
  4006. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases);
  4007. }
  4008. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit == -1)
  4009. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit =0;
  4010. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  4011. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  4012. }
  4013. if(line)
  4014. free(line);
  4015. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  4016. }
  4017. //==========================================
  4018. // Init all share memory
  4019. //==========================================
  4020. int InitShareMemory()
  4021. {
  4022. int result = PASS;
  4023. int MeterSMId;
  4024. //creat ShmSysConfigAndInfo
  4025. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  4026. {
  4027. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  4028. result = FAIL;
  4029. }
  4030. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4031. {
  4032. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  4033. result = FAIL;
  4034. }
  4035. else
  4036. {}
  4037. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  4038. {
  4039. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  4040. result = FAIL;
  4041. }
  4042. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4043. {
  4044. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  4045. result = FAIL;
  4046. }
  4047. else
  4048. {}
  4049. //creat ShmPsuData
  4050. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  4051. {
  4052. DEBUG_ERROR("shmget ShmPsuData NG\n");
  4053. result = FAIL;
  4054. }
  4055. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4056. {
  4057. DEBUG_ERROR("shmat ShmPsuData NG\n");
  4058. result = FAIL;
  4059. }
  4060. else
  4061. {}
  4062. //creat ShmOCPP20Data
  4063. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  4064. {
  4065. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  4066. result = FAIL;
  4067. }
  4068. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  4069. {
  4070. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  4071. result = FAIL;
  4072. }
  4073. else
  4074. {}
  4075. /****************************** For Initial Settings************************************************/
  4076. //offline MeterValue Interval
  4077. TempMeterValueInterval = 0;
  4078. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  4079. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  4080. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  4081. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  4082. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  4083. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  4084. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  4085. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  4086. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  4087. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  4088. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  4089. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  4090. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  4091. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  4092. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  4093. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  4094. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  4095. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  4096. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  4097. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  4098. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  4099. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  4100. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  4101. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  4102. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  4103. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  4104. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  4105. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  4106. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  4107. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  4108. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  4109. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  4110. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  4111. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  4112. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  4113. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  4114. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  4115. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  4116. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  4117. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  4118. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  4119. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  4120. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  4121. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  4122. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  4123. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  4124. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  4125. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  4126. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  4127. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  4128. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  4129. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  4130. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  4131. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  4132. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  4133. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  4134. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  4135. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  4136. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  4137. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  4138. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  4139. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  4140. return result;
  4141. }
  4142. int ProcessShareMemory()
  4143. {
  4144. if(InitShareMemory() == FAIL)
  4145. {
  4146. DEBUG_ERROR("InitShareMemory NG\n");
  4147. if(ShmStatusCodeData!=NULL)
  4148. {
  4149. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  4150. }
  4151. sleep(5);
  4152. return FAIL;
  4153. }
  4154. return PASS;
  4155. }
  4156. //---------------------common routine---------------------------//
  4157. void checkNetworkProfile(void)
  4158. {
  4159. uint8_t isGetProfile = FALSE;
  4160. json_object *priority;
  4161. priority = json_tokener_parse((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value);
  4162. if(!is_error(priority))
  4163. {
  4164. for(uint8_t idxPriority=0;idxPriority<json_object_array_length(priority);idxPriority++)
  4165. {
  4166. for(uint8_t idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile);idx++)
  4167. {
  4168. if((ShmOCPP20Data->NetworkConnectionProfile[idx].slot == json_object_get_int(json_object_array_get_idx(priority, idxPriority))) &&
  4169. (strlen((char*)ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl) > 0) &&
  4170. (ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount < 3))
  4171. {
  4172. memcpy(ShmOCPP20Data->OcppServerURL, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  4173. memcpy(ShmSysConfigAndInfo->SysConfig.OcppServerURL, ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->NetworkConnectionProfile[idx].connectionData.ocppCsmsUrl));
  4174. isGetProfile = TRUE;
  4175. ShmOCPP20Data->NetworkConnectionProfile[idx].retryCount++;
  4176. break;
  4177. }
  4178. }
  4179. }
  4180. }
  4181. json_object_put(priority);
  4182. if(!isGetProfile && (strlen((char*)ShmOCPP20Data->OcppServerURL) > 0))
  4183. {
  4184. memcpy(ShmSysConfigAndInfo->SysConfig.OcppServerURL, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  4185. }
  4186. DEBUG_INFO("Get network profile URL: %s\n", ShmSysConfigAndInfo->SysConfig.OcppServerURL);
  4187. }
  4188. void CheckSystemValue(void)
  4189. {
  4190. char filenmae[100]={0};
  4191. char str[100]={0};
  4192. int tempIndex = 0;
  4193. //===============================
  4194. // EVSE operation check
  4195. //===============================
  4196. //===============================
  4197. // Heartbeat check
  4198. //===============================
  4199. if((difftime(time((time_t*)NULL), clientTime.Heartbeat) < 0) || (HeartBeatWaitTime <= 0))
  4200. {
  4201. clientTime.Heartbeat = time((time_t*)NULL);
  4202. if(server_sign == TRUE)
  4203. {
  4204. HeartBeatWaitTime = ShmOCPP20Data->BootNotification.Response_interval;
  4205. }
  4206. else
  4207. {
  4208. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);
  4209. }
  4210. }
  4211. if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  4212. {
  4213. //parameter for test
  4214. sendHeartbeatRequest(0);
  4215. //==============================================
  4216. // Reset Waiting Time
  4217. //==============================================
  4218. HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
  4219. }
  4220. //===============================
  4221. // CSU Trigger Reset Conf
  4222. //===============================
  4223. if(isWebsocketSendable && (ShmOCPP20Data->MsMsg.bits.ResetConf == ON))
  4224. {
  4225. sendResetConfirmation((char *)ShmOCPP20Data->Reset.guid);
  4226. }
  4227. //===============================
  4228. // CSU Trigger Authorize Request
  4229. //===============================
  4230. if(isWebsocketSendable &&
  4231. (server_sign == TRUE) &&
  4232. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4233. (authorizeRetryTimes < 3))
  4234. {
  4235. sendAuthorizeRequest(0);
  4236. authorizeRetryTimes = authorizeRetryTimes + 1;
  4237. if(authorizeRetryTimes < 3)
  4238. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4239. }
  4240. else if((server_sign == TRUE) &&
  4241. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4242. (authorizeRetryTimes >= 3))
  4243. {
  4244. authorizeRetryTimes = 0;
  4245. SetOcppConnStatus(FALSE);
  4246. server_sign = FALSE;
  4247. }
  4248. else if((server_sign == FALSE) &&
  4249. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  4250. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  4251. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  4252. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  4253. {
  4254. sendAuthorizeRequest(0);
  4255. }
  4256. if(isWebsocketSendable &&
  4257. (server_sign == TRUE) &&
  4258. (ShmOCPP20Data->GetBaseReport.requestId > 0))
  4259. {
  4260. if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_ConfigurationInventory]) == 0)
  4261. {
  4262. /*
  4263. * TODO:
  4264. * 1. Fill out configuration to response message
  4265. */
  4266. }
  4267. else if(strcmp((char*)ShmOCPP20Data->GetBaseReport.reportBase, ReportBaseEnumTypeStr[ReportBaseEnumType_FullInventory]) == 0)
  4268. {
  4269. /*
  4270. * TODO:
  4271. * 1. Fill out full inventory to response message
  4272. */
  4273. }
  4274. else
  4275. {
  4276. /*
  4277. * TODO:
  4278. * 1. Fill out summary inventory to response message
  4279. */
  4280. }
  4281. sendNotifyReportRequest();
  4282. ShmOCPP20Data->GetBaseReport.requestId = 0;
  4283. }
  4284. if(isWebsocketSendable &&
  4285. (server_sign == TRUE) &&
  4286. ShmOCPP20Data->SpMsg.bits.NotifyEventReq)
  4287. {
  4288. /*
  4289. * TODO:
  4290. * 1. Fill out NotifyEvent message data
  4291. */
  4292. getNowDatetime(ShmOCPP20Data->NotifyEvent.generatedAt);
  4293. ShmOCPP20Data->NotifyEvent.tbc = FALSE;
  4294. if(ShmOCPP20Data->NotifyEvent.seqNo < 2147483647)
  4295. ShmOCPP20Data->NotifyEvent.seqNo += 1;
  4296. else
  4297. ShmOCPP20Data->NotifyEvent.seqNo = 0;
  4298. sendNotifyEventRequest();
  4299. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  4300. }
  4301. //===============================
  4302. // Each connector operation check
  4303. //===============================
  4304. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  4305. {
  4306. //==========================================
  4307. // csu trigger DataTransferReq
  4308. //==========================================
  4309. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  4310. {
  4311. sendDataTransferRequest(gun_index);
  4312. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  4313. }
  4314. //===============================
  4315. // CSU Trigger Smart Charging Profilw
  4316. //===============================
  4317. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  4318. {
  4319. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index]);
  4320. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  4321. }
  4322. //==============================================
  4323. // Charger start transaction
  4324. //==============================================
  4325. /*
  4326. if((ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq == ON))
  4327. {
  4328. ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq = OFF;
  4329. sendStartTransactionRequest(gun_index);
  4330. clientTime.StartTransaction = time((time_t*)NULL);
  4331. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4332. }*/
  4333. //==============================================
  4334. // Charger stop transaction
  4335. //==============================================
  4336. /*
  4337. if(((ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq == ON)))
  4338. {
  4339. ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq =OFF;
  4340. sendStopTransactionRequest(gun_index);
  4341. clientTime.StopTransaction = time((time_t*)NULL);
  4342. }*/
  4343. //==============================================
  4344. // Charger status notification & Transaction event report
  4345. //==============================================
  4346. //--- Check Mode Change ---//
  4347. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  4348. if(gunType[gun_index] == 'J')
  4349. {
  4350. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4351. {
  4352. tempIndex = ((gun_index==2) ? 1: 0);
  4353. }
  4354. else
  4355. {
  4356. tempIndex = gun_index;
  4357. }
  4358. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4359. {
  4360. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4361. {
  4362. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  4363. {
  4364. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  4365. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  4366. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4367. if((SystemInitial == 0) &&
  4368. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4369. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4370. {
  4371. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4372. }
  4373. }
  4374. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4375. {
  4376. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4377. if((access(filenmae,F_OK))!=-1)
  4378. {
  4379. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4380. sprintf(str,"rm -f %s",filenmae);
  4381. system(str);
  4382. }
  4383. }
  4384. #if 1 // for TempStopTransaction
  4385. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4386. {
  4387. checkTempStopTransaction(gun_index);
  4388. }
  4389. #endif
  4390. }
  4391. }
  4392. }
  4393. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4394. {
  4395. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4396. {
  4397. tempIndex = ((gun_index==2) ? 1: 0);
  4398. }
  4399. else
  4400. {
  4401. tempIndex = gun_index;
  4402. }
  4403. for (int index = 0; index < CCS_QUANTITY; index++)
  4404. {
  4405. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4406. {
  4407. 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]*/ )
  4408. {
  4409. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  4410. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  4411. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4412. if((SystemInitial == 0) &&
  4413. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4414. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4415. {
  4416. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4417. }
  4418. }
  4419. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4420. {
  4421. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4422. if((access(filenmae,F_OK))!=-1)
  4423. {
  4424. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4425. sprintf(str,"rm -f %s",filenmae);
  4426. system(str);
  4427. }
  4428. }
  4429. #if 1 // for TempStopTransaction
  4430. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4431. {
  4432. checkTempStopTransaction(gun_index);
  4433. }
  4434. #endif
  4435. }
  4436. }
  4437. }
  4438. else if(gunType[gun_index] == 'G')
  4439. {
  4440. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4441. {
  4442. tempIndex = ((gun_index==2) ? 1: 0);
  4443. }
  4444. else
  4445. {
  4446. tempIndex = gun_index;
  4447. }
  4448. for (int index = 0; index < GB_QUANTITY; index++)
  4449. {
  4450. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4451. {
  4452. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  4453. {
  4454. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  4455. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  4456. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4457. if((SystemInitial == 0) &&
  4458. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4459. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4460. {
  4461. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4462. }
  4463. }
  4464. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4465. {
  4466. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4467. if((access(filenmae,F_OK))!=-1)
  4468. {
  4469. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4470. sprintf(str,"rm -f %s",filenmae);
  4471. system(str);
  4472. }
  4473. }
  4474. #if 1 // for TempStopTransaction
  4475. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4476. {
  4477. checkTempStopTransaction(gun_index);
  4478. }
  4479. #endif
  4480. }
  4481. }
  4482. }
  4483. else if(gunType[gun_index] == 'O')
  4484. {
  4485. tempIndex = gun_index;
  4486. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4487. {
  4488. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4489. {
  4490. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  4491. {
  4492. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  4493. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  4494. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4495. if((SystemInitial == 0) &&
  4496. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING) &&
  4497. (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_COMPLETE))
  4498. {
  4499. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4500. }
  4501. }
  4502. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // complete
  4503. {
  4504. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4505. if((access(filenmae,F_OK))!=-1)
  4506. {
  4507. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4508. sprintf(str,"rm -f %s",filenmae);
  4509. system(str);
  4510. }
  4511. }
  4512. #if 1 // for TempStopTransaction
  4513. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4514. {
  4515. checkTempStopTransaction(gun_index);
  4516. }
  4517. #endif
  4518. }
  4519. }
  4520. }
  4521. else
  4522. {
  4523. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4524. {
  4525. tempIndex = 2;
  4526. }
  4527. else
  4528. {
  4529. tempIndex = gun_index;
  4530. }
  4531. for (int index = 0; index < AC_QUANTITY; index++)
  4532. {
  4533. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4534. {
  4535. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  4536. {
  4537. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  4538. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  4539. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4540. if((SystemInitial == 0) &&
  4541. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING) &&
  4542. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_COMPLETE))
  4543. {
  4544. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4545. }
  4546. }
  4547. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4548. {
  4549. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4550. if((access(filenmae,F_OK))!=-1)
  4551. {
  4552. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4553. sprintf(str,"rm -f %s",filenmae);
  4554. system(str);
  4555. }
  4556. }
  4557. #if 1 // for TempStopTransaction
  4558. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4559. {
  4560. checkTempStopTransaction(gun_index);
  4561. }
  4562. #endif
  4563. }
  4564. }// END
  4565. }
  4566. if(isWebsocketSendable &&
  4567. (cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) &&
  4568. ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 5) )
  4569. {
  4570. if(SystemInitial > 0)
  4571. SystemInitial -= 1;
  4572. sendStatusNotificationRequest(gun_index);
  4573. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  4574. }
  4575. if(isWebsocketSendable && (server_sign == TRUE) && (cpinitateMsg.bits[gun_index].TransactionEventReq == ON))
  4576. {
  4577. sendTransactionEventRequest(gun_index);
  4578. cpinitateMsg.bits[gun_index].TransactionEventReq = OFF;
  4579. memset(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], 0x00, sizeof(struct MeterValueType));
  4580. }
  4581. //==============================================
  4582. // Meter report
  4583. //==============================================
  4584. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  4585. {
  4586. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  4587. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  4588. }
  4589. // ClockAlign MeterValue
  4590. if(isWebsocketSendable && (server_sign == TRUE) && ((atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value) > 0)?((getTimePassSinceToday()%(atoi((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value)))==0):FALSE))
  4591. {
  4592. //check Transaction active
  4593. if(gunType[gun_index] == 'J')
  4594. {
  4595. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4596. {
  4597. tempIndex = ((gun_index==2) ? 1: 0);
  4598. }
  4599. else
  4600. {
  4601. tempIndex = gun_index;
  4602. }
  4603. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4604. {
  4605. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4606. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4607. {
  4608. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4609. {
  4610. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4611. }
  4612. }
  4613. }// End for CHAdeMO
  4614. }
  4615. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4616. {
  4617. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4618. {
  4619. tempIndex = ((gun_index==2) ? 1: 0);
  4620. }
  4621. else
  4622. {
  4623. tempIndex = gun_index;
  4624. }
  4625. for (int index = 0; index < CCS_QUANTITY; index++)
  4626. {
  4627. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4628. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4629. {
  4630. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4631. {
  4632. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4633. }
  4634. }
  4635. } // End for CCS
  4636. }
  4637. else if(gunType[gun_index] == 'G')
  4638. {
  4639. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4640. {
  4641. tempIndex = ((gun_index==2) ? 1: 0);
  4642. }
  4643. else
  4644. {
  4645. tempIndex = gun_index;
  4646. }
  4647. for (int index = 0; index < GB_QUANTITY; index++)
  4648. {
  4649. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4650. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4651. {
  4652. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4653. {
  4654. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4655. }
  4656. }
  4657. }// End for GB
  4658. }
  4659. else if(gunType[gun_index] == 'O')
  4660. {
  4661. tempIndex = gun_index;
  4662. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4663. {
  4664. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4665. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4666. {
  4667. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_CHARGING)
  4668. {
  4669. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4670. }
  4671. }
  4672. }
  4673. }
  4674. else
  4675. {
  4676. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4677. {
  4678. tempIndex = 2;
  4679. }
  4680. else
  4681. {
  4682. tempIndex = gun_index;
  4683. }
  4684. for (int index = 0; index < AC_QUANTITY; index++)
  4685. {
  4686. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4687. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4688. {
  4689. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4690. {
  4691. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4692. }
  4693. }
  4694. }//End for AC
  4695. }
  4696. if(cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON)
  4697. {
  4698. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  4699. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  4700. }
  4701. }
  4702. // Sample period MeterValue
  4703. if(((time((time_t*)NULL) - clientTime.MeterValues[gun_index]) > (atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1)))
  4704. {
  4705. //check Transaction active
  4706. if(gunType[gun_index] == 'J')
  4707. {
  4708. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4709. {
  4710. tempIndex = ((gun_index==2) ? 1: 0);
  4711. }
  4712. else
  4713. {
  4714. tempIndex = gun_index;
  4715. }
  4716. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4717. {
  4718. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4719. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4720. {
  4721. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4722. {
  4723. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4724. }
  4725. }
  4726. }// End for CHAdeMO
  4727. }
  4728. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4729. {
  4730. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4731. {
  4732. tempIndex = ((gun_index==2) ? 1: 0);
  4733. }
  4734. else
  4735. {
  4736. tempIndex = gun_index;
  4737. }
  4738. for (int index = 0; index < CCS_QUANTITY; index++)
  4739. {
  4740. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4741. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4742. {
  4743. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4744. {
  4745. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4746. }
  4747. }
  4748. } // End for CCS
  4749. }
  4750. else if(gunType[gun_index] == 'G')
  4751. {
  4752. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4753. {
  4754. tempIndex = ((gun_index==2) ? 1: 0);
  4755. }
  4756. else
  4757. {
  4758. tempIndex = gun_index;
  4759. }
  4760. for (int index = 0; index < GB_QUANTITY; index++)
  4761. {
  4762. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4763. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4764. {
  4765. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4766. {
  4767. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4768. }
  4769. }
  4770. }// End for GB
  4771. }
  4772. else if(gunType[gun_index] == 'O')
  4773. {
  4774. tempIndex = gun_index;
  4775. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4776. {
  4777. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4778. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4779. {
  4780. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  4781. {
  4782. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4783. }
  4784. }
  4785. }
  4786. }
  4787. else
  4788. {
  4789. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4790. {
  4791. tempIndex = 2;
  4792. }
  4793. else
  4794. {
  4795. tempIndex = gun_index;
  4796. }
  4797. for (int index = 0; index < AC_QUANTITY; index++)
  4798. {
  4799. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4800. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4801. {
  4802. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4803. {
  4804. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4805. }
  4806. }
  4807. }//End for AC
  4808. }
  4809. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  4810. {
  4811. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  4812. storeTempStopTransaction(gun_index);
  4813. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  4814. }
  4815. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4816. }
  4817. //==============================================
  4818. // Check Connector reserved
  4819. //==============================================
  4820. //===============================
  4821. // Check if Reserve is expired
  4822. //===============================
  4823. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0) )
  4824. {
  4825. double diff_t;
  4826. struct tm tp;
  4827. // current time
  4828. time_t t = time(NULL);
  4829. strptime((char *)ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime, "%Y-%m-%dT%H:%M:%S", &tp);
  4830. tp.tm_isdst = -1;
  4831. time_t utc = mktime(&tp);
  4832. diff_t = difftime(utc, t);
  4833. if(diff_t <= 0)
  4834. {
  4835. DEBUG_INFO("reserve expired.\n");
  4836. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  4837. }
  4838. }//END OF Check if Reserve is expired
  4839. //==========================================
  4840. // csu trigger FirmwareStatusNotificationReq
  4841. //==========================================
  4842. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  4843. {
  4844. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  4845. }
  4846. //==========================================
  4847. // csu trigger CancelReservationConf
  4848. //==========================================
  4849. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  4850. {
  4851. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  4852. }
  4853. //==========================================
  4854. // csu trigger ChangeAvailabilityConf
  4855. //==========================================
  4856. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  4857. {
  4858. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  4859. }
  4860. //==========================================
  4861. // csu trigger UnlockConnectorConf
  4862. //==========================================
  4863. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  4864. {
  4865. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  4866. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  4867. }
  4868. //==========================================
  4869. // csu trigger ReserveNowConf
  4870. //==========================================
  4871. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  4872. {
  4873. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  4874. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  4875. }
  4876. }
  4877. }
  4878. //==========================================
  4879. // send request routine
  4880. //==========================================
  4881. int sendAuthorizeRequest(int gun_index)
  4882. {
  4883. mtrace();
  4884. int result = FAIL;
  4885. char message[4096]={0};
  4886. char guid[37];
  4887. char tempdata[128]={0};
  4888. json_object *Authorize = json_object_new_object();
  4889. json_object *idToken = json_object_new_object();
  4890. DEBUG_INFO("sendAuthorizeRequest...\n");
  4891. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  4892. //Local Authorize
  4893. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) && (ShmOCPP20Data->OcppConnStatus == 0))
  4894. {
  4895. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  4896. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4897. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  4898. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  4899. result = PASS;
  4900. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4901. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4902. authorizeRetryTimes = 0;
  4903. return result;
  4904. }
  4905. 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)) ||
  4906. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  4907. {
  4908. // Query idtag from cache
  4909. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  4910. // Query idtag from list
  4911. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4912. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  4913. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4914. {
  4915. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  4916. {
  4917. DEBUG_INFO("Card %s does not find in list or cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  4918. }
  4919. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  4920. {
  4921. DEBUG_INFO("Card %s does not accepted in list and cache\n", ShmSysConfigAndInfo->SysConfig.UserId);
  4922. }
  4923. // Return authorize result if does not connect to server
  4924. if(!ShmOCPP20Data->OcppConnStatus)
  4925. {
  4926. DEBUG_INFO("Local Authorization Fail.\n");
  4927. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4928. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4929. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  4930. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4931. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4932. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4933. authorizeRetryTimes = 0;
  4934. return result;
  4935. }
  4936. }
  4937. else
  4938. {
  4939. DEBUG_INFO("Local Authorization get result.\n");
  4940. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  4941. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4942. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  4943. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  4944. else
  4945. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  4946. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4947. result = PASS;
  4948. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4949. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4950. authorizeRetryTimes = 0;
  4951. return result;
  4952. }
  4953. }
  4954. //initialize struct Authorize
  4955. memset(&(ShmOCPP20Data->Authorize), 0 , sizeof(struct StructAuthorize));
  4956. //get data from shared memory
  4957. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4958. strcpy((char *)ShmOCPP20Data->Authorize.idToken.type, IdTokenEnumTypeStr[IdTokenEnumType_ISO14443]);
  4959. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  4960. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  4961. json_object_object_add(Authorize, "idToken", idToken);
  4962. random_uuid(guid);
  4963. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  4964. json_object_put(Authorize);
  4965. LWS_Send(message);
  4966. sprintf(tempdata, "Authorize,%d", gun_index);
  4967. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4968. {
  4969. result = PASS;
  4970. }
  4971. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4972. return result;
  4973. }
  4974. int sendBootNotificationRequest()
  4975. {
  4976. mtrace();
  4977. int result = FAIL;
  4978. char message[4096]={0};
  4979. char guid[37]={0};
  4980. char tempdata[128]={0};
  4981. json_object *BootNotification = json_object_new_object();
  4982. json_object *chargingStation = json_object_new_object();
  4983. json_object *modem = json_object_new_object();
  4984. DEBUG_INFO("sendBootNotificationRequest...\n");
  4985. // Fill BootNotification fields
  4986. DB_getBooType();
  4987. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  4988. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  4989. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  4990. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  4991. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  4992. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  4993. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  4994. {
  4995. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  4996. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  4997. json_object_object_add(chargingStation, "modem", modem);
  4998. }
  4999. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  5000. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  5001. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  5002. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  5003. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  5004. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  5005. random_uuid(guid);
  5006. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  5007. json_object_put(BootNotification);
  5008. LWS_Send(message);
  5009. sprintf(tempdata, "BootNotification,0");
  5010. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5011. {
  5012. result = PASS;
  5013. }
  5014. return result;
  5015. }
  5016. int sendClearedChargingLimitRequest(int gun_index)
  5017. {
  5018. mtrace();
  5019. int result = FAIL;
  5020. char message[4096]={0};
  5021. char guid[37]={0};
  5022. char tempdata[128]={0};
  5023. json_object *ClearedChargingLimit = json_object_new_object();
  5024. DEBUG_INFO("sendClearedChargingLimitRequest...\n");
  5025. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  5026. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  5027. random_uuid(guid);
  5028. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  5029. json_object_put(ClearedChargingLimit);
  5030. LWS_Send(message);
  5031. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  5032. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5033. {
  5034. result = PASS;
  5035. }
  5036. return result;
  5037. }
  5038. int sendDataTransferRequest(int gun_index)
  5039. {
  5040. mtrace();
  5041. char message[1000]={0};
  5042. char guid[37]={0};
  5043. char tempdata[65]={0};
  5044. int result = FAIL;
  5045. DEBUG_INFO("sendDataTransferRequest...\n");
  5046. random_uuid(guid);
  5047. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  5048. MESSAGE_TYPE_CALL,
  5049. guid,
  5050. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  5051. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  5052. ShmOCPP20Data->DataTransfer[gun_index].data);
  5053. LWS_Send(message);
  5054. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  5055. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5056. {
  5057. result = PASS;
  5058. }
  5059. return result;
  5060. }
  5061. int sendFirmwareStatusNotificationRequest(char *status)
  5062. {
  5063. mtrace();
  5064. int result = FAIL;
  5065. char message[110]={0};
  5066. char guid[37]={0};
  5067. char tempdata[65]={0};
  5068. json_object *FirmwareStatusNotification = json_object_new_object();
  5069. DEBUG_INFO("sendFirmwareStatusNotificationRequest...\n");
  5070. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  5071. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  5072. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  5073. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  5074. random_uuid(guid);
  5075. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  5076. json_object_put(FirmwareStatusNotification);
  5077. LWS_SendNow(message);
  5078. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  5079. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5080. {
  5081. result = PASS;
  5082. }
  5083. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  5084. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  5085. //record status
  5086. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  5087. {
  5088. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  5089. }
  5090. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  5091. {
  5092. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  5093. }
  5094. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  5095. {
  5096. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  5097. }
  5098. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  5099. {
  5100. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  5101. }
  5102. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  5103. {
  5104. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  5105. }
  5106. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  5107. {
  5108. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  5109. }
  5110. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  5111. {
  5112. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  5113. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5114. }
  5115. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  5116. {
  5117. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  5118. }
  5119. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  5120. {
  5121. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  5122. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5123. }
  5124. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  5125. {
  5126. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  5127. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  5128. }
  5129. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  5130. {
  5131. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  5132. }
  5133. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  5134. {
  5135. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  5136. }
  5137. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  5138. {
  5139. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  5140. }
  5141. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  5142. {
  5143. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  5144. }
  5145. return result;
  5146. }
  5147. int sendGet15118EVCertificateRequest()
  5148. {
  5149. mtrace();
  5150. int result = FAIL;
  5151. char message[4096]={0};
  5152. char guid[37]={0};
  5153. char tempdata[128]={0};
  5154. json_object *Get15118EVCertificate = json_object_new_object();
  5155. DEBUG_INFO("sendGet15118EVCertificateRequest...\n");
  5156. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  5157. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  5158. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  5159. random_uuid(guid);
  5160. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  5161. json_object_put(Get15118EVCertificate);
  5162. LWS_Send(message);
  5163. sprintf(tempdata, "Get15118EVCertificate,0");
  5164. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5165. {
  5166. result = PASS;
  5167. }
  5168. return result;
  5169. }
  5170. int sendGetCertificateStatusRequest()
  5171. {
  5172. mtrace();
  5173. int result = FAIL;
  5174. char message[4096]={0};
  5175. char guid[37]={0};
  5176. char tempdata[128]={0};
  5177. json_object *GetCertificateStatus = json_object_new_object();
  5178. json_object *ocspRequestData = json_object_new_object();
  5179. DEBUG_INFO("sendGetCertificateStatusRequest...\n");
  5180. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  5181. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  5182. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  5183. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  5184. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  5185. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  5186. random_uuid(guid);
  5187. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  5188. json_object_put(GetCertificateStatus);
  5189. LWS_Send(message);
  5190. sprintf(tempdata, "GetCertificateStatus,0");
  5191. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5192. {
  5193. result = PASS;
  5194. }
  5195. return result;
  5196. }
  5197. int sendHeartbeatRequest()
  5198. {
  5199. mtrace();
  5200. int result = FAIL;
  5201. char message[40096]={0};
  5202. char guid[37]={0};
  5203. char tempdata[128]={0};
  5204. DEBUG_INFO("sendHeartbeatRequest...\n");
  5205. random_uuid(guid);
  5206. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  5207. , MESSAGE_TYPE_CALL
  5208. , guid );
  5209. LWS_Send(message);
  5210. sprintf(tempdata, "Heartbeat,%d", 0);
  5211. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5212. {
  5213. result = PASS;
  5214. }
  5215. return result;
  5216. }
  5217. int sendLogStatusNotificationRequest(char *status)
  5218. {
  5219. mtrace();
  5220. int result = FAIL;
  5221. char message[4096]={0};
  5222. char guid[37]={0};
  5223. char tempdata[128]={0};
  5224. json_object *LogStatusNotification = json_object_new_object();
  5225. DEBUG_INFO("sendLogStatusNotificationRequest...\n");
  5226. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  5227. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  5228. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  5229. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  5230. random_uuid(guid);
  5231. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  5232. json_object_put(LogStatusNotification);
  5233. LWS_SendNow(message);
  5234. sprintf(tempdata, "LogStatusNotification,%d", 0);
  5235. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5236. {
  5237. result = PASS;
  5238. }
  5239. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  5240. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  5241. //record status
  5242. if(strcmp(status,"BadMessage")==0)
  5243. {
  5244. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  5245. }
  5246. else if(strcmp(status,"Idle")==0)
  5247. {
  5248. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  5249. }
  5250. else if(strcmp(status,"NotSupportedOperation")==0)
  5251. {
  5252. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  5253. }
  5254. else if(strcmp(status,"PermissionDenied")==0)
  5255. {
  5256. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  5257. }
  5258. else if(strcmp(status,"Uploaded")==0)
  5259. {
  5260. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  5261. }
  5262. else if(strcmp(status,"UploadFailure")==0)
  5263. {
  5264. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  5265. }
  5266. else if(strcmp(status,"Uploading")==0)
  5267. {
  5268. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  5269. }
  5270. return result;
  5271. }
  5272. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  5273. {
  5274. mtrace();
  5275. int result = FAIL;
  5276. char guid[37]={0};
  5277. char tempdata[65]={0};
  5278. int tempIndex = 0;
  5279. json_object *MeterValueReq = json_object_new_object();
  5280. json_object *meterValues = json_object_new_array();
  5281. json_object *sampledValues = json_object_new_array();
  5282. DEBUG_INFO("sendMeterValuesRequest...\n");
  5283. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  5284. //set value
  5285. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  5286. //UTC Date time
  5287. struct timeval tmnow;
  5288. struct tm *tm;
  5289. char buf[28];//, usec_buf[6];
  5290. gettimeofday(&tmnow, NULL);
  5291. time_t t;
  5292. t = time(NULL);
  5293. /*UTC time and date*/
  5294. tm = gmtime(&t);
  5295. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  5296. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  5297. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  5298. //idx_sample=0;
  5299. //********************************(1)Current.Import L1************************************************/
  5300. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5301. if(gunType[gun_index] == 'J')
  5302. {
  5303. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5304. {
  5305. tempIndex = ((gun_index==2) ? 1: 0);
  5306. }
  5307. else
  5308. {
  5309. tempIndex = gun_index;
  5310. }
  5311. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5312. {
  5313. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5314. {
  5315. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent;
  5316. }
  5317. }
  5318. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5319. }
  5320. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5321. {
  5322. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5323. {
  5324. tempIndex = ((gun_index==2) ? 1: 0);
  5325. }
  5326. else
  5327. {
  5328. tempIndex = gun_index;
  5329. }
  5330. for (int index = 0; index < CCS_QUANTITY; index++)
  5331. {
  5332. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5333. {
  5334. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent;
  5335. }
  5336. }
  5337. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5338. }
  5339. else if(gunType[gun_index] == 'G')
  5340. {
  5341. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5342. {
  5343. tempIndex = ((gun_index==2) ? 1: 0);
  5344. }
  5345. else
  5346. {
  5347. tempIndex = gun_index;
  5348. }
  5349. for (int index = 0; index < GB_QUANTITY; index++)
  5350. {
  5351. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5352. {
  5353. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent;
  5354. }
  5355. }
  5356. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5357. }
  5358. else if(gunType[gun_index] == 'O')
  5359. {
  5360. tempIndex = gun_index;
  5361. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5362. {
  5363. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5364. {
  5365. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent;
  5366. }
  5367. }
  5368. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5369. }
  5370. else
  5371. {
  5372. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5373. {
  5374. tempIndex = 2;
  5375. }
  5376. else
  5377. {
  5378. tempIndex = gun_index;
  5379. }
  5380. for (int index = 0; index < AC_QUANTITY; index++)
  5381. {
  5382. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5383. {
  5384. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent;
  5385. }
  5386. }
  5387. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5388. }
  5389. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  5390. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5391. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5392. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  5393. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  5394. //idx_sample=1;
  5395. //********************************(2)Energy.Active.Import.Register ************************************************/
  5396. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5397. if(gunType[gun_index] == 'J')
  5398. {
  5399. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5400. {
  5401. tempIndex = ((gun_index==2) ? 1: 0);
  5402. }
  5403. else
  5404. {
  5405. tempIndex = gun_index;
  5406. }
  5407. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5408. {
  5409. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5410. {
  5411. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  5412. }
  5413. }
  5414. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5415. }
  5416. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5417. {
  5418. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5419. {
  5420. tempIndex = ((gun_index==2) ? 1: 0);
  5421. }
  5422. else
  5423. {
  5424. tempIndex = gun_index;
  5425. }
  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[1].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  5431. }
  5432. }
  5433. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5434. }
  5435. else if(gunType[gun_index] == 'G')
  5436. {
  5437. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5438. {
  5439. tempIndex = ((gun_index==2) ? 1: 0);
  5440. }
  5441. else
  5442. {
  5443. tempIndex = gun_index;
  5444. }
  5445. for (int index = 0; index < GB_QUANTITY; index++)
  5446. {
  5447. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5448. {
  5449. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  5450. }
  5451. }
  5452. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5453. }
  5454. else if(gunType[gun_index] == 'O')
  5455. {
  5456. tempIndex = gun_index;
  5457. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5458. {
  5459. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5460. {
  5461. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  5462. }
  5463. }
  5464. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5465. }
  5466. else
  5467. {
  5468. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5469. {
  5470. tempIndex = 2;
  5471. }
  5472. else
  5473. {
  5474. tempIndex = gun_index;
  5475. }
  5476. for (int index = 0; index < AC_QUANTITY; index++)
  5477. {
  5478. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5479. {
  5480. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  5481. }
  5482. }
  5483. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5484. }
  5485. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  5486. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  5487. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5488. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  5489. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5490. //idx_sample=2;
  5491. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  5492. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5493. if(gunType[gun_index] == 'J')
  5494. {
  5495. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5496. {
  5497. tempIndex = ((gun_index==2) ? 1: 0);
  5498. }
  5499. else
  5500. {
  5501. tempIndex = gun_index;
  5502. }
  5503. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5504. {
  5505. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5506. {
  5507. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
  5508. }
  5509. } // END OF FOR CHAdeMO_QUANTITY
  5510. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5511. }
  5512. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5513. {
  5514. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5515. {
  5516. tempIndex = ((gun_index==2) ? 1: 0);
  5517. }
  5518. else
  5519. {
  5520. tempIndex = gun_index;
  5521. }
  5522. for (int index = 0; index < CCS_QUANTITY; index++)
  5523. {
  5524. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5525. {
  5526. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
  5527. }
  5528. } // END OF CCS_QUANTITY
  5529. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5530. }
  5531. else if(gunType[gun_index] == 'G')
  5532. {
  5533. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5534. {
  5535. tempIndex = ((gun_index==2) ? 1: 0);
  5536. }
  5537. else
  5538. {
  5539. tempIndex = gun_index;
  5540. }
  5541. for (int index = 0; index < GB_QUANTITY; index++)
  5542. {
  5543. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5544. {
  5545. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
  5546. }
  5547. } // END OF GB_QUANTITY
  5548. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5549. }
  5550. else if(gunType[gun_index] == 'O')
  5551. {
  5552. tempIndex = gun_index;
  5553. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5554. {
  5555. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5556. {
  5557. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy;
  5558. }
  5559. }
  5560. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5561. }
  5562. else
  5563. {
  5564. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5565. {
  5566. tempIndex = 2;
  5567. }
  5568. else
  5569. {
  5570. tempIndex = gun_index;
  5571. }
  5572. for (int index = 0; index < AC_QUANTITY; index++)
  5573. {
  5574. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5575. {
  5576. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
  5577. }
  5578. }
  5579. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5580. }
  5581. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  5582. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  5583. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5584. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  5585. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5586. //idx_sample=3;
  5587. //********************************(4)Power.Active.Import************************************************/
  5588. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5589. if(gunType[gun_index] == 'J')
  5590. {
  5591. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5592. {
  5593. tempIndex = ((gun_index==2) ? 1: 0);
  5594. }
  5595. else
  5596. {
  5597. tempIndex = gun_index;
  5598. }
  5599. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5600. {
  5601. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5602. {
  5603. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower;
  5604. }
  5605. } // END OF FOR
  5606. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5607. }
  5608. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5609. {
  5610. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5611. {
  5612. tempIndex = ((gun_index==2) ? 1: 0);
  5613. }
  5614. else
  5615. {
  5616. tempIndex = gun_index;
  5617. }
  5618. for (int index = 0; index < CCS_QUANTITY; index++)
  5619. {
  5620. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5621. {
  5622. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower;
  5623. }
  5624. }
  5625. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5626. }
  5627. else if(gunType[gun_index] == 'G')
  5628. {
  5629. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5630. {
  5631. tempIndex = ((gun_index==2) ? 1: 0);
  5632. }
  5633. else
  5634. {
  5635. tempIndex = gun_index;
  5636. }
  5637. for (int index = 0; index < GB_QUANTITY; index++)
  5638. {
  5639. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5640. {
  5641. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5642. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower;
  5643. }
  5644. }
  5645. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5646. }
  5647. else if(gunType[gun_index] == 'O')
  5648. {
  5649. tempIndex = gun_index;
  5650. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5651. {
  5652. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5653. {
  5654. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5655. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower;
  5656. }
  5657. }
  5658. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5659. }
  5660. else
  5661. {
  5662. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5663. {
  5664. tempIndex = 2;
  5665. }
  5666. else
  5667. {
  5668. tempIndex = gun_index;
  5669. }
  5670. for (int index = 0; index < AC_QUANTITY; index++)
  5671. {
  5672. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5673. {
  5674. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower;
  5675. }
  5676. }
  5677. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5678. }
  5679. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  5680. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  5681. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5682. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  5683. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  5684. //idx_sample=4;
  5685. //***********************************************(5)VOLTAGE L1******************************************************/
  5686. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5687. if(gunType[gun_index] == 'J')
  5688. {
  5689. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5690. {
  5691. tempIndex = ((gun_index==2) ? 1: 0);
  5692. }
  5693. else
  5694. {
  5695. tempIndex = gun_index;
  5696. }
  5697. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5698. {
  5699. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5700. {
  5701. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage;
  5702. }
  5703. }
  5704. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5705. }
  5706. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5707. {
  5708. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5709. {
  5710. tempIndex = ((gun_index==2) ? 1: 0);
  5711. }
  5712. else
  5713. {
  5714. tempIndex = gun_index;
  5715. }
  5716. for (int index = 0; index < CCS_QUANTITY; index++)
  5717. {
  5718. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5719. {
  5720. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage;
  5721. }
  5722. }
  5723. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5724. }
  5725. else if(gunType[gun_index] == 'G')
  5726. {
  5727. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5728. {
  5729. tempIndex = ((gun_index==2) ? 1: 0);
  5730. }
  5731. else
  5732. {
  5733. tempIndex = gun_index;
  5734. }
  5735. for (int index = 0; index < GB_QUANTITY; index++)
  5736. {
  5737. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5738. {
  5739. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage;
  5740. }
  5741. }
  5742. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5743. }
  5744. else if(gunType[gun_index] == 'O')
  5745. {
  5746. tempIndex = gun_index;
  5747. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5748. {
  5749. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5750. {
  5751. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage;
  5752. }
  5753. }
  5754. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5755. }
  5756. else
  5757. {
  5758. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5759. {
  5760. tempIndex = 2;
  5761. }
  5762. else
  5763. {
  5764. tempIndex = gun_index;
  5765. }
  5766. for (int index = 0; index < AC_QUANTITY; index++)
  5767. {
  5768. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5769. {
  5770. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage;
  5771. }
  5772. }
  5773. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5774. }
  5775. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  5776. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5777. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5778. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  5779. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  5780. //***********************************************(6)SOC******************************************************/
  5781. if((gunType[gun_index] == 'J')||(gunType[gun_index] == 'U')||(gunType[gun_index] == 'E')||(gunType[gun_index] == 'G'))
  5782. {
  5783. //idx_sample=5;
  5784. //sampledValue = NULL;
  5785. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5786. {
  5787. tempIndex = ((gun_index==2) ? 1: 0);
  5788. }
  5789. else
  5790. {
  5791. tempIndex = gun_index;
  5792. }
  5793. if(gunType[gun_index] == 'J')
  5794. {
  5795. //tempIndex = ((gun_index==2) ? 1: 0);
  5796. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5797. {
  5798. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5799. {
  5800. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  5801. }
  5802. }
  5803. }
  5804. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5805. {
  5806. //tempIndex = ((gun_index==2) ? 1: 0);
  5807. for (int index = 0; index < CCS_QUANTITY; index++)
  5808. {
  5809. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5810. {
  5811. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  5812. }
  5813. }
  5814. }
  5815. else if(gunType[gun_index] == 'G')
  5816. {
  5817. //tempIndex = ((gun_index==2) ? 1: 0);
  5818. for (int index = 0; index < GB_QUANTITY; index++)
  5819. {
  5820. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5821. {
  5822. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  5823. }
  5824. }
  5825. }
  5826. else if(gunType[gun_index] == 'O')
  5827. {
  5828. //tempIndex = ((gun_index==2) ? 1: 0);
  5829. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5830. {
  5831. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5832. {
  5833. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  5834. }
  5835. }
  5836. }
  5837. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  5838. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  5839. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5840. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  5841. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  5842. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  5843. }
  5844. //********************************(7)Current.Import L2************************************************/
  5845. // Only for AC 3 phase
  5846. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5847. {
  5848. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5849. {
  5850. tempIndex = 2;
  5851. }
  5852. else
  5853. {
  5854. tempIndex = gun_index;
  5855. }
  5856. for (int index = 0; index < AC_QUANTITY; index++)
  5857. {
  5858. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5859. {
  5860. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2;
  5861. }
  5862. }
  5863. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5864. }
  5865. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  5866. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5867. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5868. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  5869. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  5870. //********************************(8)Current.Import L3************************************************/
  5871. // Only for AC 3 phase
  5872. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5873. {
  5874. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5875. {
  5876. tempIndex = 2;
  5877. }
  5878. else
  5879. {
  5880. tempIndex = gun_index;
  5881. }
  5882. for (int index = 0; index < AC_QUANTITY; index++)
  5883. {
  5884. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5885. {
  5886. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3;
  5887. }
  5888. }
  5889. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5890. }
  5891. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  5892. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5893. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5894. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  5895. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  5896. //***********************************************(9)VOLTAGE L2******************************************************/
  5897. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5898. {
  5899. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5900. {
  5901. tempIndex = 2;
  5902. }
  5903. else
  5904. {
  5905. tempIndex = gun_index;
  5906. }
  5907. for (int index = 0; index < AC_QUANTITY; index++)
  5908. {
  5909. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5910. {
  5911. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2;
  5912. }
  5913. }
  5914. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5915. }
  5916. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  5917. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5918. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5919. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  5920. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  5921. //***********************************************(10)VOLTAGE L3******************************************************/
  5922. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5923. {
  5924. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5925. {
  5926. tempIndex = 2;
  5927. }
  5928. else
  5929. {
  5930. tempIndex = gun_index;
  5931. }
  5932. for (int index = 0; index < AC_QUANTITY; index++)
  5933. {
  5934. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5935. {
  5936. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3;
  5937. }
  5938. }
  5939. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5940. }
  5941. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  5942. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5943. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5944. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  5945. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  5946. // Message create ====================================================================================================
  5947. random_uuid(guid);
  5948. for(uint8_t idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue);idxMeter++)
  5949. {
  5950. json_object *meterValue = json_object_new_object();
  5951. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  5952. {
  5953. if(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value > 0)
  5954. {
  5955. json_object *sampledValue = json_object_new_object();
  5956. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  5957. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  5958. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  5959. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  5960. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  5961. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  5962. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  5963. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  5964. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  5965. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  5966. {
  5967. json_object *unitOfMeasure = json_object_new_object();
  5968. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  5969. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  5970. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  5971. }
  5972. json_object_array_add(sampledValues, sampledValue);
  5973. }
  5974. }
  5975. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  5976. json_object_object_add(meterValue, "sampledValue", sampledValues);
  5977. json_object_array_add(meterValues, meterValue);
  5978. idxMeter++;
  5979. }
  5980. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  5981. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  5982. sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",%s]"
  5983. ,gun_index + 1
  5984. ,MESSAGE_TYPE_CALL
  5985. ,guid
  5986. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  5987. json_object_put(MeterValueReq);
  5988. if((strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]) == 0) ||
  5989. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]) == 0) ||
  5990. (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState, ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]) == 0))
  5991. {
  5992. // Transaction meter value send by TransactionEvent message
  5993. memcpy(&ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0], &ShmOCPP20Data->MeterValues[gun_index].meterValue[0], sizeof(struct MeterValueType));
  5994. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  5995. result = PASS;
  5996. }
  5997. else
  5998. {
  5999. // Put request guid to hash map
  6000. sprintf(tempdata, "MeterValues,%d", (gun_index));
  6001. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6002. {
  6003. result = PASS;
  6004. }
  6005. if((dataType != ReadingContextEnumType_Trigger) &&
  6006. (dataType != ReadingContextEnumType_Sample_Clock))
  6007. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  6008. else
  6009. {
  6010. if(FirstHeartBeat)
  6011. LWS_Send(queuedata +2);
  6012. }
  6013. }
  6014. return result;
  6015. }
  6016. int sendNotifyChargingLimitRequest(int gun_index)
  6017. {
  6018. mtrace();
  6019. int result = FAIL;
  6020. char message[4096]={0};
  6021. char guid[37]={0};
  6022. char tempdata[128]={0};
  6023. json_object *NotifyChargingLimit = json_object_new_object();
  6024. json_object *chargingLimit = json_object_new_object();
  6025. DEBUG_INFO("sendNotifyChargingLimitRequest...\n");
  6026. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  6027. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  6028. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  6029. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  6030. random_uuid(guid);
  6031. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  6032. json_object_put(NotifyChargingLimit);
  6033. LWS_Send(message);
  6034. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  6035. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6036. {
  6037. result = PASS;
  6038. }
  6039. return result;
  6040. }
  6041. int sendNotifyCustomerInformationRequest()
  6042. {
  6043. mtrace();
  6044. int result = FAIL;
  6045. char message[4096]={0};
  6046. char guid[37]={0};
  6047. char tempdata[128]={0};
  6048. json_object *NotifyCustomerInformation = json_object_new_object();
  6049. DEBUG_INFO("sendNotifyCustomerInformationRequest...\n");
  6050. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  6051. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  6052. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  6053. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  6054. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  6055. random_uuid(guid);
  6056. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  6057. json_object_put(NotifyCustomerInformation);
  6058. LWS_Send(message);
  6059. sprintf(tempdata, "NotifyCustomerInformation,0");
  6060. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6061. {
  6062. result = PASS;
  6063. }
  6064. return result;
  6065. }
  6066. int sendNotifyDisplayMessagesRequest()
  6067. {
  6068. mtrace();
  6069. int result = FAIL;
  6070. char message[4096]={0};
  6071. char guid[37]={0};
  6072. char tempdata[128]={0};
  6073. json_object *NotifyDisplayMessages = json_object_new_object();
  6074. json_object *messageInfos = json_object_new_array();
  6075. DEBUG_INFO("sendNotifyDisplayMessagesRequest...\n");
  6076. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  6077. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  6078. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  6079. {
  6080. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  6081. {
  6082. json_object *messageInfo = json_object_new_object();
  6083. json_object *message = json_object_new_object();
  6084. json_object *display = json_object_new_object();
  6085. json_object *evse = json_object_new_object();
  6086. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  6087. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  6088. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  6089. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  6090. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  6091. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  6092. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  6093. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  6094. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  6095. json_object_object_add(messageInfo, "message", message);
  6096. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  6097. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  6098. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  6099. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  6100. json_object_object_add(display, "evse",evse);
  6101. json_object_object_add(messageInfo, "evse", display);
  6102. json_object_array_add(messageInfos, messageInfo);
  6103. }
  6104. }
  6105. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  6106. random_uuid(guid);
  6107. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  6108. json_object_put(NotifyDisplayMessages);
  6109. LWS_Send(message);
  6110. sprintf(tempdata, "NotifyDisplayMessages,0");
  6111. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6112. {
  6113. result = PASS;
  6114. }
  6115. return result;
  6116. }
  6117. int sendNotifyEVChargingNeedsRequest(int gun_index)
  6118. {
  6119. mtrace();
  6120. int result = FAIL;
  6121. char message[4096]={0};
  6122. char guid[37]={0};
  6123. char tempdata[128]={0};
  6124. json_object *NotifyEVChargingNeeds = json_object_new_object();
  6125. json_object *chargingNeeds = json_object_new_object();
  6126. json_object *acChargingParameters = json_object_new_object();
  6127. json_object *dcChargingParameters = json_object_new_object();
  6128. DEBUG_INFO("sendNotifyEVChargingNeedsRequest...\n");
  6129. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  6130. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  6131. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  6132. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  6133. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  6134. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  6135. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  6136. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  6137. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  6138. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  6139. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  6140. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  6141. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  6142. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  6143. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  6144. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  6145. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  6146. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  6147. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  6148. random_uuid(guid);
  6149. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  6150. json_object_put(NotifyEVChargingNeeds);
  6151. LWS_Send(message);
  6152. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  6153. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6154. {
  6155. result = PASS;
  6156. }
  6157. return result;
  6158. }
  6159. int sendNotifyEVChargingScheduleRequest(int gun_index)
  6160. {
  6161. mtrace();
  6162. int result = FAIL;
  6163. char message[4096]={0};
  6164. char guid[37]={0};
  6165. char tempdata[128]={0};
  6166. json_object *NotifyEVChargingSchedule = json_object_new_object();
  6167. json_object *chargingSchedule = json_object_new_object();
  6168. json_object *periods = json_object_new_array();
  6169. DEBUG_INFO("sendNotifyEVChargingScheduleRequest...\n");
  6170. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  6171. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  6172. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  6173. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  6174. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  6175. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  6176. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  6177. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  6178. {
  6179. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  6180. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  6181. {
  6182. json_object *Period = json_object_new_object();
  6183. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  6184. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  6185. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  6186. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  6187. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  6188. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  6189. json_object_array_add(periods, Period);
  6190. }
  6191. }
  6192. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  6193. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  6194. random_uuid(guid);
  6195. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  6196. json_object_put(NotifyEVChargingSchedule);
  6197. LWS_Send(message);
  6198. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  6199. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6200. {
  6201. result = PASS;
  6202. }
  6203. return result;
  6204. }
  6205. int sendNotifyEventRequest()
  6206. {
  6207. mtrace();
  6208. int result = FAIL;
  6209. char message[4096]={0};
  6210. char guid[37]={0};
  6211. char tempdata[128]={0};
  6212. json_object *NotifyEvent = json_object_new_object();
  6213. json_object *eventDatas = json_object_new_array();
  6214. DEBUG_INFO("sendNotifyEventRequest...\n");
  6215. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  6216. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  6217. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  6218. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  6219. {
  6220. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  6221. {
  6222. json_object *eventData = json_object_new_object();
  6223. json_object *component = json_object_new_object();
  6224. json_object *evse = json_object_new_object();
  6225. json_object *variable = json_object_new_object();
  6226. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  6227. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  6228. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  6229. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  6230. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  6231. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  6232. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  6233. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  6234. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  6235. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  6236. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  6237. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  6238. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  6239. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  6240. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  6241. json_object_object_add(component, "evse",evse);
  6242. json_object_object_add(eventData, "component", component);
  6243. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  6244. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  6245. json_object_object_add(eventData, "variable", variable);
  6246. json_object_array_add(eventDatas, eventData);
  6247. }
  6248. }
  6249. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  6250. random_uuid(guid);
  6251. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  6252. json_object_put(NotifyEvent);
  6253. LWS_Send(message);
  6254. sprintf(tempdata, "NotifyEvent,0");
  6255. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6256. {
  6257. result = PASS;
  6258. }
  6259. return result;
  6260. }
  6261. int sendNotifyMonitoringReportRequest()
  6262. {
  6263. mtrace();
  6264. int result = FAIL;
  6265. char message[4096]={0};
  6266. char guid[37]={0};
  6267. char tempdata[128]={0};
  6268. json_object *NotifyMonitoringReport = json_object_new_object();
  6269. json_object *monitors = json_object_new_array();
  6270. DEBUG_INFO("sendNotifyMonitoringReportRequest...\n");
  6271. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  6272. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  6273. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  6274. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  6275. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  6276. {
  6277. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  6278. {
  6279. json_object *monitor = json_object_new_object();
  6280. json_object *component = json_object_new_object();
  6281. json_object *evse = json_object_new_object();
  6282. json_object *variable = json_object_new_object();
  6283. json_object *variableMonitorings = json_object_new_array();
  6284. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  6285. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  6286. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  6287. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  6288. json_object_object_add(component, "evse",evse);
  6289. json_object_object_add(monitor, "component", component);
  6290. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  6291. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  6292. json_object_object_add(monitor, "variable", variable);
  6293. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  6294. {
  6295. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  6296. {
  6297. json_object *variableMonitoring = json_object_new_object();
  6298. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  6299. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  6300. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  6301. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  6302. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  6303. json_object_array_add(variableMonitorings, variableMonitoring);
  6304. }
  6305. }
  6306. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  6307. json_object_array_add(monitors, monitor);
  6308. }
  6309. }
  6310. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  6311. random_uuid(guid);
  6312. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  6313. json_object_put(NotifyMonitoringReport);
  6314. LWS_Send(message);
  6315. sprintf(tempdata, "NotifyMonitoringReport,0");
  6316. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6317. {
  6318. result = PASS;
  6319. }
  6320. return result;
  6321. }
  6322. int sendNotifyReportRequest()
  6323. {
  6324. mtrace();
  6325. int result = FAIL;
  6326. char message[4096]={0};
  6327. char guid[37]={0};
  6328. char tempdata[128]={0};
  6329. json_object *NotifyReport = json_object_new_object();
  6330. json_object *reportDatas = json_object_new_array();
  6331. DEBUG_INFO("sendNotifyReportRequest...\n");
  6332. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  6333. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  6334. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  6335. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  6336. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  6337. {
  6338. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  6339. {
  6340. json_object *reportData = json_object_new_object();
  6341. json_object *component = json_object_new_object();
  6342. json_object *evse = json_object_new_object();
  6343. json_object *variable = json_object_new_object();
  6344. json_object *variableAttributes = json_object_new_array();
  6345. json_object *variableCharacteristics = json_object_new_object();
  6346. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  6347. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  6348. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  6349. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  6350. json_object_object_add(component, "evse",evse);
  6351. json_object_object_add(reportData, "component", component);
  6352. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  6353. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  6354. json_object_object_add(reportData, "variable",variable);
  6355. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  6356. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  6357. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  6358. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  6359. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  6360. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  6361. {
  6362. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  6363. {
  6364. json_object *variableAttribute = json_object_new_object();
  6365. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  6366. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  6367. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  6368. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  6369. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  6370. json_object_array_add(variableAttributes, variableAttribute);
  6371. }
  6372. }
  6373. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  6374. json_object_array_add(reportDatas, reportData);
  6375. }
  6376. }
  6377. json_object_object_add(NotifyReport, "reportData", reportDatas);
  6378. random_uuid(guid);
  6379. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  6380. json_object_put(NotifyReport);
  6381. LWS_Send(message);
  6382. sprintf(tempdata, "NotifyReport,0");
  6383. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6384. {
  6385. result = PASS;
  6386. }
  6387. return result;
  6388. }
  6389. int sendPublishFirmwareStatusNotificationRequest()
  6390. {
  6391. mtrace();
  6392. int result = FAIL;
  6393. char message[4096]={0};
  6394. char guid[37]={0};
  6395. char tempdata[128]={0};
  6396. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  6397. json_object *locations = json_object_new_array();
  6398. DEBUG_INFO("sendPublishFirmwareStatusNotificationRequest...\n");
  6399. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  6400. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  6401. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  6402. {
  6403. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  6404. }
  6405. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  6406. random_uuid(guid);
  6407. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  6408. json_object_put(PublishFirmwareStatusNotification);
  6409. LWS_Send(message);
  6410. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  6411. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6412. {
  6413. result = PASS;
  6414. }
  6415. return result;
  6416. }
  6417. int sendReportChargingProfilesRequest(int gun_index)
  6418. {
  6419. mtrace();
  6420. int result = FAIL;
  6421. char message[4096]={0};
  6422. char guid[37]={0};
  6423. char tempdata[128]={0};
  6424. json_object *ReportChargingProfiles = json_object_new_object();
  6425. json_object *chargingProfiles = json_object_new_array();
  6426. DEBUG_INFO("sendReportChargingProfilesRequest...\n");
  6427. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  6428. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  6429. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  6430. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  6431. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  6432. {
  6433. json_object *chargingProfile = json_object_new_object();
  6434. json_object *chargingSchedules = json_object_new_array();
  6435. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  6436. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  6437. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  6438. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  6439. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  6440. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  6441. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  6442. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  6443. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  6444. {
  6445. json_object *chargingSchedule = json_object_new_object();
  6446. json_object *chargingSchedulePeriods = json_object_new_array();
  6447. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  6448. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  6449. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  6450. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  6451. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  6452. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  6453. {
  6454. json_object *chargingSchedulePeriod = json_object_new_object();
  6455. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  6456. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  6457. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  6458. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  6459. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  6460. }
  6461. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  6462. json_object_array_add(chargingSchedules, chargingSchedule);
  6463. }
  6464. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  6465. json_object_array_add(chargingProfiles, chargingProfile);
  6466. }
  6467. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  6468. random_uuid(guid);
  6469. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  6470. json_object_put(ReportChargingProfiles);
  6471. LWS_Send(message);
  6472. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  6473. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6474. {
  6475. result = PASS;
  6476. }
  6477. return result;
  6478. }
  6479. int sendReservationStatusUpdateRequest(int gun_index)
  6480. {
  6481. mtrace();
  6482. int result = FAIL;
  6483. char message[4096]={0};
  6484. char guid[37]={0};
  6485. char tempdata[128]={0};
  6486. json_object *ReservationStatusUpdate = json_object_new_object();
  6487. DEBUG_INFO("sendReservationStatusUpdateRequest...\n");
  6488. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  6489. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  6490. random_uuid(guid);
  6491. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  6492. json_object_put(ReservationStatusUpdate);
  6493. LWS_Send(message);
  6494. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  6495. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6496. {
  6497. result = PASS;
  6498. }
  6499. return result;
  6500. }
  6501. int sendSecurityEventNotificationRequest()
  6502. {
  6503. mtrace();
  6504. int result = FAIL;
  6505. char message[4096]={0};
  6506. char guid[37]={0};
  6507. char tempdata[128]={0};
  6508. json_object *SecurityEventNotification = json_object_new_object();
  6509. DEBUG_INFO("sendSecurityEventNotificationRequest...\n");
  6510. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  6511. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  6512. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techinfo));
  6513. random_uuid(guid);
  6514. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  6515. json_object_put(SecurityEventNotification);
  6516. LWS_Send(message);
  6517. sprintf(tempdata, "SecurityEventNotification,0");
  6518. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6519. {
  6520. result = PASS;
  6521. }
  6522. return result;
  6523. }
  6524. int sendSignCertificateRequest()
  6525. {
  6526. mtrace();
  6527. int result = FAIL;
  6528. char message[4096]={0};
  6529. char guid[37]={0};
  6530. char tempdata[128]={0};
  6531. json_object *SignCertificate = json_object_new_object();
  6532. DEBUG_INFO("sendSignCertificateRequest...\n");
  6533. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  6534. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  6535. random_uuid(guid);
  6536. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  6537. json_object_put(SignCertificate);
  6538. LWS_Send(message);
  6539. sprintf(tempdata, "SignCertificate,0");
  6540. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6541. {
  6542. result = PASS;
  6543. }
  6544. return result;
  6545. }
  6546. int sendStatusNotificationRequest(int gun_index)
  6547. {
  6548. mtrace();
  6549. int result = FAIL;
  6550. char message[600]={0};
  6551. char guid[37];
  6552. int currentStatus = 0;
  6553. struct timeval tmnow;
  6554. struct tm *tm;
  6555. char buf[28];//, usec_buf[6];
  6556. char tempdata[65]={0};
  6557. int tempIndex = 0;
  6558. DEBUG_INFO("sendStatusNotificationRequest...\n");
  6559. gettimeofday(&tmnow, NULL);
  6560. time_t t;
  6561. t = time(NULL);
  6562. /*UTC time and date*/
  6563. tm = gmtime(&t);
  6564. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  6565. #if 0 // remove temporally
  6566. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  6567. strcat(buf,".");
  6568. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  6569. strcat(buf,usec_buf);
  6570. #endif
  6571. printf("%s",buf);
  6572. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  6573. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  6574. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  6575. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  6576. /*
  6577. enum _SYSTEM_STATUS
  6578. {
  6579. S_BOOTING = 0,
  6580. S_IDLE, = 1
  6581. S_AUTHORIZING, =2
  6582. S_REASSIGN_CHECK, =3
  6583. S_REASSIGN, =4
  6584. S_PRECHARGE, =5
  6585. S_PREPARING_FOR_EV, =6
  6586. S_PREPARING_FOR_EVSE, =7
  6587. S_CHARGING, =8
  6588. S_TERMINATING, =9
  6589. S_COMPLETE, =10
  6590. S_ALARM, =11
  6591. S_FAULT =12
  6592. }
  6593. */
  6594. //check Transaction active
  6595. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  6596. if(gunType[gun_index] == 'J')
  6597. {
  6598. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6599. {
  6600. tempIndex = ((gun_index==2) ? 1: 0);
  6601. }
  6602. else
  6603. {
  6604. tempIndex = gun_index;
  6605. }
  6606. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6607. {
  6608. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6609. {
  6610. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6611. {
  6612. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6613. {
  6614. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6615. }
  6616. else
  6617. {
  6618. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6619. }
  6620. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6621. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6622. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6623. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6624. }
  6625. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6626. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6627. ) //S_PRECHARGE
  6628. {
  6629. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6630. }
  6631. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6632. {
  6633. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6634. }
  6635. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6636. {
  6637. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6638. }
  6639. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6640. {
  6641. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6642. }
  6643. 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
  6644. {
  6645. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6646. }
  6647. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6648. {
  6649. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6650. }
  6651. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6652. {
  6653. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6654. }
  6655. } //end of the same index
  6656. }//end of for CHAdeMO_QUANTITY
  6657. }
  6658. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  6659. {
  6660. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6661. {
  6662. tempIndex = ((gun_index==2) ? 1: 0);
  6663. }
  6664. else
  6665. {
  6666. tempIndex = gun_index;
  6667. }
  6668. for (int index = 0; index < CCS_QUANTITY; index++)
  6669. {
  6670. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6671. {
  6672. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6673. {
  6674. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  6675. {
  6676. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6677. }
  6678. else
  6679. {
  6680. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6681. }
  6682. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6683. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6684. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6685. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6686. }
  6687. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6688. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6689. ) //S_PRECHARGE
  6690. {
  6691. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6692. }
  6693. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6694. {
  6695. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6696. }
  6697. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6698. {
  6699. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6700. }
  6701. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  6702. {
  6703. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6704. }
  6705. 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
  6706. {
  6707. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  6708. }
  6709. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6710. {
  6711. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6712. }
  6713. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6714. {
  6715. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6716. }
  6717. } //end of the same index
  6718. } // end of for CCS_QUANTITY
  6719. }
  6720. else if(gunType[gun_index] == 'G')
  6721. {
  6722. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6723. {
  6724. tempIndex = ((gun_index==2) ? 1: 0);
  6725. }
  6726. else
  6727. {
  6728. tempIndex = gun_index;
  6729. }
  6730. for (int index = 0; index < GB_QUANTITY; index++)
  6731. {
  6732. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6733. {
  6734. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6735. {
  6736. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6737. {
  6738. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6739. }
  6740. else
  6741. {
  6742. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6743. }
  6744. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6745. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6746. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6747. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6748. }
  6749. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6750. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6751. ) //S_PRECHARGE
  6752. {
  6753. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6754. }
  6755. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6756. {
  6757. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6758. }
  6759. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6760. {
  6761. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6762. }
  6763. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6764. {
  6765. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6766. }
  6767. 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
  6768. {
  6769. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6770. }
  6771. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6772. {
  6773. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6774. }
  6775. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6776. {
  6777. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6778. }
  6779. } //end of the same index
  6780. } // end of for GB_QUANTITY
  6781. }
  6782. else if(gunType[gun_index] == 'O')
  6783. {
  6784. tempIndex = gun_index;
  6785. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6786. {
  6787. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6788. {
  6789. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6790. {
  6791. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6792. {
  6793. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6794. }
  6795. else
  6796. {
  6797. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6798. }
  6799. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6800. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6801. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6802. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6803. }
  6804. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6805. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6806. ) //S_PRECHARGE
  6807. {
  6808. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6809. }
  6810. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6811. {
  6812. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6813. }
  6814. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6815. {
  6816. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6817. }
  6818. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6819. {
  6820. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6821. }
  6822. else if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_UPDATE)) // ---> Unavailable
  6823. {
  6824. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6825. }
  6826. else if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6827. {
  6828. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6829. }
  6830. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6831. {
  6832. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6833. }
  6834. } //end of the same index
  6835. }
  6836. }
  6837. else
  6838. {
  6839. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6840. {
  6841. tempIndex = 2;
  6842. }
  6843. else
  6844. {
  6845. tempIndex = gun_index;
  6846. }
  6847. for (int index = 0; index < AC_QUANTITY; index++)
  6848. {
  6849. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6850. {
  6851. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  6852. {
  6853. 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))
  6854. {
  6855. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6856. }
  6857. else
  6858. {
  6859. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6860. }
  6861. memset(&ShmOCPP20Data->TransactionEvent[index].eventType[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[index].eventType));
  6862. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6863. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6864. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6865. }
  6866. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  6867. {
  6868. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6869. }
  6870. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  6871. {
  6872. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6873. }
  6874. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  6875. {
  6876. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6877. }
  6878. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6879. {
  6880. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6881. }
  6882. 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
  6883. {
  6884. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6885. }
  6886. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6887. {
  6888. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6889. }
  6890. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6891. {
  6892. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6893. }
  6894. }//end of the same index
  6895. }//end of for AC_QUANTITY
  6896. }
  6897. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  6898. random_uuid(guid);
  6899. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  6900. , MESSAGE_TYPE_CALL
  6901. , guid
  6902. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  6903. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  6904. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  6905. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  6906. if((server_sign == TRUE))
  6907. {
  6908. LWS_Send(message);
  6909. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  6910. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6911. {
  6912. result = PASS;
  6913. }
  6914. }
  6915. else
  6916. {
  6917. result = PASS;
  6918. }
  6919. return result;
  6920. }
  6921. int sendTransactionEventRequest(int gun_index)
  6922. {
  6923. mtrace();
  6924. int result = FAIL;
  6925. char message[1024*20]={0};
  6926. char guid[37]={0};
  6927. char tempdata[128]={0};
  6928. uint8_t tempIndex;
  6929. json_object *TransactionEvent = json_object_new_object();
  6930. json_object *transactionInfo = json_object_new_object();
  6931. json_object *idToken = json_object_new_object();
  6932. json_object *evse = json_object_new_object();
  6933. json_object *meterValues = json_object_new_array();
  6934. DEBUG_INFO("sendTransactionEventRequest...\n");
  6935. if(gunType[gun_index] == 'J')
  6936. {
  6937. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6938. {
  6939. tempIndex = ((gun_index==2) ? 1: 0);
  6940. }
  6941. else
  6942. {
  6943. tempIndex = gun_index;
  6944. }
  6945. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6946. {
  6947. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6948. {
  6949. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  6950. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  6951. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  6952. else
  6953. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  6954. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  6955. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  6956. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  6957. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6958. {
  6959. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6960. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6961. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6962. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6963. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6964. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6965. {
  6966. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  6967. }
  6968. else
  6969. {
  6970. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  6971. }
  6972. }
  6973. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  6974. {
  6975. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6976. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6977. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  6978. }
  6979. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6980. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6981. ) //S_PRECHARGE
  6982. {
  6983. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  6984. {
  6985. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  6986. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  6987. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  6988. }
  6989. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  6990. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6991. else
  6992. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6993. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  6994. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6995. }
  6996. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6997. {
  6998. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6999. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7000. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7001. }
  7002. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7003. {
  7004. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7005. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7006. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7007. }
  7008. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7009. {
  7010. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7011. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7012. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7013. }
  7014. 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
  7015. {
  7016. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7017. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7018. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7019. }
  7020. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7021. {
  7022. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7023. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7024. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7025. }
  7026. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7027. {
  7028. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7029. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7030. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7031. }
  7032. } //end of the same index
  7033. }//end of for CHAdeMO_QUANTITY
  7034. }
  7035. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  7036. {
  7037. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7038. {
  7039. tempIndex = ((gun_index==2) ? 1: 0);
  7040. }
  7041. else
  7042. {
  7043. tempIndex = gun_index;
  7044. }
  7045. for (int index = 0; index < CCS_QUANTITY; index++)
  7046. {
  7047. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  7048. {
  7049. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7050. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7051. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7052. else
  7053. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7054. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7055. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7056. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7057. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7058. {
  7059. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7060. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7061. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7062. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7063. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7064. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7065. {
  7066. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7067. }
  7068. else
  7069. {
  7070. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7071. }
  7072. }
  7073. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7074. {
  7075. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7076. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7077. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7078. }
  7079. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7080. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7081. ) //S_PRECHARGE
  7082. {
  7083. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7084. {
  7085. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7086. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  7087. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7088. }
  7089. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7090. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7091. else
  7092. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7093. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7094. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7095. }
  7096. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7097. {
  7098. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7099. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7100. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7101. }
  7102. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7103. {
  7104. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7105. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7106. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7107. }
  7108. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7109. {
  7110. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7111. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7112. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7113. }
  7114. 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
  7115. {
  7116. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7117. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7118. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7119. }
  7120. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7121. {
  7122. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7123. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7124. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7125. }
  7126. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7127. {
  7128. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7129. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7130. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7131. }
  7132. } //end of the same index
  7133. } // end of for CCS_QUANTITY
  7134. }
  7135. else if(gunType[gun_index] == 'G')
  7136. {
  7137. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  7138. {
  7139. tempIndex = ((gun_index==2) ? 1: 0);
  7140. }
  7141. else
  7142. {
  7143. tempIndex = gun_index;
  7144. }
  7145. for (int index = 0; index < GB_QUANTITY; index++)
  7146. {
  7147. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  7148. {
  7149. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7150. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7151. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7152. else
  7153. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7154. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7155. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7156. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7157. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7158. {
  7159. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7160. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7161. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7162. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7163. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7164. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  7165. {
  7166. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7167. }
  7168. else
  7169. {
  7170. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7171. }
  7172. }
  7173. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7174. {
  7175. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7176. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7177. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7178. }
  7179. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7180. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7181. ) //S_PRECHARGE
  7182. {
  7183. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7184. {
  7185. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7186. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  7187. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7188. }
  7189. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7190. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7191. else
  7192. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7193. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7194. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7195. }
  7196. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7197. {
  7198. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7199. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7200. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7201. }
  7202. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7203. {
  7204. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7205. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7206. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7207. }
  7208. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7209. {
  7210. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7211. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7212. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7213. }
  7214. 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
  7215. {
  7216. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7217. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7218. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7219. }
  7220. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7221. {
  7222. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7223. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7224. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7225. }
  7226. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7227. {
  7228. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7229. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7230. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7231. }
  7232. } //end of the same index
  7233. } // end of for GB_QUANTITY
  7234. }
  7235. else if(gunType[gun_index] == 'O')
  7236. {
  7237. tempIndex = gun_index;
  7238. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  7239. {
  7240. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  7241. {
  7242. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7243. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7244. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7245. else
  7246. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7247. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7248. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7249. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7250. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  7251. {
  7252. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7253. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7254. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7255. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7256. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7257. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  7258. {
  7259. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7260. }
  7261. else
  7262. {
  7263. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7264. }
  7265. }
  7266. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7267. {
  7268. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7269. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7270. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7271. }
  7272. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7273. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7274. ) //S_PRECHARGE
  7275. {
  7276. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7277. {
  7278. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7279. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  7280. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7281. }
  7282. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7283. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7284. else
  7285. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7286. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7287. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7288. }
  7289. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7290. {
  7291. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7292. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7293. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7294. }
  7295. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7296. {
  7297. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7298. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7299. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7300. }
  7301. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7302. {
  7303. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7304. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7305. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7306. }
  7307. else if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_MAINTAIN)|| (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_UPDATE)) // ---> Unavailable
  7308. {
  7309. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7310. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7311. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7312. }
  7313. else if ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7314. {
  7315. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7316. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7317. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7318. }
  7319. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7320. {
  7321. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7322. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7323. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7324. }
  7325. } //end of the same index
  7326. }
  7327. }
  7328. else
  7329. {
  7330. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7331. {
  7332. tempIndex = 2;
  7333. }
  7334. else
  7335. {
  7336. tempIndex = gun_index;
  7337. }
  7338. for (int index = 0; index < AC_QUANTITY; index++)
  7339. {
  7340. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7341. {
  7342. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7343. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7344. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7345. else
  7346. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7347. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7348. ShmOCPP20Data->TransactionEvent[index].evse.id = (gun_index + 1);
  7349. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7350. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  7351. {
  7352. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7353. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7354. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7355. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7356. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7357. 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))
  7358. {
  7359. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7360. }
  7361. else
  7362. {
  7363. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7364. }
  7365. }
  7366. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7367. {
  7368. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7369. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7370. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7371. }
  7372. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7373. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7374. ) //S_PRECHARGE
  7375. {
  7376. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7377. {
  7378. random_uuid((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7379. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  7380. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.type, "%s", ShmOCPP20Data->Authorize.idToken.type);
  7381. }
  7382. if(ShmOCPP20Data->TransactionEvent[index].eventType[0] == '\0')
  7383. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7384. else
  7385. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7386. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7387. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7388. }
  7389. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7390. {
  7391. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7392. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7393. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7394. }
  7395. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7396. {
  7397. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7398. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7399. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7400. }
  7401. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7402. {
  7403. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7404. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7405. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7406. }
  7407. 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
  7408. {
  7409. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7410. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7411. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7412. }
  7413. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7414. {
  7415. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7416. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7417. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7418. }
  7419. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7420. {
  7421. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7422. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7423. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7424. }
  7425. }//end of the same index
  7426. }//end of for AC_QUANTITY
  7427. }
  7428. // Message
  7429. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7430. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  7431. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  7432. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  7433. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  7434. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  7435. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  7436. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  7437. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  7438. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  7439. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  7440. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  7441. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  7442. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  7443. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  7444. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  7445. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  7446. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  7447. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  7448. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  7449. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  7450. {
  7451. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  7452. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  7453. json_object_object_add(TransactionEvent, "idToken", idToken);
  7454. }
  7455. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  7456. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  7457. json_object_object_add(TransactionEvent, "evse", evse);
  7458. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  7459. {
  7460. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  7461. {
  7462. json_object *meterValue = json_object_new_object();
  7463. json_object *sampledValues = json_object_new_array();
  7464. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  7465. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  7466. {
  7467. if((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0) &&
  7468. ((strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0) || (strcmp((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]) == 0)))
  7469. {
  7470. json_object *sampledValue = json_object_new_object();
  7471. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  7472. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7473. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  7474. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  7475. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  7476. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  7477. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  7478. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  7479. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  7480. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  7481. {
  7482. json_object *unitOfMeasure = json_object_new_object();
  7483. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  7484. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  7485. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  7486. }
  7487. json_object_array_add(sampledValues, sampledValue);
  7488. }
  7489. }
  7490. json_object_object_add(meterValue, "sampledValue", sampledValues);
  7491. json_object_array_add(meterValues, meterValue);
  7492. }
  7493. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  7494. }
  7495. random_uuid(guid);
  7496. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  7497. json_object_put(TransactionEvent);
  7498. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  7499. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7500. {
  7501. result = PASS;
  7502. }
  7503. queue_operation(QUEUE_OPERATION_ADD, guid, message);
  7504. return result;
  7505. }
  7506. //==========================================
  7507. // send confirm routine
  7508. //==========================================
  7509. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  7510. {
  7511. mtrace();
  7512. int result = FAIL;
  7513. char message[4096]={0};
  7514. json_object *CancelReservation = json_object_new_object();
  7515. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  7516. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  7517. sprintf(message,"[%d,\"%s\",%s]"
  7518. ,MESSAGE_TYPE_CALLRESULT
  7519. ,uuid
  7520. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  7521. json_object_put(CancelReservation);
  7522. ShmOCPP20Data->CsMsg.bits[0].CancelReservationConf = OFF;
  7523. LWS_Send(message);
  7524. result = TRUE;
  7525. return result;
  7526. }
  7527. int sendCertificateSignedConfirmation(char *uuid)
  7528. {
  7529. mtrace();
  7530. int result = FAIL;
  7531. char message[4096]={0};
  7532. json_object *CertificateSigned = json_object_new_object();
  7533. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  7534. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  7535. sprintf(message,"[%d,\"%s\",%s]"
  7536. ,MESSAGE_TYPE_CALLRESULT
  7537. ,uuid
  7538. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  7539. json_object_put(CertificateSigned);
  7540. LWS_Send(message);
  7541. result = TRUE;
  7542. return result;
  7543. }
  7544. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  7545. {
  7546. mtrace();
  7547. int result = FAIL;
  7548. char message[4096]={0};
  7549. json_object *ChangeAvailability = json_object_new_object();
  7550. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  7551. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  7552. sprintf(message,"[%d,\"%s\",%s]"
  7553. ,MESSAGE_TYPE_CALLRESULT
  7554. ,uuid
  7555. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  7556. json_object_put(ChangeAvailability);
  7557. LWS_Send(message);
  7558. result = TRUE;
  7559. return result;
  7560. }
  7561. int sendClearCacheConfirmation(char *uuid)
  7562. {
  7563. mtrace();
  7564. int result = FAIL;
  7565. char message[4096]={0};
  7566. json_object *ClearCache = json_object_new_object();
  7567. DEBUG_INFO("sendClearCacheConfirmation...\n");
  7568. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  7569. sprintf(message,"[%d,\"%s\",%s]"
  7570. ,MESSAGE_TYPE_CALLRESULT
  7571. ,uuid
  7572. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  7573. json_object_put(ClearCache);
  7574. LWS_Send(message);
  7575. result = TRUE;
  7576. return result;
  7577. }
  7578. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  7579. {
  7580. mtrace();
  7581. int result = FAIL;
  7582. char message[500]={0};
  7583. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  7584. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  7585. LWS_Send(message);
  7586. return result;
  7587. }
  7588. int sendClearDisplayMessageConfirmation(char *uuid)
  7589. {
  7590. mtrace();
  7591. int result = FAIL;
  7592. char message[4096]={0};
  7593. json_object *ClearDisplayMessage = json_object_new_object();
  7594. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  7595. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  7596. sprintf(message,"[%d,\"%s\",%s]"
  7597. ,MESSAGE_TYPE_CALLRESULT
  7598. ,uuid
  7599. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  7600. json_object_put(ClearDisplayMessage);
  7601. LWS_Send(message);
  7602. result = TRUE;
  7603. return result;
  7604. }
  7605. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  7606. {
  7607. mtrace();
  7608. int result = FAIL;
  7609. char message[4096]={0};
  7610. json_object *ClearVariableMonitoring = json_object_new_object();
  7611. json_object *clearMonitoringResults = json_object_new_array();
  7612. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  7613. for(int idx=0;idx<variableQuantity;idx++)
  7614. {
  7615. json_object *clearMonitoringResult = json_object_new_object();
  7616. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  7617. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  7618. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  7619. }
  7620. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  7621. sprintf(message,"[%d,\"%s\",%s]"
  7622. ,MESSAGE_TYPE_CALLRESULT
  7623. ,uuid
  7624. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  7625. json_object_put(ClearVariableMonitoring);
  7626. LWS_Send(message);
  7627. result = TRUE;
  7628. return result;
  7629. }
  7630. int sendCostUpdatedConfirmation(char *uuid)
  7631. {
  7632. mtrace();
  7633. int result = FAIL;
  7634. char message[4096]={0};
  7635. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  7636. sprintf(message,"[%d,\"%s\",{}]"
  7637. ,MESSAGE_TYPE_CALLRESULT
  7638. ,uuid);
  7639. LWS_Send(message);
  7640. result = TRUE;
  7641. return result;
  7642. }
  7643. int sendCustomerInformationConfirmation(char *uuid)
  7644. {
  7645. mtrace();
  7646. int result = FAIL;
  7647. char message[4096]={0};
  7648. json_object *CustomerInformation = json_object_new_object();
  7649. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  7650. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  7651. sprintf(message,"[%d,\"%s\",%s]"
  7652. ,MESSAGE_TYPE_CALLRESULT
  7653. ,uuid
  7654. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  7655. json_object_put(CustomerInformation);
  7656. LWS_Send(message);
  7657. result = TRUE;
  7658. return result;
  7659. }
  7660. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  7661. {
  7662. mtrace();
  7663. int result = FAIL;
  7664. char message[4096]={0};
  7665. json_object *DataTransfer = json_object_new_object();
  7666. DEBUG_INFO("sendDataTransferConfirmation...\n");
  7667. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  7668. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  7669. sprintf(message,"[%d,\"%s\",%s]"
  7670. ,MESSAGE_TYPE_CALLRESULT
  7671. ,uuid
  7672. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  7673. json_object_put(DataTransfer);
  7674. LWS_Send(message);
  7675. result = TRUE;
  7676. return result;
  7677. }
  7678. int sendDeleteCertificateConfirmation(char *uuid)
  7679. {
  7680. mtrace();
  7681. int result = FAIL;
  7682. char message[4096]={0};
  7683. json_object *DeleteCertificate = json_object_new_object();
  7684. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  7685. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  7686. sprintf(message,"[%d,\"%s\",%s]"
  7687. ,MESSAGE_TYPE_CALLRESULT
  7688. ,uuid
  7689. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  7690. json_object_put(DeleteCertificate);
  7691. LWS_Send(message);
  7692. result = TRUE;
  7693. return result;
  7694. }
  7695. int sendGetBaseReportConfirmation(char *uuid)
  7696. {
  7697. mtrace();
  7698. int result = FAIL;
  7699. char message[4096]={0};
  7700. json_object *GetBaseReport = json_object_new_object();
  7701. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  7702. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  7703. sprintf(message,"[%d,\"%s\",%s]"
  7704. ,MESSAGE_TYPE_CALLRESULT
  7705. ,uuid
  7706. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  7707. json_object_put(GetBaseReport);
  7708. LWS_Send(message);
  7709. result = TRUE;
  7710. return result;
  7711. }
  7712. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  7713. {
  7714. mtrace();
  7715. int result = FAIL;
  7716. char message[4096]={0};
  7717. json_object *GetChargingProfiles = json_object_new_object();
  7718. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  7719. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  7720. sprintf(message,"[%d,\"%s\",%s]"
  7721. ,MESSAGE_TYPE_CALLRESULT
  7722. ,uuid
  7723. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  7724. json_object_put(GetChargingProfiles);
  7725. LWS_Send(message);
  7726. result = TRUE;
  7727. return result;
  7728. }
  7729. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  7730. {
  7731. mtrace();
  7732. int result = FAIL;
  7733. char message[4096]={0};
  7734. int CompositeScheduleIndex = 0;
  7735. json_object *GetCompositeSchedule = json_object_new_object();
  7736. json_object *schedule = json_object_new_object();
  7737. json_object *chargingSchedule = json_object_new_object();
  7738. json_object *chargingSchedulePeriod = json_object_new_array();
  7739. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  7740. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  7741. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  7742. if(nPeriod == 0)
  7743. {
  7744. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  7745. {
  7746. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7747. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7748. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7749. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7750. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7751. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7752. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7753. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7754. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7755. {
  7756. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7757. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7758. {
  7759. json_object *Period = json_object_new_object();
  7760. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7761. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7762. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7763. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7764. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7765. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7766. json_object_array_add(chargingSchedulePeriod, Period);
  7767. }
  7768. }
  7769. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7770. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7771. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7772. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7773. }
  7774. }
  7775. else
  7776. {
  7777. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7778. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7779. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7780. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7781. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7782. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7783. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7784. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7785. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7786. {
  7787. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7788. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7789. {
  7790. json_object *Period = json_object_new_object();
  7791. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7792. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7793. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7794. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7795. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7796. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7797. json_object_array_add(chargingSchedulePeriod, Period);
  7798. }
  7799. }
  7800. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7801. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7802. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7803. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7804. }
  7805. sprintf(message,"[%d,\"%s\",%s]"
  7806. ,MESSAGE_TYPE_CALLRESULT
  7807. ,uuid
  7808. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  7809. json_object_put(GetCompositeSchedule);
  7810. LWS_Send(message);
  7811. result = TRUE;
  7812. return result;
  7813. }
  7814. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  7815. {
  7816. mtrace();
  7817. int result = FAIL;
  7818. char message[4096]={0};
  7819. json_object *GetGetDisplayMessages = json_object_new_object();
  7820. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  7821. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  7822. sprintf(message,"[%d,\"%s\",%s]"
  7823. ,MESSAGE_TYPE_CALLRESULT
  7824. ,uuid
  7825. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  7826. json_object_put(GetGetDisplayMessages);
  7827. LWS_Send(message);
  7828. result = TRUE;
  7829. return result;
  7830. }
  7831. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  7832. {
  7833. mtrace();
  7834. int result = FAIL;
  7835. char message[4096]={0};
  7836. json_object *GetInstalledCertificateIds = json_object_new_object();
  7837. json_object *certificateHashDataChains = json_object_new_array();
  7838. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  7839. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  7840. for(int idx=0;idx<certQuantity;idx++)
  7841. {
  7842. json_object *cert = json_object_new_object();
  7843. json_object *certificateHashData = json_object_new_object();
  7844. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  7845. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  7846. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  7847. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  7848. json_object_object_add(cert, "certificateHashData", certificateHashData);
  7849. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  7850. json_object_array_add(certificateHashDataChains, cert);
  7851. }
  7852. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  7853. sprintf(message,"[%d,\"%s\",%s]"
  7854. ,MESSAGE_TYPE_CALLRESULT
  7855. ,uuid
  7856. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  7857. json_object_put(GetInstalledCertificateIds);
  7858. LWS_Send(message);
  7859. result = TRUE;
  7860. return result;
  7861. }
  7862. int sendGetLocalListVersionConfirmation(char *uuid)
  7863. {
  7864. mtrace();
  7865. int result = FAIL;
  7866. char message[4096]={0};
  7867. json_object *GetLocalListVersion = json_object_new_object();
  7868. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  7869. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  7870. sprintf(message,"[%d,\"%s\",%s]"
  7871. ,MESSAGE_TYPE_CALLRESULT
  7872. ,uuid
  7873. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  7874. json_object_put(GetLocalListVersion);
  7875. LWS_Send(message);
  7876. result = TRUE;
  7877. return result;
  7878. }
  7879. int sendGetLogConfirmation(char *uuid)
  7880. {
  7881. mtrace();
  7882. int result = FAIL;
  7883. char message[4096]={0};
  7884. json_object *GetLog = json_object_new_object();
  7885. DEBUG_INFO("sendGetLogConfirmation...\n");
  7886. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  7887. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  7888. sprintf(message,"[%d,\"%s\",%s]"
  7889. ,MESSAGE_TYPE_CALLRESULT
  7890. ,uuid
  7891. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  7892. json_object_put(GetLog);
  7893. LWS_Send(message);
  7894. result = TRUE;
  7895. return result;
  7896. }
  7897. int sendGetMonitoringReportConfirmation(char *uuid)
  7898. {
  7899. mtrace();
  7900. int result = FAIL;
  7901. char message[4096]={0};
  7902. json_object *GetMonitoringReport = json_object_new_object();
  7903. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  7904. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  7905. sprintf(message,"[%d,\"%s\",%s]"
  7906. ,MESSAGE_TYPE_CALLRESULT
  7907. ,uuid
  7908. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  7909. json_object_put(GetMonitoringReport);
  7910. LWS_Send(message);
  7911. result = TRUE;
  7912. return result;
  7913. }
  7914. int sendGetReportConfirmation(char *uuid)
  7915. {
  7916. mtrace();
  7917. int result = FAIL;
  7918. char message[4096]={0};
  7919. json_object *GetReport = json_object_new_object();
  7920. DEBUG_INFO("sendGetReportConfirmation...\n");
  7921. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  7922. sprintf(message,"[%d,\"%s\",%s]"
  7923. ,MESSAGE_TYPE_CALLRESULT
  7924. ,uuid
  7925. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  7926. json_object_put(GetReport);
  7927. LWS_Send(message);
  7928. result = TRUE;
  7929. return result;
  7930. }
  7931. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  7932. {
  7933. mtrace();
  7934. int result = FAIL;
  7935. char message[4096]={0};
  7936. json_object *GetTransactionStatus = json_object_new_object();
  7937. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  7938. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  7939. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  7940. sprintf(message,"[%d,\"%s\",%s]"
  7941. ,MESSAGE_TYPE_CALLRESULT
  7942. ,uuid
  7943. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  7944. json_object_put(GetTransactionStatus);
  7945. LWS_Send(message);
  7946. result = TRUE;
  7947. return result;
  7948. }
  7949. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  7950. {
  7951. mtrace();
  7952. int result = FAIL;
  7953. char message[4096]={0};
  7954. json_object *GetVariables = json_object_new_object();
  7955. json_object *getVariableResults = json_object_new_array();
  7956. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  7957. for(int idx=0;idx<variableQuantity;idx++)
  7958. {
  7959. json_object *variableResult = json_object_new_object();
  7960. json_object *component = json_object_new_object();
  7961. json_object *variable = json_object_new_object();
  7962. json_object *evse = json_object_new_object();
  7963. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  7964. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  7965. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  7966. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  7967. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  7968. json_object_object_add(component, "component", evse);
  7969. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  7970. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  7971. json_object_object_add(variableResult, "component", component);
  7972. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  7973. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  7974. json_object_object_add(variableResult, "variable", variable);
  7975. json_object_array_add(getVariableResults, variableResult);
  7976. }
  7977. json_object_object_add(GetVariables , "getVariableResult", getVariableResults);
  7978. sprintf(message,"[%d,\"%s\",%s]"
  7979. ,MESSAGE_TYPE_CALLRESULT
  7980. ,uuid
  7981. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  7982. json_object_put(GetVariables);
  7983. LWS_Send(message);
  7984. result = TRUE;
  7985. return result;
  7986. }
  7987. int sendInstallCertificateConfirmation(char *uuid)
  7988. {
  7989. mtrace();
  7990. int result = FAIL;
  7991. char message[4096]={0};
  7992. json_object *InstallCertificate = json_object_new_object();
  7993. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  7994. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  7995. sprintf(message,"[%d,\"%s\",%s]"
  7996. ,MESSAGE_TYPE_CALLRESULT
  7997. ,uuid
  7998. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  7999. json_object_put(InstallCertificate);
  8000. LWS_Send(message);
  8001. result = TRUE;
  8002. return result;
  8003. }
  8004. int sendPublishFirmwareConfirmation(char *uuid)
  8005. {
  8006. mtrace();
  8007. int result = FAIL;
  8008. char message[4096]={0};
  8009. json_object *PublishFirmware = json_object_new_object();
  8010. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  8011. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  8012. sprintf(message,"[%d,\"%s\",%s]"
  8013. ,MESSAGE_TYPE_CALLRESULT
  8014. ,uuid
  8015. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  8016. json_object_put(PublishFirmware);
  8017. LWS_Send(message);
  8018. result = TRUE;
  8019. return result;
  8020. }
  8021. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  8022. {
  8023. mtrace();
  8024. int result = FAIL;
  8025. char message[4096]={0};
  8026. json_object *RemoteStartTransaction = json_object_new_object();
  8027. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  8028. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  8029. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  8030. sprintf(message,"[%d,\"%s\",%s]"
  8031. ,MESSAGE_TYPE_CALLRESULT
  8032. ,uuid
  8033. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  8034. json_object_put(RemoteStartTransaction);
  8035. LWS_Send(message);
  8036. result = TRUE;
  8037. return result;
  8038. }
  8039. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  8040. {
  8041. mtrace();
  8042. int result = FAIL;
  8043. char message[4096]={0};
  8044. json_object *RemoteStopTransaction = json_object_new_object();
  8045. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  8046. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  8047. sprintf(message,"[%d,\"%s\",%s]"
  8048. ,MESSAGE_TYPE_CALLRESULT
  8049. ,uuid
  8050. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  8051. json_object_put(RemoteStopTransaction);
  8052. LWS_Send(message);
  8053. result = TRUE;
  8054. return result;
  8055. }
  8056. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  8057. {
  8058. mtrace();
  8059. int result = FAIL;
  8060. char message[4096]={0};
  8061. json_object *ReserveNow = json_object_new_object();
  8062. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  8063. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  8064. sprintf(message,"[%d,\"%s\",%s]"
  8065. ,MESSAGE_TYPE_CALLRESULT
  8066. ,uuid
  8067. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  8068. json_object_put(ReserveNow);
  8069. LWS_Send(message);
  8070. result = TRUE;
  8071. return result;
  8072. }
  8073. int sendResetConfirmation(char *uuid)
  8074. {
  8075. mtrace();
  8076. int result = FAIL;
  8077. char message[4096]={0};
  8078. json_object *Reset = json_object_new_object();
  8079. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  8080. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  8081. sprintf(message,"[%d,\"%s\",%s]"
  8082. ,MESSAGE_TYPE_CALLRESULT
  8083. ,uuid
  8084. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  8085. json_object_put(Reset);
  8086. LWS_Send(message);
  8087. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  8088. {
  8089. DB_updateBootType(BootReasonEnumType_RemoteReset);
  8090. }
  8091. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  8092. {
  8093. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  8094. }
  8095. result = TRUE;
  8096. return result;
  8097. }
  8098. int sendSendLocalListConfirmation(char *uuid)
  8099. {
  8100. mtrace();
  8101. int result = FAIL;
  8102. char message[4096]={0};
  8103. json_object *SendLocalList = json_object_new_object();
  8104. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  8105. sprintf(message,"[%d,\"%s\",%s]"
  8106. ,MESSAGE_TYPE_CALLRESULT
  8107. ,uuid
  8108. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  8109. json_object_put(SendLocalList);
  8110. LWS_Send(message);
  8111. result = TRUE;
  8112. return result;
  8113. }
  8114. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  8115. {
  8116. mtrace();
  8117. int result = FAIL;
  8118. char message[4096]={0};
  8119. json_object *SetChargingProfile = json_object_new_object();
  8120. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  8121. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  8122. sprintf(message,"[%d,\"%s\",%s]"
  8123. ,MESSAGE_TYPE_CALLRESULT
  8124. ,uuid
  8125. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  8126. json_object_put(SetChargingProfile);
  8127. LWS_Send(message);
  8128. result = TRUE;
  8129. return result;
  8130. }
  8131. int sendSetDisplayMessageConfirmation(char *uuid)
  8132. {
  8133. mtrace();
  8134. int result = FAIL;
  8135. char message[4096]={0};
  8136. json_object *SetDisplayMessage = json_object_new_object();
  8137. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  8138. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  8139. sprintf(message,"[%d,\"%s\",%s]"
  8140. ,MESSAGE_TYPE_CALLRESULT
  8141. ,uuid
  8142. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  8143. json_object_put(SetDisplayMessage);
  8144. LWS_Send(message);
  8145. result = TRUE;
  8146. return result;
  8147. }
  8148. int sendSetMonitoringBaseConfirmation(char *uuid)
  8149. {
  8150. mtrace();
  8151. int result = FAIL;
  8152. char message[4096]={0};
  8153. json_object *SetMonitoringBase = json_object_new_object();
  8154. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  8155. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  8156. sprintf(message,"[%d,\"%s\",%s]"
  8157. ,MESSAGE_TYPE_CALLRESULT
  8158. ,uuid
  8159. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  8160. json_object_put(SetMonitoringBase);
  8161. LWS_Send(message);
  8162. result = TRUE;
  8163. return result;
  8164. }
  8165. int sendSetMonitoringLevelConfirmation(char *uuid)
  8166. {
  8167. mtrace();
  8168. int result = FAIL;
  8169. char message[4096]={0};
  8170. json_object *SetMonitoringLevel = json_object_new_object();
  8171. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  8172. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  8173. sprintf(message,"[%d,\"%s\",%s]"
  8174. ,MESSAGE_TYPE_CALLRESULT
  8175. ,uuid
  8176. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  8177. json_object_put(SetMonitoringLevel);
  8178. LWS_Send(message);
  8179. result = TRUE;
  8180. return result;
  8181. }
  8182. int sendSetNetworkProfileConfirmation(char *uuid)
  8183. {
  8184. mtrace();
  8185. int result = FAIL;
  8186. char message[4096]={0};
  8187. json_object *SetNetworkProfile = json_object_new_object();
  8188. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  8189. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  8190. sprintf(message,"[%d,\"%s\",%s]"
  8191. ,MESSAGE_TYPE_CALLRESULT
  8192. ,uuid
  8193. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  8194. json_object_put(SetNetworkProfile);
  8195. LWS_Send(message);
  8196. result = TRUE;
  8197. return result;
  8198. }
  8199. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  8200. {
  8201. mtrace();
  8202. int result = FAIL;
  8203. char message[4096]={0};
  8204. json_object *SetVariableMonitoring = json_object_new_object();
  8205. json_object *setMonitoringResults = json_object_new_array();
  8206. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  8207. for(int idx=0;idx<variableQuantity;idx++)
  8208. {
  8209. json_object *variableMonitorResult = json_object_new_object();
  8210. json_object *component = json_object_new_object();
  8211. json_object *variable = json_object_new_object();
  8212. json_object *evse = json_object_new_object();
  8213. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  8214. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  8215. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  8216. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  8217. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  8218. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  8219. json_object_object_add(component, "component", evse);
  8220. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  8221. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  8222. json_object_object_add(variableMonitorResult, "component", component);
  8223. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  8224. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  8225. json_object_object_add(variableMonitorResult, "variable", variable);
  8226. json_object_array_add(setMonitoringResults, variableMonitorResult);
  8227. }
  8228. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  8229. sprintf(message,"[%d,\"%s\",%s]"
  8230. ,MESSAGE_TYPE_CALLRESULT
  8231. ,uuid
  8232. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  8233. json_object_put(SetVariableMonitoring);
  8234. LWS_Send(message);
  8235. result = TRUE;
  8236. return result;
  8237. }
  8238. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  8239. {
  8240. mtrace();
  8241. int result = FAIL;
  8242. char message[4096]={0};
  8243. json_object *SetVariable = json_object_new_object();
  8244. json_object *setVariableResults = json_object_new_array();
  8245. DEBUG_INFO("sendSetVariableConfirmation...\n");
  8246. for(int idx=0;idx<variableQuantity;idx++)
  8247. {
  8248. json_object *variableResult = json_object_new_object();
  8249. json_object *component = json_object_new_object();
  8250. json_object *variable = json_object_new_object();
  8251. json_object *evse = json_object_new_object();
  8252. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  8253. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  8254. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  8255. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  8256. json_object_object_add(component, "component", evse);
  8257. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  8258. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  8259. json_object_object_add(variableResult, "component", component);
  8260. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  8261. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  8262. json_object_object_add(variableResult, "variable", variable);
  8263. json_object_array_add(setVariableResults, variableResult);
  8264. }
  8265. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  8266. sprintf(message,"[%d,\"%s\",%s]"
  8267. ,MESSAGE_TYPE_CALLRESULT
  8268. ,uuid
  8269. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  8270. json_object_put(SetVariable);
  8271. LWS_Send(message);
  8272. result = TRUE;
  8273. return result;
  8274. }
  8275. int sendTriggerMessageConfirmation(char *uuid)
  8276. {
  8277. mtrace();
  8278. int result = FAIL;
  8279. char message[4096]={0};
  8280. json_object *TriggerMessage = json_object_new_object();
  8281. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  8282. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  8283. sprintf(message,"[%d,\"%s\",%s]",
  8284. MESSAGE_TYPE_CALLRESULT,
  8285. uuid,
  8286. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  8287. json_object_put(TriggerMessage);
  8288. LWS_Send(message);
  8289. result = TRUE;
  8290. return result;
  8291. }
  8292. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  8293. {
  8294. mtrace();
  8295. int result = FAIL;
  8296. char message[4096]={0};
  8297. json_object *UnlockConnector = json_object_new_object();
  8298. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  8299. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  8300. sprintf(message,"[%d,\"%s\",%s]",
  8301. MESSAGE_TYPE_CALLRESULT,
  8302. uuid,
  8303. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  8304. json_object_put(UnlockConnector);
  8305. LWS_Send(message);
  8306. result = TRUE;
  8307. return result;
  8308. }
  8309. int sendUnpublishFirmwareConfirmation(char *uuid)
  8310. {
  8311. mtrace();
  8312. int result = FAIL;
  8313. char message[4096]={0};
  8314. json_object *UnpublishFirmware = json_object_new_object();
  8315. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  8316. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  8317. sprintf(message,"[%d,\"%s\",%s]"
  8318. ,MESSAGE_TYPE_CALLRESULT
  8319. ,uuid
  8320. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  8321. json_object_put(UnpublishFirmware);
  8322. LWS_Send(message);
  8323. result = TRUE;
  8324. return result;
  8325. }
  8326. int sendUpdateFirmwareConfirmation(char *uuid)
  8327. {
  8328. mtrace();
  8329. int result = FAIL;
  8330. char message[4096]={0};
  8331. json_object *UpdateFirmware = json_object_new_object();
  8332. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  8333. sprintf((char*)ShmOCPP20Data->UpdateFirmware.Response_status, "%s", UpdateFirmwareStatusEnumTypeStr[UpdateFirmwareStatusEnumType_Accepted]);
  8334. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  8335. sprintf(message,"[%d,\"%s\",%s]"
  8336. ,MESSAGE_TYPE_CALLRESULT
  8337. ,uuid
  8338. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  8339. json_object_put(UpdateFirmware);
  8340. LWS_Send(message);
  8341. result = TRUE;
  8342. return result;
  8343. }
  8344. //==========================================
  8345. // send CallError routine
  8346. //==========================================
  8347. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  8348. {
  8349. mtrace();
  8350. char message[220]={0};
  8351. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  8352. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  8353. LWS_Send(message);
  8354. }
  8355. //==========================================
  8356. // Handle server request routine Start
  8357. //==========================================
  8358. int handleCancelReservationRequest(char *uuid, char *payload)
  8359. {
  8360. mtrace();
  8361. int result = FAIL;
  8362. int gunNO = 0;
  8363. int reservationIdInt = -1;
  8364. DEBUG_INFO("handleCancelReservationRequest...\n");
  8365. json_object *CancelReservation;
  8366. CancelReservation = json_tokener_parse(payload);
  8367. if(!is_error(CancelReservation))
  8368. {
  8369. // Required data
  8370. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  8371. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  8372. }
  8373. json_object_put(CancelReservation);
  8374. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  8375. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  8376. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  8377. if(reservationIdInt != -1)
  8378. {
  8379. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  8380. //check Transaction active
  8381. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  8382. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8383. {
  8384. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  8385. {
  8386. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8387. if(gunType[2] == 'J')
  8388. {
  8389. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  8390. }
  8391. else
  8392. {
  8393. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  8394. }
  8395. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8396. goto end;
  8397. }
  8398. }
  8399. for (int index = 0; index < CCS_QUANTITY; index++)
  8400. {
  8401. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  8402. {
  8403. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8404. if((gunType[2] == 'U') || (gunType[2] == 'E'))
  8405. {
  8406. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  8407. }
  8408. else
  8409. {
  8410. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  8411. }
  8412. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8413. goto end;
  8414. }
  8415. }
  8416. for (int index = 0; index < GB_QUANTITY; index++)
  8417. {
  8418. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  8419. {
  8420. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8421. if(gunType[2] == 'G')
  8422. {
  8423. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  8424. }
  8425. else
  8426. {
  8427. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  8428. }
  8429. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8430. goto end;
  8431. }
  8432. }
  8433. for (int index = 0; index < AC_QUANTITY; index++)
  8434. {
  8435. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  8436. {
  8437. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8438. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8439. {
  8440. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  8441. }
  8442. else
  8443. {
  8444. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  8445. }
  8446. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8447. goto end;
  8448. }
  8449. }
  8450. }
  8451. //The reservationId does NOT match the reservationId
  8452. sendCancelReservationConfirmation(uuid, gunNO);
  8453. end:
  8454. // Fill in ocpp packet uuid
  8455. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  8456. return result;
  8457. }
  8458. int handleCertificateSignedRequest(char *uuid, char *payload)
  8459. {
  8460. mtrace();
  8461. int result = FAIL;
  8462. json_object *CertificateSigned;
  8463. DEBUG_INFO("handleCertificateSignedRequest...\n");
  8464. CertificateSigned = json_tokener_parse(payload);
  8465. if(!is_error(CertificateSigned))
  8466. {
  8467. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  8468. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  8469. // Required data
  8470. if(json_object_array_length(json_object_object_get(CertificateSigned, "certificate")) <= ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.certificate))
  8471. {
  8472. for(int idx=0;idx<json_object_array_length(json_object_object_get(CertificateSigned, "certificate"));idx++)
  8473. {
  8474. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificate[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(CertificateSigned, "certificateType"), idx)));
  8475. /*
  8476. * TODO:
  8477. * 1. Certificate install response
  8478. */
  8479. }
  8480. }
  8481. // Optional data
  8482. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  8483. {
  8484. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  8485. }
  8486. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  8487. }
  8488. else
  8489. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  8490. json_object_put(CertificateSigned);
  8491. sendCertificateSignedConfirmation(uuid);
  8492. return result;
  8493. }
  8494. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  8495. {
  8496. mtrace();
  8497. int result = FAIL;
  8498. int evseId = 0, gunIndex = 0;
  8499. char operationalStatus[16]={0};
  8500. char comfirmstr[20];
  8501. int specificId = FALSE;
  8502. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  8503. json_object *ChangeAvailability;
  8504. ChangeAvailability = json_tokener_parse(payload);
  8505. if(!is_error(ChangeAvailability))
  8506. {
  8507. // Required data
  8508. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  8509. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  8510. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  8511. {
  8512. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  8513. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  8514. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  8515. }
  8516. }
  8517. json_object_put(ChangeAvailability);
  8518. if((evseId != 0) && (evseId <= gunTotalNumber))
  8519. {
  8520. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  8521. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  8522. }
  8523. else if(evseId == 0)
  8524. {
  8525. for(int i=0; i < gunTotalNumber; i++)
  8526. {
  8527. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  8528. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8529. }
  8530. }
  8531. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8532. {
  8533. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  8534. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  8535. }
  8536. else if(gunIndex == 0)
  8537. {
  8538. for(int i=0; i < gunTotalNumber; i++)
  8539. {
  8540. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  8541. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8542. }
  8543. }
  8544. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  8545. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8546. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  8547. {
  8548. specificId = TRUE;
  8549. }
  8550. if(specificId == FALSE)
  8551. goto end;
  8552. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  8553. {
  8554. //----------------------gunIndex is 0 ------------------------------------------------//
  8555. if(gunIndex == 0)
  8556. {
  8557. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8558. {
  8559. for(int i=0; i < gunTotalNumber; i++)
  8560. {
  8561. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8562. {
  8563. if ((gunType[i] == 'J')&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  8564. {
  8565. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8566. {
  8567. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8568. goto end;
  8569. }
  8570. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8571. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8572. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8573. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8574. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8575. {
  8576. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8577. goto end;
  8578. }
  8579. }
  8580. }//END FOR CHAdeMO_QUANTITY
  8581. for (int index = 0; index < CCS_QUANTITY; index++)
  8582. {
  8583. if (((gunType[i] == 'U')||(gunType[i] == 'E'))&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  8584. {
  8585. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  8586. {
  8587. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8588. goto end;
  8589. }
  8590. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8591. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8592. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8593. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8594. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8595. {
  8596. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8597. goto end;
  8598. }
  8599. }
  8600. }//END FOR CCS_QUANTITY
  8601. for (int index = 0; index < GB_QUANTITY; index++)
  8602. {
  8603. if ((gunType[i] == 'G')&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  8604. {
  8605. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8606. {
  8607. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8608. goto end;
  8609. }
  8610. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8611. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8612. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8613. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8614. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8615. {
  8616. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8617. goto end;
  8618. }
  8619. }
  8620. }// END FOR GB_QUANTITY
  8621. for (int index = 0; index < AC_QUANTITY; index++)
  8622. {
  8623. if (((gunType[i] > '0')&&(gunType[i] <= '9'))&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  8624. {
  8625. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8626. {
  8627. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8628. goto end;
  8629. }
  8630. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8631. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8632. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8633. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8634. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8635. {
  8636. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8637. goto end;
  8638. }
  8639. }
  8640. }//END FOR AC_QUANTITY
  8641. }// END FOR gunTotalNumber
  8642. }
  8643. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8644. {
  8645. for(int i=0; i < gunTotalNumber; i++)
  8646. {
  8647. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8648. {
  8649. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8650. goto end;
  8651. }
  8652. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8653. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  8654. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  8655. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  8656. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8657. {
  8658. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8659. goto end;
  8660. }
  8661. }
  8662. }
  8663. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8664. goto end;
  8665. }
  8666. //----------------------gunIndex is not 0 ------------------------------------------------//
  8667. //check Transaction active
  8668. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8669. {
  8670. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J'))
  8671. {
  8672. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  8673. {
  8674. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8675. goto end;
  8676. }
  8677. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8678. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8679. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8680. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8681. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8682. {
  8683. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8684. goto end;
  8685. }
  8686. else
  8687. {
  8688. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  8689. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8690. goto end;
  8691. }
  8692. }
  8693. }//END FOR CHAdeMO_QUANTITY
  8694. for (int index = 0; index < CCS_QUANTITY; index++)
  8695. {
  8696. if ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E')))
  8697. {
  8698. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  8699. {
  8700. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8701. goto end;
  8702. }
  8703. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8704. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8705. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8706. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8707. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8708. {
  8709. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8710. goto end;
  8711. }
  8712. else
  8713. {
  8714. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  8715. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8716. goto end;
  8717. }
  8718. }
  8719. }//END FOR CCS_QUANTITY
  8720. for (int index = 0; index < GB_QUANTITY; index++)
  8721. {
  8722. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))
  8723. {
  8724. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8725. {
  8726. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8727. goto end;
  8728. }
  8729. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8730. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8731. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8732. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8733. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8734. {
  8735. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8736. goto end;
  8737. }
  8738. else
  8739. {
  8740. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  8741. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8742. goto end;
  8743. }
  8744. }
  8745. }// END FOR GB_QUANTITY
  8746. for (int index = 0; index < AC_QUANTITY; index++)
  8747. {
  8748. if ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))
  8749. {
  8750. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8751. {
  8752. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8753. goto end;
  8754. }
  8755. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8756. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8757. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8758. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8759. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8760. {
  8761. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8762. goto end;
  8763. }
  8764. else
  8765. {
  8766. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  8767. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8768. goto end;
  8769. }
  8770. }
  8771. }//END FOR AC_QUANTITY
  8772. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  8773. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  8774. {
  8775. //----------------------gunIndex is 0 ------------------------------------------------//
  8776. if(gunIndex == 0)
  8777. {
  8778. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8779. {
  8780. for(int i=0; i < gunTotalNumber; i++)
  8781. {
  8782. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8783. {
  8784. 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
  8785. {
  8786. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8787. goto end;
  8788. }
  8789. }//END FOR CHAdeMO_QUANTITY
  8790. for (int index = 0; index < CCS_QUANTITY; index++)
  8791. {
  8792. 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
  8793. {
  8794. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8795. goto end;
  8796. }
  8797. }//END FOR CCS_QUANTITY
  8798. for (int index = 0; index < GB_QUANTITY; index++)
  8799. {
  8800. 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
  8801. {
  8802. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8803. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8804. goto end;
  8805. }
  8806. }// END FOR GB_QUANTITY
  8807. for (int index = 0; index < AC_QUANTITY; index++)
  8808. {
  8809. 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
  8810. {
  8811. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8812. goto end;
  8813. }
  8814. }//END FOR CHAdeMO_QUANTITY
  8815. }// END FOR gunTotalNumber
  8816. }
  8817. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8818. {
  8819. for(int i=0; i < gunTotalNumber; i++)
  8820. {
  8821. for (int index = 0; index < AC_QUANTITY; index++)
  8822. {
  8823. 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
  8824. {
  8825. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8826. goto end;
  8827. }
  8828. }//END FOR CHAdeMO_QUANTITY
  8829. } // END FOR gunTotalNumber
  8830. }
  8831. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8832. goto end;
  8833. }
  8834. //----------------------gunIndex is not 0 ------------------------------------------------//
  8835. //check Transaction active
  8836. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8837. {
  8838. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'J') ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8839. {
  8840. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8841. goto end;
  8842. }
  8843. }//END FOR CHAdeMO_QUANTITY
  8844. for (int index = 0; index < CCS_QUANTITY; index++)
  8845. {
  8846. if ((((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8847. {
  8848. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8849. goto end;
  8850. }
  8851. }//END FOR CCS_QUANTITY
  8852. for (int index = 0; index < GB_QUANTITY; index++)
  8853. {
  8854. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8855. {
  8856. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8857. goto end;
  8858. }
  8859. }// END FOR GB_QUANTITY
  8860. for (int index = 0; index < AC_QUANTITY; index++)
  8861. {
  8862. if (((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9'))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8863. {
  8864. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8865. goto end;
  8866. }
  8867. }//END FOR AC_QUANTITY
  8868. }//END FOR AvailabilityEnumTypeStr[Operative]
  8869. end:
  8870. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8871. {
  8872. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  8873. }
  8874. else
  8875. {
  8876. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  8877. }
  8878. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8879. {
  8880. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  8881. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8882. }
  8883. else if(gunIndex == 0)
  8884. {
  8885. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  8886. {
  8887. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  8888. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  8889. }
  8890. }
  8891. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  8892. return result;
  8893. }
  8894. int handleClearCacheRequest(char *uuid, char *payload)
  8895. {
  8896. mtrace();
  8897. int result = FAIL;
  8898. char rmFileCmd[100]={0};
  8899. struct stat stats;
  8900. DEBUG_INFO("handleClearCacheRequest...\n");
  8901. stat("/Storage/OCPP", &stats);
  8902. // Check for directory existence
  8903. if (S_ISDIR(stats.st_mode) == 1)
  8904. {}
  8905. else
  8906. {
  8907. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  8908. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  8909. system(rmFileCmd);
  8910. }
  8911. /*
  8912. * TODO:
  8913. * 1. Clear cache from sqlite db
  8914. */
  8915. if(1)
  8916. {
  8917. DEBUG_INFO("open AuthorizationCache file failed\n");
  8918. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  8919. }
  8920. else
  8921. {
  8922. DEBUG_INFO("open AuthorizationCache file successful\n");
  8923. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  8924. }
  8925. sendClearCacheConfirmation(uuid);
  8926. return result;
  8927. }
  8928. int handleClearChargingProfileRequest(char *uuid, char *payload)
  8929. {
  8930. mtrace();
  8931. int result = FAIL;
  8932. int resultRename;
  8933. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  8934. char chargingProfilePurposeStr[26]={0};
  8935. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  8936. char tempchargingProfilePurposeStr[26]={0};
  8937. char sstr[160]={0};
  8938. char str[100]={0};
  8939. int c = 0;
  8940. char *loc;
  8941. char fname[200]={0};
  8942. char comfirmstr[20]={0};
  8943. char word[1600]={0};
  8944. int clearflag = FALSE;
  8945. int chargingProfileIdIsNULL = FALSE;
  8946. int connectorIsNULL = FALSE;
  8947. int chargingProfilePurposeIsNULL = FALSE;
  8948. int stackLevelIsNULL = FALSE;
  8949. //int GotoEnd = FALSE;
  8950. FILE *fptr1, *fptr2;
  8951. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  8952. int n_chargingProfile=0;
  8953. int isEmptyFile = FALSE;
  8954. char sLineWord[1600]={0};
  8955. char chargingProfiles[10][100]={0};
  8956. int ChargeProfileCount = 0;
  8957. int ch;
  8958. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  8959. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  8960. json_object *ClearChargingProfile;
  8961. ClearChargingProfile = json_tokener_parse(payload);
  8962. if(!is_error(ClearChargingProfile))
  8963. {
  8964. // Optional data
  8965. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  8966. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  8967. else
  8968. chargingProfileIdIsNULL = TRUE;
  8969. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  8970. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  8971. else
  8972. connectorIsNULL = TRUE;
  8973. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  8974. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  8975. else
  8976. chargingProfilePurposeIsNULL = TRUE;
  8977. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  8978. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  8979. else
  8980. stackLevelIsNULL = TRUE;
  8981. }
  8982. json_object_put(ClearChargingProfile);
  8983. if(connectorIsNULL == FALSE)
  8984. {
  8985. switch(connectorIdInt)
  8986. {
  8987. case 0:
  8988. if(chargingProfilePurposeIsNULL == TRUE)
  8989. {
  8990. int l = 0;
  8991. strcpy(fname, ChargePointMaxProfile_JSON);
  8992. if((access(fname,F_OK))!=-1)
  8993. {
  8994. strcpy(chargingProfiles[l], fname);
  8995. l = l + 1;
  8996. }
  8997. strcpy(fname, TxDefaultProfile_0_JSON);
  8998. if((access(fname,F_OK))!=-1)
  8999. {
  9000. strcpy(chargingProfiles[l], fname);
  9001. l = l + 1;
  9002. }
  9003. ChargeProfileCount = l;
  9004. }
  9005. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  9006. {
  9007. strcpy(fname, ChargePointMaxProfile_JSON);
  9008. if((access(fname,F_OK))!=-1)
  9009. {
  9010. strcpy(chargingProfiles[0], fname);
  9011. ChargeProfileCount = 1;
  9012. }
  9013. }
  9014. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  9015. {
  9016. strcpy(fname, TxDefaultProfile_0_JSON);
  9017. if((access(fname,F_OK))!=-1)
  9018. {
  9019. strcpy(chargingProfiles[0], fname);
  9020. ChargeProfileCount = 1;
  9021. }
  9022. }
  9023. break;
  9024. default:
  9025. if(chargingProfilePurposeIsNULL == TRUE)
  9026. {
  9027. int m = 0;
  9028. memset(fname, 0, ARRAY_SIZE(fname));
  9029. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  9030. if((access(fname,F_OK))!=-1)
  9031. {
  9032. strcpy(chargingProfiles[m], fname);
  9033. m = m + 1;
  9034. }
  9035. memset(fname, 0, ARRAY_SIZE(fname));
  9036. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  9037. if((access(fname,F_OK))!=-1)
  9038. {
  9039. strcpy(chargingProfiles[m], fname);
  9040. m = m + 1;
  9041. }
  9042. ChargeProfileCount = m;
  9043. }
  9044. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  9045. {
  9046. //strcpy(fname, TxDefaultProfile_1_JSON);
  9047. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  9048. if((access(fname,F_OK))!=-1)
  9049. {
  9050. strcpy(chargingProfiles[0], fname);
  9051. ChargeProfileCount = 1;
  9052. }
  9053. }
  9054. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  9055. {
  9056. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  9057. if((access(fname,F_OK))!=-1)
  9058. {
  9059. strcpy(chargingProfiles[0], fname);
  9060. ChargeProfileCount = 1;
  9061. }
  9062. }
  9063. //strcpy(fname, ChargePointMaxProfile_JSON );
  9064. break;
  9065. }
  9066. }
  9067. else // Check all Charging Profiles
  9068. {
  9069. int i = 0;
  9070. char fnametemp[200]={0};
  9071. ChargeProfileCount = 0;
  9072. //Check ChargePointMaxProfile.json exit
  9073. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  9074. {
  9075. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  9076. i = i + 1;
  9077. }
  9078. //Check TxDefaultProfile_0.json exit
  9079. if((access("/Storage/OCPP/TxDefaultProfile_0.json",F_OK))!=-1)
  9080. {
  9081. strcpy(chargingProfiles[i], "/Storage/OCPP/TxDefaultProfile_0.json");
  9082. i = i + 1;
  9083. }
  9084. //Check TxDefaultProfile_%d.json
  9085. for(int j=1; j <= gunTotalNumber; j++)
  9086. {
  9087. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  9088. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d.json", j);
  9089. if((access(fnametemp,F_OK))!=-1)
  9090. {
  9091. strcpy(chargingProfiles[i], fnametemp);
  9092. i = i + 1;
  9093. }
  9094. }
  9095. //Check TxProfile_%d.json
  9096. for(int j=1; j <= gunTotalNumber; j++)
  9097. {
  9098. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  9099. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d.json", j);
  9100. if((access(fnametemp,F_OK))!=-1)
  9101. {
  9102. strcpy(chargingProfiles[i], fnametemp);
  9103. i = i + 1;
  9104. }
  9105. }
  9106. ChargeProfileCount = i;
  9107. }// End connectorIsNULL is TRUE
  9108. if(ChargeProfileCount == 0)
  9109. {
  9110. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9111. goto end;
  9112. }
  9113. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  9114. {
  9115. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9116. goto end;
  9117. }
  9118. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  9119. {
  9120. memset(str, 0, ARRAY_SIZE(str));
  9121. // clear temp file
  9122. sprintf(str,"rm -f %s",temp);
  9123. system(str);
  9124. for(int k=0; k < ChargeProfileCount; k++)
  9125. {
  9126. memset(str, 0, ARRAY_SIZE(str));
  9127. //clear file in C
  9128. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9129. system(str);
  9130. }
  9131. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9132. goto end;
  9133. }
  9134. else if(connectorIsNULL == TRUE)
  9135. {
  9136. for(int k=0; k < ChargeProfileCount; k++)
  9137. {
  9138. fptr1 = fopen(chargingProfiles[k], "r");
  9139. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  9140. //Check Charging Profile Count
  9141. while(fscanf(fptr1, "%s", word) != EOF)
  9142. {
  9143. //DEBUG_INFO("word=%s\n",word);
  9144. if(strstr(word, "chargingProfileId")!= NULL)
  9145. {
  9146. //DEBUG_INFO("test chargingProfileId \n");
  9147. n_chargingProfile = n_chargingProfile + 1;
  9148. //DEBUG_INFO("chargingProfileId Found\n");
  9149. }
  9150. }
  9151. rewind(fptr1);
  9152. //search Charging Profile Element
  9153. //int i= 0;
  9154. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9155. {
  9156. //------------------------tempconnectorIdInt------------------------//
  9157. loc = strstr(sLineWord, "connectorId");
  9158. c = 0;
  9159. memset(sstr ,0, sizeof(sstr) );
  9160. while (loc[strlen("connectorId")+2+c] != ',')
  9161. {
  9162. sstr[c] = loc[strlen("connectorId")+2+c];
  9163. c++;
  9164. }
  9165. sstr[c] = '\0';
  9166. tempconnectorIdInt = atoi(sstr);
  9167. printf("file's gun number is %d\n", tempconnectorIdInt);
  9168. //--------------------------chargingProfileId--------------------//
  9169. c = 0;
  9170. loc = strstr(sLineWord, "chargingProfileId");
  9171. memset(sstr ,0, ARRAY_SIZE(sstr));
  9172. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9173. {
  9174. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9175. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9176. c++;
  9177. }
  9178. sstr[c] = '\0';
  9179. tempchargingProfileIdInt = atoi(sstr);
  9180. //stackLevel
  9181. c = 0;
  9182. loc = strstr(sLineWord, "stackLevel");
  9183. memset(sstr ,0, ARRAY_SIZE(sstr));
  9184. while (loc[strlen("stackLevel")+2+c] != ',')
  9185. {
  9186. sstr[c] = loc[strlen("stackLevel")+2+c];
  9187. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9188. c++;
  9189. }
  9190. sstr[c] = '\0';
  9191. tempstackLevelInt = atoi(sstr);
  9192. c = 0;
  9193. loc = strstr(sLineWord, "chargingProfilePurpose");
  9194. memset(sstr ,0, ARRAY_SIZE(sstr));
  9195. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9196. {
  9197. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9198. c++;
  9199. }
  9200. sstr[c] = '\0';
  9201. strcpy(tempchargingProfilePurposeStr, sstr);
  9202. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9203. {
  9204. //------- not write to fptr2-------//
  9205. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9206. //clearflag = TRUE;
  9207. }
  9208. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  9209. {
  9210. //------- not write to fptr2-------//
  9211. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9212. }
  9213. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9214. {
  9215. //------- not write to fptr2-------//
  9216. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9217. }
  9218. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  9219. {
  9220. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9221. }
  9222. else
  9223. {
  9224. fprintf(fptr2, sLineWord);//writing data into file
  9225. }
  9226. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9227. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9228. if(clearflag == TRUE)
  9229. {
  9230. fclose(fptr1);
  9231. fclose(fptr2);
  9232. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9233. system(str);
  9234. // clear temp file
  9235. sprintf(str,"rm -f %s",temp);
  9236. system(str);
  9237. }
  9238. else
  9239. {
  9240. fclose(fptr1);
  9241. fclose(fptr2);
  9242. memset(str, 0, ARRAY_SIZE(str));
  9243. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9244. system(str);
  9245. resultRename = rename(temp, chargingProfiles[k]);
  9246. if(resultRename == 0)
  9247. {
  9248. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  9249. }
  9250. else
  9251. {
  9252. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  9253. }
  9254. if(comfirmstr[0]== 0)
  9255. {
  9256. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9257. }
  9258. //Check chargingProfile is empty file
  9259. /*------ Read the file ----------------*/
  9260. fptr1=fopen(chargingProfiles[k],"r");
  9261. ch=fgetc(fptr1);
  9262. rewind(fptr1);
  9263. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9264. if(ch!=EOF)
  9265. {
  9266. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9267. {
  9268. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9269. if(sLineWord[0]=='\0')
  9270. {
  9271. isEmptyFile = TRUE;
  9272. break;
  9273. }
  9274. else
  9275. {
  9276. isEmptyFile = FALSE;
  9277. break;
  9278. }
  9279. }
  9280. }
  9281. else
  9282. isEmptyFile = TRUE;
  9283. fclose(fptr1);
  9284. if(isEmptyFile == TRUE)
  9285. {
  9286. memset(str, 0, ARRAY_SIZE(str));
  9287. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9288. system(str);
  9289. }
  9290. }
  9291. }// End of while(int k=0; k < ChargePointCount; k++)
  9292. }
  9293. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  9294. {
  9295. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  9296. for(int k=0; k < ChargeProfileCount; k++)
  9297. {
  9298. fptr1 = fopen(chargingProfiles[k], "r");
  9299. fptr2 = fopen(temp, "w+");
  9300. //Check Charging Profile Count
  9301. while(fscanf(fptr1, "%s", word) != EOF)
  9302. {
  9303. //DEBUG_INFO("word=%s\n",word);
  9304. if(strstr(word, "chargingProfileId")!= NULL)
  9305. {
  9306. n_chargingProfile = n_chargingProfile + 1;
  9307. }
  9308. }
  9309. rewind(fptr1);
  9310. //search Charging Profile Element
  9311. //int i= 0;
  9312. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9313. {
  9314. //*************************tempconnectorIdInt*********************************/
  9315. loc = strstr(sLineWord, "connectorId");
  9316. c = 0;
  9317. memset(sstr ,0, ARRAY_SIZE(sstr));
  9318. while (loc[strlen("connectorId")+2+c] != ',')
  9319. {
  9320. sstr[c] = loc[strlen("connectorId")+2+c];
  9321. c++;
  9322. }
  9323. sstr[c] = '\0';
  9324. tempconnectorIdInt = atoi(sstr);
  9325. //chargingProfileId
  9326. c = 0;
  9327. loc = strstr(sLineWord, "chargingProfileId");
  9328. memset(sstr ,0, ARRAY_SIZE(sstr));
  9329. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9330. {
  9331. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9332. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9333. c++;
  9334. }
  9335. sstr[c] = '\0';
  9336. tempchargingProfileIdInt = atoi(sstr);
  9337. //stackLevel
  9338. c = 0;
  9339. loc = strstr(sLineWord, "stackLevel");
  9340. memset(sstr ,0, ARRAY_SIZE(sstr));
  9341. while (loc[strlen("stackLevel")+2+c] != ',')
  9342. {
  9343. sstr[c] = loc[strlen("stackLevel")+2+c];
  9344. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9345. c++;
  9346. }
  9347. sstr[c] = '\0';
  9348. tempstackLevelInt = atoi(sstr);
  9349. c = 0;
  9350. loc = strstr(sLineWord, "chargingProfilePurpose");
  9351. memset(sstr ,0, ARRAY_SIZE(sstr));
  9352. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9353. {
  9354. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9355. c++;
  9356. }
  9357. sstr[c] = '\0';
  9358. strcpy(tempchargingProfilePurposeStr, sstr);
  9359. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9360. {
  9361. //------- not write to fptr2-------//
  9362. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9363. //clearflag = TRUE;
  9364. }
  9365. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9366. {
  9367. //------- not write to fptr2-------//
  9368. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9369. }
  9370. else if(stackLevelIsNULL == TRUE)
  9371. {
  9372. //Clear Whole File
  9373. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9374. clearflag = TRUE;
  9375. break;
  9376. }
  9377. else
  9378. {
  9379. fprintf(fptr2, sLineWord);//writing data into file
  9380. }
  9381. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9382. }
  9383. if(clearflag == TRUE)
  9384. {
  9385. fclose(fptr1);
  9386. fclose(fptr2);
  9387. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9388. system(str);
  9389. // clear temp file
  9390. sprintf(str,"rm -f %s",temp);
  9391. system(str);
  9392. }
  9393. else
  9394. {
  9395. fclose(fptr1);
  9396. fclose(fptr2);
  9397. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9398. system(str);
  9399. resultRename = rename(temp, chargingProfiles[k]);
  9400. if(resultRename == 0)
  9401. {
  9402. DEBUG_INFO("File ChargingProfile renamed successfully");
  9403. }
  9404. else
  9405. {
  9406. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  9407. }
  9408. if(comfirmstr[0]== 0)
  9409. {
  9410. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9411. }
  9412. //Check chargingProfile is empty file
  9413. /*------ Read the file ----------------*/
  9414. fptr1=fopen(chargingProfiles[k],"r");
  9415. ch=fgetc(fptr1);
  9416. rewind(fptr1);
  9417. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9418. if(ch!=EOF)
  9419. {
  9420. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9421. {
  9422. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9423. if(sLineWord[0]=='\0')
  9424. {
  9425. isEmptyFile = TRUE;
  9426. break;
  9427. }
  9428. else
  9429. {
  9430. isEmptyFile = FALSE;
  9431. break;
  9432. }
  9433. }
  9434. }
  9435. else
  9436. isEmptyFile = TRUE;
  9437. fclose(fptr1);
  9438. if(isEmptyFile == TRUE)
  9439. {
  9440. memset(str, 0, ARRAY_SIZE(str));
  9441. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9442. system(str);
  9443. }
  9444. /*------- End of reading ---------------*/
  9445. }
  9446. } // while(int k=0; k < ChargeProfileCount; k++)
  9447. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  9448. end:
  9449. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  9450. {
  9451. if(connectorIdInt == 0)
  9452. {
  9453. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  9454. {
  9455. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  9456. }
  9457. }
  9458. else
  9459. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1]);
  9460. }
  9461. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  9462. return result;
  9463. }
  9464. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  9465. {
  9466. mtrace();
  9467. int result = FAIL;
  9468. json_object *ClearDisplayMessage;
  9469. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  9470. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  9471. ClearDisplayMessage = json_tokener_parse(payload);
  9472. if(!is_error(ClearDisplayMessage))
  9473. {
  9474. // Required data
  9475. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  9476. {
  9477. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  9478. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  9479. }
  9480. }
  9481. json_object_put(ClearDisplayMessage);
  9482. sendCostUpdatedConfirmation(uuid);
  9483. return result;
  9484. }
  9485. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  9486. {
  9487. mtrace();
  9488. int result = FAIL;
  9489. json_object *ClearVariableMonitorin;
  9490. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  9491. ClearVariableMonitorin = json_tokener_parse(payload);
  9492. if(!is_error(ClearVariableMonitorin))
  9493. {
  9494. // Required data
  9495. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  9496. {
  9497. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  9498. {
  9499. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  9500. /*
  9501. * TODO:
  9502. * 1. Check response
  9503. */
  9504. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  9505. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  9506. }
  9507. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  9508. }
  9509. }
  9510. json_object_put(ClearVariableMonitorin);
  9511. return result;
  9512. }
  9513. int handleCostUpdatedRequest(char *uuid, char *payload)
  9514. {
  9515. mtrace();
  9516. int result = FAIL;
  9517. json_object *CostUpdate;
  9518. DEBUG_INFO("handleCostUpdatedRequest...\n");
  9519. CostUpdate = json_tokener_parse(payload);
  9520. if(!is_error(CostUpdate))
  9521. {
  9522. // Required data
  9523. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  9524. {
  9525. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  9526. }
  9527. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  9528. {
  9529. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  9530. }
  9531. }
  9532. json_object_put(CostUpdate);
  9533. sendCostUpdatedConfirmation(uuid);
  9534. return result;
  9535. }
  9536. int handleCustomerInformationRequest(char *uuid, char *payload)
  9537. {
  9538. mtrace();
  9539. int result = FAIL;
  9540. json_object *CustomerInformation;
  9541. DEBUG_INFO("handleCustomerInformationRequest...\n");
  9542. CustomerInformation = json_tokener_parse(payload);
  9543. if(!is_error(CustomerInformation))
  9544. {
  9545. // Required data
  9546. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  9547. {
  9548. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  9549. }
  9550. if(json_object_object_get(CustomerInformation, "report") != NULL)
  9551. {
  9552. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  9553. }
  9554. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  9555. {
  9556. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  9557. }
  9558. // Optional data
  9559. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  9560. {
  9561. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  9562. {
  9563. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  9564. }
  9565. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  9566. {
  9567. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  9568. }
  9569. }
  9570. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  9571. {
  9572. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  9573. {
  9574. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  9575. }
  9576. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  9577. {
  9578. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  9579. }
  9580. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  9581. {
  9582. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  9583. }
  9584. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  9585. {
  9586. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  9587. }
  9588. }
  9589. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  9590. }
  9591. else
  9592. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  9593. json_object_put(CustomerInformation);
  9594. sendCustomerInformationConfirmation(uuid);
  9595. return result;
  9596. }
  9597. void createFirmwareVersionByDataTransfer(void)
  9598. {
  9599. json_object *FirmwareDataTransfer = json_object_new_object();
  9600. // AC & DC model
  9601. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  9602. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  9603. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  9604. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  9605. // DC model
  9606. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]!='O')
  9607. {
  9608. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  9609. {
  9610. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  9611. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  9612. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  9613. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  9614. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  9615. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  9616. }
  9617. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
  9618. ((gunType[1] != '0') || (gunType[2] != '0') || (gunType[3] != '0')))
  9619. {
  9620. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  9621. }
  9622. }
  9623. else
  9624. {
  9625. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  9626. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  9627. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  9628. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  9629. json_object_object_add(FirmwareDataTransfer, "DD0_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuBootLoadFwRev));
  9630. json_object_object_add(FirmwareDataTransfer, "DD0_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuKernelFwRev));
  9631. json_object_object_add(FirmwareDataTransfer, "DD0_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuRootFsFwRev));
  9632. json_object_object_add(FirmwareDataTransfer, "DD0_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].CsuPrimFwRev));
  9633. json_object_object_add(FirmwareDataTransfer, "DD0_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].FanModuleFwRev));
  9634. json_object_object_add(FirmwareDataTransfer, "DD0_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].RelayModuleFwRev));
  9635. json_object_object_add(FirmwareDataTransfer, "DD0_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].LedModuleFwRev));
  9636. json_object_object_add(FirmwareDataTransfer, "DD0_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector1FwRev));
  9637. json_object_object_add(FirmwareDataTransfer, "DD0_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[0].Connector2FwRev));
  9638. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev) > 0)
  9639. json_object_object_add(FirmwareDataTransfer, "DD1_CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuBootLoadFwRev));
  9640. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev) > 0)
  9641. json_object_object_add(FirmwareDataTransfer, "DD1_CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuKernelFwRev));
  9642. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev) > 0)
  9643. json_object_object_add(FirmwareDataTransfer, "DD1_CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuRootFsFwRev));
  9644. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev) > 0)
  9645. json_object_object_add(FirmwareDataTransfer, "DD1_CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].CsuPrimFwRev));
  9646. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev) > 0)
  9647. json_object_object_add(FirmwareDataTransfer, "DD1_FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].FanModuleFwRev));
  9648. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev) > 0)
  9649. json_object_object_add(FirmwareDataTransfer, "DD1_RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].RelayModuleFwRev));
  9650. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev) > 0)
  9651. json_object_object_add(FirmwareDataTransfer, "DD1_LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].LedModuleFwRev));
  9652. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev) > 0)
  9653. json_object_object_add(FirmwareDataTransfer, "DD1_Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector1FwRev));
  9654. if(strlen((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev) > 0)
  9655. json_object_object_add(FirmwareDataTransfer, "DD1_Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.DispenserInfo.Dispenser[1].Connector2FwRev));
  9656. }
  9657. // 4G model
  9658. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  9659. {
  9660. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  9661. }
  9662. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "Phihong Technology");
  9663. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion");
  9664. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, json_object_to_json_string(FirmwareDataTransfer));
  9665. }
  9666. int handleDataTransferRequest(char *uuid, char *payload)
  9667. {
  9668. mtrace();
  9669. int result = PASS;
  9670. DEBUG_INFO("handleDataTransferRequest...\n");
  9671. if((uuid != NULL) && (payload != NULL))
  9672. {
  9673. json_object *DataTransfer;
  9674. DataTransfer = json_tokener_parse(payload);
  9675. if(!is_error(DataTransfer))
  9676. {
  9677. // Required data
  9678. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  9679. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  9680. // Optional data
  9681. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  9682. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  9683. if(json_object_object_get(DataTransfer, "data") != NULL)
  9684. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  9685. result = PASS;
  9686. }
  9687. json_object_put(DataTransfer);
  9688. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  9689. {
  9690. // Send all moudle firmware version on EVSE
  9691. createFirmwareVersionByDataTransfer();
  9692. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9693. }
  9694. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_Tmate") != NULL)
  9695. {
  9696. system("/usr/bin/run_tmate_restart.sh &");
  9697. }
  9698. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  9699. {
  9700. json_object *data;
  9701. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  9702. if(!is_error(data))
  9703. {
  9704. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  9705. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  9706. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  9707. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  9708. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  9709. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  9710. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  9711. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  9712. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  9713. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  9714. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9715. }
  9716. else
  9717. {
  9718. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  9719. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  9720. }
  9721. json_object_put(data);
  9722. }
  9723. else
  9724. {
  9725. // Can not find valid message id
  9726. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9727. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  9728. ,ShmOCPP20Data->DataTransfer[0].vendorId
  9729. ,ShmOCPP20Data->DataTransfer[0].messageId
  9730. ,ShmOCPP20Data->DataTransfer[0].data);
  9731. }
  9732. }
  9733. else
  9734. {
  9735. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9736. result = FAIL;
  9737. }
  9738. sendDataTransferConfirmation(uuid, 0);
  9739. return result;
  9740. }
  9741. int handleDeleteCertificateRequest(char *uuid, char *payload)
  9742. {
  9743. mtrace();
  9744. int result = FAIL;
  9745. json_object *DeleteCertificate;
  9746. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  9747. DeleteCertificate = json_tokener_parse(payload);
  9748. if(!is_error(DeleteCertificate))
  9749. {
  9750. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  9751. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  9752. // Required data
  9753. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  9754. {
  9755. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  9756. {
  9757. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  9758. }
  9759. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  9760. {
  9761. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  9762. }
  9763. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  9764. {
  9765. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  9766. }
  9767. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  9768. {
  9769. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  9770. }
  9771. /*
  9772. * TODO:
  9773. * 1. Delete certification and response
  9774. */
  9775. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  9776. }
  9777. }
  9778. else
  9779. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  9780. json_object_put(DeleteCertificate);
  9781. sendDeleteCertificateConfirmation(uuid);
  9782. return result;
  9783. }
  9784. int handleGetBaseReportRequest(char *uuid, char *payload)
  9785. {
  9786. mtrace();
  9787. int result = FAIL;
  9788. json_object *GetBaseRepor;
  9789. DEBUG_INFO("handleGetBaseReportRequest...\n");
  9790. GetBaseRepor = json_tokener_parse(payload);
  9791. if(!is_error(GetBaseRepor))
  9792. {
  9793. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  9794. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  9795. // Required data
  9796. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  9797. {
  9798. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  9799. }
  9800. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  9801. {
  9802. sprintf((char*)ShmOCPP20Data->GetBaseReport.reportBase, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  9803. }
  9804. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  9805. }
  9806. else
  9807. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  9808. json_object_put(GetBaseRepor);
  9809. sendGetBaseReportConfirmation(uuid);
  9810. return result;
  9811. }
  9812. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  9813. {
  9814. mtrace();
  9815. int result = FAIL;
  9816. int gun_index = -1;
  9817. json_object *GetChargingProfiles;
  9818. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  9819. GetChargingProfiles = json_tokener_parse(payload);
  9820. if(!is_error(GetChargingProfiles))
  9821. {
  9822. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  9823. {
  9824. 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;
  9825. }
  9826. if(gun_index >-1)
  9827. {
  9828. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  9829. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  9830. // Required data
  9831. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  9832. {
  9833. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  9834. }
  9835. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  9836. {
  9837. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  9838. {
  9839. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  9840. }
  9841. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  9842. {
  9843. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  9844. }
  9845. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  9846. {
  9847. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  9848. {
  9849. 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)));
  9850. }
  9851. }
  9852. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  9853. {
  9854. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  9855. {
  9856. 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));
  9857. }
  9858. }
  9859. }
  9860. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  9861. }
  9862. else
  9863. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  9864. }
  9865. json_object_put(GetChargingProfiles);
  9866. sendGetChargingProfilesConfirmation(uuid, gun_index);
  9867. return result;
  9868. }
  9869. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  9870. {
  9871. mtrace();
  9872. int result = FAIL;
  9873. int connectorIdInt, durationInt;
  9874. char chargingRateUnitStr[4]={0};
  9875. char comfirmstr[20];
  9876. int confirmPeriods = 0;
  9877. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  9878. json_object *GetCompositeSchedule;
  9879. GetCompositeSchedule = json_tokener_parse(payload);
  9880. if(!is_error(GetCompositeSchedule))
  9881. {
  9882. // Required data
  9883. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  9884. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  9885. else
  9886. connectorIdInt = -1;
  9887. if(json_object_object_get(GetCompositeSchedule, "duration"))
  9888. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  9889. else
  9890. durationInt = 86400;
  9891. // Optional data
  9892. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  9893. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  9894. }
  9895. json_object_put(GetCompositeSchedule);
  9896. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  9897. if((connectorIdInt == 0) ||
  9898. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  9899. {
  9900. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  9901. struct ChargingProfileType tmpProfile[1];
  9902. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  9903. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  9904. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0]);
  9905. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  9906. {
  9907. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  9908. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  9909. }
  9910. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  9911. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  9912. {
  9913. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  9914. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  9915. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  9916. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0))
  9917. {
  9918. confirmPeriods = idx;
  9919. break;
  9920. }
  9921. }
  9922. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  9923. }
  9924. else
  9925. {
  9926. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  9927. }
  9928. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  9929. return result;
  9930. }
  9931. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  9932. {
  9933. mtrace();
  9934. int result = FAIL;
  9935. json_object *GetDisplayMessages;
  9936. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  9937. GetDisplayMessages = json_tokener_parse(payload);
  9938. if(!is_error(GetDisplayMessages))
  9939. {
  9940. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  9941. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  9942. // Required data
  9943. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  9944. {
  9945. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  9946. }
  9947. // Optional data
  9948. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  9949. {
  9950. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  9951. }
  9952. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  9953. {
  9954. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  9955. }
  9956. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  9957. {
  9958. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  9959. {
  9960. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  9961. }
  9962. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  9963. }
  9964. else
  9965. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  9966. }
  9967. json_object_put(GetDisplayMessages);
  9968. return result;
  9969. }
  9970. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  9971. {
  9972. mtrace();
  9973. int result = FAIL;
  9974. json_object *GetInstalledCertificateIds;
  9975. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  9976. GetInstalledCertificateIds = json_tokener_parse(payload);
  9977. if(!is_error(GetInstalledCertificateIds))
  9978. {
  9979. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  9980. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  9981. // Optional data
  9982. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  9983. {
  9984. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  9985. {
  9986. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  9987. /*
  9988. * TODO:
  9989. * 1. Get installed certificate info for response
  9990. */
  9991. }
  9992. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  9993. }
  9994. else
  9995. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  9996. }
  9997. json_object_put(GetInstalledCertificateIds);
  9998. sendInstallCertificateConfirmation(uuid);
  9999. return result;
  10000. }
  10001. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  10002. {
  10003. mtrace();
  10004. int result = FAIL;
  10005. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  10006. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  10007. {
  10008. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  10009. localversion = -1;
  10010. }
  10011. else
  10012. {
  10013. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  10014. DB_getListVerion();
  10015. }
  10016. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  10017. sendGetLocalListVersionConfirmation(uuid);
  10018. return result;
  10019. }
  10020. static char fnamePlusPath[100]={0};
  10021. static char fnamePWithNoPath[60]={0};
  10022. void checkUploadLog(void)
  10023. {
  10024. FILE *fp;
  10025. /* Open the command for reading. */
  10026. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  10027. if (fp == NULL) {
  10028. printf("Failed to run command\n" );
  10029. exit(1);
  10030. }
  10031. int ftppathlen = 0;
  10032. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  10033. int i = 0;
  10034. /* Read the output a line at a time - output it. */
  10035. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  10036. if(i==0)
  10037. {
  10038. ftppathlen = strlen(fnamePlusPath);
  10039. printf("%s\n", fnamePlusPath);
  10040. fnamePlusPath[ftppathlen]='\0';
  10041. break;
  10042. }
  10043. i= i+1;
  10044. }
  10045. /* close */
  10046. pclose(fp);
  10047. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  10048. {
  10049. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  10050. {
  10051. fnamePlusPath[k]='\0';
  10052. }
  10053. }
  10054. i=1;
  10055. //char fname[60]={0};
  10056. while(i < ftppathlen)
  10057. {
  10058. int len=ftppathlen-i;
  10059. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  10060. {
  10061. printf("compare '/' all right\n");
  10062. break;
  10063. }
  10064. i=i+1;
  10065. }
  10066. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  10067. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  10068. fnamePWithNoPath[i+1] = '\0';
  10069. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  10070. {
  10071. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  10072. {
  10073. fnamePWithNoPath[j]='\0';
  10074. }
  10075. }
  10076. FILE* fp1 = fopen(fnamePlusPath, "r");
  10077. if (fp1)
  10078. {
  10079. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  10080. // file exists
  10081. fclose(fp1);
  10082. }
  10083. else
  10084. {
  10085. // file doesn't exist
  10086. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  10087. }
  10088. }
  10089. void* GetLogProcess(void* data)
  10090. {
  10091. pthread_detach(pthread_self());
  10092. mtrace();
  10093. int requestId, retriesInt=0, retryIntervalInt=0;
  10094. char logType[32], remoteLocation[512]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  10095. 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};
  10096. int port=0;
  10097. int isSuccess = FALSE;
  10098. char ftpbuf[200]={0};
  10099. json_object *GetLog;
  10100. DEBUG_INFO("GetGetProcess...\n");
  10101. GetLog = json_tokener_parse(data);
  10102. if(!is_error(GetLog))
  10103. {
  10104. // Required data
  10105. if(json_object_object_get(GetLog, "requestId") != NULL)
  10106. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  10107. if(json_object_object_get(GetLog, "logType") != NULL)
  10108. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  10109. if(json_object_object_get(GetLog, "log") != NULL)
  10110. {
  10111. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  10112. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  10113. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  10114. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  10115. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  10116. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  10117. }
  10118. // Optional data
  10119. if(json_object_object_get(GetLog, "retries") != NULL)
  10120. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  10121. else
  10122. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  10123. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  10124. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  10125. else
  10126. retryIntervalInt = 30;
  10127. }
  10128. json_object_put(GetLog);
  10129. ShmOCPP20Data->GetLog.requestId = requestId;
  10130. //****************location*******************/
  10131. if(strcmp(remoteLocation,"")==0)
  10132. {
  10133. DEBUG_INFO("remoteLocation is <Empty>!\n");
  10134. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10135. goto end;
  10136. }
  10137. memset(protocol, 0, ARRAY_SIZE(protocol));
  10138. memset(user, 0, ARRAY_SIZE(user) );
  10139. memset(password, 0, ARRAY_SIZE(password));
  10140. memset(host, 0, ARRAY_SIZE(host));
  10141. memset(path, 0, ARRAY_SIZE(path));
  10142. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  10143. memset(host1, 0, ARRAY_SIZE(host1));
  10144. memset(path1, 0, ARRAY_SIZE(path1));
  10145. /*location: ftp://user:password@host:port/path*/
  10146. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  10147. if((access(fnamePlusPath,F_OK))!=-1)
  10148. {
  10149. DEBUG_INFO("fnamePlusPath exist.\n");
  10150. }
  10151. else
  10152. {
  10153. DEBUG_INFO("fnamePlusPath not exist!\n");
  10154. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10155. goto end;
  10156. }
  10157. if(strchr(remoteLocation,'@')==NULL)
  10158. {
  10159. sscanf(remoteLocation,
  10160. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  10161. protocol, host, &port, path);
  10162. strcpy(user,"anonymous");
  10163. strcpy(password,"");
  10164. }
  10165. else
  10166. {
  10167. //DEBUG_INFO("pch=%s\n", pch);
  10168. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  10169. protocol, user, password, host, &port, path);
  10170. }
  10171. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
  10172. {
  10173. DEBUG_INFO("protocol is not ftp/http ! \n");
  10174. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10175. goto end;
  10176. }
  10177. if(strncmp(remoteLocation,"http", 4) == 0)
  10178. {
  10179. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  10180. sprintf(ftppath,"/%s", path);
  10181. do
  10182. {
  10183. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  10184. sleep(3);
  10185. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  10186. if(!isSuccess)
  10187. {
  10188. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  10189. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10190. sleep(retryIntervalInt);
  10191. }
  10192. else
  10193. {
  10194. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  10195. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  10196. }
  10197. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt--));
  10198. }
  10199. else
  10200. {
  10201. sscanf(host,"%[^/]%s",host1, path1);
  10202. sprintf(ftppath,"%s", path1);
  10203. int ftppathlen=strlen(ftppath);
  10204. int i=1;
  10205. char filenametemp[50];
  10206. while(i < ftppathlen)
  10207. {
  10208. int len=ftppathlen-i;
  10209. if(ftppath[len]== 47) // '/' ascll code: 47
  10210. {
  10211. DEBUG_INFO("find '/' all right\n");
  10212. break;
  10213. }
  10214. i=i+1;
  10215. }
  10216. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  10217. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  10218. filenametemp[i+1] = 0;
  10219. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  10220. if(port == 0)
  10221. port = 21;
  10222. do
  10223. {
  10224. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  10225. sleep(3);
  10226. isSuccess = ftpUploadFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  10227. if(!isSuccess)
  10228. {
  10229. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  10230. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  10231. sleep(retryIntervalInt);
  10232. }
  10233. else
  10234. {
  10235. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  10236. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  10237. }
  10238. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  10239. }
  10240. end:
  10241. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  10242. pthread_exit(NULL);
  10243. }
  10244. int handleGetLogRequest(char *uuid, char *payload)
  10245. {
  10246. mtrace();
  10247. int result = FAIL;
  10248. char cmdBuf[512];
  10249. char fName[258];
  10250. time_t CurrentTime;
  10251. struct tm *tm;
  10252. pthread_t th_Status;
  10253. CurrentTime = time(NULL);
  10254. tm = localtime(&CurrentTime);
  10255. 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);
  10256. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  10257. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  10258. sendGetLogConfirmation(uuid);
  10259. system("exec /root/logPackTools 'log' 6");
  10260. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", fName);
  10261. system(cmdBuf);
  10262. checkUploadLog();
  10263. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  10264. return result;
  10265. }
  10266. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  10267. {
  10268. mtrace();
  10269. int result = FAIL;
  10270. json_object *GetMonitoringReport;
  10271. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  10272. GetMonitoringReport = json_tokener_parse(payload);
  10273. if(!is_error(GetMonitoringReport))
  10274. {
  10275. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  10276. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  10277. // Required data
  10278. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  10279. {
  10280. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  10281. }
  10282. // Optional data
  10283. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  10284. {
  10285. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  10286. }
  10287. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  10288. {
  10289. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  10290. {
  10291. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  10292. {
  10293. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  10294. {
  10295. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  10296. {
  10297. 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")));
  10298. }
  10299. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10300. {
  10301. 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")));
  10302. }
  10303. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10304. {
  10305. 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)
  10306. {
  10307. 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"));
  10308. }
  10309. 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)
  10310. {
  10311. 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"));
  10312. }
  10313. }
  10314. }
  10315. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  10316. {
  10317. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10318. {
  10319. 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")));
  10320. }
  10321. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10322. {
  10323. 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")));
  10324. }
  10325. }
  10326. }
  10327. }
  10328. }
  10329. }
  10330. json_object_put(GetMonitoringReport);
  10331. /*
  10332. * TODO:
  10333. * 1. Response result
  10334. */
  10335. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10336. sendGetMonitoringReportConfirmation(uuid);
  10337. return result;
  10338. }
  10339. int handleGetReportRequest(char *uuid, char *payload)
  10340. {
  10341. mtrace();
  10342. int result = FAIL;
  10343. json_object *GetReport;
  10344. DEBUG_INFO("handleGetReportRequest...\n");
  10345. GetReport = json_tokener_parse(payload);
  10346. if(!is_error(GetReport))
  10347. {
  10348. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  10349. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  10350. // Required data
  10351. if(json_object_object_get(GetReport, "requestId") != NULL)
  10352. {
  10353. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  10354. }
  10355. // Optional data
  10356. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  10357. {
  10358. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  10359. }
  10360. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  10361. {
  10362. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  10363. {
  10364. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  10365. {
  10366. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  10367. {
  10368. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  10369. {
  10370. 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")));
  10371. }
  10372. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10373. {
  10374. 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")));
  10375. }
  10376. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10377. {
  10378. 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)
  10379. {
  10380. 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"));
  10381. }
  10382. 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)
  10383. {
  10384. 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"));
  10385. }
  10386. }
  10387. }
  10388. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  10389. {
  10390. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10391. {
  10392. 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")));
  10393. }
  10394. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10395. {
  10396. 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")));
  10397. }
  10398. }
  10399. }
  10400. }
  10401. }
  10402. }
  10403. json_object_put(GetReport);
  10404. /*
  10405. * TODO:
  10406. * 1. Response result
  10407. */
  10408. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10409. sendGetReportConfirmation(uuid);
  10410. return result;
  10411. }
  10412. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  10413. {
  10414. mtrace();
  10415. int result = FAIL;
  10416. int8_t gun_index = -1;
  10417. json_object *GetTransactionStatus;
  10418. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  10419. GetTransactionStatus = json_tokener_parse(payload);
  10420. if(!is_error(GetTransactionStatus))
  10421. {
  10422. /*
  10423. * TODO:
  10424. * 1. Check transaction locate which connector
  10425. */
  10426. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  10427. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  10428. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  10429. {
  10430. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  10431. }
  10432. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  10433. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  10434. }
  10435. json_object_put(GetTransactionStatus);
  10436. sendGetTransactionStatusConfirmation(uuid, gun_index);
  10437. return result;
  10438. }
  10439. int handleGetVariablesRequest(char *uuid, char *payload)
  10440. {
  10441. mtrace();
  10442. int result = FAIL;
  10443. json_object *GetVariables;
  10444. DEBUG_INFO("handleGetVariablesRequest...\n");
  10445. GetVariables = json_tokener_parse(payload);
  10446. if(!is_error(GetVariables))
  10447. {
  10448. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  10449. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  10450. // Required data
  10451. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  10452. {
  10453. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  10454. {
  10455. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  10456. {
  10457. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  10458. {
  10459. 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")));
  10460. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  10461. }
  10462. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  10463. {
  10464. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  10465. {
  10466. 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")));
  10467. }
  10468. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  10469. {
  10470. 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")));
  10471. }
  10472. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  10473. {
  10474. 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)
  10475. {
  10476. 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"));
  10477. }
  10478. 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)
  10479. {
  10480. 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"));
  10481. }
  10482. }
  10483. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  10484. }
  10485. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  10486. {
  10487. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  10488. {
  10489. 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")));
  10490. }
  10491. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  10492. {
  10493. 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")));
  10494. }
  10495. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  10496. }
  10497. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  10498. {
  10499. if((strstr((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) != NULL) &&
  10500. (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) &&
  10501. (strstr((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) != NULL) &&
  10502. (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))
  10503. {
  10504. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  10505. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type);
  10506. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  10507. }
  10508. else
  10509. {
  10510. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  10511. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  10512. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  10513. }
  10514. }
  10515. }
  10516. }
  10517. }
  10518. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  10519. }
  10520. json_object_put(GetVariables);
  10521. return result;
  10522. }
  10523. int handleInstallCertificateRequest(char *uuid, char *payload)
  10524. {
  10525. mtrace();
  10526. int result = FAIL;
  10527. json_object *InstallCertificate;
  10528. DEBUG_INFO("handleInstallCertificateRequest...\n");
  10529. InstallCertificate = json_tokener_parse(payload);
  10530. if(!is_error(InstallCertificate))
  10531. {
  10532. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  10533. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  10534. // Required data
  10535. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  10536. {
  10537. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  10538. }
  10539. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  10540. {
  10541. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  10542. }
  10543. }
  10544. json_object_put(InstallCertificate);
  10545. /*
  10546. * TODO:
  10547. * 1. Install certification preocess and response
  10548. */
  10549. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10550. sendInstallCertificateConfirmation(uuid);
  10551. return result;
  10552. }
  10553. int handlePublishFirmwareRequest(char *uuid, char *payload)
  10554. {
  10555. mtrace();
  10556. int result = FAIL;
  10557. json_object *PublishFirmware;
  10558. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  10559. PublishFirmware = json_tokener_parse(payload);
  10560. if(!is_error(PublishFirmware))
  10561. {
  10562. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  10563. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  10564. // Required data
  10565. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  10566. {
  10567. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  10568. }
  10569. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  10570. {
  10571. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  10572. }
  10573. // Optional data
  10574. if(json_object_object_get(PublishFirmware, "location") != NULL)
  10575. {
  10576. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  10577. }
  10578. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  10579. {
  10580. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  10581. }
  10582. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  10583. {
  10584. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  10585. }
  10586. }
  10587. json_object_put(PublishFirmware);
  10588. /*
  10589. * TODO:
  10590. * 1. Publish firmware preocess and response
  10591. */
  10592. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10593. sendPublishFirmwareConfirmation(uuid);
  10594. return result;
  10595. }
  10596. int handleRemoteStartTransactionRequest(char *uuid, char *payload)
  10597. {
  10598. mtrace();
  10599. int result = FAIL;
  10600. int8_t gun_index = -1;
  10601. uint8_t isPeriodOverMax = FALSE;
  10602. uint8_t isProfileOverMax = FALSE;
  10603. uint8_t isConnectorMismatch = FALSE;
  10604. uint8_t isTxProfile = FALSE;
  10605. uint8_t existProfileQuantity = 0;
  10606. uint8_t filename[128]={0};
  10607. uint8_t word[2048]={0};
  10608. FILE *filePtr;
  10609. json_object *RemoteStartTransaction;
  10610. DEBUG_INFO("handleRemoteStartTransactionRequest...\n");
  10611. RemoteStartTransaction = json_tokener_parse(payload);
  10612. if(!is_error(RemoteStartTransaction))
  10613. {
  10614. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  10615. {
  10616. gun_index = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
  10617. }
  10618. else
  10619. {
  10620. /*
  10621. * TODO:
  10622. * 1. Selected connector process
  10623. */
  10624. gun_index = 0;
  10625. }
  10626. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  10627. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  10628. // Required data
  10629. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  10630. {
  10631. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  10632. }
  10633. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  10634. {
  10635. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  10636. {
  10637. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  10638. }
  10639. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  10640. {
  10641. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  10642. }
  10643. }
  10644. // Optional data
  10645. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  10646. {
  10647. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  10648. {
  10649. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  10650. }
  10651. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  10652. {
  10653. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  10654. }
  10655. }
  10656. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  10657. {
  10658. // Check periods is over max configuration
  10659. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  10660. {
  10661. isPeriodOverMax = TRUE;
  10662. }
  10663. // Check periods is over max configuration
  10664. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  10665. {
  10666. if(gun_index > 0)
  10667. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  10668. else
  10669. isConnectorMismatch = TRUE;
  10670. if(!isConnectorMismatch)
  10671. {
  10672. filePtr = fopen((char*)filename, "r");
  10673. if (!filePtr)
  10674. {
  10675. DEBUG_INFO("%s not exist, create it.\n", filename);
  10676. filePtr = fopen((char*)filename, "w+");
  10677. }
  10678. else
  10679. {
  10680. //Check Charging Profile Count
  10681. while(fscanf(filePtr, "%s", word) != EOF)
  10682. {
  10683. //DEBUG_INFO("word=%s\n",word);
  10684. if(strstr((char*)word, "chargingProfileId")!= NULL)
  10685. {
  10686. existProfileQuantity += 1;
  10687. }
  10688. }
  10689. }
  10690. fclose(filePtr);
  10691. }
  10692. }
  10693. else
  10694. {
  10695. }
  10696. if(existProfileQuantity > 3)
  10697. isProfileOverMax = TRUE;
  10698. }
  10699. // Profile replace or add info
  10700. if((gun_index > 0) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTxProfile)
  10701. {
  10702. FILE *infile;
  10703. FILE *outfile;
  10704. char tmpProfileName[32];
  10705. char rmFileCmd[128];
  10706. char tempchargingProfilePurposeStr[30]={0};
  10707. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  10708. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfileRemote");
  10709. infile = fopen ((char*)filename, "r");
  10710. outfile = fopen ((char*)tmpProfileName, "w");
  10711. int d = fgetc(infile);
  10712. rewind(infile);
  10713. if(d == EOF)
  10714. {
  10715. // Profile is empty
  10716. fprintf(outfile,"%s\n", payload);
  10717. fclose(infile);
  10718. fclose(outfile);
  10719. sprintf(rmFileCmd,"rm -f %s",filename);
  10720. system(rmFileCmd);
  10721. rename((char*)tmpProfileName, (char*)filename);
  10722. }
  10723. else
  10724. {
  10725. // Profile is not empty
  10726. char buf[2048]={0};
  10727. int ChargingProfileAdded = FALSE;
  10728. while (fgets(buf, sizeof(buf), infile) != NULL)
  10729. {
  10730. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  10731. json_object *tmpChargingProfile;
  10732. tmpChargingProfile = json_tokener_parse(buf);
  10733. if(!is_error(tmpChargingProfile))
  10734. {
  10735. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  10736. {
  10737. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  10738. }
  10739. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  10740. {
  10741. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  10742. {
  10743. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  10744. }
  10745. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  10746. {
  10747. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  10748. }
  10749. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  10750. {
  10751. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  10752. }
  10753. }
  10754. }
  10755. json_object_put(tmpChargingProfile);
  10756. if((tempconnectorIdInt == gun_index) &&
  10757. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId"))))
  10758. {
  10759. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel"))) &&
  10760. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  10761. {
  10762. if(ChargingProfileAdded == FALSE)
  10763. {
  10764. fprintf(outfile,"%s\n",payload);
  10765. ChargingProfileAdded = TRUE;
  10766. }
  10767. }
  10768. else
  10769. {
  10770. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10771. {
  10772. if(ChargingProfileAdded == FALSE)
  10773. {
  10774. fprintf(outfile,"%s\n",buf);
  10775. fprintf(outfile,"%s\n",payload);
  10776. ChargingProfileAdded = TRUE;
  10777. }
  10778. else
  10779. {
  10780. fprintf(outfile,"%s\n",buf);
  10781. }
  10782. }
  10783. else
  10784. {
  10785. if(ChargingProfileAdded == FALSE)
  10786. {
  10787. fprintf(outfile,"%s\n",buf);
  10788. fprintf(outfile,"%s\n",payload);
  10789. ChargingProfileAdded = TRUE;
  10790. }
  10791. else
  10792. {
  10793. fprintf(outfile,"%s\n",buf);
  10794. }
  10795. }
  10796. }
  10797. }
  10798. else
  10799. {
  10800. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId")))
  10801. {
  10802. if(ChargingProfileAdded == FALSE)
  10803. {
  10804. fprintf(outfile,"%s\n",buf);
  10805. fprintf(outfile,"%s\n",payload);
  10806. ChargingProfileAdded = TRUE;
  10807. }
  10808. else
  10809. {
  10810. fprintf(outfile,"%s\n",buf);
  10811. }
  10812. }
  10813. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10814. {
  10815. if(ChargingProfileAdded == FALSE)
  10816. {
  10817. fprintf(outfile,"%s\n",buf);
  10818. fprintf(outfile,"%s\n",payload);
  10819. ChargingProfileAdded = TRUE;
  10820. }
  10821. else
  10822. {
  10823. fprintf(outfile,"%s\n",buf);
  10824. }
  10825. }
  10826. else
  10827. {
  10828. if(ChargingProfileAdded == FALSE)
  10829. {
  10830. fprintf(outfile,"%s\n",buf);
  10831. fprintf(outfile,"%s\n",payload);
  10832. ChargingProfileAdded = TRUE;
  10833. }
  10834. else
  10835. {
  10836. fprintf(outfile,"%s\n",buf);
  10837. }
  10838. }
  10839. }
  10840. } // end of while loop
  10841. fclose(infile);
  10842. fclose(outfile);
  10843. sprintf(rmFileCmd,"rm -f %s",filename);
  10844. system(rmFileCmd);
  10845. rename((char*)tmpProfileName, (char*)filename);
  10846. }
  10847. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted] );
  10848. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_transactionId);
  10849. result = PASS;
  10850. }
  10851. else
  10852. {
  10853. if(gun_index <= 0)
  10854. DEBUG_WARN("Connector id is wrong.\n");
  10855. if(isConnectorMismatch)
  10856. DEBUG_WARN("Connector id is mismatch.\n");
  10857. if(isPeriodOverMax)
  10858. DEBUG_WARN("Profile periods quantity is over spec.\n");
  10859. if(isProfileOverMax)
  10860. DEBUG_WARN("Profile quantity is over spec.\n");
  10861. if(!isTxProfile)
  10862. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  10863. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  10864. }
  10865. }
  10866. json_object_put(RemoteStartTransaction);
  10867. sendRemoteStartTransactionConfirmation(uuid, gun_index);
  10868. return result;
  10869. }
  10870. int handleRemoteStopTransactionRequest(char *uuid, char *payload)
  10871. {
  10872. mtrace();
  10873. int result = FAIL;
  10874. int match = FALSE;
  10875. int GunNO = 0;
  10876. int tempIndex = 0;
  10877. char transactionIdStr[37];
  10878. int transactionIdIsNULL= TRUE;
  10879. json_object *RemoteStopTransaction;
  10880. DEBUG_INFO("handleRemoteStopTransactionRequest...\n");
  10881. if(server_pending == TRUE)
  10882. {
  10883. return 0;
  10884. }
  10885. RemoteStopTransaction = json_tokener_parse(payload);
  10886. if(!is_error(RemoteStopTransaction))
  10887. {
  10888. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  10889. {
  10890. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  10891. transactionIdIsNULL = FALSE;
  10892. }
  10893. }
  10894. json_object_put(RemoteStopTransaction);
  10895. if(transactionIdIsNULL == FALSE)
  10896. {
  10897. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  10898. {
  10899. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  10900. {
  10901. //check Transaction active
  10902. if(gunType[gun_index] == 'J')
  10903. {
  10904. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10905. {
  10906. tempIndex = ((gun_index==2) ? 1: 0);
  10907. }
  10908. else
  10909. {
  10910. tempIndex = gun_index;
  10911. }
  10912. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10913. {
  10914. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  10915. {
  10916. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10917. {
  10918. match = TRUE;
  10919. GunNO = gun_index;
  10920. }
  10921. }
  10922. }// END FOR CHAdeMO_QUANTITY
  10923. }
  10924. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  10925. {
  10926. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10927. {
  10928. tempIndex = ((gun_index==2) ? 1: 0);
  10929. }
  10930. else
  10931. {
  10932. tempIndex = gun_index;
  10933. }
  10934. for (int index = 0; index < CCS_QUANTITY; index++)
  10935. {
  10936. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  10937. {
  10938. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10939. {
  10940. match = TRUE;
  10941. GunNO = gun_index;
  10942. }
  10943. }
  10944. }// END FOR CCS_QUANTITY
  10945. }
  10946. else if(gunType[gun_index] == 'G')
  10947. {
  10948. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10949. {
  10950. tempIndex = ((gun_index==2) ? 1: 0);
  10951. }
  10952. else
  10953. {
  10954. tempIndex = gun_index;
  10955. }
  10956. for (int index = 0; index < GB_QUANTITY; index++)
  10957. {
  10958. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  10959. {
  10960. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10961. {
  10962. match = TRUE;
  10963. GunNO = gun_index;
  10964. }
  10965. }
  10966. }// END FOR GB_QUANTITY
  10967. }
  10968. else if(gunType[gun_index] == 'O')
  10969. {
  10970. tempIndex = gun_index;
  10971. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10972. {
  10973. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  10974. {
  10975. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10976. {
  10977. match = TRUE;
  10978. GunNO = gun_index;
  10979. }
  10980. }
  10981. }// END FOR GB_QUANTITY
  10982. }
  10983. else
  10984. {
  10985. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10986. {
  10987. tempIndex = 2;
  10988. }
  10989. else
  10990. {
  10991. tempIndex = gun_index;
  10992. }
  10993. for (int index = 0; index < AC_QUANTITY; index++)
  10994. {
  10995. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  10996. {
  10997. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10998. {
  10999. match = TRUE;
  11000. GunNO = gun_index;
  11001. }
  11002. }
  11003. }// END FOR CHAdeMO_QUANTITY
  11004. } // END FOR AC ELSE
  11005. }// CHECK IF ResponseTransactionId == transactionIdInt
  11006. }//END FOR
  11007. if( match == TRUE)
  11008. {
  11009. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  11010. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  11011. }
  11012. else
  11013. {
  11014. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  11015. }
  11016. }
  11017. else
  11018. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  11019. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  11020. return result;
  11021. }
  11022. int handleReserveNowRequest(char *uuid, char *payload)
  11023. {
  11024. mtrace();
  11025. int result = FAIL;
  11026. int connectorIdInt=0, reservationIdInt=0;
  11027. int tempIndex = 0;
  11028. json_object *ReserveNow;
  11029. DEBUG_INFO("handleReserveNowRequest ...\n");
  11030. ReserveNow = json_tokener_parse(payload);
  11031. if(!is_error(ReserveNow))
  11032. {
  11033. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  11034. {
  11035. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  11036. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  11037. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  11038. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  11039. }
  11040. // Required data
  11041. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  11042. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  11043. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  11044. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  11045. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  11046. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  11047. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  11048. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  11049. // Optional data
  11050. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  11051. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  11052. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  11053. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  11054. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  11055. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  11056. result = PASS;
  11057. }
  11058. json_object_put(ReserveNow);
  11059. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11060. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  11061. {
  11062. //check Transaction active
  11063. if(gunType[connectorIdInt -1] == 'J')
  11064. {
  11065. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11066. {
  11067. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11068. }
  11069. else
  11070. {
  11071. tempIndex = connectorIdInt -1;
  11072. }
  11073. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11074. {
  11075. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  11076. {
  11077. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  11078. {
  11079. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  11080. {
  11081. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11082. {
  11083. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11084. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11085. }
  11086. 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'))
  11087. {
  11088. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11089. }
  11090. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11091. {
  11092. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11093. }
  11094. else
  11095. {
  11096. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11097. }
  11098. }
  11099. 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
  11100. {
  11101. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11102. }
  11103. }
  11104. else
  11105. {
  11106. //replace reservation
  11107. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11108. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11109. }
  11110. }
  11111. } // END FOR CHAdeMO_QUANTITY
  11112. }
  11113. else if((gunType[connectorIdInt -1] == 'U')||(gunType[connectorIdInt -1] == 'E'))
  11114. {
  11115. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11116. {
  11117. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11118. }
  11119. else
  11120. {
  11121. tempIndex = connectorIdInt -1;
  11122. }
  11123. for (int index = 0; index < CCS_QUANTITY; index++)
  11124. {
  11125. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  11126. {
  11127. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  11128. {
  11129. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11130. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  11131. {
  11132. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11133. {
  11134. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11135. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11136. }
  11137. 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'))
  11138. {
  11139. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11140. }
  11141. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  11142. {
  11143. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11144. }
  11145. else
  11146. {
  11147. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11148. }
  11149. }
  11150. 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
  11151. {
  11152. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11153. }
  11154. }
  11155. else
  11156. {
  11157. //replace reservation
  11158. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11159. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11160. }
  11161. }
  11162. } // END FOR CCS_QUANTITY
  11163. }
  11164. else if(gunType[connectorIdInt -1] == 'G')
  11165. {
  11166. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  11167. {
  11168. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  11169. }
  11170. else
  11171. {
  11172. tempIndex = connectorIdInt -1;
  11173. }
  11174. for (int index = 0; index < GB_QUANTITY; index++)
  11175. {
  11176. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  11177. {
  11178. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  11179. {
  11180. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  11181. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11182. {
  11183. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11184. {
  11185. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11186. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11187. }
  11188. 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'))
  11189. {
  11190. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11191. }
  11192. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11193. {
  11194. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11195. }
  11196. else
  11197. {
  11198. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11199. }
  11200. }
  11201. 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
  11202. {
  11203. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11204. }
  11205. }
  11206. else
  11207. {
  11208. //replace reservation
  11209. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11210. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11211. }
  11212. }
  11213. }// END FOR GB_QUANTITY
  11214. }
  11215. else
  11216. {
  11217. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  11218. {
  11219. tempIndex = 2;
  11220. }
  11221. else
  11222. {
  11223. tempIndex = (connectorIdInt -1);
  11224. }
  11225. for (int index = 0; index < AC_QUANTITY; index++)
  11226. {
  11227. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  11228. {
  11229. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11230. {
  11231. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  11232. {
  11233. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11234. {
  11235. 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))
  11236. {
  11237. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11238. }
  11239. else
  11240. {
  11241. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11242. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11243. }
  11244. }
  11245. 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'))
  11246. {
  11247. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11248. }
  11249. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  11250. {
  11251. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11252. }
  11253. else
  11254. {
  11255. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11256. }
  11257. }
  11258. 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
  11259. {
  11260. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11261. }
  11262. }
  11263. else
  11264. {
  11265. //replace reservation
  11266. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  11267. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11268. }
  11269. }
  11270. } // END FOR AC_QUANTITY
  11271. }
  11272. }
  11273. else if(connectorIdInt == 0)
  11274. {
  11275. //check Transaction active
  11276. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11277. {
  11278. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  11279. {
  11280. 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'))
  11281. {
  11282. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11283. goto end;
  11284. }
  11285. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11286. {
  11287. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11288. goto end;
  11289. }
  11290. 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
  11291. {
  11292. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11293. goto end;
  11294. }
  11295. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11296. {
  11297. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11298. goto end;
  11299. }
  11300. }
  11301. }// END FOR CHAdeMO_QUANTITY
  11302. for (int index = 0; index < CCS_QUANTITY; index++)
  11303. {
  11304. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  11305. {
  11306. 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'))
  11307. {
  11308. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11309. goto end;
  11310. }
  11311. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  11312. {
  11313. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11314. goto end;
  11315. }
  11316. 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
  11317. {
  11318. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11319. goto end;
  11320. }
  11321. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11322. {
  11323. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11324. goto end;
  11325. }
  11326. }
  11327. } // END FOR CCS_QUANTITY
  11328. for (int index = 0; index < GB_QUANTITY; index++)
  11329. {
  11330. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  11331. {
  11332. 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'))
  11333. {
  11334. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11335. goto end;
  11336. }
  11337. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11338. {
  11339. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11340. goto end;
  11341. }
  11342. 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
  11343. {
  11344. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11345. goto end;
  11346. }
  11347. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11348. {
  11349. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11350. goto end;
  11351. }
  11352. }
  11353. } // END FOR GB_QUANTITY
  11354. for (int index = 0; index < AC_QUANTITY; index++)
  11355. {
  11356. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11357. {
  11358. 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'))
  11359. {
  11360. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11361. goto end;
  11362. }
  11363. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11364. {
  11365. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11366. goto end;
  11367. }
  11368. 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
  11369. {
  11370. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11371. goto end;
  11372. }
  11373. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11374. {
  11375. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_B) ||(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_C) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState == CP_STATE_D))
  11376. {
  11377. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11378. goto end;
  11379. }
  11380. }
  11381. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11382. {
  11383. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11384. goto end;
  11385. }
  11386. }
  11387. }// END FOR AC_QUANTITY
  11388. //The connectorId is 0
  11389. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  11390. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11391. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  11392. result = TRUE;
  11393. return result;
  11394. }
  11395. else
  11396. {
  11397. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11398. }
  11399. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReserveNowStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  11400. {
  11401. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  11402. result = TRUE;
  11403. return result;
  11404. }
  11405. end:
  11406. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  11407. return result;
  11408. }
  11409. int handleResetRequest(char *uuid, char *payload)
  11410. {
  11411. mtrace();
  11412. int result = FAIL;
  11413. json_object *Reset = json_object_new_object();
  11414. DEBUG_INFO("handleResetRequest...\n");
  11415. Reset = json_tokener_parse(payload);
  11416. if(!is_error(Reset))
  11417. {
  11418. // Required data
  11419. if(json_object_object_get(Reset, "type") != NULL)
  11420. {
  11421. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  11422. }
  11423. if(json_object_object_get(Reset, "evseId") != NULL)
  11424. {
  11425. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  11426. }
  11427. }
  11428. json_object_put(Reset);
  11429. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  11430. {
  11431. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  11432. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  11433. result = TRUE;
  11434. return result;
  11435. }
  11436. else
  11437. {
  11438. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  11439. goto errorend;
  11440. }
  11441. errorend:
  11442. sendResetConfirmation(uuid);
  11443. return result;
  11444. }
  11445. int handleSendLocalListRequest(char *uuid, char *payload)
  11446. {
  11447. mtrace();
  11448. int result = FAIL;
  11449. char updateTypestr[15]={0};
  11450. int checkState_Faulted = FALSE;
  11451. json_object *SendLocalList;
  11452. DEBUG_INFO("handleSendLocalListRequest...\n");
  11453. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  11454. {
  11455. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11456. goto end;
  11457. }
  11458. SendLocalList = json_tokener_parse(payload);
  11459. if(!is_error(SendLocalList))
  11460. {
  11461. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  11462. // Required data
  11463. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  11464. {
  11465. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  11466. }
  11467. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  11468. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  11469. // Optional data
  11470. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  11471. {
  11472. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  11473. {
  11474. // Required data
  11475. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  11476. {
  11477. 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")));
  11478. 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")));
  11479. }
  11480. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  11481. {
  11482. 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")));
  11483. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  11484. 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")));
  11485. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  11486. 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"));
  11487. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  11488. {
  11489. 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")));
  11490. 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")));
  11491. }
  11492. }
  11493. }
  11494. }
  11495. }
  11496. json_object_put(SendLocalList);
  11497. //check Charge Point state
  11498. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11499. {
  11500. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11501. {
  11502. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11503. }
  11504. }
  11505. for (int index = 0; index < CCS_QUANTITY; index++)
  11506. {
  11507. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11508. {
  11509. checkState_Faulted = TRUE; //OCPP Status
  11510. }
  11511. }
  11512. for (int index = 0; index < GB_QUANTITY; index++)
  11513. {
  11514. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11515. {
  11516. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11517. }
  11518. }
  11519. for (int index = 0; index < AC_QUANTITY; index++)
  11520. {
  11521. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11522. {
  11523. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11524. }
  11525. }
  11526. if(checkState_Faulted == TRUE)
  11527. {
  11528. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11529. goto end;
  11530. }
  11531. // Check update type
  11532. if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  11533. {
  11534. //Local list full update
  11535. DEBUG_INFO("Local list full update.\n");
  11536. DB_getListVerion();
  11537. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11538. {
  11539. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11540. goto end;
  11541. }
  11542. DB_cleanLocalList();
  11543. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11544. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11545. }
  11546. else if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  11547. {
  11548. //Local list different update
  11549. DEBUG_INFO("Local list different update.\n");
  11550. DB_getListVerion();
  11551. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11552. {
  11553. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  11554. goto end;
  11555. }
  11556. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11557. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11558. }
  11559. else
  11560. {
  11561. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11562. goto end;
  11563. }
  11564. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  11565. end:
  11566. sendSendLocalListConfirmation(uuid);
  11567. return result;
  11568. }
  11569. int handleSetChargingProfileRequest(char *uuid, char *payload)
  11570. {
  11571. mtrace();
  11572. int result = FAIL;
  11573. int8_t gun_index = -1;
  11574. uint8_t isPeriodOverMax = FALSE;
  11575. uint8_t isProfileOverMax = FALSE;
  11576. uint8_t isConnectorMismatch = FALSE;
  11577. uint8_t existProfileQuantity = 0;
  11578. uint8_t filename[128]={0};
  11579. uint8_t word[2048]={0};
  11580. FILE *filePtr;
  11581. json_object *SetChargingProfile;
  11582. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  11583. SetChargingProfile = json_tokener_parse(payload);
  11584. if(!is_error(SetChargingProfile))
  11585. {
  11586. // Required data
  11587. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  11588. {
  11589. gun_index = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  11590. }
  11591. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  11592. {
  11593. // Check periods is over max configuration
  11594. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  11595. {
  11596. isPeriodOverMax = TRUE;
  11597. }
  11598. // Check periods is over max configuration
  11599. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  11600. {
  11601. if(gun_index == 0)
  11602. {
  11603. sprintf((char*)filename, ChargePointMaxProfile_JSON);
  11604. filePtr = fopen((char*)filename, "r");
  11605. if (!filePtr)
  11606. {
  11607. DEBUG_INFO("%s not exist, create it.\n", ChargePointMaxProfile_JSON);
  11608. filePtr = fopen((char*)filename, "w+");
  11609. }
  11610. else
  11611. {
  11612. //Check Charging Profile Count
  11613. while(fscanf(filePtr, "%s", word) != EOF)
  11614. {
  11615. //DEBUG_INFO("word=%s\n",word);
  11616. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11617. {
  11618. existProfileQuantity += 1;
  11619. }
  11620. }
  11621. }
  11622. fclose(filePtr);
  11623. }
  11624. else
  11625. isConnectorMismatch = TRUE;
  11626. }
  11627. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  11628. {
  11629. if(gun_index < 5)
  11630. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", gun_index);
  11631. else
  11632. isConnectorMismatch = TRUE;
  11633. if(!isConnectorMismatch)
  11634. {
  11635. filePtr = fopen((char*)filename, "r");
  11636. if (!filePtr)
  11637. {
  11638. DEBUG_INFO("%s not exist, create it.\n", filename);
  11639. filePtr = fopen((char*)filename, "w+");
  11640. }
  11641. else
  11642. {
  11643. //Check Charging Profile Count
  11644. while(fscanf(filePtr, "%s", word) != EOF)
  11645. {
  11646. //DEBUG_INFO("word=%s\n",word);
  11647. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11648. {
  11649. existProfileQuantity += 1;
  11650. }
  11651. }
  11652. }
  11653. fclose(filePtr);
  11654. }
  11655. }
  11656. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  11657. {
  11658. if(gun_index>0)
  11659. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  11660. else
  11661. isConnectorMismatch = TRUE;
  11662. if(!isConnectorMismatch)
  11663. {
  11664. filePtr = fopen((char*)filename, "r");
  11665. if (!filePtr)
  11666. {
  11667. DEBUG_INFO("%s not exist, create it.\n", filename);
  11668. filePtr = fopen((char*)filename, "w+");
  11669. }
  11670. else
  11671. {
  11672. //Check Charging Profile Count
  11673. while(fscanf(filePtr, "%s", word) != EOF)
  11674. {
  11675. //DEBUG_INFO("word=%s\n",word);
  11676. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11677. {
  11678. existProfileQuantity += 1;
  11679. }
  11680. }
  11681. }
  11682. fclose(filePtr);
  11683. }
  11684. }
  11685. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  11686. {
  11687. }
  11688. else
  11689. {
  11690. }
  11691. if(existProfileQuantity > 3)
  11692. isProfileOverMax = TRUE;
  11693. }
  11694. // Profile replace or add info
  11695. if((gun_index > -1) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch)
  11696. {
  11697. FILE *infile;
  11698. FILE *outfile;
  11699. char tmpProfileName[32];
  11700. char rmFileCmd[128];
  11701. char tempchargingProfilePurposeStr[30]={0};
  11702. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  11703. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfile");
  11704. infile = fopen ((char*)filename, "r");
  11705. outfile = fopen ((char*)tmpProfileName, "w");
  11706. int d = fgetc(infile);
  11707. rewind(infile);
  11708. if(d == EOF)
  11709. {
  11710. // Profile is empty
  11711. fprintf(outfile,"%s\n", payload);
  11712. fclose(infile);
  11713. fclose(outfile);
  11714. sprintf(rmFileCmd,"rm -f %s",filename);
  11715. system(rmFileCmd);
  11716. rename((char*)tmpProfileName, (char*)filename);
  11717. }
  11718. else
  11719. {
  11720. // Profile is not empty
  11721. char buf[2048]={0};
  11722. int ChargingProfileAdded = FALSE;
  11723. while (fgets(buf, sizeof(buf), infile) != NULL)
  11724. {
  11725. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  11726. json_object *tmpChargingProfile;
  11727. tmpChargingProfile = json_tokener_parse(buf);
  11728. if(!is_error(tmpChargingProfile))
  11729. {
  11730. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  11731. {
  11732. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  11733. }
  11734. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  11735. {
  11736. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  11737. {
  11738. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  11739. }
  11740. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  11741. {
  11742. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  11743. }
  11744. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  11745. {
  11746. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  11747. }
  11748. }
  11749. }
  11750. json_object_put(tmpChargingProfile);
  11751. if((tempconnectorIdInt == gun_index) &&
  11752. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId"))))
  11753. {
  11754. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel"))) &&
  11755. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  11756. {
  11757. //DEBUG_INFO("update set chargingProfile to file -0\n");
  11758. if(ChargingProfileAdded == FALSE)
  11759. {
  11760. fprintf(outfile,"%s\n",payload);
  11761. ChargingProfileAdded = TRUE;
  11762. }
  11763. }
  11764. else
  11765. {
  11766. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11767. {
  11768. if(ChargingProfileAdded == FALSE)
  11769. {
  11770. fprintf(outfile,"%s\n",buf);
  11771. fprintf(outfile,"%s\n",payload);
  11772. ChargingProfileAdded = TRUE;
  11773. }
  11774. else
  11775. {
  11776. fprintf(outfile,"%s\n",buf);
  11777. }
  11778. }
  11779. else
  11780. {
  11781. if(ChargingProfileAdded == FALSE)
  11782. {
  11783. fprintf(outfile,"%s\n",buf);
  11784. fprintf(outfile,"%s\n",payload);
  11785. ChargingProfileAdded = TRUE;
  11786. }
  11787. else
  11788. {
  11789. fprintf(outfile,"%s\n",buf);
  11790. }
  11791. }
  11792. }
  11793. }
  11794. else
  11795. {
  11796. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId")))
  11797. {
  11798. if(ChargingProfileAdded == FALSE)
  11799. {
  11800. fprintf(outfile,"%s\n",buf);
  11801. fprintf(outfile,"%s\n",payload);
  11802. ChargingProfileAdded = TRUE;
  11803. }
  11804. else
  11805. {
  11806. fprintf(outfile,"%s\n",buf);
  11807. }
  11808. }
  11809. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11810. {
  11811. if(ChargingProfileAdded == FALSE)
  11812. {
  11813. fprintf(outfile,"%s\n",buf);
  11814. fprintf(outfile,"%s\n",payload);
  11815. ChargingProfileAdded = TRUE;
  11816. }
  11817. else
  11818. {
  11819. fprintf(outfile,"%s\n",buf);
  11820. }
  11821. }
  11822. else
  11823. {
  11824. if(ChargingProfileAdded == FALSE)
  11825. {
  11826. fprintf(outfile,"%s\n",buf);
  11827. fprintf(outfile,"%s\n",payload);
  11828. ChargingProfileAdded = TRUE;
  11829. }
  11830. else
  11831. {
  11832. fprintf(outfile,"%s\n",buf);
  11833. }
  11834. }
  11835. }
  11836. } // end of while loop
  11837. fclose(infile);
  11838. fclose(outfile);
  11839. sprintf(rmFileCmd,"rm -f %s",filename);
  11840. system(rmFileCmd);
  11841. rename((char*)tmpProfileName, (char*)filename);
  11842. }
  11843. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  11844. result = PASS;
  11845. }
  11846. else
  11847. {
  11848. if(gun_index == -1)
  11849. DEBUG_WARN("Connector id is wrong.\n");
  11850. if(isConnectorMismatch)
  11851. DEBUG_WARN("Connector id is mismatch.\n");
  11852. if(isPeriodOverMax)
  11853. DEBUG_WARN("Profile periods quantity is over spec.\n");
  11854. if(isProfileOverMax)
  11855. DEBUG_WARN("Profile quantity is over spec.\n");
  11856. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  11857. }
  11858. }
  11859. json_object_put(SetChargingProfile);
  11860. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  11861. {
  11862. if(gun_index == 0)
  11863. {
  11864. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  11865. {
  11866. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  11867. }
  11868. }
  11869. else
  11870. checkCompositeSchedule(gun_index, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index-1]);
  11871. }
  11872. sendSetChargingProfileConfirmation(uuid, (gun_index==0?gun_index:gun_index-1));
  11873. return result;
  11874. }
  11875. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  11876. {
  11877. mtrace();
  11878. int result = FAIL;
  11879. json_object *SetDisplayMessage;
  11880. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  11881. SetDisplayMessage = json_tokener_parse(payload);
  11882. if(!is_error(SetDisplayMessage))
  11883. {
  11884. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  11885. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  11886. // Required data
  11887. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  11888. {
  11889. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  11890. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  11891. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  11892. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  11893. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  11894. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  11895. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  11896. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  11897. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  11898. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  11899. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  11900. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  11901. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  11902. {
  11903. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  11904. 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")));
  11905. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  11906. 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")));
  11907. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  11908. 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")));
  11909. }
  11910. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  11911. {
  11912. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  11913. 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")));
  11914. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  11915. 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")));
  11916. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  11917. {
  11918. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  11919. 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"));
  11920. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  11921. 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"));
  11922. }
  11923. }
  11924. }
  11925. }
  11926. json_object_put(SetDisplayMessage);
  11927. /*
  11928. * TODO:
  11929. * 1. Configure display message and response
  11930. */
  11931. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  11932. sendSetMonitoringBaseConfirmation(uuid);
  11933. return result;
  11934. }
  11935. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  11936. {
  11937. mtrace();
  11938. int result = FAIL;
  11939. json_object *SetMonitoringBase;
  11940. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  11941. SetMonitoringBase = json_tokener_parse(payload);
  11942. if(!is_error(SetMonitoringBase))
  11943. {
  11944. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  11945. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  11946. // Required data
  11947. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  11948. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  11949. }
  11950. json_object_put(SetMonitoringBase);
  11951. /*
  11952. * TODO:
  11953. * 1. Configure monitor base and response
  11954. */
  11955. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  11956. sendSetMonitoringBaseConfirmation(uuid);
  11957. return result;
  11958. }
  11959. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  11960. {
  11961. mtrace();
  11962. int result = FAIL;
  11963. json_object *SetMonitoringLevel;
  11964. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  11965. SetMonitoringLevel = json_tokener_parse(payload);
  11966. if(!is_error(SetMonitoringLevel))
  11967. {
  11968. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  11969. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  11970. // Required data
  11971. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  11972. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  11973. }
  11974. json_object_put(SetMonitoringLevel);
  11975. /*
  11976. * TODO:
  11977. * Configure monitor status and response
  11978. */
  11979. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  11980. sendSetMonitoringLevelConfirmation(uuid);
  11981. return result;
  11982. }
  11983. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  11984. {
  11985. mtrace();
  11986. int result = FAIL;
  11987. json_object *SetNetworkProfile;
  11988. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  11989. SetNetworkProfile = json_tokener_parse(payload);
  11990. if(!is_error(SetNetworkProfile))
  11991. {
  11992. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  11993. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  11994. // Required data
  11995. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  11996. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  11997. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  11998. {
  11999. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  12000. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  12001. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  12002. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  12003. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  12004. {
  12005. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  12006. memcpy((char*)ShmSysConfigAndInfo->SysConfig.OcppServerURL, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl));
  12007. }
  12008. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  12009. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  12010. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  12011. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  12012. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  12013. {
  12014. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  12015. 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")));
  12016. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  12017. 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")));
  12018. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  12019. 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")));
  12020. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  12021. 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")));
  12022. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  12023. 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")));
  12024. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  12025. 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")));
  12026. }
  12027. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  12028. {
  12029. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  12030. {
  12031. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  12032. 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")));
  12033. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  12034. }
  12035. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  12036. {
  12037. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  12038. 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")));
  12039. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  12040. }
  12041. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  12042. {
  12043. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  12044. 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")));
  12045. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  12046. }
  12047. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  12048. 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"));
  12049. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  12050. 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")));
  12051. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  12052. 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"));
  12053. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  12054. 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")));
  12055. }
  12056. DB_addNetworkProfile(ShmOCPP20Data->SetNetworkProfile.configurationSlot, (char*)json_object_get_string(json_object_object_get(SetNetworkProfile, "connectionData")));
  12057. }
  12058. }
  12059. json_object_put(SetNetworkProfile);
  12060. /*
  12061. * TODO:
  12062. * 1. Process network configuration and response
  12063. */
  12064. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  12065. {
  12066. }
  12067. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  12068. {
  12069. }
  12070. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  12071. {
  12072. }
  12073. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  12074. {
  12075. }
  12076. else
  12077. {
  12078. }
  12079. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  12080. {
  12081. }
  12082. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  12083. {
  12084. }
  12085. else
  12086. {
  12087. }
  12088. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  12089. {
  12090. }
  12091. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  12092. {
  12093. }
  12094. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  12095. {
  12096. }
  12097. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  12098. {
  12099. }
  12100. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  12101. {
  12102. }
  12103. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  12104. {
  12105. }
  12106. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  12107. {
  12108. }
  12109. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  12110. {
  12111. }
  12112. else
  12113. {
  12114. }
  12115. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  12116. {
  12117. }
  12118. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  12119. {
  12120. }
  12121. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  12122. {
  12123. }
  12124. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  12125. {
  12126. }
  12127. else
  12128. {
  12129. }
  12130. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  12131. {
  12132. }
  12133. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  12134. {
  12135. }
  12136. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  12137. {
  12138. }
  12139. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  12140. {
  12141. }
  12142. else
  12143. {
  12144. }
  12145. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  12146. sendSetNetworkProfileConfirmation(uuid);
  12147. return result;
  12148. }
  12149. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  12150. {
  12151. mtrace();
  12152. int result = FAIL;
  12153. json_object *SetVariableMonitoring;
  12154. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  12155. SetVariableMonitoring = json_tokener_parse(payload);
  12156. if(!is_error(SetVariableMonitoring))
  12157. {
  12158. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  12159. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  12160. // Required data
  12161. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  12162. {
  12163. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  12164. {
  12165. 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"));
  12166. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  12167. }
  12168. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  12169. {
  12170. 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"));
  12171. /*
  12172. * TODO:
  12173. * 1. Check monitor value status
  12174. */
  12175. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, MonitorEnumTypeStr[MonitorEnumType_Delta]);
  12176. }
  12177. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  12178. {
  12179. 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")));
  12180. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  12181. }
  12182. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  12183. {
  12184. 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"));
  12185. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  12186. }
  12187. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  12188. {
  12189. 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"));
  12190. }
  12191. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component") != NULL)
  12192. {
  12193. 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)
  12194. {
  12195. 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")));
  12196. }
  12197. 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)
  12198. {
  12199. 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")));
  12200. }
  12201. 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)
  12202. {
  12203. 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)
  12204. {
  12205. 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"));
  12206. }
  12207. 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)
  12208. {
  12209. 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"));
  12210. }
  12211. }
  12212. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  12213. }
  12214. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable") != NULL)
  12215. {
  12216. 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)
  12217. {
  12218. 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")));
  12219. }
  12220. 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)
  12221. {
  12222. 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")));
  12223. }
  12224. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  12225. }
  12226. }
  12227. }
  12228. json_object_put(SetVariableMonitoring);
  12229. return result;
  12230. }
  12231. int handleSetVariablesRequest(char *uuid, char *payload)
  12232. {
  12233. mtrace();
  12234. int result = FAIL;
  12235. json_object *SetVariables;
  12236. DEBUG_INFO("handleSetVariablesRequest...\n");
  12237. SetVariables = json_tokener_parse(payload);
  12238. if(!is_error(SetVariables))
  12239. {
  12240. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  12241. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  12242. // Required data
  12243. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  12244. {
  12245. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  12246. {
  12247. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  12248. {
  12249. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  12250. {
  12251. 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")));
  12252. }
  12253. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  12254. {
  12255. 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")));
  12256. }
  12257. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  12258. {
  12259. 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)
  12260. {
  12261. 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"));
  12262. }
  12263. 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)
  12264. {
  12265. 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"));
  12266. }
  12267. }
  12268. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  12269. }
  12270. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  12271. {
  12272. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  12273. {
  12274. 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")));
  12275. }
  12276. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  12277. {
  12278. 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")));
  12279. }
  12280. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  12281. }
  12282. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  12283. {
  12284. 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")));
  12285. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  12286. }
  12287. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  12288. {
  12289. 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")));
  12290. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  12291. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  12292. {
  12293. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name) != NULL) &&
  12294. (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) &&
  12295. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name) != NULL) &&
  12296. (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))
  12297. {
  12298. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  12299. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  12300. if(((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, "OCPPCommCtrlr") != NULL)) && (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, "NetworkConfigurationPriority") != NULL))
  12301. {
  12302. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_RebootRequired]);
  12303. }
  12304. else
  12305. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  12306. }
  12307. }
  12308. }
  12309. }
  12310. }
  12311. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  12312. }
  12313. json_object_put(SetVariables);
  12314. return result;
  12315. }
  12316. int handleTriggerMessageRequest(char *uuid, char *payload)
  12317. {
  12318. mtrace();
  12319. int result = FAIL;
  12320. int connectorIdIsNULL = FALSE;
  12321. int connectorIdInt =0;
  12322. char requestedMessagestr[40]={0};
  12323. json_object *TriggerMessage;
  12324. DEBUG_INFO("handleTriggerMessageRequest\n");
  12325. TriggerMessage = json_tokener_parse(payload);
  12326. if(!is_error(TriggerMessage))
  12327. {
  12328. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  12329. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  12330. // Required data
  12331. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  12332. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  12333. // Optional data
  12334. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  12335. {
  12336. // Required data
  12337. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  12338. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  12339. // Optional data
  12340. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  12341. {
  12342. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  12343. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  12344. }
  12345. else
  12346. connectorIdIsNULL = TRUE;
  12347. }
  12348. }
  12349. json_object_put(TriggerMessage);
  12350. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  12351. {
  12352. if((strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  12353. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  12354. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  12355. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  12356. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  12357. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  12358. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  12359. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  12360. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  12361. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  12362. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  12363. {
  12364. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  12365. sendTriggerMessageConfirmation(uuid);
  12366. return TRUE;
  12367. }
  12368. else
  12369. {
  12370. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  12371. sendTriggerMessageConfirmation(uuid);
  12372. }
  12373. }
  12374. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  12375. {
  12376. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  12377. sendTriggerMessageConfirmation(uuid);
  12378. return TRUE;
  12379. }
  12380. //==========================
  12381. // Trigger message
  12382. //==========================
  12383. if( strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  12384. {
  12385. if((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) &&
  12386. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) &&
  12387. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) &&
  12388. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing) )
  12389. {
  12390. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  12391. }
  12392. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusNotificationStatus]);
  12393. }
  12394. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  12395. {
  12396. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[LogStatusNotificationStatus]);
  12397. }
  12398. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  12399. {
  12400. if(DB_updateBootType(BootReasonEnumType_Triggered))
  12401. server_sign = FALSE;
  12402. }
  12403. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  12404. {
  12405. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval);
  12406. }
  12407. else if (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  12408. {
  12409. if(connectorIdIsNULL == FALSE)
  12410. {
  12411. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12412. {
  12413. //sendMeterValuesRequest((connectorIdInt -1), ReadingContext_Trigger);
  12414. cpinitateMsg.bits[connectorIdInt -1].TriggerMeterValueReq = ON;
  12415. }
  12416. }
  12417. else
  12418. {
  12419. for(int idx=0;idx< gunTotalNumber;idx++)
  12420. {
  12421. //sendMeterValuesRequest(idx, ReadingContext_Trigger);
  12422. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  12423. }
  12424. }
  12425. }
  12426. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  12427. {
  12428. if(connectorIdIsNULL == FALSE)
  12429. {
  12430. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12431. {
  12432. cpinitateMsg.bits[connectorIdInt -1].StatusNotificationReq = ON;
  12433. }
  12434. }
  12435. else
  12436. {
  12437. for(int idx=0;idx< gunTotalNumber;idx++)
  12438. cpinitateMsg.bits[idx].StatusNotificationReq = ON;
  12439. }
  12440. }
  12441. return result;
  12442. }
  12443. int handleUnlockConnectorRequest(char *uuid, char *payload)
  12444. {
  12445. mtrace();
  12446. int result = FAIL;
  12447. int connectorIdInt =0;
  12448. int tempIndex = 0;
  12449. json_object *UnlockConnector;
  12450. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  12451. UnlockConnector = json_tokener_parse(payload);
  12452. if(!is_error(UnlockConnector))
  12453. {
  12454. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  12455. {
  12456. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  12457. }
  12458. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  12459. {
  12460. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  12461. }
  12462. }
  12463. json_object_put(UnlockConnector);
  12464. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  12465. if(gunTotalNumber == 0)
  12466. {
  12467. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12468. goto end;
  12469. }
  12470. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  12471. {
  12472. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12473. goto end;
  12474. }
  12475. else
  12476. {
  12477. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  12478. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  12479. //check Transaction active
  12480. if(gunType[connectorIdInt-1] == 'J')
  12481. {
  12482. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12483. {
  12484. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12485. }
  12486. else
  12487. {
  12488. tempIndex = connectorIdInt -1;
  12489. }
  12490. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12491. {
  12492. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12493. {
  12494. //stop Transaction
  12495. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12496. }
  12497. }
  12498. }
  12499. else if((gunType[connectorIdInt-1] == 'U')||(gunType[connectorIdInt-1] == 'E'))
  12500. {
  12501. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12502. {
  12503. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12504. }
  12505. else
  12506. {
  12507. tempIndex = connectorIdInt -1;
  12508. }
  12509. for (int index = 0; index < CCS_QUANTITY; index++)
  12510. {
  12511. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12512. {
  12513. //stop Transaction
  12514. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12515. }
  12516. }
  12517. }
  12518. else if(gunType[connectorIdInt-1] == 'G')
  12519. {
  12520. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12521. {
  12522. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12523. }
  12524. else
  12525. {
  12526. tempIndex = connectorIdInt -1;
  12527. }
  12528. for (int index = 0; index < GB_QUANTITY; index++)
  12529. {
  12530. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)))
  12531. {
  12532. //stop Transaction
  12533. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12534. }
  12535. }
  12536. }
  12537. else
  12538. {
  12539. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  12540. {
  12541. tempIndex = 2;
  12542. }
  12543. else
  12544. {
  12545. tempIndex = connectorIdInt-1;
  12546. }
  12547. for (int index = 0; index < AC_QUANTITY; index++)
  12548. {
  12549. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12550. {
  12551. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12552. }
  12553. }
  12554. }
  12555. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  12556. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  12557. result = TRUE;
  12558. return result;
  12559. }
  12560. end:
  12561. //json_object_put(obj); --- remove temporally
  12562. sendUnlockConnectorConfirmation(uuid, connectorIdInt-1);
  12563. return result;
  12564. }
  12565. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  12566. {
  12567. mtrace();
  12568. int result = FAIL;
  12569. json_object *UnpublishFirmware;
  12570. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  12571. UnpublishFirmware = json_tokener_parse(payload);
  12572. if(!is_error(UnpublishFirmware))
  12573. {
  12574. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  12575. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  12576. // Required data
  12577. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  12578. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  12579. }
  12580. json_object_put(UnpublishFirmware);
  12581. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  12582. /*
  12583. * TODO:
  12584. * 1. Check unpublished status
  12585. */
  12586. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  12587. sendUnpublishFirmwareConfirmation(uuid);
  12588. return result;
  12589. }
  12590. static char UpdateFirmwarepayloadData[512]={0};
  12591. void *UpdateFirmwareProcess(void *data)
  12592. {
  12593. pthread_detach(pthread_self());
  12594. mtrace();
  12595. int retriesInt =0, retryIntervalInt=0;
  12596. char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
  12597. int port=0;
  12598. char locationstr[160]={0}, retrieveDatestr[30]={0};
  12599. int isSuccess = 0;
  12600. char ftpbuf[200];
  12601. char temp[100];
  12602. char * pch;
  12603. DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
  12604. json_object *UpdateFirmware;
  12605. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  12606. if(!is_error(UpdateFirmware))
  12607. {
  12608. // Required data
  12609. if(json_object_object_get(UpdateFirmware, "location") != NULL)
  12610. sprintf((char*)locationstr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "location")));
  12611. if(json_object_object_get(UpdateFirmware, "retrieveDate") != NULL)
  12612. sprintf((char*)retrieveDatestr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "retrieveDate")));
  12613. // Optional data
  12614. if(json_object_object_get(UpdateFirmware, "retries"))
  12615. {
  12616. retriesInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  12617. }
  12618. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  12619. {
  12620. retryIntervalInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  12621. }
  12622. }
  12623. json_object_put(UpdateFirmware);
  12624. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  12625. memset(path, 0, ARRAY_SIZE(path));
  12626. system("rm -f /mnt/*");
  12627. if(strncmp(locationstr,"http", 4) == 0)
  12628. {
  12629. sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  12630. //sscanf(locationstr,"%[^:]:%*2[/]%[^:]:%[^@]@%[^/]%199[^\n]",
  12631. // protocol, user, password, host, path);
  12632. sprintf(ftppath,"/%s", path);
  12633. DEBUG_INFO("locationstr: %s\n", locationstr);
  12634. DEBUG_INFO("protocol: %s\n",protocol);
  12635. DEBUG_INFO("host: %s\n",host);
  12636. DEBUG_INFO("path: %s\n",path);
  12637. DEBUG_INFO("ftppath: %s\n",ftppath);
  12638. int ftppathlen=strlen(ftppath);
  12639. int i=1;
  12640. char filenametemp[50];
  12641. while(i < ftppathlen)
  12642. {
  12643. int len=ftppathlen-i;
  12644. if(ftppath[len]== 47) // '/' ascll code: 47
  12645. {
  12646. DEBUG_INFO("compare '/' all right\n");
  12647. break;
  12648. }
  12649. i=i+1;
  12650. }
  12651. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12652. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  12653. filenametemp[i+1] = 0;
  12654. do
  12655. {
  12656. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12657. sleep(3);
  12658. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
  12659. if(!isSuccess)
  12660. {
  12661. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12662. sleep(retryIntervalInt);
  12663. }
  12664. else
  12665. {
  12666. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12667. }
  12668. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
  12669. }
  12670. else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
  12671. {
  12672. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12673. memset(temp, 0, ARRAY_SIZE(temp));
  12674. //DEBUG_INFO("locationstr=%s\n",locationstr);
  12675. strcpy(ftpbuf, locationstr/*"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/DemoDC1_2018-07-13_185011_PSULog.zip"*/ );
  12676. int ftppathlen=strlen(ftpbuf);
  12677. int i=1;
  12678. char filenametemp[50];
  12679. while(i < ftppathlen)
  12680. {
  12681. int len=ftppathlen-i;
  12682. if(ftpbuf[len]== 47) // '/' ascll code: 47
  12683. {
  12684. DEBUG_INFO(" compare '/' all right\n");
  12685. break;
  12686. }
  12687. i=i+1;
  12688. }
  12689. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12690. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  12691. filenametemp[i+1] = 0;
  12692. strncpy(temp, ftpbuf, ftppathlen-i+1);
  12693. pch=strchr(temp,'@');
  12694. if(pch==NULL)
  12695. {
  12696. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  12697. protocol, host, &port, path);
  12698. strcpy(user,"anonymous");
  12699. strcpy(password,"");
  12700. }
  12701. else
  12702. {
  12703. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  12704. protocol, user, password, host, &port, path);
  12705. }
  12706. sscanf(host,"%[^/]%s",host1, path1);
  12707. sprintf(ftppath,"%s", path1);
  12708. //DEBUG_INFO("protocol =%s\n",protocol);
  12709. //DEBUG_INFO("user =%s\n",user);
  12710. //DEBUG_INFO("password =%s\n",password);
  12711. //DEBUG_INFO("host1 =%s\n",host1);
  12712. //DEBUG_INFO("port =%d\n",port);
  12713. //DEBUG_INFO("path1 =%s\n",path1);
  12714. //DEBUG_INFO("ftppath=%s\n",ftppath);
  12715. //ftpFile(host, user, password, port, ftppath, fname);
  12716. //download firmware pthred
  12717. if(port == 0)
  12718. {
  12719. port = 21;
  12720. }
  12721. do
  12722. {
  12723. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12724. sleep(3);
  12725. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
  12726. if(!isSuccess)
  12727. {
  12728. //BulldogUtil.sleepMs(interval*1000);
  12729. DEBUG_INFO("Update firmware request and download file fail.\n");
  12730. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12731. sleep(retryIntervalInt);
  12732. }
  12733. else
  12734. {
  12735. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12736. }
  12737. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  12738. }
  12739. else
  12740. {
  12741. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12742. }
  12743. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  12744. pthread_exit(NULL);
  12745. }
  12746. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  12747. {
  12748. mtrace();
  12749. int result = FAIL;
  12750. pthread_t t;
  12751. sendUpdateFirmwareConfirmation(uuid);
  12752. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  12753. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  12754. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  12755. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  12756. ////pthread_join(t, NULL); //
  12757. //pthread_detach(t);
  12758. //sendUpdateFirmwareConfirmation(uuid);
  12759. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  12760. return result;
  12761. }
  12762. //==========================================
  12763. // Handle server response routine
  12764. //==========================================
  12765. void handleAuthorizeResponse(char *payload, int gun_index)
  12766. {
  12767. mtrace();
  12768. DEBUG_INFO("handleAuthorizeResponse...\n");
  12769. json_object *Authorize;
  12770. Authorize = json_tokener_parse(payload);
  12771. if(!is_error(Authorize))
  12772. {
  12773. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  12774. {
  12775. // Required data
  12776. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  12777. // Optional data
  12778. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  12779. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  12780. else
  12781. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  12782. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  12783. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  12784. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  12785. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  12786. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  12787. {
  12788. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  12789. {
  12790. 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));
  12791. }
  12792. }
  12793. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  12794. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  12795. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  12796. {
  12797. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  12798. 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")));
  12799. else
  12800. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  12801. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  12802. 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")));
  12803. }
  12804. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  12805. {
  12806. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  12807. 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")));
  12808. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  12809. 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")));
  12810. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  12811. 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")));
  12812. }
  12813. }
  12814. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  12815. {
  12816. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  12817. }
  12818. }
  12819. json_object_put(Authorize);
  12820. //Update idTag information to authorization cache if supported
  12821. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  12822. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  12823. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  12824. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  12825. {
  12826. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  12827. }
  12828. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  12829. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  12830. authorizeRetryTimes = 0;
  12831. }
  12832. void handleBootNotificationResponse(char *payload, int gun_index)
  12833. {
  12834. mtrace();
  12835. char statusStr[12]={0};
  12836. char currentTimeStr[30]={0};
  12837. int intervalInt = 0;
  12838. struct tm tp;
  12839. char buf[28]={0};
  12840. char timebuf[50]={0};
  12841. DEBUG_INFO("handleBootNotificationResponse...\n");
  12842. json_object *BootNotification;
  12843. BootNotification = json_tokener_parse(payload);
  12844. if(!is_error(BootNotification))
  12845. {
  12846. // Required data
  12847. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  12848. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  12849. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  12850. }
  12851. json_object_put(BootNotification);
  12852. DEBUG_INFO("statusStr: %s\n", statusStr);
  12853. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  12854. BootNotificationInterval = intervalInt;
  12855. HeartBeatWaitTime = intervalInt;
  12856. //write back to ShmOCPP20Data->BootNotification
  12857. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  12858. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  12859. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  12860. {
  12861. server_sign = TRUE;
  12862. server_pending =FALSE;
  12863. DB_updateBootType(BootReasonEnumType_PowerUp);
  12864. }
  12865. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  12866. {
  12867. server_pending = TRUE;
  12868. }
  12869. strptime((const char *)ShmOCPP20Data->BootNotification.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  12870. tp.tm_isdst = -1;
  12871. //time_t utc = mktime(&tp);
  12872. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  12873. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  12874. sprintf(timebuf,"date -s '%s'",buf);
  12875. system(timebuf);
  12876. srand(time(NULL));
  12877. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  12878. //==============================================
  12879. // RTC sync
  12880. //==============================================
  12881. system("/sbin/hwclock -w --systohc");
  12882. SetOcppConnStatus(TRUE);
  12883. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  12884. }
  12885. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  12886. {
  12887. mtrace();
  12888. json_object *ClearedChargingLimit;
  12889. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  12890. ClearedChargingLimit = json_tokener_parse(payload);
  12891. if(!is_error(ClearedChargingLimit))
  12892. {
  12893. // Required data
  12894. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  12895. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  12896. }
  12897. json_object_put(ClearedChargingLimit);
  12898. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitReq = OFF;
  12899. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitConf = ON;
  12900. }
  12901. void handleDataTransferResponse(char *payload, int gun_index)
  12902. {
  12903. mtrace();
  12904. json_object *DataTrans;
  12905. DEBUG_INFO("handleDataTransferResponse...\n");
  12906. DataTrans = json_tokener_parse(payload);
  12907. if(!is_error(DataTrans))
  12908. {
  12909. // Required data
  12910. if(json_object_object_get(DataTrans,"status") != NULL)
  12911. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  12912. // Optional data
  12913. if(json_object_object_get(DataTrans,"data") != NULL)
  12914. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  12915. }
  12916. json_object_put(DataTrans);
  12917. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  12918. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  12919. }
  12920. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  12921. {
  12922. mtrace();
  12923. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  12924. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  12925. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  12926. }
  12927. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  12928. {
  12929. mtrace();
  12930. json_object *Get15118EVCertificate;
  12931. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  12932. Get15118EVCertificate = json_tokener_parse(payload);
  12933. if(!is_error(Get15118EVCertificate))
  12934. {
  12935. // Required data
  12936. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  12937. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  12938. // Optional data
  12939. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  12940. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  12941. }
  12942. json_object_put(Get15118EVCertificate);
  12943. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  12944. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  12945. }
  12946. void hanldeGetCertificateStatusResponse(char *payload, int gun_index)
  12947. {
  12948. mtrace();
  12949. json_object *GetCertificateStatus;
  12950. DEBUG_INFO("hanldeGetCertificateStatusResponse...\n");
  12951. GetCertificateStatus = json_tokener_parse(payload);
  12952. if(!is_error(GetCertificateStatus))
  12953. {
  12954. // Required data
  12955. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  12956. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  12957. // Optional data
  12958. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  12959. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  12960. }
  12961. json_object_put(GetCertificateStatus);
  12962. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  12963. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  12964. }
  12965. void handleHeartbeatResponse(char *payload, int gun_index)
  12966. {
  12967. mtrace();
  12968. struct tm tp;
  12969. char buf[28]={0};
  12970. char timebuf[128]={0};
  12971. DEBUG_INFO("handleHeartbeatResponse...\n");
  12972. json_object *Heartbeat;
  12973. Heartbeat = json_tokener_parse(payload);
  12974. if(!is_error(Heartbeat))
  12975. {
  12976. // Required data
  12977. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  12978. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  12979. }
  12980. json_object_put(Heartbeat);
  12981. if(FirstHeartBeat == OFF)
  12982. {
  12983. FirstHeartBeat = ON;
  12984. DEBUG_INFO("FirstHeartBeat \n");
  12985. }
  12986. HeartBeatWithNOResponse = 0;
  12987. clientTime.Heartbeat=time((time_t*)NULL);
  12988. strptime((const char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  12989. tp.tm_isdst = -1;
  12990. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  12991. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  12992. sprintf(timebuf,"date -s '%s'",buf);
  12993. system(timebuf);
  12994. //==============================================
  12995. // RTC sync
  12996. //==============================================
  12997. system("/sbin/hwclock -w --systohc");
  12998. }
  12999. void hanldeLogStatusNotificationResponse(char *payload, int gun_index)
  13000. {
  13001. mtrace();
  13002. DEBUG_INFO("hanldeLogStatusNotificationResponse...\n");
  13003. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  13004. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  13005. }
  13006. void handleMeterValuesResponse(char *payload, int gun_index)
  13007. {
  13008. mtrace();
  13009. DEBUG_INFO("handleMeterValuesResponse...\n");
  13010. }
  13011. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  13012. {
  13013. mtrace();
  13014. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  13015. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  13016. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  13017. }
  13018. void hanldeNotifyCustomerInformationResponse(char *payload, int gun_index)
  13019. {
  13020. mtrace();
  13021. DEBUG_INFO("hanldeNotifyCustomerInformationResponse...\n");
  13022. }
  13023. void hanldeNotifyDisplayMessagesResponse(char *payload, int gun_index)
  13024. {
  13025. mtrace();
  13026. DEBUG_INFO("hanldeNotifyDisplayMessagesResponse...\n");
  13027. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  13028. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  13029. }
  13030. void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  13031. {
  13032. mtrace();
  13033. json_object *NotifyEVChargingNeeds;
  13034. DEBUG_INFO("hanldeNotifyEVChargingNeedsResponse...\n");
  13035. NotifyEVChargingNeeds = json_tokener_parse(payload);
  13036. if(!is_error(NotifyEVChargingNeeds))
  13037. {
  13038. // Required data
  13039. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  13040. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  13041. }
  13042. json_object_put(NotifyEVChargingNeeds);
  13043. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  13044. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  13045. }
  13046. void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  13047. {
  13048. mtrace();
  13049. json_object *NotifyEVChargingSchedule;
  13050. DEBUG_INFO("hanldeNotifyEVChargingScheduleResponse...\n");
  13051. NotifyEVChargingSchedule = json_tokener_parse(payload);
  13052. if(!is_error(NotifyEVChargingSchedule))
  13053. {
  13054. // Required data
  13055. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  13056. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  13057. }
  13058. json_object_put(NotifyEVChargingSchedule);
  13059. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  13060. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  13061. }
  13062. void hanldeNotifyEventResponse(char *payload, int gun_index)
  13063. {
  13064. mtrace();
  13065. DEBUG_INFO("hanldeNotifyEventResponse...\n");
  13066. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  13067. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  13068. }
  13069. void hanldeNotifyMonitoringReportResponse(char *payload, int gun_index)
  13070. {
  13071. mtrace();
  13072. DEBUG_INFO("hanldeNotifyMonitoringReportResponse...\n");
  13073. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  13074. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  13075. }
  13076. void hanldeNotifyReportResponse(char *payload, int gun_index)
  13077. {
  13078. mtrace();
  13079. DEBUG_INFO("hanldeNotifyReportResponse...\n");
  13080. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  13081. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  13082. }
  13083. void hanldePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  13084. {
  13085. mtrace();
  13086. DEBUG_INFO("hanldePublishFirmwareStatusNotificationResponse...\n");
  13087. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  13088. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  13089. }
  13090. void hanldeReportChargingProfilesResponse(char *payload, int gun_index)
  13091. {
  13092. mtrace();
  13093. DEBUG_INFO("hanldeReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  13094. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  13095. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  13096. }
  13097. void hanldeReservationStatusUpdateResponse(char *payload, int gun_index)
  13098. {
  13099. mtrace();
  13100. DEBUG_INFO("hanldeReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  13101. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  13102. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  13103. }
  13104. void hanldeSecurityEventNotificationResponse(char *payload, int gun_index)
  13105. {
  13106. mtrace();
  13107. DEBUG_INFO("hanldeSecurityEventNotificationResponse...\n");
  13108. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  13109. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  13110. }
  13111. void hanldeSignCertificateResponse(char *payload, int gun_index)
  13112. {
  13113. mtrace();
  13114. json_object *SignCertificate;
  13115. DEBUG_INFO("hanldeSignCertificateResponse...\n");
  13116. SignCertificate = json_tokener_parse(payload);
  13117. if(!is_error(SignCertificate))
  13118. {
  13119. // Required data
  13120. if(json_object_object_get(SignCertificate,"status") != NULL)
  13121. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  13122. }
  13123. json_object_put(SignCertificate);
  13124. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  13125. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  13126. }
  13127. void handleStatusNotificationResponse(char *payload, int gun_index)
  13128. {
  13129. mtrace();
  13130. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  13131. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13132. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  13133. }
  13134. void hanldeTransactionEvenResponse(char *payload, int gun_index)
  13135. {
  13136. mtrace();
  13137. json_object *TransactionEven;
  13138. DEBUG_INFO("hanldeTransactionEvenResponse...\n");
  13139. TransactionEven = json_tokener_parse(payload);
  13140. if(!is_error(TransactionEven))
  13141. {
  13142. // Required data
  13143. // Optional data
  13144. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  13145. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  13146. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  13147. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  13148. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  13149. {
  13150. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  13151. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  13152. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  13153. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  13154. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  13155. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  13156. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  13157. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  13158. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  13159. {
  13160. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  13161. 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")));
  13162. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  13163. 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")));
  13164. }
  13165. }
  13166. }
  13167. json_object_put(TransactionEven);
  13168. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  13169. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  13170. }
  13171. //==========================================
  13172. // Handle Error routine
  13173. //==========================================
  13174. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  13175. {
  13176. mtrace();
  13177. #ifdef SystemLogMessage
  13178. DEBUG_INFO("errorCode: %s\n", errorCode);
  13179. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  13180. DEBUG_INFO("errorDetails: %s\n", payload);
  13181. #endif
  13182. }
  13183. //===============================================
  13184. // Common routine
  13185. //===============================================
  13186. int initialConfigurationTable(void)
  13187. {
  13188. DEBUG_INFO("initialConfigurationTable...\n");
  13189. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  13190. DB_variableIsCreate();
  13191. DB_variableLoadFromDb();
  13192. DB_getNetworkProfileFromDb();
  13193. return 0;
  13194. }
  13195. int TransactionMessageAttemptsGet(void)
  13196. {
  13197. return TransactionMessageAttemptsValue;
  13198. }
  13199. int FirstHeartBeatResponse(void)
  13200. {
  13201. return FirstHeartBeat;
  13202. }
  13203. int TransactionMessageRetryIntervalGet(void)
  13204. {
  13205. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  13206. }
  13207. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  13208. {
  13209. char rmFileCmd[100]={0};
  13210. char FilePath[100]={0};
  13211. char ftpbuf[200];
  13212. int systemresult;
  13213. //DEBUG_INFO("filename=%s\n",filename);
  13214. //DEBUG_INFO("url=%s\n",url);
  13215. sprintf(FilePath,"/mnt/%s",filename);
  13216. system("ping 8.8.8.8 &");
  13217. if((access(FilePath,F_OK))!=-1)
  13218. {
  13219. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13220. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13221. system(rmFileCmd);
  13222. }
  13223. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13224. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13225. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13226. systemresult = system(ftpbuf);
  13227. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13228. if(systemresult != 0)
  13229. {
  13230. DEBUG_INFO("http DownLoad error!\n");
  13231. return FALSE;
  13232. }
  13233. system("pkill ping");
  13234. return TRUE;
  13235. }
  13236. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  13237. {
  13238. char rmFileCmd[100]={0};
  13239. char FilePath[100]={0};
  13240. char ftpbuf[200];
  13241. int systemresult;
  13242. //char temp[100];
  13243. sprintf(FilePath,"/mnt/%s",filename);
  13244. system("ping 8.8.8.8 &");
  13245. if((access(FilePath,F_OK))!=-1)
  13246. {
  13247. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13248. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13249. system(rmFileCmd);
  13250. }
  13251. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13252. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  13253. //sprintf(ftpbuf, "ftpget -u %s -p %s %s -P %d %s %s%s",user,password,IPbuffer,port/*21*/,filename,path,filename); --- remove temporally
  13254. //DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13255. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13256. systemresult = system(ftpbuf);
  13257. //DEBUG_INFO("systemresult=%d\n",systemresult);
  13258. if(systemresult != 0)
  13259. {
  13260. printf("wget error!\n");
  13261. return FALSE;
  13262. }
  13263. system("pkill ping");
  13264. return TRUE;
  13265. }
  13266. int httpUploadFile(char *location, char *path, char *filename,char *url)
  13267. {
  13268. char rmFileCmd[100]={0};
  13269. char FilePath[100]={0};
  13270. char ftpbuf[200];
  13271. int systemresult;
  13272. //DEBUG_INFO("filename=%s\n",filename);
  13273. //DEBUG_INFO("url=%s\n",url);
  13274. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  13275. if((access(FilePath,F_OK))!=-1)
  13276. {
  13277. DEBUG_INFO("filename=%s exist.\n",FilePath);
  13278. sprintf(rmFileCmd,"rm -f %s",FilePath);
  13279. system(rmFileCmd);
  13280. }
  13281. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  13282. if(fp == NULL)
  13283. {
  13284. DEBUG_INFO("log is NULL\n");
  13285. return FALSE;
  13286. }
  13287. else
  13288. {
  13289. fprintf(fp, "%s\n", url);
  13290. fprintf(fp, "%s\n", filename);
  13291. fclose(fp);
  13292. }
  13293. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13294. sprintf(ftpbuf, "%s","/bin/php-cgi /var/www/ocpp_upload.php");
  13295. systemresult = system(ftpbuf);
  13296. DEBUG_INFO("systemresult = %d\n",systemresult);
  13297. if(systemresult != 0)
  13298. {
  13299. DEBUG_INFO("http upload error!\n");
  13300. return FALSE;
  13301. }
  13302. return TRUE;
  13303. }
  13304. int ftpUploadFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  13305. {
  13306. struct hostent* server;
  13307. char *IPbuffer;
  13308. char ftpbuf[200];
  13309. int systemresult;
  13310. // To retrieve host information
  13311. server = gethostbyname(location);
  13312. // To convert an Internet network
  13313. // address into ASCII string
  13314. IPbuffer = inet_ntoa(*((struct in_addr*)
  13315. server->h_addr_list[0]));
  13316. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13317. /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
  13318. /* format : ftpput -u username -p passwd IP target source*/
  13319. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
  13320. DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13321. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13322. systemresult = system(ftpbuf);
  13323. DEBUG_INFO("systemresult=%d\n",systemresult);
  13324. if(systemresult != 0)
  13325. {
  13326. DEBUG_INFO("ftpput error!\n");
  13327. return FALSE;
  13328. }
  13329. return TRUE;
  13330. }
  13331. //=========================================
  13332. // Routine
  13333. //=========================================
  13334. int GetOcppServerURL()
  13335. {
  13336. int result = FALSE;
  13337. struct yuarel url;
  13338. char urlStr[512];
  13339. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  13340. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  13341. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  13342. if((ShmSysConfigAndInfo->SysConfig.OcppServerURL != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0) )
  13343. {
  13344. memcpy(urlStr, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  13345. if(yuarel_parse(&url, urlStr) != -1)
  13346. {
  13347. sprintf(OcppProtocol, "%s", url.scheme);
  13348. sprintf(OcppHost, "%s", url.host);
  13349. if(url.path == NULL)
  13350. OcppTempPath[0] = '\0';
  13351. else
  13352. {
  13353. if((url.path[strlen(url.path)-1] != '/') && (strlen(url.path) > 0))
  13354. {
  13355. sprintf(OcppTempPath, "%s/", url.path);
  13356. }
  13357. else
  13358. {
  13359. sprintf(OcppTempPath, "%s", url.path);
  13360. }
  13361. }
  13362. if(url.port == 0)
  13363. {
  13364. if(strcmp(OcppProtocol, "wss") == 0)
  13365. OcppPort = 443;
  13366. else
  13367. OcppPort = 80;
  13368. }
  13369. else
  13370. OcppPort = url.port;
  13371. result = TRUE;
  13372. }
  13373. }
  13374. else if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  13375. {
  13376. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  13377. if(yuarel_parse(&url, urlStr) != -1)
  13378. {
  13379. sprintf(OcppProtocol, "%s", url.scheme);
  13380. sprintf(OcppHost, "%s", url.host);
  13381. if(url.path == NULL)
  13382. OcppTempPath[0] = '\0';
  13383. else
  13384. sprintf(OcppTempPath, "%s", url.path);
  13385. if(url.port == 0)
  13386. {
  13387. if(strcmp(OcppProtocol, "wss") == 0)
  13388. OcppPort = 443;
  13389. else
  13390. OcppPort = 80;
  13391. }
  13392. else
  13393. OcppPort = url.port;
  13394. result = TRUE;
  13395. }
  13396. }
  13397. else
  13398. {
  13399. strcpy(OcppHost,"");
  13400. }
  13401. return result;
  13402. }
  13403. int GetOcppPath()
  13404. {
  13405. int result = FALSE;
  13406. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  13407. {
  13408. if(OcppTempPath == NULL)
  13409. {
  13410. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13411. }
  13412. else
  13413. {
  13414. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13415. }
  13416. result = TRUE;
  13417. }
  13418. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  13419. {
  13420. if(OcppTempPath == NULL)
  13421. {
  13422. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  13423. }
  13424. else
  13425. {
  13426. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  13427. }
  13428. result = TRUE;
  13429. }
  13430. else
  13431. {
  13432. strcpy(OcppPath,"");
  13433. }
  13434. return result;
  13435. }
  13436. int GetOcppPort()
  13437. {
  13438. return OcppPort;
  13439. }
  13440. int GetOcppConnStatus(void)
  13441. {
  13442. return ShmOCPP20Data->OcppConnStatus;
  13443. }
  13444. void SetOcppConnStatus(uint8_t status)
  13445. {
  13446. ShmOCPP20Data->OcppConnStatus = status;
  13447. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  13448. }
  13449. int GetHeartBeatWithNOResponse(void)
  13450. {
  13451. return HeartBeatWithNOResponse;
  13452. }
  13453. void SetHeartBeatWithNOResponse(void)
  13454. {
  13455. HeartBeatWithNOResponse = 0;
  13456. }
  13457. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  13458. void storeTempStopTransaction(int gun_index)
  13459. {
  13460. }
  13461. void checkTempStopTransaction(int gun_index)
  13462. {
  13463. FILE *fptr1;
  13464. char ch;
  13465. char str[QUEUE_MESSAGE_LENGTH]={0};
  13466. char guid[37]={0};
  13467. char tempdata[65]={0};
  13468. char connectorStr[2]={0};
  13469. char TempStopTransaction[256];
  13470. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  13471. fptr1 = fopen(TempStopTransaction, "r");
  13472. if (!fptr1)
  13473. {
  13474. //DEBUG_INFO("TempStopTransaction_%d not found or unable to open the input file!\n", (gun_index+1));
  13475. return ;
  13476. }
  13477. ch=fgetc(fptr1);
  13478. rewind(fptr1);
  13479. if(ch!=EOF)
  13480. {
  13481. // copy all contents to the temporary file except the specific line
  13482. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  13483. {
  13484. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13485. if(str[0]=='\0')
  13486. {
  13487. break;
  13488. }
  13489. //TempStopTransaction格式: 槍號,StopTransaction封包
  13490. strncpy(connectorStr, str, 1);
  13491. if(atoi(connectorStr) != (gun_index+1))
  13492. {
  13493. DEBUG_INFO("atoi(connectorStr) = %d, gun_index = %d\n", atoi(connectorStr), gun_index);
  13494. fclose(fptr1);
  13495. return ;
  13496. }
  13497. //random_uuid(guid);
  13498. strncpy(guid, str+6, 36); //copy guid
  13499. sprintf(tempdata, "StopTransaction,%d", (gun_index));
  13500. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  13501. {
  13502. //DEBUG_INFO("StopTransaction mapitem pass\n");
  13503. }
  13504. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  13505. memset(str,0,ARRAY_SIZE(str));
  13506. }
  13507. }
  13508. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  13509. fclose(fptr1);
  13510. remove(TempStopTransaction); // remove the original file
  13511. }
  13512. int GetWebSocketPingInterval(void)
  13513. {
  13514. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  13515. }
  13516. int GetServerSign(void)
  13517. {
  13518. return server_sign;
  13519. }
  13520. uint8_t GetOcppSecurityProfile()
  13521. {
  13522. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  13523. }
  13524. void GetOcppChargerBoxId(uint8_t *data)
  13525. {
  13526. sprintf((char*)data, "%s", ShmOCPP20Data->ChargeBoxId);
  13527. }
  13528. void GetOcppSecurityPassword(uint8_t *data)
  13529. {
  13530. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  13531. }
  13532. void SetServerSign(int value)
  13533. {
  13534. server_sign = value;
  13535. }
  13536. int GetBootNotificationInterval(void)
  13537. {
  13538. return BootNotificationInterval;
  13539. }
  13540. int GetInternetConn(void)
  13541. {
  13542. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  13543. }
  13544. void InitialSystemValue(void)
  13545. {
  13546. int connectorIndex = 0;
  13547. gunTotalNumber=0;
  13548. SystemInitial = 0;
  13549. localversion=0;
  13550. BootNotificationInterval = 10;
  13551. authorizeRetryTimes = 0;
  13552. GunStatusInterval = 10;
  13553. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  13554. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  13555. //Hear Beat
  13556. HeartBeatWithNOResponse = 0;
  13557. HeartBeatCountPerHour = 0;
  13558. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  13559. FirstHeartBeat = 0;
  13560. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  13561. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  13562. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  13563. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  13564. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  13565. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  13566. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  13567. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  13568. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  13569. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  13570. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  13571. memset(gunType, 0, ARRAY_SIZE(gunType));
  13572. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13573. {
  13574. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O')
  13575. {
  13576. // DO series
  13577. for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
  13578. {
  13579. SystemInitial = SystemInitial + 1;
  13580. gunTotalNumber = gunTotalNumber + 1;
  13581. gunType[connectorIndex] = 'O';
  13582. connectorIndex = connectorIndex + 1;
  13583. }
  13584. }
  13585. else
  13586. {
  13587. // DM, DW, DS series
  13588. //check connector / socket type (index: 8, 9, 10)
  13589. for(int index=7; index <10 ; index++)
  13590. {
  13591. if(index != 8)
  13592. {
  13593. // DC Connector
  13594. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] >= 'A') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= 'Z'))
  13595. {
  13596. SystemInitial = SystemInitial + 1;
  13597. gunTotalNumber = gunTotalNumber + 1;
  13598. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13599. connectorIndex = connectorIndex + 1;
  13600. }
  13601. }
  13602. else
  13603. {
  13604. // AC Connector
  13605. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13606. {
  13607. SystemInitial = SystemInitial + 1;
  13608. gunTotalNumber = gunTotalNumber + 1;
  13609. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13610. connectorIndex = connectorIndex + 1;
  13611. }
  13612. }
  13613. }
  13614. }
  13615. //DEBUG_INFO("DC ...\n");
  13616. }
  13617. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  13618. {
  13619. //check connector / socket type (index: 8, 9, 10)
  13620. for(int index=7; index <10 ; index++)
  13621. {
  13622. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13623. {
  13624. SystemInitial = SystemInitial + 1;
  13625. gunTotalNumber = gunTotalNumber + 1;
  13626. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13627. connectorIndex = connectorIndex + 1;
  13628. //DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
  13629. }
  13630. }
  13631. }
  13632. //Status && ConnectorPlugIn Setting
  13633. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13634. {
  13635. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  13636. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  13637. }
  13638. for (int index = 0; index < CCS_QUANTITY; index++)
  13639. {
  13640. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  13641. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  13642. }
  13643. for (int index = 0; index < GB_QUANTITY; index++)
  13644. {
  13645. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  13646. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  13647. }
  13648. for (int index = 0; index < AC_QUANTITY; index++)
  13649. {
  13650. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  13651. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  13652. }
  13653. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13654. {
  13655. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  13656. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  13657. }
  13658. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  13659. {
  13660. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13661. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  13662. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  13663. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  13664. }
  13665. clientTime.Heartbeat=time((time_t*)NULL);
  13666. sleep(1);
  13667. }
  13668. void LWS_Send(char * str)
  13669. {
  13670. //=====================================================
  13671. // Check InternetConn 0: disconnected, 1: connected
  13672. //====================================================
  13673. if(GetOcppConnStatus() == 0)
  13674. {
  13675. DEBUG_INFO("offline now !!!\n");
  13676. return;
  13677. }
  13678. pthread_mutex_lock(&lock_send);
  13679. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13680. sprintf((char *)SendBuffer, "%s", str);
  13681. SendBufLen = strlen(str);
  13682. pthread_mutex_unlock(&lock_send);
  13683. lws_callback_on_writable(wsi_client);
  13684. //lws_service(context, 0);
  13685. //sleep(1);
  13686. }
  13687. void LWS_SendNow(char * str)
  13688. {
  13689. //=====================================================
  13690. // Check InternetConn 0: disconnected, 1: connected
  13691. //====================================================
  13692. if(GetOcppConnStatus() == 0)
  13693. {
  13694. DEBUG_INFO("offline now !!!\n");
  13695. return;
  13696. }
  13697. pthread_mutex_lock(&lock_send);
  13698. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13699. sprintf((char *)SendBuffer, "%s", str);
  13700. SendBufLen = strlen(str);
  13701. pthread_mutex_unlock(&lock_send);
  13702. lws_callback_on_writable(wsi_client);
  13703. lws_service(context, 0);
  13704. //sleep(1);
  13705. }