MessageHandler.c 782 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716
  1. #include "Module_OcppBackend20.h"
  2. #include "define.h"
  3. //#define TEST_OCPP20
  4. static char *APNAuthenticationEnumTypeStr[] = {
  5. MACROSTR(CHAP),
  6. MACROSTR(NONE),
  7. MACROSTR(PAP),
  8. MACROSTR(AUTO)
  9. };
  10. static char *AttributeEnumTypeStr[] = {
  11. MACROSTR(Actual),
  12. MACROSTR(Target),
  13. MACROSTR(MinSet),
  14. MACROSTR(MaxSet)
  15. };
  16. static char *AuthorizationStatusEnumTypeStr[] = {
  17. MACROSTR(Accepted),
  18. MACROSTR(Blocked),
  19. MACROSTR(ConcurrentTx),
  20. MACROSTR(Expired),
  21. MACROSTR(Invalid),
  22. MACROSTR(NoCredit),
  23. MACROSTR(NotAllowedTypeEVSE),
  24. MACROSTR(NotAtThisLocation),
  25. MACROSTR(NotAtThisTime),
  26. MACROSTR(Unknown)
  27. };
  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. static char *BootReasonEnumTypeStr[] = {
  38. MACROSTR(ApplicationReset),
  39. MACROSTR(FirmwareUpdate),
  40. MACROSTR(LocalReset),
  41. MACROSTR(PowerUp),
  42. MACROSTR(RemoteReset),
  43. MACROSTR(ScheduledReset),
  44. MACROSTR(Triggered),
  45. MACROSTR(Unknown),
  46. MACROSTR(Watchdog)
  47. };
  48. static char *CancelReservationStatusEnumTypeStr[] = {
  49. MACROSTR(Accepted),
  50. MACROSTR(Rejected)
  51. };
  52. static char *CertificateActionEnumTypeStr[] = {
  53. MACROSTR(Install),
  54. MACROSTR(Update)
  55. };
  56. static char *CertificateSignedStatusEnumTypeStr[] = {
  57. MACROSTR(Accepted),
  58. MACROSTR(Rejected)
  59. };
  60. static char *CertificateSigningUseEnumTypeStr[] = {
  61. MACROSTR(ChargingStationCertificate),
  62. MACROSTR(V2GCertificate)
  63. };
  64. static char *ChangeAvailabilityStatusEnumTypeStr[] = {
  65. MACROSTR(Accepted),
  66. MACROSTR(Rejected),
  67. MACROSTR(Scheduled)
  68. };
  69. static char *ChargingLimitSourceEnumTypeStr[] = {
  70. MACROSTR(EMS),
  71. MACROSTR(Other),
  72. MACROSTR(SO),
  73. MACROSTR(CSO)
  74. };
  75. static char *ChargingProfileKindEnumTypeStr[] = {
  76. MACROSTR(Absolute),
  77. MACROSTR(Recurring),
  78. MACROSTR(Relative)
  79. };
  80. static char *ChargingProfilePurposeEnumTypeStr[] = {
  81. MACROSTR(ChargingStationExternalConstraints),
  82. MACROSTR(ChargingStationMaxProfile),
  83. MACROSTR(TxDefaultProfile),
  84. MACROSTR(TxProfile)
  85. };
  86. static char *ChargingProfileStatusEnumTypeStr[] = {
  87. MACROSTR(Accepted),
  88. MACROSTR(Rejected)
  89. };
  90. static char *ChargingRateUnitEnumTypeStr[] = {
  91. MACROSTR(W),
  92. MACROSTR(A)
  93. };
  94. static char *ChargingStateEnumTypeStr[] = {
  95. MACROSTR(Charging),
  96. MACROSTR(EVConnected),
  97. MACROSTR(SuspendedEV),
  98. MACROSTR(SuspendedEVSE),
  99. MACROSTR(Idle)
  100. };
  101. static char *ClearCacheStatusEnumTypeStr[] = {
  102. MACROSTR(Accepted),
  103. MACROSTR(Rejected)
  104. };
  105. static char *ClearChargingProfileStatusEnumTypeStr[] = {
  106. MACROSTR(Accepted),
  107. MACROSTR(Unknown)
  108. };
  109. static char *ClearMessageStatusEnumTypeStr[] = {
  110. MACROSTR(Accepted),
  111. MACROSTR(Unknown)
  112. };
  113. static char *ClearMonitoringStatusEnumTypeStr[] = {
  114. MACROSTR(Accepted),
  115. MACROSTR(Rejected),
  116. MACROSTR(NotFound)
  117. };
  118. static char *ComponentCriterionEnumTypeStr[] = {
  119. MACROSTR(Active),
  120. MACROSTR(Available),
  121. MACROSTR(Enabled),
  122. MACROSTR(Problem)
  123. };
  124. static char *ConnectorEnumTypeStr[] = {
  125. MACROSTR(cCCS1),
  126. MACROSTR(cCCS2),
  127. MACROSTR(cG105),
  128. MACROSTR(cTesla),
  129. MACROSTR(cType1),
  130. MACROSTR(cType2),
  131. MACROSTR(s309-1P-16A),
  132. MACROSTR(s309-1P-32A),
  133. MACROSTR(s309-3P-16A),
  134. MACROSTR(s309-3P-32A),
  135. MACROSTR(sBS1361),
  136. MACROSTR(sCEE-7-7),
  137. MACROSTR(sType2),
  138. MACROSTR(sType3),
  139. MACROSTR(Other1PhMax16A),
  140. MACROSTR(Other1PhOver16A),
  141. MACROSTR(Other3Ph),
  142. MACROSTR(Pan),
  143. MACROSTR(wInductive),
  144. MACROSTR(wResonant),
  145. MACROSTR(Undetermined),
  146. MACROSTR(Unknown)
  147. };
  148. static char *ConnectorStatusEnumTypeStr[] = {
  149. MACROSTR(Available),
  150. MACROSTR(Occupied),
  151. MACROSTR(Reserved),
  152. MACROSTR(Unavailable),
  153. MACROSTR(Faulted)
  154. };
  155. static char *CostKindEnumTypeStr[] = {
  156. MACROSTR(CarbonDioxideEmission),
  157. MACROSTR(RelativePricePercentage),
  158. MACROSTR(RenewableGenerationPercentage)
  159. };
  160. static char *CustomerInformationStatusEnumTypeStr[] = {
  161. MACROSTR(Accepted),
  162. MACROSTR(Rejected),
  163. MACROSTR(Invalid)
  164. };
  165. static char *DataEnumTypeStr[] = {
  166. MACROSTR(string),
  167. MACROSTR(decimal),
  168. MACROSTR(integer),
  169. MACROSTR(dateTime),
  170. MACROSTR(boolean),
  171. MACROSTR(OptionList),
  172. MACROSTR(SequenceList),
  173. MACROSTR(MemberList)
  174. };
  175. static char *DataTransferStatusEnumTypeStr[] = {
  176. MACROSTR(Accepted),
  177. MACROSTR(Rejected),
  178. MACROSTR(UnknownMessageId),
  179. MACROSTR(UnknownVendorId)
  180. };
  181. static char *DeleteCertificateStatusEnumTypeStr[] = {
  182. MACROSTR(Accepted),
  183. MACROSTR(Failed),
  184. MACROSTR(NotFound)
  185. };
  186. static char *DisplayMessageStatusEnumTypeStr[] = {
  187. MACROSTR(Accepted),
  188. MACROSTR(NotSupportedMessageFormat),
  189. MACROSTR(Rejected),
  190. MACROSTR(NotSupportedPriority),
  191. MACROSTR(NotSupportedState),
  192. MACROSTR(UnknownTransaction)
  193. };
  194. static char *EnergyTransferModeEnumTypeStr[] = {
  195. MACROSTR(DC),
  196. MACROSTR(AC_single_phase),
  197. MACROSTR(AC_two_phase),
  198. MACROSTR(AC_three_phase)
  199. };
  200. static char *EventNotificationEnumTypeStr[] = {
  201. MACROSTR(HardWiredNotification),
  202. MACROSTR(HardWiredMonitor),
  203. MACROSTR(PreconfiguredMonitor),
  204. MACROSTR(CustomMonitor)
  205. };
  206. static char *EventTriggerEnumTypeStr[] = {
  207. MACROSTR(Alerting),
  208. MACROSTR(Delta),
  209. MACROSTR(Periodic)
  210. };
  211. static char *FirmwareStatusEnumTypeStr[] = {
  212. MACROSTR(Downloaded),
  213. MACROSTR(DownloadFailed),
  214. MACROSTR(Downloading),
  215. MACROSTR(DownloadScheduled),
  216. MACROSTR(DownloadPaused),
  217. MACROSTR(Idle),
  218. MACROSTR(InstallationFailed),
  219. MACROSTR(Installing),
  220. MACROSTR(Installed),
  221. MACROSTR(InstallRebooting),
  222. MACROSTR(InstallScheduled),
  223. MACROSTR(InstallVerificationFailed),
  224. MACROSTR(InvalidSignature),
  225. MACROSTR(SignatureVerified)
  226. };
  227. static char *GenericDeviceModelStatusEnumTypeStr[] = {
  228. MACROSTR(Accepted),
  229. MACROSTR(Rejected),
  230. MACROSTR(NotSupported),
  231. MACROSTR(EmptyResultSet)
  232. };
  233. static char *GenericStatusEnumTypeStr[] = {
  234. MACROSTR(Accepted),
  235. MACROSTR(Rejected)
  236. };
  237. static char *GetCertificateIdUseEnumTypeStr[] = {
  238. MACROSTR(V2GRootCertificate),
  239. MACROSTR(MORootCertificate),
  240. MACROSTR(CSMSRootCertificate),
  241. MACROSTR(V2GCertificateChain),
  242. MACROSTR(ManufacturerRootCertificate)
  243. };
  244. static char *GetCertificateStatusEnumTypeStr[] = {
  245. MACROSTR(Accepted),
  246. MACROSTR(Failed)
  247. };
  248. static char *GetChargingProfileStatusEnumTypeStr[] = {
  249. MACROSTR(Accepted),
  250. MACROSTR(NoProfiles)
  251. };
  252. static char *GetDisplayMessagesStatusEnumTypeStr[] = {
  253. MACROSTR(Accepted),
  254. MACROSTR(Unknown)
  255. };
  256. static char *GetInstalledCertificateStatusEnumTypeStr[] = {
  257. MACROSTR(Accepted),
  258. MACROSTR(NotFound)
  259. };
  260. static char *GetVariableStatusEnumTypeStr[] = {
  261. MACROSTR(Accepted),
  262. MACROSTR(Rejected),
  263. MACROSTR(UnknownComponent),
  264. MACROSTR(UnknownVariable),
  265. MACROSTR(NotSupportedAttributeType)
  266. };
  267. static char *HashAlgorithmEnumTypeStr[] = {
  268. MACROSTR(SHA256),
  269. MACROSTR(SHA384),
  270. MACROSTR(SHA512)
  271. };
  272. static char *IdTokenEnumTypeStr[] = {
  273. MACROSTR(Central),
  274. MACROSTR(eMAID),
  275. MACROSTR(ISO14443),
  276. MACROSTR(KeyCode),
  277. MACROSTR(Local),
  278. MACROSTR(NoAuthorization),
  279. MACROSTR(ISO15693)
  280. };
  281. static char *InstallCertificateUseEnumTypeStr[] = {
  282. MACROSTR(V2GRootCertificate),
  283. MACROSTR(MORootCertificate),
  284. MACROSTR(CSMSRootCertificate),
  285. MACROSTR(ManufacturerRootCertificate)
  286. };
  287. static char *InstallCertificateStatusEnumTypeStr[]={
  288. MACROSTR(Accepted),
  289. MACROSTR(Failed),
  290. MACROSTR(Rejected)
  291. };
  292. static char *Iso15118EVCertificateStatusEnumTypeStr[] = {
  293. MACROSTR(Accepted),
  294. MACROSTR(Failed)
  295. };
  296. static char *LocationEnumTypeStr[] = {
  297. MACROSTR(Body),
  298. MACROSTR(Cable),
  299. MACROSTR(EV),
  300. MACROSTR(Inlet),
  301. MACROSTR(Outlet)
  302. };
  303. static char *LogEnumTypeStr[] = {
  304. MACROSTR(DiagnosticsLog),
  305. MACROSTR(SecurityLog)
  306. };
  307. static char *LogStatusEnumTypeStr[] = {
  308. MACROSTR(Accepted),
  309. MACROSTR(Rejected),
  310. MACROSTR(AcceptedCanceled)
  311. };
  312. static char *MeasurandEnumTypeStr[] = {
  313. MACROSTR(Current.Export),
  314. MACROSTR(Current.Import),
  315. MACROSTR(Current.Offered),
  316. MACROSTR(Energy.Active.Export.Register),
  317. MACROSTR(Energy.Active.Import.Register),
  318. MACROSTR(Energy.Reactive.Export.Register),
  319. MACROSTR(Energy.Reactive.Import.Register),
  320. MACROSTR(Energy.Active.Export.Interval),
  321. MACROSTR(Energy.Active.Import.Interval),
  322. MACROSTR(Energy.Active.Net),
  323. MACROSTR(Energy.Reactive.Export.Interval),
  324. MACROSTR(Energy.Reactive.Import.Interval),
  325. MACROSTR(Energy.Reactive.Net),
  326. MACROSTR(Energy.Apparent.Net),
  327. MACROSTR(Energy.Apparent.Import),
  328. MACROSTR(Energy.Apparent.Export),
  329. MACROSTR(Frequency),
  330. MACROSTR(Power.Active.Export),
  331. MACROSTR(Power.Active.Import),
  332. MACROSTR(Power.Factor),
  333. MACROSTR(Power.Offered),
  334. MACROSTR(Power.Reactive.Export),
  335. MACROSTR(Power.Reactive.Import),
  336. MACROSTR(SoC),
  337. MACROSTR(Voltage)
  338. };
  339. static char *MessageFormatEnumTypeStr[] = {
  340. MACROSTR(ASCII),
  341. MACROSTR(HTML),
  342. MACROSTR(URI),
  343. MACROSTR(UTF8)
  344. };
  345. static char *MessagePriorityEnumTypeStr[] = {
  346. MACROSTR(AlwaysFront),
  347. MACROSTR(InFront),
  348. MACROSTR(NormalCycle)
  349. };
  350. static char *MessageStateEnumTypeStr[] = {
  351. MACROSTR(Charging),
  352. MACROSTR(Faulted),
  353. MACROSTR(Idle),
  354. MACROSTR(Unavailable)
  355. };
  356. static char *MessageTriggerEnumTypeStr[] = {
  357. MACROSTR(BootNotification),
  358. MACROSTR(LogStatusNotification),
  359. MACROSTR(FirmwareStatusNotification),
  360. MACROSTR(Heartbeat),
  361. MACROSTR(MeterValues),
  362. MACROSTR(SignChargingStationCertificate),
  363. MACROSTR(SignV2GCertificate),
  364. MACROSTR(StatusNotification),
  365. MACROSTR(TransactionEvent),
  366. MACROSTR(SignCombinedCertificate),
  367. MACROSTR(PublishFirmwareStatusNotification)
  368. };
  369. static char *MonitorEnumTypeStr[] = {
  370. MACROSTR(UpperThreshold),
  371. MACROSTR(LowerThreshold),
  372. MACROSTR(Delta),
  373. MACROSTR(Periodic),
  374. MACROSTR(PeriodicClockAligned)
  375. };
  376. static char *MonitoringBaseEnumTypeStr[] = {
  377. MACROSTR(All),
  378. MACROSTR(FactoryDefault),
  379. MACROSTR(HardWiredOnly)
  380. };
  381. static char *MonitoringCriterionEnumTypeStr[] = {
  382. MACROSTR(ThresholdMonitoring),
  383. MACROSTR(DeltaMonitoring),
  384. MACROSTR(PeriodicMonitoring)
  385. };
  386. static char *MutabilityEnumTypeStr[] = {
  387. MACROSTR(ReadOnly),
  388. MACROSTR(WriteOnly),
  389. MACROSTR(ReadWrite)
  390. };
  391. static char *NotifyEVChargingNeedsStatusEnumTypeStr[] = {
  392. MACROSTR(Accepted),
  393. MACROSTR(Rejected),
  394. MACROSTR(Processing)
  395. };
  396. static char *OCPPInterfaceEnumTypeStr[] = {
  397. MACROSTR(Wired0),
  398. MACROSTR(Wired1),
  399. MACROSTR(Wired2),
  400. MACROSTR(Wired3),
  401. MACROSTR(Wireless0),
  402. MACROSTR(Wireless1),
  403. MACROSTR(Wireless2),
  404. MACROSTR(Wireless3)
  405. };
  406. static char *OCPPTransportEnumTypeStr[] = {
  407. MACROSTR(JSON),
  408. MACROSTR(SOAP)
  409. };
  410. static char *OCPPVersionEnumTypeStr[] = {
  411. MACROSTR(OCPP12),
  412. MACROSTR(OCPP15),
  413. MACROSTR(OCPP16),
  414. MACROSTR(OCPP20)
  415. };
  416. static char *OperationalStatusEnumTypeStr[] = {
  417. MACROSTR(Inoperative),
  418. MACROSTR(Operative)
  419. };
  420. static char *PhaseEnumTypeStr[] = {
  421. MACROSTR(L1),
  422. MACROSTR(L2),
  423. MACROSTR(L3),
  424. MACROSTR(N),
  425. MACROSTR(L1-N),
  426. MACROSTR(L2-N),
  427. MACROSTR(L3-N),
  428. MACROSTR(L1-L2),
  429. MACROSTR(L2-L3),
  430. MACROSTR(L3-L1)
  431. };
  432. static char *PublishFirmwareStatusEnumTypeStr[] = {
  433. MACROSTR(Downloaded),
  434. MACROSTR(DownloadFailed),
  435. MACROSTR(Downloading),
  436. MACROSTR(DownloadScheduled),
  437. MACROSTR(DownloadPaused),
  438. MACROSTR(PublishFailed),
  439. MACROSTR(Published),
  440. MACROSTR(InvalidChecksum),
  441. MACROSTR(ChecksumVerified)
  442. };
  443. static char *ReadingContextEnumTypeStr[] = {
  444. MACROSTR(Interruption.Begin),
  445. MACROSTR(Interruption.End),
  446. MACROSTR(Other),
  447. MACROSTR(Sample.Clock),
  448. MACROSTR(Sample.Periodic),
  449. MACROSTR(Transaction.Begin),
  450. MACROSTR(Transaction.End),
  451. MACROSTR(Trigger)
  452. };
  453. static char *ReasonEnumTypeStr[] = {
  454. MACROSTR(DeAuthorized),
  455. MACROSTR(EmergencyStop),
  456. MACROSTR(EnergyLimitReached),
  457. MACROSTR(EVDisconnected),
  458. MACROSTR(GroundFault),
  459. MACROSTR(ImmediateReset),
  460. MACROSTR(Local),
  461. MACROSTR(LocalOutOfCredit),
  462. MACROSTR(MasterPass),
  463. MACROSTR(Other),
  464. MACROSTR(OvercurrentFault),
  465. MACROSTR(PowerLoss),
  466. MACROSTR(PowerQuality),
  467. MACROSTR(Reboot),
  468. MACROSTR(Remote),
  469. MACROSTR(SOCLimitReached),
  470. MACROSTR(StoppedByEV),
  471. MACROSTR(TimeLimitReached),
  472. MACROSTR(TimeLimitReached)
  473. };
  474. static char *RecurrencyKindEnumTypeStr[] = {
  475. MACROSTR(Daily),
  476. MACROSTR(Weekly)
  477. };
  478. static char *RegistrationStatusEnumTypeStr[] = {
  479. MACROSTR(Accepted),
  480. MACROSTR(Pending),
  481. MACROSTR(Rejected)
  482. };
  483. static char *ReportBaseEnumTypeStr[] = {
  484. MACROSTR(ConfigurationInventory),
  485. MACROSTR(FullInventory),
  486. MACROSTR(SummaryInventory)
  487. };
  488. static char *RequestStartStopStatusEnumTypeStr[] = {
  489. MACROSTR(Accepted),
  490. MACROSTR(Rejected)
  491. };
  492. static char *ReservationUpdateStatusEnumTypeStr[] = {
  493. MACROSTR(Expired),
  494. MACROSTR(Removed)
  495. };
  496. static char *ReserveNowStatusEnumTypeStr[] = {
  497. MACROSTR(Accepted),
  498. MACROSTR(Faulted),
  499. MACROSTR(Occupied),
  500. MACROSTR(Rejected),
  501. MACROSTR(Unavailable)
  502. };
  503. static char *ResetEnumTypeStr[] = {
  504. MACROSTR(Immediate),
  505. MACROSTR(OnIdle)
  506. };
  507. static char *ResetStatusEnumTypeStr[] = {
  508. MACROSTR(Accepted),
  509. MACROSTR(Rejected),
  510. MACROSTR(Scheduled)
  511. };
  512. static char *SetMonitoringStatusEnumTypeStr[] = {
  513. MACROSTR(Accepted),
  514. MACROSTR(UnknownComponent),
  515. MACROSTR(UnknownVariable),
  516. MACROSTR(UnsupportedMonitorType),
  517. MACROSTR(Rejected),
  518. MACROSTR(OutOfRange),
  519. MACROSTR(Duplicate)
  520. };
  521. static char *SetNetworkProfileStatusEnumTypeStr[] = {
  522. MACROSTR(Accepted),
  523. MACROSTR(Rejected),
  524. MACROSTR(Failed)
  525. };
  526. static char *SetVariableStatusEnumTypeStr[] = {
  527. MACROSTR(Accepted),
  528. MACROSTR(Rejected),
  529. MACROSTR(InvalidValue),
  530. MACROSTR(UnknownComponent),
  531. MACROSTR(UnknownVariable),
  532. MACROSTR(NotSupportedAttributeType),
  533. MACROSTR(OutOfRange),
  534. MACROSTR(RebootRequired)
  535. };
  536. static char *TransactionEventEnumTypeStr[] = {
  537. MACROSTR(Ended),
  538. MACROSTR(Started),
  539. MACROSTR(Updated)
  540. };
  541. static char *TriggerMessageStatusEnumTypeStr[] = {
  542. MACROSTR(Accepted),
  543. MACROSTR(Rejected),
  544. MACROSTR(NotImplemented)
  545. };
  546. static char *TriggerReasonEnumTypeStr[] = {
  547. MACROSTR(Authorized),
  548. MACROSTR(CablePluggedIn),
  549. MACROSTR(ChargingRateChanged),
  550. MACROSTR(ChargingStateChanged),
  551. MACROSTR(Deauthorized),
  552. MACROSTR(EnergyLimitReached),
  553. MACROSTR(EVCommunicationLost),
  554. MACROSTR(EVConnectTimeout),
  555. MACROSTR(MeterValueClock),
  556. MACROSTR(MeterValuePeriodic),
  557. MACROSTR(TimeLimitReached),
  558. MACROSTR(Trigger),
  559. MACROSTR(UnlockCommand),
  560. MACROSTR(StopAuthorized),
  561. MACROSTR(EVDeparted),
  562. MACROSTR(EVDetected),
  563. MACROSTR(RemoteStop),
  564. MACROSTR(RemoteStart),
  565. MACROSTR(AbnormalCondition),
  566. MACROSTR(SignedDataReceived),
  567. MACROSTR(ResetCommand)
  568. };
  569. static char *UnlockStatusEnumTypeStr[] = {
  570. MACROSTR(Unlocked),
  571. MACROSTR(UnlockFailed),
  572. MACROSTR(OngoingAuthorizedTransaction),
  573. MACROSTR(UnknownConnector)
  574. };
  575. static char *UnpublishFirmwareStatusEnumTypeStr[] = {
  576. MACROSTR(DownloadOngoing),
  577. MACROSTR(NoFirmware),
  578. MACROSTR(Unpublished)
  579. };
  580. static char *UpdateEnumTypeStr[] = {
  581. MACROSTR(Differential),
  582. MACROSTR(Full)
  583. };
  584. static char *UpdateFirmwareStatusEnumTypeStr[] = {
  585. MACROSTR(Accepted),
  586. MACROSTR(Rejected),
  587. MACROSTR(AcceptedCanceled),
  588. MACROSTR(InvalidCertificate),
  589. MACROSTR(RevokedCertificate)
  590. };
  591. static char *UpdateStatusEnumTypeStr[] = {
  592. MACROSTR(Accepted),
  593. MACROSTR(Failed),
  594. MACROSTR(VersionMismatch)
  595. };
  596. static char *UploadLogStatusEnumTypeStr[] = {
  597. MACROSTR(BadMessage),
  598. MACROSTR(Idle),
  599. MACROSTR(NotSupportedOperation),
  600. MACROSTR(PermissionDenied),
  601. MACROSTR(Uploaded),
  602. MACROSTR(UploadFailure),
  603. MACROSTR(Uploading)
  604. };
  605. static char *VPNEnumTypeStr[] = {
  606. MACROSTR(IKEv2),
  607. MACROSTR(IPSec),
  608. MACROSTR(L2TP),
  609. MACROSTR(PPTP)
  610. };
  611. #if 0
  612. static char *ChargePointErrorCodeEnumTypeStr[] = {
  613. MACROSTR(ConnectorLockFailure),
  614. MACROSTR(EVCommunicationError),
  615. MACROSTR(GroundFailure),
  616. MACROSTR(HighTemperature),
  617. MACROSTR(InternalError),
  618. MACROSTR(LocalListConflict),
  619. MACROSTR(NoError),
  620. MACROSTR(OtherError),
  621. MACROSTR(OverCurrentFailure),
  622. MACROSTR(OverVoltage),
  623. MACROSTR(PowerMeterFailure),
  624. MACROSTR(PowerSwitchFailure),
  625. MACROSTR(ReaderFailure),
  626. MACROSTR(ResetFailure),
  627. MACROSTR(UnderVoltage),
  628. MACROSTR(WeakSignal)
  629. };
  630. #endif
  631. static char *GetCompositeScheduleStatusEnumTypeStr[] = {
  632. MACROSTR(Accepted),
  633. MACROSTR(Rejected)
  634. };
  635. static char *RemoteStartStopStatusEnumTypeStr[] = {
  636. MACROSTR(Accepted),
  637. MACROSTR(Rejected)
  638. };
  639. static char *ReservationStatusEnumTypeStr[] = {
  640. MACROSTR(Accepted),
  641. MACROSTR(Faulted),
  642. MACROSTR(Occupied),
  643. MACROSTR(Rejected),
  644. MACROSTR(Unavailable)
  645. };
  646. #if 0
  647. static char * StopTransactionReasonEnumTypeStr[] = {
  648. MACROSTR(EmergencyStop),
  649. MACROSTR(EVDisconnected),
  650. MACROSTR(HardReset),
  651. MACROSTR(Local),
  652. MACROSTR(Other),
  653. MACROSTR(PowerLoss),
  654. MACROSTR(Reboot),
  655. MACROSTR(Remote),
  656. MACROSTR(SoftReset),
  657. MACROSTR(UnlockCommand),
  658. MACROSTR(DeAuthorized)
  659. };
  660. #endif
  661. //ChargePointMaxProfile
  662. #define ChargePointMaxProfile_JSON "/Storage/OCPP/ChargePointMaxProfile_OCPP20.json"
  663. //TxDefaultProfile
  664. #define TxDefaultProfile_0_JSON "/Storage/OCPP/TxDefaultProfile_0_OCPP20.json"
  665. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  666. struct StatusCodeData *ShmStatusCodeData;
  667. struct PsuData *ShmPsuData ;
  668. struct OCPP20Data *ShmOCPP20Data;
  669. pthread_mutex_t lock_send = PTHREAD_MUTEX_INITIALIZER;
  670. char queuedata[QUEUE_MESSAGE_LENGTH] = {0};
  671. //===============================
  672. // Gun Total Numbers
  673. //===============================
  674. static int gunTotalNumber = 0;
  675. static uint8_t gunType[4] = {0};
  676. //===============================
  677. // Local List Version
  678. //===============================
  679. static int localversion=0;
  680. //===============================
  681. // OCPP sign variable
  682. //===============================
  683. static int server_sign = FALSE;
  684. int server_pending = FALSE;
  685. static int BootNotificationInterval = 0;
  686. static int SystemInitial = 0;//= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY; // System Boot UP
  687. //===============================
  688. // OCPP auth variable
  689. //===============================
  690. static int authorizeRetryTimes = 0; //number of Retry times
  691. //===============================
  692. // OCPP other variables
  693. //===============================
  694. static int HeartBeatWaitTime = 10;
  695. static int FirstHeartBeat = 0;
  696. static int FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  697. static int LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  698. static char CurrentChargingProfileScheduleStr[30] = {0};
  699. //========================================
  700. // OCPP status/previous related variables
  701. //========================================
  702. static int GunStatusInterval = 10;
  703. static uint8_t ChademoPreviousSystemStatus[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  704. static uint8_t CcsPreviousSystemStatus[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  705. static uint8_t GbPreviousSystemStatus[(GB_QUANTITY>0?GB_QUANTITY:1)];
  706. static uint8_t AcPreviousSystemStatus[(AC_QUANTITY>0?AC_QUANTITY:1)];
  707. static uint8_t DoPreviousSystemStatus[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  708. static uint8_t ChademoPreviousConnectorPlugIn[(CHAdeMO_QUANTITY>0?CHAdeMO_QUANTITY:1)];
  709. static uint8_t CcsPreviousConnectorPlugIn[(CCS_QUANTITY>0?CCS_QUANTITY:1)];
  710. static uint8_t GbPreviousConnectorPlugIn[(GB_QUANTITY>0?GB_QUANTITY:1)];
  711. static uint8_t AcPreviousConnectorPlugIn[(AC_QUANTITY>0?AC_QUANTITY:1)];
  712. static uint8_t DoPreviousConnectorPlugIn[(CONNECTOR_QUANTITY>0?CONNECTOR_QUANTITY:1)];
  713. static int TransactionMessageAttemptsValue = 0;
  714. static int TransactionMessageRetryIntervalValue = 0;
  715. static int TempMeterValueInterval = 0;
  716. static struct AuthorizationData idTagQuery;
  717. //=============================================
  718. // OCPP HeartBeat Response Not Receive Counts
  719. //============================================
  720. static int HeartBeatWithNOResponse = 0;
  721. static int HeartBeatCountPerHour = 0;
  722. sqlite3 *db;
  723. int TransactionMessageAttemptsGet(void);
  724. int TransactionMessageRetryIntervalGet(void);
  725. int GetOcppConnStatus(void);
  726. void SetOcppConnStatus(uint8_t status);
  727. int setKeyValue(char *key, char *value);
  728. void OCPP_get_TableAuthlocalAllData(void);
  729. void processUnkownKey(void);
  730. struct StructOCPPMeterValue
  731. {
  732. unsigned char TimeStamp[28];
  733. struct StructSampledValue SampledValue[10];
  734. };
  735. struct ClientTime
  736. {
  737. unsigned int Heartbeat;
  738. unsigned int StatusNotification[CONNECTOR_QUANTITY];
  739. unsigned int StartTransaction;
  740. unsigned int StopTransaction;
  741. unsigned int MeterValues[CONNECTOR_QUANTITY];
  742. }clientTime;
  743. typedef union
  744. {
  745. //Operations Initiated by Central System
  746. unsigned char CsMsgValue[CONNECTOR_QUANTITY];
  747. struct
  748. {
  749. //CsMsgValue[0]
  750. unsigned char StatusNotificationReq:1; //bit 0,
  751. unsigned char StatusNotificationConf:1; //bit 1,
  752. unsigned char TriggerMeterValueReq:1; //bit 2,
  753. unsigned char TransactionEventReq:1; //bit 3,
  754. unsigned char SampleMeterReq:1; //bit 4,
  755. unsigned char ClockAlignMeterReq:1; //bit 5,
  756. unsigned char :2;
  757. }bits[CONNECTOR_QUANTITY];
  758. }CpinitiateMsg;
  759. CpinitiateMsg cpinitateMsg;
  760. //=========================================
  761. // Date time related function
  762. //=========================================
  763. void getNowDatetime(uint8_t *data)
  764. {
  765. time_t t = time(NULL);
  766. struct tm tm = *localtime(&t);
  767. 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);
  768. }
  769. //=========================================
  770. // Sqlite3 related function
  771. //=========================================
  772. int DB_Initial()
  773. {
  774. int result = PASS;
  775. char* errMsg = NULL;
  776. char *sqlOcppAuthCache = "create table if not exists ocpp20_auth_cache (idx integer primary key,"
  777. "idToken text UNIQUE,"
  778. "type text,"
  779. "status text,"
  780. "cacheExpiryDateTime text,"
  781. "chargingPriority integer,"
  782. "language1 text,"
  783. "evseId text,"
  784. "language2 text,"
  785. "groupIdToken_idToken text,"
  786. "groupIdToken_type text,"
  787. "personalMessage text);";
  788. char *sqlOcppAuthLocal = "create table if not exists ocpp20_auth_local (idx integer primary key,"
  789. "idToken text UNIQUE,"
  790. "type text,"
  791. "status text,"
  792. "cacheExpiryDateTime text,"
  793. "chargingPriority integer,"
  794. "language1 text,"
  795. "evseId text,"
  796. "language2 text,"
  797. "groupIdToken_idToken text,"
  798. "groupIdToken_type text,"
  799. "personalMessage text,"
  800. "version text);";
  801. char *sqlOcppVariable = "create table if not exists ocpp20_variable (idx integer primary key,"
  802. "componentName text NOT NULL ,"
  803. "componentInstance text, "
  804. "variableName text NOT NULL, "
  805. "variableInstance text, "
  806. "variableCharacteristicsDataType integer, "
  807. "variableCharacteristicsUnit text, "
  808. "variableCharacteristicsMaxLimit real,"
  809. "variableAttributesType text, "
  810. "variableAttributesTypeMutability text, "
  811. "variableAttributesTypeValue text, "
  812. "unique(componentName, componentInstance,variableName, variableInstance) on conflict replace);";
  813. char *sqlBootType = "create table if not exists ocpp20_boot_type (idx integer primary key,"
  814. "type);";
  815. //sqlite3_config(SQLITE_CONFIG_URI, 1);
  816. if(sqlite3_open(OCPP_LOCAL_DB_FILE, &db))
  817. {
  818. result = FAIL;
  819. DEBUG_ERROR( "Can't open database: %s\n", sqlite3_errmsg(db));
  820. sqlite3_close(db);
  821. }
  822. else
  823. {
  824. DEBUG_INFO( "OCPP local database open successfully.\n");
  825. if (sqlite3_exec(db, sqlOcppAuthCache, 0, 0, &errMsg) != SQLITE_OK)
  826. {
  827. result = FAIL;
  828. DEBUG_ERROR( "Create OCPP 2.0 auth cache table error message: %s\n", errMsg);
  829. }
  830. else
  831. {
  832. DEBUG_INFO( "Create OCPP 2.0 auth cache table table successfully\n");
  833. }
  834. if (sqlite3_exec(db, sqlOcppAuthLocal, 0, 0, &errMsg) != SQLITE_OK)
  835. {
  836. result = FAIL;
  837. DEBUG_ERROR( "Create OCPP 2.0 auth list table error message: %s\n", errMsg);
  838. }
  839. else
  840. {
  841. DEBUG_INFO( "Create OCPP 2.0 auth list table successfully\n");
  842. }
  843. if (sqlite3_exec(db, sqlOcppVariable, 0, 0, &errMsg) != SQLITE_OK)
  844. {
  845. result = FAIL;
  846. DEBUG_ERROR( "Create OCPP 2.0 variable table error message: %s\n", errMsg);
  847. }
  848. else
  849. {
  850. DEBUG_INFO( "Create OCPP 2.0 variable table successfully\n");
  851. }
  852. if (sqlite3_exec(db, sqlBootType, 0, 0, &errMsg) != SQLITE_OK)
  853. {
  854. result = FAIL;
  855. DEBUG_ERROR( "Create OCPP 2.0 boot_type table error message: %s\n", errMsg);
  856. }
  857. else
  858. {
  859. DEBUG_INFO( "Create OCPP 2.0 boot_type table successfully\n");
  860. }
  861. //sqlite3_close(db);
  862. }
  863. return result;
  864. }
  865. int versionCallback(void *para, int columnCount, char **columnValue, char **columnName)
  866. {
  867. localversion = columnValue[12] ? atoi(columnValue[12]) : 0;
  868. return 0;
  869. }
  870. void DB_getListVerion()
  871. {
  872. char sql[256];
  873. char* errMsg = NULL;
  874. strcpy(sql, "select * from ocpp20_auth_local order by version desc, idx desc limit 1");
  875. /* Execute SQL statement */
  876. if( sqlite3_exec(db, sql, versionCallback, 0, &errMsg) != SQLITE_OK )
  877. {
  878. DEBUG_INFO("SQL error: %s", errMsg);
  879. }
  880. }
  881. int IdTagCallback(void *para, int columnCount, char **columnValue, char **columnName)
  882. {
  883. sprintf((char*)idTagQuery.idToken.idToken,"%s", columnValue[1] ? columnValue[1] : "NULL");
  884. sprintf((char*)idTagQuery.idToken.type,"%s", columnValue[2] ? columnValue[2] : "NULL");
  885. sprintf((char*)idTagQuery.idTokenInfo.status,"%s", columnValue[3] ? columnValue[3] : "NULL");
  886. sprintf((char*)idTagQuery.idTokenInfo.cacheExpiryDateTime,"%s", columnValue[4] ? columnValue[4] : "NULL");
  887. idTagQuery.idTokenInfo.chargingPriority = columnValue[5] ? atoi(columnValue[5]) : -1;
  888. sprintf((char*)idTagQuery.idTokenInfo.language1,"%s", columnValue[6] ? columnValue[6] : "NULL");
  889. sprintf((char*)idTagQuery.idTokenInfo.language2,"%s", columnValue[8] ? columnValue[8] : "NULL");
  890. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.idToken,"%s", columnValue[9] ? columnValue[9] : "NULL");
  891. sprintf((char*)idTagQuery.idTokenInfo.groupIdToken.type,"%s", columnValue[10] ? columnValue[10] : "NULL");
  892. return 0;
  893. }
  894. void DB_getIdTag(char idTag[], uint8_t isQueryFromCache)
  895. {
  896. char sql[256];
  897. char* errMsg = NULL;
  898. memset(&idTagQuery, 0, sizeof(idTagQuery));
  899. //DEBUG_INFO("look up card: %s in ocpp_auth_local table", idTag);
  900. if(isQueryFromCache)
  901. sprintf(sql,"select * from ocpp20_auth_cache where idToken='%s'", idTag);
  902. else
  903. sprintf(sql,"select * from ocpp20_auth_local where idToken='%s'", idTag);
  904. /* Execute SQL statement */
  905. if(sqlite3_exec(db, sql, IdTagCallback, 0, &errMsg) != SQLITE_OK )
  906. {
  907. DEBUG_INFO("SQL error: %s", errMsg);
  908. }
  909. }
  910. int sqlite3_exec_callback(void *para, int columnCount, char **columnValue, char **columnName)
  911. {
  912. for (int i = 0; i < columnCount; i++)
  913. {
  914. DEBUG_INFO("%s = %s, ", columnName[i], columnValue[i]);
  915. }
  916. return 0;
  917. }
  918. void DB_get_TableAuthlocalAllData(void)
  919. {
  920. char sql[256];
  921. char* errMsg = NULL;
  922. sprintf(sql,"select * from ocpp20_auth_local;");
  923. /* Execute SQL statement */
  924. if(sqlite3_exec(db, sql, &sqlite3_exec_callback, 0,(char **)&errMsg) != SQLITE_OK)
  925. {
  926. DEBUG_INFO("SQL error: %s", errMsg);
  927. }
  928. }
  929. int listCallback(void *para, int columnCount, char **columnValue, char **columnName)
  930. {
  931. for(int i = 0; i<columnCount; i++)
  932. {
  933. // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
  934. }
  935. return 0;
  936. }
  937. int DB_addLocalList(int listVersion, struct AuthorizationData *data)
  938. {
  939. int result = PASS;
  940. char sql[512];
  941. char* errMsg = NULL;
  942. 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;",
  943. data->idToken.idToken,
  944. data->idToken.type,
  945. data->idTokenInfo.status,
  946. data->idTokenInfo.cacheExpiryDateTime,
  947. data->idTokenInfo.chargingPriority,
  948. data->idTokenInfo.language1,
  949. data->idTokenInfo.language2,
  950. data->idTokenInfo.groupIdToken.idToken,
  951. data->idTokenInfo.groupIdToken.type,
  952. listVersion);
  953. //* Execute SQL statement */
  954. if(sqlite3_exec(db, sql, listCallback, 0, &errMsg) != SQLITE_OK)
  955. {
  956. DEBUG_INFO("SQL error: %s\n", errMsg);
  957. result = FAIL;
  958. }
  959. else
  960. {
  961. memset(sql, 0, ARRAY_SIZE(sql));
  962. sprintf(sql, "UPDATE ocpp20_auth_local SET version=%d",listVersion);
  963. if( sqlite3_exec(db, sql, NULL, NULL, &errMsg) != SQLITE_OK )
  964. {
  965. DEBUG_INFO("SQL error: %s\n", errMsg);
  966. result = FAIL;
  967. }
  968. }
  969. return result;
  970. }
  971. int DB_addLocalCache(struct IdTokenType *idToken, struct IdTokenInfoType *idTokenInfo)
  972. {
  973. int result = PASS;
  974. char sql[512];
  975. char* errMsg = NULL;
  976. 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;",
  977. idToken->idToken,
  978. idToken->type,
  979. idTokenInfo->status,
  980. idTokenInfo->cacheExpiryDateTime,
  981. idTokenInfo->chargingPriority,
  982. idTokenInfo->language1,
  983. idTokenInfo->language2,
  984. idTokenInfo->groupIdToken.idToken,
  985. idTokenInfo->groupIdToken.type);
  986. //* Execute SQL statement */
  987. if(sqlite3_exec(db, sql, listCallback, 0, &errMsg) != SQLITE_OK)
  988. {
  989. DEBUG_INFO("SQL error: %s\n", errMsg);
  990. result = FAIL;
  991. }
  992. return result;
  993. }
  994. static int deleteIdTagcallback(void *para, int columnCount, char **columnValue, char **columnName)
  995. {
  996. // localversion = argv[5] ? atoi(columnValue[5]) : 0;
  997. // printf("localversion=%d\n", localversion);
  998. return 0;
  999. }
  1000. void DB_deleteIdTag(char idTag[])
  1001. {
  1002. char sql[512];
  1003. char* errMsg = NULL;
  1004. sprintf(sql,"DELETE from ocpp20_auth_local where idToken='%s'; SELECT * from ocpp20_auth_local;", idTag);
  1005. //* Execute SQL statement */
  1006. if( sqlite3_exec(db, sql, deleteIdTagcallback, 0, &errMsg) != SQLITE_OK )
  1007. {
  1008. DEBUG_INFO("SQL error: %s", errMsg);
  1009. }
  1010. }
  1011. int DB_cleanLocalList()
  1012. {
  1013. int result = PASS;
  1014. char * sqlcleanLocalList = "delete from ocpp20_auth_cache";
  1015. char *errMsg = 0;
  1016. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1017. {
  1018. DEBUG_INFO("%s\n", errMsg);
  1019. result = FAIL;
  1020. }
  1021. return result;
  1022. }
  1023. int DB_cleanLocalCache()
  1024. {
  1025. int result = PASS;
  1026. char * sqlcleanLocalList = "delete from ocpp20_auth_local";
  1027. char *errMsg = 0;
  1028. if (sqlite3_exec(db, sqlcleanLocalList, 0, 0, &errMsg) != SQLITE_OK)
  1029. {
  1030. DEBUG_INFO("%s\n", errMsg);
  1031. result = FAIL;
  1032. }
  1033. return result;
  1034. }
  1035. int BootTypecallback(void *para, int columnCount, char **columnValue, char **columnName)
  1036. {
  1037. sprintf((char*)ShmOCPP20Data->BootNotification.reason,"%s", columnValue[1] ? columnValue[1] : BootReasonEnumTypeStr[BootReasonEnumType_PowerUp]);
  1038. return 0;
  1039. }
  1040. void DB_getBooType()
  1041. {
  1042. char sql[256];
  1043. char* errMsg = NULL;
  1044. sprintf(sql,"select * from ocpp20_boot_type;");
  1045. /* Execute SQL statement */
  1046. if(sqlite3_exec(db, sql, BootTypecallback, 0, &errMsg) != SQLITE_OK )
  1047. {
  1048. DEBUG_INFO("SQL error: %s\n", errMsg);
  1049. }
  1050. }
  1051. int DB_updateBootType(BootReasonEnumType reason)
  1052. {
  1053. int result = PASS;
  1054. char sql[512];
  1055. char* errMsg = NULL;
  1056. sprintf(sql,"insert or replace into ocpp20_boot_type (idx, type) VALUES(1, '%s');", BootReasonEnumTypeStr[reason>BootReasonEnumType_Watchdog?BootReasonEnumType_PowerUp:reason]);
  1057. //* Execute SQL statement */
  1058. if(sqlite3_exec(db, sql, listCallback, 0, &errMsg) != SQLITE_OK)
  1059. {
  1060. DEBUG_INFO("SQL error: %s\n", errMsg);
  1061. result = FAIL;
  1062. }
  1063. return result;
  1064. }
  1065. uint8_t DB_variableSaveToDb(struct ReportDataType *variable)
  1066. {
  1067. uint8_t result = FAIL;
  1068. char sql[4096];
  1069. char* errMsg = NULL;
  1070. 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;",
  1071. variable->component.name,
  1072. variable->component.instance,
  1073. variable->variable.name,
  1074. variable->variable.instance,
  1075. variable->variableCharacteristics.dataType,
  1076. variable->variableCharacteristics.unit,
  1077. variable->variableCharacteristics.maxLimit,
  1078. variable->variableAttribute[0].type,
  1079. variable->variableAttribute[0].mutability,
  1080. variable->variableAttribute[0].value);
  1081. //* Execute SQL statement */
  1082. if(sqlite3_exec(db, sql, listCallback, 0, &errMsg) != SQLITE_OK)
  1083. {
  1084. DEBUG_INFO("SQL error: %s\n", errMsg);
  1085. result = FAIL;
  1086. }
  1087. return result;
  1088. }
  1089. int cbVariableIsCreate(void *para, int columnCount, char **columnValue, char **columnName)
  1090. {
  1091. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0x00, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  1092. if(atoi(columnValue[0]) == 0)
  1093. {
  1094. DB_updateBootType(BootReasonEnumType_PowerUp);
  1095. // Create variable table content
  1096. /* AlignedDataCtrlr Required item */
  1097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  1098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  1099. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1103. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled]);
  1104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  1105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  1106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1110. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available]);
  1111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  1112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  1113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1116. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1117. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1118. else
  1119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1120. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands]);
  1121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  1122. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  1123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.unit, "Seconds");
  1124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variableAttribute[0].value, "0");
  1128. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval]);
  1129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  1130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  1131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1133. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variableAttribute[0].value, "TRUE");
  1135. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle]);
  1136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  1137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  1138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1142. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings]);
  1143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  1144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1148. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage,SOC");
  1150. else
  1151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, "Current.Import,Energy.Active.Import.Register,Energy.Active.Import.Interval,Power.Active.Import,Voltage");
  1152. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands]);
  1153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  1154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1157. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1160. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval]);
  1161. /* AuthCtrlrVariable Required item */
  1162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  1163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  1164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1168. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled]);
  1169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  1170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  1171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variableAttribute[0].value, "0");
  1175. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage]);
  1176. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  1177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  1178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "FALSE");
  1182. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled]);
  1183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  1184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  1185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variableAttribute[0].value, "FALSE");
  1189. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart]);
  1190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  1191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  1192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE");
  1196. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline]);
  1197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  1198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  1199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE");
  1203. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize]);
  1204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  1205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  1206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1207. ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableCharacteristics.maxLimit = 36;
  1208. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variableAttribute[0].value, " ");
  1211. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId]);
  1212. /* AuthCacheCtrlr Variable Required item*/
  1213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  1214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  1215. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1219. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled]);
  1220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  1221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  1222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variableAttribute[0].value, "TRUE");
  1226. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available]);
  1227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  1228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  1229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.unit, "Seconds");
  1230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1232. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variableAttribute[0].value, "TRUE");
  1234. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime]);
  1235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  1236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  1237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1238. ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableCharacteristics.maxLimit = (1024*100);
  1239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variableAttribute[0].value, "TRUE");
  1242. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage]);
  1243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  1244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  1245. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variableAttribute[0].value, "LRU,LFU");
  1249. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy]);
  1250. /* ClockCtrlr Variable Required item */
  1251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  1252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  1253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1256. getNowDatetime(ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variableAttribute[0].value);
  1257. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime]);
  1258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  1259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  1260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variableAttribute[0].value, "DHCP, manual");
  1264. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource]);
  1265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  1266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  1267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  1268. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variableAttribute[0].value, " ");
  1272. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri]);
  1273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  1274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  1275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variableAttribute[0].value, "+00:00");
  1279. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset]);
  1280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  1281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  1282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_dateTime]);
  1283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variableAttribute[0].value, " ");
  1286. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime]);
  1287. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  1288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  1289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  1290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variableAttribute[0].value, "+00:00");
  1294. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset]);
  1295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  1296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  1297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variableAttribute[0].value, "Heartbeat,RealTimeClock");
  1301. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource]);
  1302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  1303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  1304. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1305. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1306. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1307. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variableAttribute[0].value, "UTC");
  1308. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone]);
  1309. /* ChargingStation Required item */
  1310. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  1311. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  1312. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1313. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1314. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1315. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variableAttribute[0].value, "FALSE");
  1316. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available]);
  1317. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  1318. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  1319. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1320. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1321. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1322. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1323. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState]);
  1324. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  1325. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  1326. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1329. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variableAttribute[0].value, "3");
  1330. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases]);
  1331. /* Connector Required item */
  1332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  1333. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  1334. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1335. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1336. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1337. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variableAttribute[0].value, "FALSE");
  1338. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_Available]);
  1339. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  1340. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  1341. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1342. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1343. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1344. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variableAttribute[0].value, " ");
  1345. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType]);
  1346. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  1347. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  1348. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1349. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1350. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1351. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variableAttribute[0].value, "3");
  1352. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases]);
  1353. /* CustomizationCtrlr Required item */
  1354. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].component.name, "CustomizationCtrlr");
  1355. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variable.name, "CustomImplementationEnabled");
  1356. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1357. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1358. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1359. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled].variableAttribute[0].value, "FALSE");
  1360. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[CustomizationCtrlr_CustomImplementationEnabled]);
  1361. /* DeviceDataCtrlr Required item */
  1362. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1363. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  1364. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1365. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1366. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1367. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1368. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variableAttribute[0].value, "10");
  1369. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage]);
  1370. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1371. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  1372. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1373. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1374. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1375. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1376. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1377. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage]);
  1378. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1379. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  1380. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  1381. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1382. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1383. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1384. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variableAttribute[0].value, "2048");
  1385. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage]);
  1386. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1387. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  1388. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1389. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1390. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1391. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1392. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1393. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage]);
  1394. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  1395. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  1396. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.maxLimit = 1000;
  1397. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1398. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1399. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1400. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variableAttribute[0].value, "10");
  1401. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize]);
  1402. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  1403. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  1404. ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.maxLimit = 2500;
  1405. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1406. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1407. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1408. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variableAttribute[0].value, "10");
  1409. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize]);
  1410. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  1411. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  1412. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1413. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1414. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1415. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1416. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variableAttribute[0].value, "10");
  1417. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage]);
  1418. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  1419. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  1420. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  1421. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1422. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1423. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1424. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variableAttribute[0].value, "2048");
  1425. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage]);
  1426. /* DisplayMessageCtrlr Required item */
  1427. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  1428. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  1429. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1430. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1431. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1432. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1433. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled]);
  1434. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  1435. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  1436. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1437. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1438. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1439. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variableAttribute[0].value, "FALSE");
  1440. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available]);
  1441. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  1442. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  1443. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1444. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1445. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1446. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variableAttribute[0].value, "%s", "0");
  1447. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages]);
  1448. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  1449. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  1450. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1451. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1452. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1453. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variableAttribute[0].value, " ");
  1454. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats]);
  1455. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  1456. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  1457. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1458. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1459. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1460. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variableAttribute[0].value, " ");
  1461. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities]);
  1462. /* EVSE Required item */
  1463. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  1464. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  1465. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1466. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1467. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1468. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variableAttribute[0].value, "FALSE");
  1469. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Available]);
  1470. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  1471. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  1472. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1473. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1474. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1475. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variableAttribute[0].value, "Available,Occupied,Reserved,Unavailable,Faulted");
  1476. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState]);
  1477. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  1478. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  1479. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1480. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1481. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1482. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variableAttribute[0].value, "3");
  1483. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases]);
  1484. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  1485. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  1486. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1487. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1488. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1489. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variableAttribute[0].value, "7700");
  1490. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[EVSE_Power]);
  1491. /* LocalAuthListCtrlr Required item */
  1492. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  1493. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  1494. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1495. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1496. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1497. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1498. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled]);
  1499. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  1500. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  1501. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1502. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1503. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1504. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variableAttribute[0].value, "5000");
  1505. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries]);
  1506. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  1507. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  1508. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1509. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1510. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1511. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variableAttribute[0].value, "TRUE");
  1512. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available]);
  1513. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  1514. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1515. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  1516. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1517. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1518. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1519. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variableAttribute[0].value, "50");
  1520. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage]);
  1521. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  1522. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  1523. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  1524. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1525. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1526. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1527. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variableAttribute[0].value, "2048");
  1528. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage]);
  1529. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  1530. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  1531. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1532. ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableCharacteristics.maxLimit = 1024*1024;
  1533. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1534. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1535. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variableAttribute[0].value, "5000");
  1536. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage]);
  1537. /* MonitoringCtrlr Required item */
  1538. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  1539. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  1540. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1541. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1542. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1543. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variableAttribute[0].value, "FALSE");
  1544. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled]);
  1545. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  1546. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  1547. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1548. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1549. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1550. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variableAttribute[0].value, "FALSE");
  1551. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available]);
  1552. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1553. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  1554. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1555. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1556. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1557. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1558. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1559. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage]);
  1560. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  1561. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  1562. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  1563. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1564. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1565. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1566. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variableAttribute[0].value, "1");
  1567. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage]);
  1568. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1569. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  1570. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1571. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1572. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1573. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1574. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1575. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage]);
  1576. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  1577. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  1578. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  1579. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1580. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1581. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1582. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variableAttribute[0].value, "2048");
  1583. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage]);
  1584. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  1585. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  1586. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1587. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1588. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1589. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variableAttribute[0].value, "2048");
  1590. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity]);
  1591. /* OCPPCommCtrlr Required item */
  1592. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  1593. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  1594. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1595. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1596. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1597. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variableAttribute[0].value, "1");
  1598. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile]);
  1599. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  1600. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  1601. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  1602. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.unit, "Seconds");
  1603. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1604. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1605. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1606. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variableAttribute[0].value, "30");
  1607. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout]);
  1608. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  1609. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  1610. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1611. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1612. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1613. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variableAttribute[0].value, "FTP,FTPS,HTTP,HTTPS");
  1614. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols]);
  1615. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  1616. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  1617. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.unit, "Seconds");
  1618. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1619. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1620. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1621. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value, "30");
  1622. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval]);
  1623. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  1624. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  1625. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_SequenceList]);
  1626. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1627. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1628. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variableAttribute[0].value, "LAN,WIFI,4G");
  1629. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority]);
  1630. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  1631. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  1632. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1633. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1634. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1635. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variableAttribute[0].value, "3");
  1636. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts]);
  1637. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  1638. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  1639. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.unit, "Seconds");
  1640. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1641. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1642. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1643. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variableAttribute[0].value, "30");
  1644. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold]);
  1645. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  1646. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  1647. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1648. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1649. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1650. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variableAttribute[0].value, "FALSE");
  1651. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages]);
  1652. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  1653. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  1654. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  1655. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.unit, "Seconds");
  1656. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1657. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1658. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1659. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value, "3");
  1660. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts]);
  1661. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  1662. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  1663. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  1664. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.unit, "Seconds");
  1665. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1666. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1667. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1668. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value, "3");
  1669. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval]);
  1670. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  1671. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  1672. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1673. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1674. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1675. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1676. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect]);
  1677. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  1678. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  1679. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.unit, "Seconds");
  1680. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1681. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1682. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1683. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value, "30");
  1684. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval]);
  1685. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  1686. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  1687. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1688. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1689. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1690. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variableAttribute[0].value, "3");
  1691. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries]);
  1692. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  1693. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  1694. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1695. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1696. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1697. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variableAttribute[0].value, "Never,OncePerTransaction,EveryMeterValue");
  1698. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue]);
  1699. /* ReservationCtrlr Required item */
  1700. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  1701. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  1702. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1703. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1704. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1705. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1706. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled]);
  1707. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  1708. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  1709. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1710. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1711. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1712. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variableAttribute[0].value, "TRUE");
  1713. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available]);
  1714. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  1715. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  1716. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1717. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1718. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1719. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variableAttribute[0].value, "FALSE");
  1720. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific]);
  1721. /* SampledDataCtrlr Required item */
  1722. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  1723. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  1724. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1725. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1726. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1727. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1728. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled]);
  1729. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  1730. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  1731. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1732. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1733. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1734. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variableAttribute[0].value, "TRUE");
  1735. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available]);
  1736. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  1737. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  1738. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1739. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1740. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1741. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variableAttribute[0].value, "FALSE");
  1742. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings]);
  1743. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  1744. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  1745. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1746. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1747. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1748. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variableAttribute[0].value, " ");
  1749. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands]);
  1750. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  1751. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  1752. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.unit, "Seconds");
  1753. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1754. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1755. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1756. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variableAttribute[0].value, "0");
  1757. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval]);
  1758. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  1759. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  1760. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1761. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1762. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1763. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variableAttribute[0].value, " ");
  1764. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands]);
  1765. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  1766. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  1767. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1768. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1769. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1770. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variableAttribute[0].value, " ");
  1771. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands]);
  1772. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  1773. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  1774. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.unit, "Seconds");
  1775. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1776. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1777. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1778. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value, "0");
  1779. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval]);
  1780. /* SecurityCtrlr Required item */
  1781. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  1782. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  1783. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1784. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableCharacteristics.maxLimit = 40;
  1785. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1786. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1787. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value, " ");
  1788. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword]);
  1789. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  1790. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  1791. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1792. ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableCharacteristics.maxLimit = 48;
  1793. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1794. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1795. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variableAttribute[0].value, "Phihong Technology");
  1796. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity]);
  1797. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  1798. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  1799. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1800. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1801. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1802. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variableAttribute[0].value, "Phihong");
  1803. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName]);
  1804. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  1805. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  1806. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1807. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1808. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1809. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variableAttribute[0].value, "1");
  1810. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries]);
  1811. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  1812. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  1813. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1814. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1815. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1816. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value, "0");
  1817. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile]);
  1818. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  1819. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  1820. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1821. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1822. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1823. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variableAttribute[0].value, "FALSE");
  1824. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck]);
  1825. /* SmartChargingCtrlr Required item */
  1826. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  1827. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  1828. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1829. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1830. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1831. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variableAttribute[0].value, "TRUE");
  1832. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled]);
  1833. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  1834. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  1835. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1836. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1837. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1838. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variableAttribute[0].value, "TRUE");
  1839. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available]);
  1840. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  1841. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  1842. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1843. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1844. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1845. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variableAttribute[0].value, "FALSE");
  1846. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported]);
  1847. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  1848. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  1849. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1850. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1851. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1852. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variableAttribute[0].value, "0");
  1853. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel]);
  1854. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  1855. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  1856. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_MemberList]);
  1857. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1858. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1859. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variableAttribute[0].value, "A,W");
  1860. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit]);
  1861. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  1862. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  1863. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1864. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1865. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1866. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variableAttribute[0].value, "10");
  1867. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule]);
  1868. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  1869. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  1870. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1871. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1872. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1873. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variableAttribute[0].value, "FALSE");
  1874. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled]);
  1875. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  1876. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  1877. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1878. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1879. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1880. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variableAttribute[0].value, "FALSE");
  1881. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules]);
  1882. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  1883. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  1884. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1885. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1886. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1887. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variableAttribute[0].value, "FALSE");
  1888. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1]);
  1889. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  1890. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  1891. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1892. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1893. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1894. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variableAttribute[0].value, "3");
  1895. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries]);
  1896. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  1897. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  1898. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_decimal]);
  1899. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1900. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1901. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variableAttribute[0].value, "1");
  1902. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance]);
  1903. /* TariffCostCtrlr Required item */
  1904. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  1905. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  1906. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  1907. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1908. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1909. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1910. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variableAttribute[0].value, "FALSE");
  1911. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled]);
  1912. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  1913. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  1914. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  1915. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1916. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1917. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1918. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variableAttribute[0].value, "FALSE");
  1919. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_Available]);
  1920. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  1921. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  1922. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1923. ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableCharacteristics.maxLimit = 255;
  1924. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1925. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1926. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variableAttribute[0].value, " ");
  1927. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage]);
  1928. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  1929. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  1930. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  1931. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1932. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1933. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1934. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variableAttribute[0].value, "FALSE");
  1935. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled]);
  1936. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  1937. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  1938. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  1939. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1940. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1941. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1942. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variableAttribute[0].value, "FALSE");
  1943. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Available]);
  1944. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  1945. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  1946. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1947. ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableCharacteristics.maxLimit = 255;
  1948. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1949. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1950. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variableAttribute[0].value, " ");
  1951. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage]);
  1952. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  1953. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  1954. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_string]);
  1955. ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableCharacteristics.maxLimit = 3;
  1956. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1957. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1958. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variableAttribute[0].value, "NTD");
  1959. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[Cost_Currency]);
  1960. /* TxCtrlr Required item */
  1961. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  1962. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  1963. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1964. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1965. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1966. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  1967. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled]);
  1968. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  1969. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  1970. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.unit, "Seconds");
  1971. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  1972. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1973. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1974. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variableAttribute[0].value, "180");
  1975. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut]);
  1976. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  1977. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  1978. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1979. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1980. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1981. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variableAttribute[0].value, "TRUE");
  1982. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect]);
  1983. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  1984. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  1985. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  1986. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1987. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  1988. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variableAttribute[0].value, "FALSE");
  1989. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled]);
  1990. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  1991. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  1992. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  1993. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  1994. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  1995. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variableAttribute[0].value, "EVConnected,Authorized,PowerPathClosed");
  1996. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint]);
  1997. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  1998. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  1999. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_OptionList]);
  2000. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2001. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadOnly]);
  2002. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variableAttribute[0].value, "EVConnected,Authorized,PowerPathClosed");
  2003. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint]);
  2004. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2005. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2006. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_integer]);
  2007. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableCharacteristics.unit, "Wh");
  2008. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2009. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2010. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variableAttribute[0].value, "60000");
  2011. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId]);
  2012. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2013. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2014. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableCharacteristics.dataType, "%s", DataEnumTypeStr[DataEnumType_boolean]);
  2015. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].type, "%s", AttributeEnumTypeStr[AttributeEnumType_Target]);
  2016. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].mutability, "%s", MutabilityEnumTypeStr[MutabilityEnumType_ReadWrite]);
  2017. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variableAttribute[0].value, "FALSE");
  2018. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId]);
  2019. }
  2020. else
  2021. {
  2022. // Variable name init
  2023. /* AlignedDataCtrlr Required item */
  2024. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].component.name, "AlignedDataCtrlr");
  2025. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Enabled].variable.name, "Enabled");
  2026. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].component.name, "AlignedDataCtrlr");
  2027. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Available].variable.name, "Available");
  2028. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].component.name, "AlignedDataCtrlr");
  2029. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Measurands].variable.name, "Measurands");
  2030. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].component.name, "AlignedDataCtrlr");
  2031. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_Interval].variable.name, "Interval");
  2032. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].component.name, "AlignedDataCtrlr");
  2033. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SendDuringIdle].variable.name, "SendDuringIdle");
  2034. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].component.name, "AlignedDataCtrlr");
  2035. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_SignReadings].variable.name, "SignReadings");
  2036. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].component.name, "AlignedDataCtrlr");
  2037. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2038. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].component.name, "AlignedDataCtrlr");
  2039. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AlignedDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2040. /* AuthCtrlrVariable Required item */
  2041. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].component.name, "AuthCtrlr");
  2042. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variable.name, "Enabled");
  2043. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].component.name, "AlignedDataCtrlr");
  2044. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AdditionalInfoItemsPerMessage].variable.name, "AdditionalInfoItemsPerMessage");
  2045. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].component.name, "AuthCtrlr");
  2046. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variable.name, "OfflineTxForUnknownIdEnabled");
  2047. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].component.name, "AuthCtrlr");
  2048. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_AuthorizeRemoteStart].variable.name, "AuthorizeRemoteStart");
  2049. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].component.name, "AuthCtrlr");
  2050. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variable.name, "LocalAuthorizeOffline");
  2051. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].component.name, "AuthCtrlr");
  2052. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variable.name, "LocalPreAuthorize");
  2053. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].component.name, "AuthCtrlr");
  2054. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_MasterPassGroupId].variable.name, "MasterPassGroupId");
  2055. /* AuthCacheCtrlr Variable Required item */
  2056. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].component.name, "AuthCacheCtrlr");
  2057. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variable.name, "Enabled");
  2058. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].component.name, "AuthCacheCtrlr");
  2059. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Available].variable.name, "Available");
  2060. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].component.name, "AuthCacheCtrlr");
  2061. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_LifeTime].variable.name, "LifeTime");
  2062. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].component.name, "AuthCacheCtrlr");
  2063. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Storage].variable.name, "Storage");
  2064. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].component.name, "AuthCacheCtrlr");
  2065. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Policy].variable.name, "Policy");
  2066. /* ClockCtrlr Variable Required item */
  2067. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].component.name, "ClockCtrlr");
  2068. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_DateTime].variable.name, "DateTime");
  2069. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].component.name, "ClockCtrlr");
  2070. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpSource].variable.name, "NtpSource");
  2071. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].component.name, "ClockCtrlr");
  2072. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.name, "NtpServerUri");
  2073. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NtpServerUri].variable.instance, "1");
  2074. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].component.name, "ClockCtrlr");
  2075. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeOffset].variable.name, "TimeOffset");
  2076. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].component.name, "ClockCtrlr");
  2077. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTimeOffsetTransitionDateTime].variable.name, "NextTimeOffsetTransitionDateTime");
  2078. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].component.name, "ClockCtrlr");
  2079. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.name, "TimeOffset");
  2080. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_NextTransition_TimeOffset].variable.instance, "NextTransition");
  2081. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].component.name, "ClockCtrlr");
  2082. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeSource].variable.name, "TimeSource");
  2083. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].component.name, "ClockCtrlr");
  2084. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ClockCtrlr_TimeZone].variable.name, "TimeZone");
  2085. /* ChargingStation Required item */
  2086. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].component.name, "ChargingStation");
  2087. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_Available].variable.name, "Available");
  2088. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].component.name, "ChargingStation");
  2089. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_AvailabilityState].variable.name, "AvailabilityState");
  2090. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].component.name, "ChargingStation");
  2091. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ChargingStation_SupplyPhases].variable.name, "SupplyPhases");
  2092. /* Connector Required item */
  2093. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].component.name, "Connector");
  2094. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_Available].variable.name, "Available");
  2095. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].component.name, "Connector");
  2096. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_ConnectorType].variable.name, "ConnectorType");
  2097. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].component.name, "Connector");
  2098. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Connector_SupplyPhases].variable.name, "SupplyPhases");
  2099. /* DeviceDataCtrlr Required item */
  2100. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2101. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.instance, "GetReport");
  2102. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2103. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2104. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.instance, "GetVariables");
  2105. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2106. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2107. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.instance, "GetReport");
  2108. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetReport_BytesPerMessage].variable.name, "BytesPerMessage");
  2109. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2110. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.instance, "GetVariables");
  2111. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_GetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2112. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].component.name, "DeviceDataCtrlr");
  2113. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ConfigurationValueSize].variable.name, "ConfigurationValueSize");
  2114. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].component.name, "DeviceDataCtrlr");
  2115. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_ReportingValueSize].variable.name, "ReportingValueSize");
  2116. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].component.name, "DeviceDataCtrlr");
  2117. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.instance, "SetVariables");
  2118. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2119. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].component.name, "DeviceDataCtrlr");
  2120. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.instance, "SetVariables");
  2121. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DeviceDataCtrlr_SetVariables_BytesPerMessage].variable.name, "BytesPerMessage");
  2122. /* DisplayMessageCtrlr Required item */
  2123. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].component.name, "DisplayMessageCtrlr");
  2124. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Enabled].variable.name, "Enabled");
  2125. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].component.name, "DisplayMessageCtrlr");
  2126. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_Available].variable.name, "Available");
  2127. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].component.name, "DisplayMessageCtrlr");
  2128. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_DisplayMessages].variable.name, "DisplayMessages");
  2129. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].component.name, "DisplayMessageCtrlr");
  2130. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedFormats].variable.name, "SupportedFormats");
  2131. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].component.name, "DisplayMessageCtrlr");
  2132. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[DisplayMessageCtrlr_SupportedPriorities].variable.name, "SupportedPriorities");
  2133. /* EVSE Required item */
  2134. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].component.name, "EVSE");
  2135. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Available].variable.name, "Available");
  2136. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].component.name, "EVSE");
  2137. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_AvailabilityState].variable.name, "AvailabilityState");
  2138. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].component.name, "EVSE");
  2139. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_SupplyPhases].variable.name, "SupplyPhases");
  2140. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].component.name, "EVSE");
  2141. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[EVSE_Power].variable.name, "Power");
  2142. /* LocalAuthListCtrlr Required item */
  2143. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].component.name, "LocalAuthListCtrlr");
  2144. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variable.name, "Enabled");
  2145. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].component.name, "LocalAuthListCtrlr");
  2146. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Entries].variable.name, "Entries");
  2147. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].component.name, "LocalAuthListCtrlr");
  2148. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Available].variable.name, "Available");
  2149. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].component.name, "LocalAuthListCtrlr");
  2150. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2151. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_ItemsPerMessage].variable.instance, "SendLocalList");
  2152. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].component.name, "LocalAuthListCtrlr");
  2153. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.name, "BytesPerMessage");
  2154. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_BytesPerMessage].variable.instance, "SendLocalList");
  2155. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].component.name, "LocalAuthListCtrlr");
  2156. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Storage].variable.name, "Storage");
  2157. /* MonitoringCtrlr Required item */
  2158. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].component.name, "MonitoringCtrlr");
  2159. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Enabled].variable.instance, "Enabled");
  2160. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].component.name, "MonitoringCtrlr");
  2161. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_Available].variable.instance, "Available");
  2162. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2163. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.instance, "ClearVariableMonitoring");
  2164. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2165. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].component.name, "MonitoringCtrlr");
  2166. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.instance, "SetVariableMonitoring");
  2167. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage].variable.name, "ItemsPerMessage");
  2168. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2169. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.instance, "ClearVariableMonitoring");
  2170. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2171. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].component.name, "MonitoringCtrlr");
  2172. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.instance, "SetVariableMonitoring");
  2173. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage].variable.name, "BytesPerMessage");
  2174. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].component.name, "MonitoringCtrlr");
  2175. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[MonitoringCtrlr_OfflineQueuingSeverity].variable.name, "OfflineQueuingSeverity");
  2176. /* OCPPCommCtrlr Required item */
  2177. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].component.name, "OCPPCommCtrlr");
  2178. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ActiveNetworkProfile].variable.name, "ActiveNetworkProfile");
  2179. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].component.name, "OCPPCommCtrlr");
  2180. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.instance, "Default");
  2181. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageTimeout].variable.name, "MessageTimeout");
  2182. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].component.name, "OCPPCommCtrlr");
  2183. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_FileTransferProtocols].variable.name, "FileTransferProtocols");
  2184. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].component.name, "OCPPCommCtrlr");
  2185. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variable.name, "HeartbeatInterval");
  2186. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].component.name, "OCPPCommCtrlr");
  2187. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkConfigurationPriority].variable.name, "NetworkConfigurationPriority");
  2188. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].component.name, "OCPPCommCtrlr");
  2189. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_NetworkProfileConnectionAttempts].variable.name, "NetworkProfileConnectionAttempts");
  2190. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].component.name, "OCPPCommCtrlr");
  2191. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_OfflineThreshold].variable.name, "OfflineThreshold");
  2192. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].component.name, "OCPPCommCtrlr");
  2193. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_QueueAllMessages].variable.name, "QueueAllMessages");
  2194. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].component.name, "OCPPCommCtrlr");
  2195. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.instance, "TransactionEvent");
  2196. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variable.name, "MessageAttempts");
  2197. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].component.name, "OCPPCommCtrlr");
  2198. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.instance, "TransactionEvent");
  2199. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variable.name, "MessageAttemptInterval");
  2200. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].component.name, "OCPPCommCtrlr");
  2201. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_UnlockOnEVSideDisconnect].variable.name, "UnlockOnEVSideDisconnect");
  2202. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].component.name, "OCPPCommCtrlr");
  2203. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variable.name, "WebSocketPingInterval");
  2204. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].component.name, "OCPPCommCtrlr");
  2205. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_ResetRetries].variable.name, "ResetRetries");
  2206. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].component.name, "OCPPCommCtrlr");
  2207. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_PublicKeyWithSignedMeterValue].variable.name, "PublicKeyWithSignedMeterValue");
  2208. /* ReservationCtrlr Required item */
  2209. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].component.name, "ReservationCtrlr");
  2210. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Enabled].variable.name, "Enabled");
  2211. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].component.name, "ReservationCtrlr");
  2212. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_Available].variable.name, "Available");
  2213. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].component.name, "ReservationCtrlr");
  2214. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[ReservationCtrlr_NonEvseSpecific].variable.name, "NonEvseSpecific");
  2215. /* SampledDataCtrlr Required item */
  2216. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].component.name, "SampledDataCtrlr");
  2217. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Enabled].variable.name, "Enabled");
  2218. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].component.name, "SampledDataCtrlr");
  2219. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_Available].variable.name, "Available");
  2220. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].component.name, "SampledDataCtrlr");
  2221. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_SignReadings].variable.name, "SignReadings");
  2222. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].component.name, "SampledDataCtrlr");
  2223. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedMeasurands].variable.name, "TxEndedMeasurands");
  2224. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].component.name, "SampledDataCtrlr");
  2225. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxEndedInterval].variable.name, "TxEndedInterval");
  2226. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].component.name, "SampledDataCtrlr");
  2227. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxStartedMeasurands].variable.name, "TxStartedMeasurands");
  2228. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].component.name, "SampledDataCtrlr");
  2229. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedMeasurands].variable.name, "TxUpdatedMeasurands");
  2230. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].component.name, "SampledDataCtrlr");
  2231. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variable.name, "TxUpdatedInterval");
  2232. /* SecurityCtrlr Required item */
  2233. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].component.name, "SecurityCtrlr");
  2234. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variable.name, "BasicAuthPassword");
  2235. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].component.name, "SecurityCtrlr");
  2236. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_Identity].variable.name, "Identity");
  2237. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].component.name, "SecurityCtrlr");
  2238. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_OrganizationName].variable.name, "OrganizationName");
  2239. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].component.name, "SecurityCtrlr");
  2240. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_CertificateEntries].variable.name, "CertificateEntries");
  2241. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].component.name, "SecurityCtrlr");
  2242. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variable.name, "SecurityProfile");
  2243. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].component.name, "SecurityCtrlr");
  2244. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_AdditionalRootCertificateCheck].variable.name, "AdditionalRootCertificateCheck");
  2245. /* SmartChargingCtrlr Required item */
  2246. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].component.name, "SmartChargingCtrlr");
  2247. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Enabled].variable.name, "Enabled");
  2248. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].component.name, "SmartChargingCtrlr");
  2249. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Available].variable.name, "Available");
  2250. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].component.name, "SmartChargingCtrlr");
  2251. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ACPhaseSwitchingSupported].variable.name, "ACPhaseSwitchingSupported");
  2252. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].component.name, "SmartChargingCtrlr");
  2253. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ProfileStackLevel].variable.name, "ProfileStackLevel");
  2254. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].component.name, "SmartChargingCtrlr");
  2255. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_RateUnit].variable.name, "RateUnit");
  2256. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].component.name, "SmartChargingCtrlr");
  2257. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_PeriodsPerSchedule].variable.name, "PeriodsPerSchedule");
  2258. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].component.name, "SmartChargingCtrlr");
  2259. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_ExternalControlSignalsEnabled].variable.name, "ExternalControlSignalsEnabled");
  2260. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].component.name, "SmartChargingCtrlr");
  2261. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_NotifyChargingLimitWithSchedules].variable.name, "NotifyChargingLimitWithSchedules");
  2262. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].component.name, "SmartChargingCtrlr");
  2263. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Phases3to1].variable.name, "Phases3to1");
  2264. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].component.name, "SmartChargingCtrlr");
  2265. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_Entries].variable.name, "Entries");
  2266. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].component.name, "SmartChargingCtrlr");
  2267. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[SmartChargingCtrlr_LimitChangeSignificance].variable.name, "LimitChangeSignificance");
  2268. /* TariffCostCtrlr Required item */
  2269. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].component.name, "TariffCostCtrlr");
  2270. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.instance, "Tariff");
  2271. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Enabled].variable.name, "Enabled");
  2272. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].component.name, "TariffCostCtrlr");
  2273. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.instance, "Tariff");
  2274. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_Available].variable.name, "Available");
  2275. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].component.name, "TariffCostCtrlr");
  2276. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Tariff_TariffFallbackMessage].variable.name, "TariffFallbackMessage");
  2277. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].component.name, "TariffCostCtrlr");
  2278. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.instance, "Cost");
  2279. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Enabled].variable.name, "Enabled");
  2280. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].component.name, "TariffCostCtrlr");
  2281. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.instance, "Cost");
  2282. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Available].variable.name, "Available");
  2283. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].component.name, "TariffCostCtrlr");
  2284. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_TotalCostFallbackMessage].variable.name, "TotalCostFallbackMessage");
  2285. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].component.name, "TariffCostCtrlr");
  2286. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[Cost_Currency].variable.name, "Currency");
  2287. /* TxCtrlr Required item */
  2288. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2289. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_ChargingBeforeAcceptedEnabled].variable.name, "ChargingBeforeAcceptedEnabled");
  2290. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].component.name, "TxCtrlr");
  2291. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_EVConnectionTimeOut].variable.name, "EVConnectionTimeOut");
  2292. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].component.name, "TxCtrlr");
  2293. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnEVSideDisconnect].variable.name, "StopTxOnEVSideDisconnect");
  2294. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].component.name, "TxCtrlr");
  2295. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxBeforeAcceptedEnabled].variable.name, "TxBeforeAcceptedEnabled");
  2296. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].component.name, "TxCtrlr");
  2297. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStartPoint].variable.name, "TxStartPoint");
  2298. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].component.name, "TxCtrlr");
  2299. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_TxStopPoint].variable.name, "TxStopPoint");
  2300. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].component.name, "TxCtrlr");
  2301. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_MaxEnergyOnInvalidId].variable.name, "MaxEnergyOnInvalidId");
  2302. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].component.name, "TxCtrlr");
  2303. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[TxCtrlr_StopTxOnInvalidId].variable.name, "StopTxOnInvalidId");
  2304. }
  2305. return 0;
  2306. }
  2307. void DB_variableIsCreate()
  2308. {
  2309. char sql[512];
  2310. char* errMsg = NULL;
  2311. sprintf(sql,"select count(idx) as quantity from ocpp20_variable;");
  2312. /* Execute SQL statement */
  2313. if(sqlite3_exec(db, sql, cbVariableIsCreate, 0, &errMsg) != SQLITE_OK )
  2314. {
  2315. DEBUG_INFO("SQL error: %s\n", errMsg);
  2316. }
  2317. }
  2318. int cbVariableLoadFromDb(void *para, int columnCount, char **columnValue, char **columnName)
  2319. {
  2320. for(int idx=0;idx<CtrlrVariable_CNT;idx++)
  2321. {
  2322. if((strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.name, columnValue[1]) != NULL) &&
  2323. (strlen(columnValue[2])>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].component.instance, columnValue[2]) != NULL):TRUE) &&
  2324. (strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.name, columnValue[3]) != NULL) &&
  2325. (strlen(columnValue[4])>0?(strstr((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variable.instance, columnValue[4]) != NULL):TRUE))
  2326. {
  2327. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.dataType, "%s", columnValue[5]);
  2328. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.unit, "%s", columnValue[6]);
  2329. ShmOCPP20Data->ControllerComponentVariable[idx].variableCharacteristics.maxLimit = strlen(columnValue[7])>0?atoi(columnValue[7]):255;
  2330. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].type, "%s", columnValue[8]);
  2331. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].mutability, "%s", columnValue[9]);
  2332. sprintf((char*)ShmOCPP20Data->ControllerComponentVariable[idx].variableAttribute[0].value, "%s", columnValue[10]);
  2333. }
  2334. }
  2335. return 0;
  2336. }
  2337. void DB_variableLoadFromDb()
  2338. {
  2339. char sql[512];
  2340. char* errMsg = NULL;
  2341. sprintf(sql,"select * from ocpp20_variable;");
  2342. /* Execute SQL statement */
  2343. if(sqlite3_exec(db, sql, cbVariableLoadFromDb, 0, &errMsg) != SQLITE_OK )
  2344. {
  2345. DEBUG_INFO("SQL error: %s\n", errMsg);
  2346. }
  2347. }
  2348. //==========================================
  2349. // Check time passed since today
  2350. //==========================================
  2351. long long DiffTimebWithNow(struct timeb ST)
  2352. {
  2353. //return milli-second
  2354. struct timeb ET;
  2355. long long StartTime,StopTime;
  2356. ftime(&ET);
  2357. StartTime=(long long)ST.time;
  2358. StopTime=(long long)ET.time;
  2359. return ((StopTime-StartTime)*1000) + (ET.millitm-ST.millitm);
  2360. }
  2361. int getTimePassSinceToday()
  2362. {
  2363. int result = -1;
  2364. time_t t;
  2365. struct tm *tmStartToday;
  2366. struct timeb tbStartToday;
  2367. t=time(NULL);
  2368. tmStartToday=localtime(&t);
  2369. tmStartToday->tm_hour = 0;
  2370. tmStartToday->tm_min = 0;
  2371. tmStartToday->tm_sec = 0;
  2372. tbStartToday.time = mktime(tmStartToday);
  2373. tbStartToday.millitm = 0;
  2374. result = DiffTimebWithNow(tbStartToday)/1000;
  2375. return result;
  2376. }
  2377. //==========================================
  2378. // GetCompositeSchedule logic related function
  2379. //==========================================
  2380. int DiffTimebSec(struct timeb ST, struct timeb ET)
  2381. {
  2382. //return milli-second
  2383. unsigned int StartTime,StopTime;
  2384. StartTime=(unsigned int)ST.time;
  2385. StopTime=(unsigned int)ET.time;
  2386. return (StopTime-StartTime);
  2387. }
  2388. int DiffTimebWithNowSec(struct timeb ST)
  2389. {
  2390. //return milli-second
  2391. struct timeb ET;
  2392. unsigned int StartTime,StopTime;
  2393. ftime(&ET);
  2394. StartTime=(unsigned int)ST.time;
  2395. StopTime=(unsigned int)ET.time;
  2396. return (StopTime-StartTime);
  2397. }
  2398. int getStartStop(uint8_t *start, uint8_t *stop)
  2399. {
  2400. int result = -1;
  2401. struct tm tmStart;
  2402. struct timeb tbStart;
  2403. struct tm tmStop;
  2404. struct timeb tbStop;
  2405. 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) &&
  2406. (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))
  2407. {
  2408. //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);
  2409. //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);
  2410. tmStart.tm_year -= 1900;
  2411. tmStart.tm_mon -= 1;
  2412. tbStart.time = mktime(&tmStart);
  2413. tbStart.millitm = 0;
  2414. tmStop.tm_year -= 1900;
  2415. tmStop.tm_mon -= 1;
  2416. tbStop.time = mktime(&tmStop);
  2417. tbStop.millitm = 0;
  2418. result = DiffTimebSec(tbStart, tbStop);
  2419. //DEBUG_INFO("getStartStop(): %d\n", result);
  2420. }
  2421. else
  2422. {
  2423. DEBUG_WARN("Start or stop date parsing error.\r\n");
  2424. }
  2425. return result;
  2426. }
  2427. int isOvertNow(uint8_t *start)
  2428. {
  2429. int result = YES;
  2430. struct tm tmStart;
  2431. struct timeb tbStart;
  2432. 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))
  2433. {
  2434. //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);
  2435. tmStart.tm_year -= 1900;
  2436. tmStart.tm_mon -= 1;
  2437. tbStart.time = mktime(&tmStart);
  2438. tbStart.millitm = 0;
  2439. if(DiffTimebWithNowSec(tbStart) <= 0)
  2440. result = NO;
  2441. }
  2442. else
  2443. {
  2444. DEBUG_WARN("Start date parsing error.\r\n");
  2445. }
  2446. return result;
  2447. }
  2448. int getStartSinceRecurring(uint8_t *start, uint8_t *stop, uint8_t isDaily)
  2449. {
  2450. int result = -1;
  2451. struct tm tmStart;
  2452. struct timeb tbStart;
  2453. struct tm tmStop;
  2454. struct timeb tbStop;
  2455. 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) &&
  2456. (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))
  2457. {
  2458. tmStart.tm_year -= 1900;
  2459. tmStart.tm_mon -= 1;
  2460. tbStart.time = mktime(&tmStart);
  2461. tbStart.millitm = 0;
  2462. tmStop.tm_year -= 1900;
  2463. tmStop.tm_mon -= 1;
  2464. tbStop.time = mktime(&tmStop);
  2465. tbStop.millitm = 0;
  2466. result = DiffTimebSec(tbStart, tbStop)%(isDaily?86400:604800);
  2467. }
  2468. return result;
  2469. }
  2470. void checkCompositeSchedule(uint8_t connectorId, uint32_t durationReq, struct ChargingProfileType *compositeProfile)
  2471. {
  2472. FILE *fp;
  2473. char profileFileName[128];
  2474. char *line = NULL;
  2475. size_t len = 0;
  2476. time_t CurrentTime;
  2477. struct tm *tmComposite;
  2478. struct ChargingProfileType maxProfile;
  2479. struct ChargingProfileType defaultTxProfile;
  2480. struct ChargingProfileType txProfile;
  2481. struct ChargingSchedulePeriodType tmpPeriod;
  2482. uint8_t limitMax=0;
  2483. uint8_t limitDef=0;
  2484. uint8_t limitTx=0;
  2485. int compositePeriodIdx = 0;
  2486. CurrentTime = time(NULL);
  2487. tmComposite=localtime(&CurrentTime);
  2488. 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);
  2489. sprintf((char*)compositeProfile->chargingSchedule[0].chargingRateUnit, "A");
  2490. compositeProfile->chargingSchedule[0].duration = durationReq;
  2491. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2492. {
  2493. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2494. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2495. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2496. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 0;
  2497. }
  2498. compositeProfile->id = 0;
  2499. compositeProfile->stackLevel = 99 ;
  2500. sprintf((char*)compositeProfile->chargingProfileKind ,ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]);
  2501. maxProfile.id = -1;
  2502. defaultTxProfile.id = -1;
  2503. txProfile.id = -1;
  2504. maxProfile.chargingSchedule[0].duration = -1;
  2505. defaultTxProfile.chargingSchedule[0].duration = -1;
  2506. txProfile.chargingSchedule[0].duration = -1;
  2507. system("yes|rm /tmp/*.json");
  2508. system("cp /Storage/OCPP/*.json /tmp");
  2509. /*
  2510. * Search valid charging profile
  2511. */
  2512. //DEBUG_INFO("====================================\n");
  2513. // Search tx profile
  2514. sprintf(profileFileName, "/tmp/TxProfile_%d.json", connectorId);
  2515. if((access(profileFileName, F_OK))!=-1)
  2516. {
  2517. fp = fopen(profileFileName, "r");
  2518. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2519. {
  2520. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2521. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2522. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2523. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2524. }
  2525. txProfile.id = -1;
  2526. txProfile.stackLevel = -1;
  2527. while(getline(&line, &len, fp) != -1)
  2528. {
  2529. json_object *obj = NULL;
  2530. obj = json_tokener_parse(line);
  2531. if(is_error(obj))
  2532. {
  2533. DEBUG_ERROR("Parse txProfile from file error.\n");
  2534. }
  2535. else
  2536. {
  2537. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != txProfile.id) &&
  2538. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= txProfile.stackLevel)
  2539. )
  2540. {
  2541. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2542. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2543. )
  2544. {
  2545. struct tm tmFrom, tmTo;
  2546. struct timeb tbFrom, tbTo;
  2547. 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) &&
  2548. (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))
  2549. {
  2550. tmFrom.tm_year -= 1900;
  2551. tmFrom.tm_mon -= 1;
  2552. tbFrom.time = mktime(&tmFrom);
  2553. tmTo.tm_year -= 1900;
  2554. tmTo.tm_mon -= 1;
  2555. tbTo.time = mktime(&tmTo);
  2556. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2557. {
  2558. if(txProfile.id == -1)
  2559. DEBUG_INFO("TxProfile found.\n");
  2560. else
  2561. DEBUG_INFO("TxProfile updated.\n");
  2562. // Required item
  2563. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2564. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2565. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2566. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2567. 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++)
  2568. {
  2569. 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"));
  2570. 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")));
  2571. 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?
  2572. 3:
  2573. 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")));
  2574. }
  2575. // Optional item
  2576. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2577. {
  2578. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2579. }
  2580. else
  2581. {
  2582. sprintf((char*)txProfile.validFrom, " ");
  2583. }
  2584. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2585. {
  2586. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2587. }
  2588. else
  2589. {
  2590. sprintf((char*)txProfile.validTo, " ");
  2591. }
  2592. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2593. {
  2594. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2595. }
  2596. else
  2597. {
  2598. sprintf((char*)txProfile.recurrencyKind, " ");
  2599. }
  2600. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2601. {
  2602. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2603. }
  2604. else
  2605. {
  2606. sprintf((char*)txProfile.transactionId, " ");
  2607. }
  2608. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2609. {
  2610. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2611. }
  2612. else
  2613. {
  2614. txProfile.chargingSchedule[0].duration = 86400;
  2615. }
  2616. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2617. {
  2618. 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")));
  2619. }
  2620. else
  2621. {
  2622. 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));
  2623. }
  2624. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2625. {
  2626. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2627. }
  2628. else
  2629. {
  2630. txProfile.chargingSchedule[0].minChargingRate = -1;
  2631. }
  2632. }
  2633. }
  2634. }
  2635. else
  2636. {
  2637. if(txProfile.id == -1)
  2638. DEBUG_INFO("TxProfile found.\n");
  2639. else
  2640. DEBUG_INFO("TxProfile updated.\n");
  2641. // Required item
  2642. txProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2643. txProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2644. sprintf((char*)txProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2645. sprintf((char*)txProfile.chargingSchedule[0].chargingRateUnit, "A");
  2646. 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++)
  2647. {
  2648. 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"));
  2649. 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")));
  2650. 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?
  2651. 3:
  2652. 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")));
  2653. }
  2654. // Optional item
  2655. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2656. {
  2657. sprintf((char*)txProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2658. }
  2659. else
  2660. {
  2661. sprintf((char*)txProfile.validFrom, " ");
  2662. }
  2663. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2664. {
  2665. sprintf((char*)txProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2666. }
  2667. else
  2668. {
  2669. sprintf((char*)txProfile.validTo, " ");
  2670. }
  2671. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2672. {
  2673. sprintf((char*)txProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2674. }
  2675. else
  2676. {
  2677. sprintf((char*)txProfile.recurrencyKind, " ");
  2678. }
  2679. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2680. {
  2681. sprintf((char*)txProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2682. }
  2683. else
  2684. {
  2685. sprintf((char*)txProfile.transactionId, " ");
  2686. }
  2687. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2688. {
  2689. txProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2690. }
  2691. else
  2692. {
  2693. txProfile.chargingSchedule[0].duration = 86400;
  2694. }
  2695. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2696. {
  2697. 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")));
  2698. }
  2699. else
  2700. {
  2701. 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));
  2702. }
  2703. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2704. {
  2705. txProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2706. }
  2707. else
  2708. {
  2709. txProfile.chargingSchedule[0].minChargingRate = -1;
  2710. }
  2711. }
  2712. }
  2713. }
  2714. json_object_put(obj);
  2715. }
  2716. fclose(fp);
  2717. /*
  2718. if(txProfile.ChargingProfileId != -1)
  2719. {
  2720. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  2721. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  2722. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  2723. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  2724. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  2725. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  2726. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  2727. DEBUG_INFO("Profile start schedule: %s\n", txProfile.chargingSchedule[0].StartSchedule);
  2728. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  2729. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  2730. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  2731. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  2732. {
  2733. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  2734. {
  2735. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  2736. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  2737. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  2738. }
  2739. }
  2740. }
  2741. else
  2742. DEBUG_INFO("TxProfile not found.\n");*/
  2743. }
  2744. // Search default tx profile
  2745. sprintf(profileFileName, "/tmp/TxDefaultProfile_%d.json", connectorId);
  2746. if((access(profileFileName, F_OK))==-1)
  2747. sprintf(profileFileName, "/tmp/TxDefaultProfile_0.json");
  2748. if((access(profileFileName, F_OK))!=-1)
  2749. {
  2750. fp = fopen(profileFileName, "r");
  2751. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2752. {
  2753. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2754. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2755. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2756. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].phaseToUse = 0;
  2757. }
  2758. defaultTxProfile.id = -1;
  2759. defaultTxProfile.stackLevel = -1;
  2760. while(getline(&line, &len, fp) != -1)
  2761. {
  2762. json_object *obj = NULL;
  2763. obj = json_tokener_parse(line);
  2764. if(is_error(obj))
  2765. {
  2766. DEBUG_ERROR("Parse TxDefaultProfile from file error.\n");
  2767. }
  2768. else
  2769. {
  2770. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != defaultTxProfile.id) &&
  2771. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= defaultTxProfile.stackLevel)
  2772. )
  2773. {
  2774. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  2775. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2776. )
  2777. {
  2778. struct tm tmFrom, tmTo;
  2779. struct timeb tbFrom, tbTo;
  2780. 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) &&
  2781. (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))
  2782. {
  2783. tmFrom.tm_year -= 1900;
  2784. tmFrom.tm_mon -= 1;
  2785. tbFrom.time = mktime(&tmFrom);
  2786. tmTo.tm_year -= 1900;
  2787. tmTo.tm_mon -= 1;
  2788. tbTo.time = mktime(&tmTo);
  2789. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  2790. {
  2791. if(defaultTxProfile.id == -1)
  2792. DEBUG_INFO("TxDefaultProfile found.\n");
  2793. else
  2794. DEBUG_INFO("TxDefaultProfile updated.\n");
  2795. // Required item
  2796. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2797. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2798. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2799. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  2800. 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++)
  2801. {
  2802. 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"));
  2803. 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")));
  2804. 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?
  2805. 3:
  2806. 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")));
  2807. }
  2808. // Optional item
  2809. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2810. {
  2811. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2812. }
  2813. else
  2814. {
  2815. sprintf((char*)defaultTxProfile.validFrom, " ");
  2816. }
  2817. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2818. {
  2819. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2820. }
  2821. else
  2822. {
  2823. sprintf((char*)defaultTxProfile.validTo, " ");
  2824. }
  2825. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2826. {
  2827. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2828. }
  2829. else
  2830. {
  2831. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  2832. }
  2833. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2834. {
  2835. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2836. }
  2837. else
  2838. {
  2839. sprintf((char*)defaultTxProfile.transactionId, " ");
  2840. }
  2841. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2842. {
  2843. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2844. }
  2845. else
  2846. {
  2847. defaultTxProfile.chargingSchedule[0].duration = 86400;
  2848. }
  2849. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2850. {
  2851. 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")));
  2852. }
  2853. else
  2854. {
  2855. 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));
  2856. }
  2857. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2858. {
  2859. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2860. }
  2861. else
  2862. {
  2863. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  2864. }
  2865. }
  2866. }
  2867. }
  2868. else
  2869. {
  2870. if(defaultTxProfile.id == -1)
  2871. DEBUG_INFO("TxDefaultProfile found.\n");
  2872. else
  2873. DEBUG_INFO("TxDefaultProfile updated.\n");
  2874. // Required item
  2875. defaultTxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  2876. defaultTxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  2877. sprintf((char*)defaultTxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  2878. sprintf((char*)defaultTxProfile.chargingSchedule[0].chargingRateUnit, "A");
  2879. 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++)
  2880. {
  2881. 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"));
  2882. 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")));
  2883. 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?
  2884. 3:
  2885. 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")));
  2886. }
  2887. // Optional item
  2888. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  2889. {
  2890. sprintf((char*)defaultTxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  2891. }
  2892. else
  2893. {
  2894. sprintf((char*)defaultTxProfile.validFrom, " ");
  2895. }
  2896. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  2897. {
  2898. sprintf((char*)defaultTxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  2899. }
  2900. else
  2901. {
  2902. sprintf((char*)defaultTxProfile.validTo, " ");
  2903. }
  2904. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  2905. {
  2906. sprintf((char*)defaultTxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  2907. }
  2908. else
  2909. {
  2910. sprintf((char*)defaultTxProfile.recurrencyKind, " ");
  2911. }
  2912. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  2913. {
  2914. sprintf((char*)defaultTxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  2915. }
  2916. else
  2917. {
  2918. sprintf((char*)defaultTxProfile.transactionId, " ");
  2919. }
  2920. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  2921. {
  2922. defaultTxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  2923. }
  2924. else
  2925. {
  2926. defaultTxProfile.chargingSchedule[0].duration = 86400;
  2927. }
  2928. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  2929. {
  2930. 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")));
  2931. }
  2932. else
  2933. {
  2934. 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));
  2935. }
  2936. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  2937. {
  2938. defaultTxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  2939. }
  2940. else
  2941. {
  2942. defaultTxProfile.chargingSchedule[0].minChargingRate = -1;
  2943. }
  2944. }
  2945. }
  2946. }
  2947. json_object_put(obj);
  2948. }
  2949. fclose(fp);
  2950. /*
  2951. if(defaultTxProfile.ChargingProfileId != -1)
  2952. {
  2953. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  2954. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  2955. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  2956. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  2957. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  2958. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  2959. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  2960. DEBUG_INFO("Profile start schedule: %s\n", defaultTxProfile.chargingSchedule[0].StartSchedule);
  2961. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  2962. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  2963. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  2964. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  2965. {
  2966. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  2967. {
  2968. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  2969. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  2970. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  2971. }
  2972. }
  2973. }
  2974. else
  2975. DEBUG_INFO("TxDefaultProfile not found.\n");
  2976. DEBUG_INFO("------------------------------------\n");*/
  2977. }
  2978. // Search max profile
  2979. sprintf(profileFileName, "/tmp/ChargePointMaxProfile.json");
  2980. if((access(profileFileName, F_OK))!=-1)
  2981. {
  2982. fp = fopen(profileFileName, "r");
  2983. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  2984. {
  2985. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = -1;
  2986. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit = -1;
  2987. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases = 3;
  2988. }
  2989. maxProfile.id = -1;
  2990. maxProfile.stackLevel = -1;
  2991. while(getline(&line, &len, fp) != -1)
  2992. {
  2993. json_object *obj = NULL;
  2994. obj = json_tokener_parse(line);
  2995. if(is_error(obj))
  2996. {
  2997. DEBUG_ERROR("Parse MaxProfile from file error.\n");
  2998. }
  2999. else
  3000. {
  3001. if((json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "ChargingProfileId")) != maxProfile.id) &&
  3002. (json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel")) >= maxProfile.stackLevel)
  3003. )
  3004. {
  3005. if((json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL) &&
  3006. (json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3007. )
  3008. {
  3009. struct tm tmFrom, tmTo;
  3010. struct timeb tbFrom, tbTo;
  3011. 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) &&
  3012. (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))
  3013. {
  3014. tmFrom.tm_year -= 1900;
  3015. tmFrom.tm_mon -= 1;
  3016. tbFrom.time = mktime(&tmFrom);
  3017. tmTo.tm_year -= 1900;
  3018. tmTo.tm_mon -= 1;
  3019. tbTo.time = mktime(&tmTo);
  3020. if((DiffTimebWithNowSec(tbFrom)>=0) && (DiffTimebWithNowSec(tbTo)<=0))
  3021. {
  3022. if(maxProfile.id == -1)
  3023. DEBUG_INFO("MaxProfile found.\n");
  3024. else
  3025. DEBUG_INFO("MaxProfile updated.\n");
  3026. // Required item
  3027. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3028. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3029. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3030. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3031. 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++)
  3032. {
  3033. 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"));
  3034. 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")));
  3035. 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?
  3036. 3:
  3037. 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")));
  3038. }
  3039. // Optional item
  3040. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3041. {
  3042. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3043. }
  3044. else
  3045. {
  3046. sprintf((char*)maxProfile.validFrom, " ");
  3047. }
  3048. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3049. {
  3050. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3051. }
  3052. else
  3053. {
  3054. sprintf((char*)maxProfile.validTo, " ");
  3055. }
  3056. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3057. {
  3058. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3059. }
  3060. else
  3061. {
  3062. sprintf((char*)maxProfile.recurrencyKind, " ");
  3063. }
  3064. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3065. {
  3066. sprintf((char*)maxProfile.transactionId, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3067. }
  3068. else
  3069. {
  3070. sprintf((char*)maxProfile.transactionId, " ");
  3071. }
  3072. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3073. {
  3074. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3075. }
  3076. else
  3077. {
  3078. maxProfile.chargingSchedule[0].duration = 86400;
  3079. }
  3080. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3081. {
  3082. 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")));
  3083. }
  3084. else
  3085. {
  3086. 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));
  3087. }
  3088. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3089. {
  3090. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3091. }
  3092. else
  3093. {
  3094. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3095. }
  3096. }
  3097. }
  3098. }
  3099. else
  3100. {
  3101. if(maxProfile.id == -1)
  3102. DEBUG_INFO("MaxProfile found.\n");
  3103. else
  3104. DEBUG_INFO("MaxProfile updated.\n");
  3105. // Required item
  3106. maxProfile.id = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileId"));
  3107. maxProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "stackLevel"));
  3108. sprintf((char*)maxProfile.chargingProfileKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingProfileKind")));
  3109. sprintf((char*)maxProfile.chargingSchedule[0].chargingRateUnit, "A");
  3110. 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++)
  3111. {
  3112. 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"));
  3113. 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")));
  3114. 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?
  3115. 3:
  3116. 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")));
  3117. }
  3118. // Optional item
  3119. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom") != NULL)
  3120. {
  3121. sprintf((char*)maxProfile.validFrom, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validFrom")));
  3122. }
  3123. else
  3124. {
  3125. sprintf((char*)maxProfile.validFrom, " ");
  3126. }
  3127. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo") != NULL)
  3128. {
  3129. sprintf((char*)maxProfile.validTo, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "validTo")));
  3130. }
  3131. else
  3132. {
  3133. sprintf((char*)maxProfile.validTo, " ");
  3134. }
  3135. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind") != NULL)
  3136. {
  3137. sprintf((char*)maxProfile.recurrencyKind, "%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "RecurrencyKind")));
  3138. }
  3139. else
  3140. {
  3141. sprintf((char*)maxProfile.recurrencyKind, " ");
  3142. }
  3143. if(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId") != NULL)
  3144. {
  3145. sprintf((char*)maxProfile.transactionId,"%s", json_object_get_string(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "transactionId")));
  3146. }
  3147. else
  3148. {
  3149. sprintf((char*)maxProfile.transactionId, " ");
  3150. }
  3151. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration") != NULL)
  3152. {
  3153. maxProfile.chargingSchedule[0].duration = json_object_get_int(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "duration"));
  3154. }
  3155. else
  3156. {
  3157. maxProfile.chargingSchedule[0].duration = 86400;
  3158. }
  3159. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "startSchedule") != NULL)
  3160. {
  3161. 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")));
  3162. }
  3163. else
  3164. {
  3165. 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));
  3166. }
  3167. if(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate") != NULL)
  3168. {
  3169. maxProfile.chargingSchedule[0].minChargingRate = json_object_get_double(json_object_object_get(json_object_object_get(json_object_object_get(obj, "csChargingProfiles"), "chargingSchedule"), "minChargingRate"));
  3170. }
  3171. else
  3172. {
  3173. maxProfile.chargingSchedule[0].minChargingRate = -1;
  3174. }
  3175. }
  3176. }
  3177. }
  3178. json_object_put(obj);
  3179. }
  3180. fclose(fp);
  3181. /*
  3182. if(maxProfile.ChargingProfileId !=-1)
  3183. {
  3184. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3185. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3186. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3187. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3188. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3189. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3190. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3191. DEBUG_INFO("Profile start schedule: %s\n", maxProfile.chargingSchedule[0].StartSchedule);
  3192. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3193. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3194. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3195. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3196. {
  3197. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3198. {
  3199. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3200. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3201. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3202. }
  3203. }
  3204. }
  3205. else
  3206. DEBUG_INFO("MaxProfile not found.\n");
  3207. DEBUG_INFO("------------------------------------\n");*/
  3208. }
  3209. /*
  3210. * Align found profile start schedule & periods
  3211. */
  3212. //DEBUG_INFO("====================================\n");
  3213. /*
  3214. // For local test usage, force modify found profile start schedule info
  3215. 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);
  3216. 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);
  3217. 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);
  3218. */
  3219. if(txProfile.id != -1)
  3220. {
  3221. if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3222. {
  3223. if(txProfile.chargingSchedule[0].duration != -1)
  3224. {
  3225. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3226. 0:
  3227. (txProfile.chargingSchedule[0].duration-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3228. }
  3229. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3230. {
  3231. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3232. {
  3233. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3234. 0:
  3235. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3236. if(idxPeriod > 0)
  3237. {
  3238. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3239. {
  3240. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3241. }
  3242. }
  3243. }
  3244. }
  3245. }
  3246. else if(strstr((char*)txProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3247. {
  3248. if(txProfile.chargingSchedule[0].duration != -1)
  3249. {
  3250. 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?
  3251. 0:
  3252. (txProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3253. }
  3254. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3255. {
  3256. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3257. {
  3258. 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?
  3259. 0:
  3260. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3261. if(idxPeriod > 0)
  3262. {
  3263. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3264. {
  3265. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3266. }
  3267. }
  3268. }
  3269. }
  3270. }
  3271. else
  3272. {
  3273. if(strstr((char*)txProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3274. {
  3275. if(txProfile.chargingSchedule[0].duration != -1)
  3276. {
  3277. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3278. 0:
  3279. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3280. }
  3281. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3282. {
  3283. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3284. {
  3285. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3286. 0:
  3287. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3288. if(idxPeriod > 0)
  3289. {
  3290. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3291. {
  3292. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3293. }
  3294. }
  3295. }
  3296. }
  3297. }
  3298. else
  3299. {
  3300. if(txProfile.chargingSchedule[0].duration != -1)
  3301. {
  3302. txProfile.chargingSchedule[0].duration = ((txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3303. 0:
  3304. (txProfile.chargingSchedule[0].duration-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3305. }
  3306. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3307. {
  3308. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3309. {
  3310. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3311. 0:
  3312. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(txProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3313. if(idxPeriod > 0)
  3314. {
  3315. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3316. {
  3317. txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3318. }
  3319. }
  3320. }
  3321. }
  3322. }
  3323. }
  3324. /*
  3325. DEBUG_INFO("txProfile after align.\n");
  3326. DEBUG_INFO("Profile ID: %d\n", txProfile.ChargingProfileId);
  3327. DEBUG_INFO("Profile stackLevel: %d\n", txProfile.StackLevel);
  3328. DEBUG_INFO("Profile TransactionId: %d\n", txProfile.TransactionId);
  3329. DEBUG_INFO("Profile valid from: %s\n", txProfile.ValidFrom);
  3330. DEBUG_INFO("Profile valid to: %s\n", txProfile.ValidTo);
  3331. DEBUG_INFO("Profile ChargingProfileKind: %s\n", txProfile.ChargingProfileKind);
  3332. DEBUG_INFO("Profile RecurrencyKind: %s\n", txProfile.RecurrencyKind);
  3333. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3334. DEBUG_INFO("Profile schedule duration: %d\n", txProfile.chargingSchedule[0].Duration);
  3335. DEBUG_INFO("Profile charging rate unit: %s\n", txProfile.chargingSchedule[0].ChargingRateUnit);
  3336. DEBUG_INFO("Profile charging min rate: %f\n", txProfile.chargingSchedule[0].MinChargingRate);
  3337. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(txProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3338. {
  3339. if(txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3340. {
  3341. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3342. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3343. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, txProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3344. }
  3345. }*/
  3346. }
  3347. if(defaultTxProfile.id != -1)
  3348. {
  3349. if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3350. {
  3351. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3352. {
  3353. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3354. 0:
  3355. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3356. }
  3357. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3358. {
  3359. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3360. {
  3361. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3362. 0:
  3363. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3364. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3365. {
  3366. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3367. }
  3368. if(idxPeriod > 0)
  3369. {
  3370. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3371. {
  3372. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3373. }
  3374. }
  3375. }
  3376. }
  3377. }
  3378. else if(strstr((char*)defaultTxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3379. {
  3380. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3381. {
  3382. 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?
  3383. 0:
  3384. (defaultTxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3385. }
  3386. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3387. {
  3388. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3389. {
  3390. 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?
  3391. 0:
  3392. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3393. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3394. {
  3395. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3396. }
  3397. if(idxPeriod > 0)
  3398. {
  3399. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3400. {
  3401. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3402. }
  3403. }
  3404. }
  3405. }
  3406. }
  3407. else
  3408. {
  3409. if(strstr((char*)defaultTxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3410. {
  3411. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3412. {
  3413. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3414. 0:
  3415. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3416. }
  3417. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3418. {
  3419. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3420. {
  3421. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3422. 0:
  3423. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3424. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3425. {
  3426. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3427. }
  3428. if(idxPeriod > 0)
  3429. {
  3430. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3431. {
  3432. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3433. }
  3434. }
  3435. }
  3436. }
  3437. }
  3438. else
  3439. {
  3440. if(defaultTxProfile.chargingSchedule[0].duration != -1)
  3441. {
  3442. defaultTxProfile.chargingSchedule[0].duration = ((defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3443. 0:
  3444. (defaultTxProfile.chargingSchedule[0].duration-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3445. }
  3446. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3447. {
  3448. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3449. {
  3450. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3451. 0:
  3452. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(defaultTxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3453. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod < txProfile.chargingSchedule[0].duration)
  3454. {
  3455. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod += (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3456. }
  3457. if(idxPeriod > 0)
  3458. {
  3459. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3460. {
  3461. defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3462. }
  3463. }
  3464. }
  3465. }
  3466. }
  3467. }
  3468. /*
  3469. DEBUG_INFO("defaultTxProfile after align.\n");
  3470. DEBUG_INFO("Profile ID: %d\n", defaultTxProfile.ChargingProfileId);
  3471. DEBUG_INFO("Profile stackLevel: %d\n", defaultTxProfile.StackLevel);
  3472. DEBUG_INFO("Profile TransactionId: %d\n", defaultTxProfile.TransactionId);
  3473. DEBUG_INFO("Profile valid from: %s\n", defaultTxProfile.ValidFrom);
  3474. DEBUG_INFO("Profile valid to: %s\n", defaultTxProfile.ValidTo);
  3475. DEBUG_INFO("Profile ChargingProfileKind: %s\n", defaultTxProfile.ChargingProfileKind);
  3476. DEBUG_INFO("Profile RecurrencyKind: %s\n", defaultTxProfile.RecurrencyKind);
  3477. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3478. DEBUG_INFO("Profile schedule duration: %d\n", defaultTxProfile.chargingSchedule[0].Duration);
  3479. DEBUG_INFO("Profile charging rate unit: %s\n", defaultTxProfile.chargingSchedule[0].ChargingRateUnit);
  3480. DEBUG_INFO("Profile charging min rate: %f\n", defaultTxProfile.chargingSchedule[0].MinChargingRate);
  3481. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3482. {
  3483. if(defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3484. {
  3485. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3486. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3487. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, defaultTxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3488. }
  3489. }
  3490. DEBUG_INFO("------------------------------------\n");*/
  3491. }
  3492. if(maxProfile.id != -1)
  3493. {
  3494. if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Absolute]) != NULL)
  3495. {
  3496. if(maxProfile.chargingSchedule[0].duration != -1)
  3497. {
  3498. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3499. 0:
  3500. (maxProfile.chargingSchedule[0].duration-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3501. }
  3502. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3503. {
  3504. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3505. {
  3506. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule))<0?
  3507. 0:
  3508. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule)));
  3509. if(idxPeriod > 0)
  3510. {
  3511. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3512. {
  3513. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3514. }
  3515. }
  3516. }
  3517. }
  3518. }
  3519. else if(strstr((char*)maxProfile.chargingProfileKind, ChargingProfileKindEnumTypeStr[ChargingProfileKindEnumType_Relative]) != NULL)
  3520. {
  3521. if(maxProfile.chargingSchedule[0].duration != -1)
  3522. {
  3523. 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?
  3524. 0:
  3525. (maxProfile.chargingSchedule[0].duration-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[9].startSchedule)));
  3526. }
  3527. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3528. {
  3529. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3530. {
  3531. 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?
  3532. 0:
  3533. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartStop(ShmOCPP20Data->TransactionEvent[(connectorId==0?0:connectorId-1)].timestamp, compositeProfile->chargingSchedule[0].startSchedule)));
  3534. if(idxPeriod > 0)
  3535. {
  3536. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3537. {
  3538. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3539. }
  3540. }
  3541. }
  3542. }
  3543. }
  3544. else
  3545. {
  3546. if(strstr((char*)maxProfile.recurrencyKind, RecurrencyKindEnumTypeStr[RecurrencyKindEnumType_Weekly]) != NULL)
  3547. {
  3548. if(maxProfile.chargingSchedule[0].duration != -1)
  3549. {
  3550. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3551. 0:
  3552. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3553. }
  3554. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3555. {
  3556. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3557. {
  3558. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE))<0?
  3559. 0:
  3560. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, FALSE)));
  3561. if(idxPeriod > 0)
  3562. {
  3563. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3564. {
  3565. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3566. }
  3567. }
  3568. }
  3569. }
  3570. }
  3571. else
  3572. {
  3573. if(maxProfile.chargingSchedule[0].duration != -1)
  3574. {
  3575. maxProfile.chargingSchedule[0].duration = ((maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3576. 0:
  3577. (maxProfile.chargingSchedule[0].duration-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3578. }
  3579. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3580. {
  3581. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod != -1)
  3582. {
  3583. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod = ((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE))<0?
  3584. 0:
  3585. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod-getStartSinceRecurring(maxProfile.chargingSchedule[0].startSchedule, compositeProfile->chargingSchedule[0].startSchedule, TRUE)));
  3586. if(idxPeriod > 0)
  3587. {
  3588. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].startPeriod == maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod)
  3589. {
  3590. maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod-1].limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit;
  3591. }
  3592. }
  3593. }
  3594. }
  3595. }
  3596. }
  3597. /*
  3598. DEBUG_INFO("MaxProfile after align.\n");
  3599. DEBUG_INFO("Profile ID: %d\n", maxProfile.ChargingProfileId);
  3600. DEBUG_INFO("Profile stackLevel: %d\n", maxProfile.StackLevel);
  3601. DEBUG_INFO("Profile TransactionId: %d\n", maxProfile.TransactionId);
  3602. DEBUG_INFO("Profile valid from: %s\n", maxProfile.ValidFrom);
  3603. DEBUG_INFO("Profile valid to: %s\n", maxProfile.ValidTo);
  3604. DEBUG_INFO("Profile ChargingProfileKind: %s\n", maxProfile.ChargingProfileKind);
  3605. DEBUG_INFO("Profile RecurrencyKind: %s\n", maxProfile.RecurrencyKind);
  3606. DEBUG_INFO("Profile start schedule: %s\n", compositeProfile->ChargingSchedule.StartSchedule);
  3607. DEBUG_INFO("Profile schedule duration: %d\n", maxProfile.chargingSchedule[0].Duration);
  3608. DEBUG_INFO("Profile charging rate unit: %s\n", maxProfile.chargingSchedule[0].ChargingRateUnit);
  3609. DEBUG_INFO("Profile charging min rate: %f\n", maxProfile.chargingSchedule[0].MinChargingRate);
  3610. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(maxProfile.chargingSchedule[0].ChargingSchedulePeriod);idxPeriod++)
  3611. {
  3612. if(maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod >= 0)
  3613. {
  3614. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].StartPeriod);
  3615. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].Limit);
  3616. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, maxProfile.chargingSchedule[0].ChargingSchedulePeriod[idxPeriod].NumberPhases);
  3617. }
  3618. }
  3619. DEBUG_INFO("------------------------------------\n");*/
  3620. }
  3621. /*
  3622. * Merge to conposite schedule
  3623. */
  3624. //DEBUG_INFO("====================================\n");
  3625. // Find each profile period quantity
  3626. for(int idx=0;idx<ARRAY_SIZE(maxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3627. {
  3628. if(maxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3629. limitMax = idx+1;
  3630. }
  3631. for(int idx=0;idx<ARRAY_SIZE(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3632. {
  3633. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3634. limitDef = idx+1;
  3635. }
  3636. for(int idx=0;idx<ARRAY_SIZE(txProfile.chargingSchedule[0].chargingSchedulePeriod);idx++)
  3637. {
  3638. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idx].limit != -1)
  3639. limitTx = idx+1;
  3640. }
  3641. // TxProfile found, composite schedule based on it
  3642. if(txProfile.id != -1)
  3643. {
  3644. for(int idxTxPeriod=0;idxTxPeriod<limitTx;idxTxPeriod++)
  3645. {
  3646. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit != -1) &&
  3647. (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod < durationReq) &&
  3648. (txProfile.chargingSchedule[0].duration > 0))
  3649. {
  3650. if(maxProfile.id != -1)
  3651. {
  3652. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3653. {
  3654. if((txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod))
  3655. {
  3656. if((maxProfile.chargingSchedule[0].duration > 0))
  3657. {
  3658. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3659. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3660. 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);
  3661. }
  3662. else
  3663. {
  3664. tmpPeriod.startPeriod = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod;
  3665. tmpPeriod.numberPhases = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].numberPhases;
  3666. tmpPeriod.limit = txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].limit;
  3667. }
  3668. }
  3669. if(idxMaxPeriod == (limitMax-1))
  3670. {
  3671. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3672. {
  3673. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3674. {
  3675. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3676. compositePeriodIdx++;
  3677. }
  3678. else
  3679. {
  3680. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3681. }
  3682. }
  3683. }
  3684. }
  3685. }
  3686. else
  3687. {
  3688. if(txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3689. {
  3690. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3691. compositePeriodIdx++;
  3692. }
  3693. else
  3694. {
  3695. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod],sizeof(struct ChargingSchedulePeriodType));
  3696. }
  3697. }
  3698. }
  3699. if(idxTxPeriod == (limitTx-1))
  3700. {
  3701. if(defaultTxProfile.id != -1)
  3702. {
  3703. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3704. {
  3705. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= (txProfile.chargingSchedule[0].chargingSchedulePeriod[idxTxPeriod].startPeriod + (txProfile.chargingSchedule[0].duration-defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod))) &&
  3706. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3707. (defaultTxProfile.chargingSchedule[0].duration>0))
  3708. {
  3709. if(maxProfile.id != -1)
  3710. {
  3711. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3712. {
  3713. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3714. {
  3715. if((maxProfile.chargingSchedule[0].duration > 0))
  3716. {
  3717. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3718. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3719. 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);
  3720. }
  3721. else
  3722. {
  3723. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3724. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3725. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3726. }
  3727. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3728. {
  3729. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3730. {
  3731. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3732. compositePeriodIdx++;
  3733. }
  3734. else
  3735. {
  3736. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3737. }
  3738. }
  3739. break;
  3740. }
  3741. }
  3742. }
  3743. else
  3744. {
  3745. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3746. {
  3747. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3748. compositePeriodIdx++;
  3749. }
  3750. else
  3751. {
  3752. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3753. }
  3754. }
  3755. }
  3756. }
  3757. }
  3758. }
  3759. }
  3760. }
  3761. // TxProfile not found but defaultTxProfile found, composite schedule based on it
  3762. else if(defaultTxProfile.id != -1)
  3763. {
  3764. for(int idxDefPeriod=0;idxDefPeriod<limitDef;idxDefPeriod++)
  3765. {
  3766. if((defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit != -1) &&
  3767. (defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod < durationReq) &&
  3768. (defaultTxProfile.chargingSchedule[0].duration > 0))
  3769. {
  3770. if(maxProfile.id != -1)
  3771. {
  3772. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3773. {
  3774. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod >= maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod)
  3775. {
  3776. if((maxProfile.chargingSchedule[0].duration > 0))
  3777. {
  3778. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3779. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3780. 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);
  3781. }
  3782. else
  3783. {
  3784. tmpPeriod.startPeriod = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod;
  3785. tmpPeriod.numberPhases = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].numberPhases;
  3786. tmpPeriod.limit = defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].limit;
  3787. }
  3788. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3789. {
  3790. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3791. {
  3792. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3793. compositePeriodIdx++;
  3794. }
  3795. else
  3796. {
  3797. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3798. }
  3799. }
  3800. break;
  3801. }
  3802. }
  3803. }
  3804. else
  3805. {
  3806. if(defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod].startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3807. {
  3808. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3809. compositePeriodIdx++;
  3810. }
  3811. else
  3812. {
  3813. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &defaultTxProfile.chargingSchedule[0].chargingSchedulePeriod[idxDefPeriod],sizeof(struct ChargingSchedulePeriodType));
  3814. }
  3815. }
  3816. }
  3817. }
  3818. }
  3819. // Fill other period by MaxProfile
  3820. if(maxProfile.id != -1)
  3821. {
  3822. for(int idxMaxPeriod=0;idxMaxPeriod<limitMax;idxMaxPeriod++)
  3823. {
  3824. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit != -1) &&
  3825. (maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod < durationReq) &&
  3826. (maxProfile.chargingSchedule[0].duration > 0))
  3827. {
  3828. if((maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].startPeriod >= compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod) &&
  3829. (maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3830. {
  3831. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod;
  3832. tmpPeriod.numberPhases = compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].numberPhases;
  3833. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3834. }
  3835. if((maxProfile.chargingSchedule[0].duration > compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx==0?0:compositePeriodIdx-1].startPeriod))
  3836. {
  3837. tmpPeriod.startPeriod = compositeProfile->chargingSchedule[0].duration;
  3838. tmpPeriod.numberPhases = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].numberPhases;
  3839. tmpPeriod.limit = maxProfile.chargingSchedule[0].chargingSchedulePeriod[idxMaxPeriod].limit;
  3840. }
  3841. if(tmpPeriod.limit != -1)
  3842. {
  3843. if(tmpPeriod.limit != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].limit)
  3844. {
  3845. if(tmpPeriod.startPeriod != compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)].startPeriod)
  3846. {
  3847. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[compositePeriodIdx], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3848. compositePeriodIdx++;
  3849. }
  3850. else
  3851. {
  3852. memcpy(&compositeProfile->chargingSchedule[0].chargingSchedulePeriod[(compositePeriodIdx==0?compositePeriodIdx:compositePeriodIdx-1)], &tmpPeriod , sizeof(struct ChargingSchedulePeriodType));
  3853. }
  3854. }
  3855. }
  3856. }
  3857. }
  3858. }
  3859. DEBUG_INFO("Connector-%d composite schedule ready.\n", connectorId);
  3860. DEBUG_INFO("Schedule start: %s\n", compositeProfile->chargingSchedule[0].startSchedule);
  3861. DEBUG_INFO("Schedule duration: %d\n", compositeProfile->chargingSchedule[0].duration);
  3862. DEBUG_INFO("Rate unit: %s\n", compositeProfile->chargingSchedule[0].chargingRateUnit);
  3863. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(compositeProfile->chargingSchedule[0].chargingSchedulePeriod);idxPeriod++)
  3864. {
  3865. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod >= 0)
  3866. {
  3867. compositeProfile->id = 1;
  3868. DEBUG_INFO("Period-%02d startPeriod: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod);
  3869. DEBUG_INFO("Period-%02d limit: %f\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit);
  3870. DEBUG_INFO("Period-%02d NumberPhases: %d\n", idxPeriod, compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].numberPhases);
  3871. }
  3872. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit == -1)
  3873. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].limit =0;
  3874. if(compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod == -1)
  3875. compositeProfile->chargingSchedule[0].chargingSchedulePeriod[idxPeriod].startPeriod =0;
  3876. }
  3877. if(line)
  3878. free(line);
  3879. ShmOCPP20Data->CSUMsg.bits[(connectorId==0?0:connectorId-1)].ChargingProfileConf = ON;
  3880. }
  3881. //==========================================
  3882. // Init all share memory
  3883. //==========================================
  3884. int InitShareMemory()
  3885. {
  3886. int result = PASS;
  3887. int MeterSMId;
  3888. //creat ShmSysConfigAndInfo
  3889. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  3890. {
  3891. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  3892. result = FAIL;
  3893. }
  3894. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  3895. {
  3896. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  3897. result = FAIL;
  3898. }
  3899. else
  3900. {}
  3901. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  3902. {
  3903. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  3904. result = FAIL;
  3905. }
  3906. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  3907. {
  3908. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  3909. result = FAIL;
  3910. }
  3911. else
  3912. {}
  3913. //creat ShmPsuData
  3914. if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
  3915. {
  3916. DEBUG_ERROR("shmget ShmPsuData NG\n");
  3917. result = FAIL;
  3918. }
  3919. else if ((ShmPsuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  3920. {
  3921. DEBUG_ERROR("shmat ShmPsuData NG\n");
  3922. result = FAIL;
  3923. }
  3924. else
  3925. {}
  3926. //creat ShmOCPP20Data
  3927. if ((MeterSMId = shmget(ShmOcpp20ModuleKey, sizeof(struct OCPP20Data), 0777)) < 0)
  3928. {
  3929. DEBUG_ERROR("shmget ShmOCPP20Data NG\n");
  3930. result = FAIL;
  3931. }
  3932. else if ((ShmOCPP20Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  3933. {
  3934. DEBUG_ERROR("shmat ShmOCPP20Data NG\n");
  3935. result = FAIL;
  3936. }
  3937. else
  3938. {}
  3939. /****************************** For Initial Settings************************************************/
  3940. //offline MeterValue Interval
  3941. TempMeterValueInterval = 0;
  3942. DEBUG_INFO("Authorize_20 size: %d\n", sizeof(struct Authorize_20));
  3943. DEBUG_INFO("BootNotification_20 size: %d\n", sizeof(struct BootNotification_20));
  3944. DEBUG_INFO("CancelReservation_20 size: %d\n", sizeof(struct CancelReservation_20));
  3945. DEBUG_INFO("CertificateSigned_20 size: %d\n", sizeof(struct CertificateSigned_20));
  3946. DEBUG_INFO("ChangeAvailability_20 size: %d\n", sizeof(struct ChangeAvailability_20));
  3947. DEBUG_INFO("ClearCache_20 size: %d\n", sizeof(struct ClearCache_20));
  3948. DEBUG_INFO("ClearChargingProfile_20 size: %d\n", sizeof(struct ClearChargingProfile_20));
  3949. DEBUG_INFO("ClearDisplayMessage_20 size: %d\n", sizeof(struct ClearDisplayMessage_20));
  3950. DEBUG_INFO("ClearedChargingLimit_20 size: %d\n", sizeof(struct ClearedChargingLimit_20));
  3951. DEBUG_INFO("ClearVariableMonitoring_20 size: %d\n", sizeof(struct ClearVariableMonitoring_20));
  3952. DEBUG_INFO("CostUpdated_20 size: %d\n", sizeof(struct CostUpdated_20));
  3953. DEBUG_INFO("CustomerInformation_20 size: %d\n", sizeof(struct CustomerInformation_20));
  3954. DEBUG_INFO("DeleteCertificate_20 size: %d\n", sizeof(struct DeleteCertificate_20));
  3955. DEBUG_INFO("FirmwareStatusNotification_20 size: %d\n", sizeof(struct FirmwareStatusNotification_20));
  3956. DEBUG_INFO("Get15118EVCertificate_20 size: %d\n", sizeof(struct Get15118EVCertificate_20));
  3957. DEBUG_INFO("GetBaseReport_20 size: %d\n", sizeof(struct GetBaseReport_20));
  3958. DEBUG_INFO("GetCertificateStatus_20 size: %d\n", sizeof(struct GetCertificateStatus_20));
  3959. DEBUG_INFO("GetChargingProfiles_20 size: %d\n", sizeof(struct GetChargingProfiles_20));
  3960. DEBUG_INFO("GetCompositeSchedule_20 size: %d\n", sizeof(struct GetCompositeSchedule_20));
  3961. DEBUG_INFO("GetDisplayMessages_20 size: %d\n", sizeof(struct GetDisplayMessages_20));
  3962. DEBUG_INFO("GetInstalledCertificateIds_20 size: %d\n", sizeof(struct GetInstalledCertificateIds_20));
  3963. DEBUG_INFO("GetLog_20 size: %d\n", sizeof(struct GetLog_20));
  3964. DEBUG_INFO("GetMonitoringReport_20 size: %d\n", sizeof(struct GetMonitoringReport_20));
  3965. DEBUG_INFO("GetReport_20 size: %d\n", sizeof(struct GetReport_20));
  3966. DEBUG_INFO("GetTransactionStatus_20 size: %d\n", sizeof(struct GetTransactionStatus_20));
  3967. DEBUG_INFO("GetVariables_20 size: %d\n", sizeof(struct GetVariables_20));
  3968. DEBUG_INFO("InstallCertificate_20 size: %d\n", sizeof(struct InstallCertificate_20));
  3969. DEBUG_INFO("LogStatusNotification_20 size: %d\n", sizeof(struct LogStatusNotification_20));
  3970. DEBUG_INFO("MeterValues_20 size: %d\n", sizeof(struct MeterValues_20));
  3971. DEBUG_INFO("NotifyChargingLimit_20 size: %d\n", sizeof(struct NotifyChargingLimit_20));
  3972. DEBUG_INFO("NotifyCustomerInformation_20 size: %d\n", sizeof(struct NotifyCustomerInformation_20));
  3973. DEBUG_INFO("NotifyDisplayMessages_20 size: %d\n", sizeof(struct NotifyDisplayMessages_20));
  3974. DEBUG_INFO("NotifyEVChargingNeeds_20 size: %d\n", sizeof(struct NotifyEVChargingNeeds_20));
  3975. DEBUG_INFO("NotifyEVChargingSchedule_20 size: %d\n", sizeof(struct NotifyEVChargingSchedule_20));
  3976. DEBUG_INFO("NotifyEvent_20 size: %d\n", sizeof(struct NotifyEvent_20));
  3977. DEBUG_INFO("NotifyMonitoringReport_20 size: %d\n", sizeof(struct NotifyMonitoringReport_20));
  3978. DEBUG_INFO("NotifyReport_20 size: %d\n", sizeof(struct NotifyReport_20));
  3979. DEBUG_INFO("PublishFirmware_20 size: %d\n", sizeof(struct PublishFirmware_20));
  3980. DEBUG_INFO("PublishFirmwareStatusNotification_20 size: %d\n", sizeof(struct PublishFirmwareStatusNotification_20));
  3981. DEBUG_INFO("ReportChargingProfiles_20 size: %d\n", sizeof(struct ReportChargingProfiles_20));
  3982. DEBUG_INFO("RequestStartTransaction_20 size: %d\n", sizeof(struct RequestStartTransaction_20));
  3983. DEBUG_INFO("RequestStopTransaction_20 size: %d\n", sizeof(struct RequestStopTransaction_20));
  3984. DEBUG_INFO("ReservationStatusUpdate_20 size: %d\n", sizeof(struct ReservationStatusUpdate_20));
  3985. DEBUG_INFO("ReserveNow_20 size: %d\n", sizeof(struct ReserveNow_20));
  3986. DEBUG_INFO("Reset_20 size: %d\n", sizeof(struct Reset_20));
  3987. DEBUG_INFO("SecurityEventNotification_20 size: %d\n", sizeof(struct SecurityEventNotification_20));
  3988. DEBUG_INFO("SendLocalList_20 size: %d\n", sizeof(struct SendLocalList_20));
  3989. DEBUG_INFO("SetChargingProfile_20 size: %d\n", sizeof(struct SetChargingProfile_20));
  3990. DEBUG_INFO("SetDisplayMessage_20 size: %d\n", sizeof(struct SetDisplayMessage_20));
  3991. DEBUG_INFO("SetMonitoringBase_20 size: %d\n", sizeof(struct SetMonitoringBase_20));
  3992. DEBUG_INFO("SetMonitoringLevel_20 size: %d\n", sizeof(struct SetMonitoringLevel_20));
  3993. DEBUG_INFO("SetNetworkProfile_20 size: %d\n", sizeof(struct SetNetworkProfile_20));
  3994. DEBUG_INFO("SetVariableMonitoring_20 size: %d\n", sizeof(struct SetVariableMonitoring_20));
  3995. DEBUG_INFO("SetVariables_20 size: %d\n", sizeof(struct SetVariables_20));
  3996. DEBUG_INFO("SignCertificate_20 size: %d\n", sizeof(struct SignCertificate_20));
  3997. DEBUG_INFO("StatusNotification_20 size: %d\n", sizeof(struct StatusNotification_20));
  3998. DEBUG_INFO("TransactionEvent_20 size: %d\n", sizeof(struct TransactionEvent_20));
  3999. DEBUG_INFO("TriggerMessage_20 size: %d\n", sizeof(struct TriggerMessage_20));
  4000. DEBUG_INFO("UnlockConnector_20 size: %d\n", sizeof(struct UnlockConnector_20));
  4001. DEBUG_INFO("UnpublishFirmware_20 size: %d\n", sizeof(struct UnpublishFirmware_20));
  4002. DEBUG_INFO("UpdateFirmware_20 size: %d\n", sizeof(struct UpdateFirmware_20));
  4003. DEBUG_INFO("ChargingProfileType size: %d\n", sizeof(struct ChargingProfileType));
  4004. return result;
  4005. }
  4006. int ProcessShareMemory()
  4007. {
  4008. if(InitShareMemory() == FAIL)
  4009. {
  4010. DEBUG_ERROR("InitShareMemory NG\n");
  4011. if(ShmStatusCodeData!=NULL)
  4012. {
  4013. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
  4014. }
  4015. sleep(5);
  4016. return FAIL;
  4017. }
  4018. return PASS;
  4019. }
  4020. //---------------------common routine---------------------------//
  4021. int isOFFline(void)
  4022. {
  4023. if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
  4024. {
  4025. if(TempMeterValueInterval >= 2 )
  4026. {
  4027. TempMeterValueInterval = 0;
  4028. return TRUE;
  4029. }
  4030. else
  4031. {
  4032. TempMeterValueInterval = TempMeterValueInterval+ 1;
  4033. return FALSE;
  4034. }
  4035. }
  4036. else
  4037. {
  4038. return FALSE;
  4039. }
  4040. }
  4041. void CheckSystemValue(void)
  4042. {
  4043. char filenmae[100]={0};
  4044. char str[100]={0};
  4045. int tempIndex = 0;
  4046. //===============================
  4047. // EVSE operation check
  4048. //===============================
  4049. //===============================
  4050. // Heartbeat check
  4051. //===============================
  4052. if((difftime(time((time_t*)NULL), clientTime.Heartbeat) < 0) || (HeartBeatWaitTime <= 0))
  4053. {
  4054. clientTime.Heartbeat = time((time_t*)NULL);
  4055. if(server_sign == TRUE)
  4056. {
  4057. HeartBeatWaitTime = ShmOCPP20Data->BootNotification.Response_interval;
  4058. }
  4059. else
  4060. {
  4061. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);
  4062. }
  4063. }
  4064. if((server_sign == TRUE) && (difftime(time((time_t*)NULL), clientTime.Heartbeat) >= (HeartBeatWaitTime + HeartBeatWithNOResponse)))
  4065. {
  4066. //parameter for test
  4067. sendHeartbeatRequest(0);
  4068. //==============================================
  4069. // Reset Waiting Time
  4070. //==============================================
  4071. HeartBeatWithNOResponse = HeartBeatWithNOResponse + 1;
  4072. }
  4073. //===============================
  4074. // CSU Trigger Reset Conf
  4075. //===============================
  4076. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->MsMsg.bits.ResetConf == ON))
  4077. {
  4078. sendResetConfirmation((char *)ShmOCPP20Data->Reset.guid);
  4079. }
  4080. //===============================
  4081. // CSU Trigger Authorize Request
  4082. //===============================
  4083. if(isWebsocketSendable &&
  4084. (server_sign == TRUE) &&
  4085. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4086. (authorizeRetryTimes < 3))
  4087. {
  4088. sendAuthorizeRequest(0);
  4089. authorizeRetryTimes = authorizeRetryTimes + 1;
  4090. if(authorizeRetryTimes < 3)
  4091. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4092. }
  4093. else if((server_sign == TRUE) &&
  4094. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON) &&
  4095. (authorizeRetryTimes >= 3))
  4096. {
  4097. authorizeRetryTimes = 0;
  4098. ShmOCPP20Data->OcppConnStatus = 0; // ocpp off-line
  4099. server_sign = FALSE;
  4100. }
  4101. else if((server_sign == FALSE) &&
  4102. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalAuthorizeOffline].variableAttribute[0].value, "TRUE") == 0) &&
  4103. (strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  4104. (ShmOCPP20Data->OcppConnStatus == OFF) &&
  4105. (ShmOCPP20Data->SpMsg.bits.AuthorizeReq == ON))
  4106. {
  4107. sendAuthorizeRequest(0);
  4108. }
  4109. //===============================
  4110. // Each connector operation check
  4111. //===============================
  4112. for(int gun_index=0;gun_index < gunTotalNumber ;gun_index++)
  4113. {
  4114. //==========================================
  4115. // csu trigger DataTransferReq
  4116. //==========================================
  4117. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  4118. {
  4119. sendDataTransferRequest(gun_index);
  4120. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = OFF;
  4121. }
  4122. //===============================
  4123. // CSU Trigger Smart Charging Profilw
  4124. //===============================
  4125. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  4126. {
  4127. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index]);
  4128. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  4129. }
  4130. //==============================================
  4131. // Charger start transaction
  4132. //==============================================
  4133. /*
  4134. if((ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq == ON))
  4135. {
  4136. ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq = OFF;
  4137. sendStartTransactionRequest(gun_index);
  4138. clientTime.StartTransaction = time((time_t*)NULL);
  4139. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4140. }*/
  4141. //==============================================
  4142. // Charger stop transaction
  4143. //==============================================
  4144. /*
  4145. if(((ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq == ON)))
  4146. {
  4147. ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq =OFF;
  4148. sendStopTransactionRequest(gun_index);
  4149. clientTime.StopTransaction = time((time_t*)NULL);
  4150. }*/
  4151. //==============================================
  4152. // Charger status notification & Transaction event report
  4153. //==============================================
  4154. //--- Check Mode Change ---//
  4155. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  4156. if(gunType[gun_index] == 'J')
  4157. {
  4158. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4159. {
  4160. tempIndex = ((gun_index==2) ? 1: 0);
  4161. }
  4162. else
  4163. {
  4164. tempIndex = gun_index;
  4165. }
  4166. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4167. {
  4168. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4169. {
  4170. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  4171. {
  4172. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  4173. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  4174. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4175. if(SystemInitial == 0)
  4176. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4177. }
  4178. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4179. {
  4180. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4181. if((access(filenmae,F_OK))!=-1)
  4182. {
  4183. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4184. sprintf(str,"rm -f %s",filenmae);
  4185. system(str);
  4186. }
  4187. }
  4188. #if 1 // for TempStopTransaction
  4189. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4190. {
  4191. checkTempStopTransaction(gun_index);
  4192. }
  4193. #endif
  4194. }
  4195. }
  4196. }
  4197. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4198. {
  4199. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4200. {
  4201. tempIndex = ((gun_index==2) ? 1: 0);
  4202. }
  4203. else
  4204. {
  4205. tempIndex = gun_index;
  4206. }
  4207. for (int index = 0; index < CCS_QUANTITY; index++)
  4208. {
  4209. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4210. {
  4211. 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]*/ )
  4212. {
  4213. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  4214. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  4215. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4216. if(SystemInitial == 0)
  4217. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4218. }
  4219. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4220. {
  4221. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4222. if((access(filenmae,F_OK))!=-1)
  4223. {
  4224. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4225. sprintf(str,"rm -f %s",filenmae);
  4226. system(str);
  4227. }
  4228. }
  4229. #if 1 // for TempStopTransaction
  4230. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4231. {
  4232. checkTempStopTransaction(gun_index);
  4233. }
  4234. #endif
  4235. }
  4236. }
  4237. }
  4238. else if(gunType[gun_index] == 'G')
  4239. {
  4240. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4241. {
  4242. tempIndex = ((gun_index==2) ? 1: 0);
  4243. }
  4244. else
  4245. {
  4246. tempIndex = gun_index;
  4247. }
  4248. for (int index = 0; index < GB_QUANTITY; index++)
  4249. {
  4250. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4251. {
  4252. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  4253. {
  4254. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  4255. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  4256. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4257. if(SystemInitial == 0)
  4258. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4259. }
  4260. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4261. {
  4262. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4263. if((access(filenmae,F_OK))!=-1)
  4264. {
  4265. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4266. sprintf(str,"rm -f %s",filenmae);
  4267. system(str);
  4268. }
  4269. }
  4270. #if 1 // for TempStopTransaction
  4271. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4272. {
  4273. checkTempStopTransaction(gun_index);
  4274. }
  4275. #endif
  4276. }
  4277. }
  4278. }
  4279. else if(gunType[gun_index] == 'O')
  4280. {
  4281. tempIndex = gun_index;
  4282. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4283. {
  4284. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4285. {
  4286. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  4287. {
  4288. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  4289. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  4290. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4291. if(SystemInitial == 0)
  4292. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4293. }
  4294. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // complete
  4295. {
  4296. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4297. if((access(filenmae,F_OK))!=-1)
  4298. {
  4299. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4300. sprintf(str,"rm -f %s",filenmae);
  4301. system(str);
  4302. }
  4303. }
  4304. #if 1 // for TempStopTransaction
  4305. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4306. {
  4307. checkTempStopTransaction(gun_index);
  4308. }
  4309. #endif
  4310. }
  4311. }
  4312. }
  4313. else
  4314. {
  4315. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4316. {
  4317. tempIndex = 2;
  4318. }
  4319. else
  4320. {
  4321. tempIndex = gun_index;
  4322. }
  4323. for (int index = 0; index < AC_QUANTITY; index++)
  4324. {
  4325. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4326. {
  4327. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  4328. {
  4329. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  4330. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  4331. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4332. if(SystemInitial == 0)
  4333. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4334. }
  4335. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4336. {
  4337. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4338. if((access(filenmae,F_OK))!=-1)
  4339. {
  4340. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4341. sprintf(str,"rm -f %s",filenmae);
  4342. system(str);
  4343. }
  4344. }
  4345. #if 1 // for TempStopTransaction
  4346. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4347. {
  4348. checkTempStopTransaction(gun_index);
  4349. }
  4350. #endif
  4351. }
  4352. }// END
  4353. }
  4354. if(isWebsocketSendable &&
  4355. (cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) &&
  4356. ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 10) )
  4357. {
  4358. if(SystemInitial > 0)
  4359. SystemInitial -= 1;
  4360. sendStatusNotificationRequest(gun_index);
  4361. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  4362. }
  4363. if(isWebsocketSendable && (server_sign == TRUE) && (cpinitateMsg.bits[gun_index].TransactionEventReq == ON))
  4364. {
  4365. sendTransactionEventRequest(gun_index);
  4366. cpinitateMsg.bits[gun_index].TransactionEventReq = OFF;
  4367. }
  4368. //==============================================
  4369. // Meter report
  4370. //==============================================
  4371. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  4372. {
  4373. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  4374. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  4375. }
  4376. // ClockAlign MeterValue
  4377. 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))
  4378. {
  4379. //check Transaction active
  4380. if(gunType[gun_index] == 'J')
  4381. {
  4382. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4383. {
  4384. tempIndex = ((gun_index==2) ? 1: 0);
  4385. }
  4386. else
  4387. {
  4388. tempIndex = gun_index;
  4389. }
  4390. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4391. {
  4392. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4393. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4394. {
  4395. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4396. {
  4397. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4398. }
  4399. }
  4400. }// End for CHAdeMO
  4401. }
  4402. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4403. {
  4404. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4405. {
  4406. tempIndex = ((gun_index==2) ? 1: 0);
  4407. }
  4408. else
  4409. {
  4410. tempIndex = gun_index;
  4411. }
  4412. for (int index = 0; index < CCS_QUANTITY; index++)
  4413. {
  4414. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4415. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4416. {
  4417. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4418. {
  4419. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4420. }
  4421. }
  4422. } // End for CCS
  4423. }
  4424. else if(gunType[gun_index] == 'G')
  4425. {
  4426. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4427. {
  4428. tempIndex = ((gun_index==2) ? 1: 0);
  4429. }
  4430. else
  4431. {
  4432. tempIndex = gun_index;
  4433. }
  4434. for (int index = 0; index < GB_QUANTITY; index++)
  4435. {
  4436. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4437. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4438. {
  4439. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4440. {
  4441. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4442. }
  4443. }
  4444. }// End for GB
  4445. }
  4446. else if(gunType[gun_index] == 'O')
  4447. {
  4448. tempIndex = gun_index;
  4449. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4450. {
  4451. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4452. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4453. {
  4454. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_CHARGING)
  4455. {
  4456. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4457. }
  4458. }
  4459. }
  4460. }
  4461. else
  4462. {
  4463. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4464. {
  4465. tempIndex = 2;
  4466. }
  4467. else
  4468. {
  4469. tempIndex = gun_index;
  4470. }
  4471. for (int index = 0; index < AC_QUANTITY; index++)
  4472. {
  4473. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4474. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4475. {
  4476. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4477. {
  4478. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4479. }
  4480. }
  4481. }//End for AC
  4482. }
  4483. if(cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON)
  4484. {
  4485. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  4486. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  4487. }
  4488. }
  4489. // Sample period MeterValue
  4490. if(((time((time_t*)NULL) - clientTime.MeterValues[gun_index]) > (atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1)))
  4491. {
  4492. //check Transaction active
  4493. if(gunType[gun_index] == 'J')
  4494. {
  4495. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4496. {
  4497. tempIndex = ((gun_index==2) ? 1: 0);
  4498. }
  4499. else
  4500. {
  4501. tempIndex = gun_index;
  4502. }
  4503. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4504. {
  4505. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4506. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4507. {
  4508. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4509. {
  4510. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4511. }
  4512. }
  4513. }// End for CHAdeMO
  4514. }
  4515. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4516. {
  4517. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4518. {
  4519. tempIndex = ((gun_index==2) ? 1: 0);
  4520. }
  4521. else
  4522. {
  4523. tempIndex = gun_index;
  4524. }
  4525. for (int index = 0; index < CCS_QUANTITY; index++)
  4526. {
  4527. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4528. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4529. {
  4530. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4531. {
  4532. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4533. }
  4534. }
  4535. } // End for CCS
  4536. }
  4537. else if(gunType[gun_index] == 'G')
  4538. {
  4539. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4540. {
  4541. tempIndex = ((gun_index==2) ? 1: 0);
  4542. }
  4543. else
  4544. {
  4545. tempIndex = gun_index;
  4546. }
  4547. for (int index = 0; index < GB_QUANTITY; index++)
  4548. {
  4549. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4550. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4551. {
  4552. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4553. {
  4554. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4555. }
  4556. }
  4557. }// End for GB
  4558. }
  4559. else if(gunType[gun_index] == 'O')
  4560. {
  4561. tempIndex = gun_index;
  4562. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4563. {
  4564. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4565. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4566. {
  4567. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  4568. {
  4569. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4570. }
  4571. }
  4572. }
  4573. }
  4574. else
  4575. {
  4576. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4577. {
  4578. tempIndex = 2;
  4579. }
  4580. else
  4581. {
  4582. tempIndex = gun_index;
  4583. }
  4584. for (int index = 0; index < AC_QUANTITY; index++)
  4585. {
  4586. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4587. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4588. {
  4589. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4590. {
  4591. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4592. }
  4593. }
  4594. }//End for AC
  4595. }
  4596. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  4597. {
  4598. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  4599. storeTempStopTransaction(gun_index);
  4600. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  4601. }
  4602. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4603. }
  4604. //==============================================
  4605. // Check Connector reserved
  4606. //==============================================
  4607. //===============================
  4608. // Check if Reserve is expired
  4609. //===============================
  4610. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0) )
  4611. {
  4612. double diff_t;
  4613. struct tm tp;
  4614. // current time
  4615. time_t t = time(NULL);
  4616. strptime((char *)ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime, "%Y-%m-%dT%H:%M:%S", &tp);
  4617. tp.tm_isdst = -1;
  4618. time_t utc = mktime(&tp);
  4619. diff_t = difftime(utc, t);
  4620. if(diff_t <= 0)
  4621. {
  4622. DEBUG_INFO("reserve expired.\n");
  4623. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  4624. }
  4625. }//END OF Check if Reserve is expired
  4626. //==========================================
  4627. // csu trigger FirmwareStatusNotificationReq
  4628. //==========================================
  4629. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  4630. {
  4631. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  4632. }
  4633. //==========================================
  4634. // csu trigger CancelReservationConf
  4635. //==========================================
  4636. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  4637. {
  4638. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  4639. }
  4640. //==========================================
  4641. // csu trigger ChangeAvailabilityConf
  4642. //==========================================
  4643. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  4644. {
  4645. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  4646. }
  4647. //==========================================
  4648. // csu trigger UnlockConnectorConf
  4649. //==========================================
  4650. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  4651. {
  4652. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  4653. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  4654. }
  4655. //==========================================
  4656. // csu trigger ReserveNowConf
  4657. //==========================================
  4658. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  4659. {
  4660. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  4661. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  4662. }
  4663. }
  4664. }
  4665. //==========================================
  4666. // send request routine
  4667. //==========================================
  4668. int sendAuthorizeRequest(int gun_index)
  4669. {
  4670. mtrace();
  4671. int result = FAIL;
  4672. char message[4096]={0};
  4673. char guid[37];
  4674. char tempdata[128]={0};
  4675. json_object *Authorize = json_object_new_object();
  4676. json_object *idToken = json_object_new_object();
  4677. DEBUG_INFO("sendAuthorizeRequest...\n");
  4678. memset(&(ShmOCPP20Data->Authorize.Response_idTokenInfo),0,sizeof(struct IdTokenInfoType));
  4679. //Local Authorize
  4680. if ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_OfflineTxForUnknownIdEnabled].variableAttribute[0].value, "TRUE")==0) &&(ShmOCPP20Data->OcppConnStatus == 0))
  4681. {
  4682. DEBUG_INFO("Allow OfflineTx UnknownId Pass !!!!\n");
  4683. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4684. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, "");
  4685. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]);
  4686. result = PASS;
  4687. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4688. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4689. authorizeRetryTimes = 0;
  4690. return result;
  4691. }
  4692. 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))||
  4693. ((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCtrlr_LocalPreAuthorize].variableAttribute[0].value, "TRUE") == 0)&&(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0)))
  4694. {
  4695. // Query idtag from cache
  4696. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, TRUE);
  4697. // Query idtag from list
  4698. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4699. DB_getIdTag((char *)ShmSysConfigAndInfo->SysConfig.UserId, FALSE);
  4700. if((strcmp((char*)idTagQuery.idToken.idToken,"") == 0) || (strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0) )
  4701. {
  4702. if(strcmp((char*)idTagQuery.idToken.idToken,"") == 0)
  4703. {
  4704. DEBUG_INFO("offline Local Authorization Fail !!!!, Card %s is blank!!!!\n", idTagQuery.idToken.idToken);
  4705. }
  4706. if(strcmp((char*)idTagQuery.idTokenInfo.status,AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != 0)
  4707. {
  4708. DEBUG_INFO("offline Local Authorization Fail !!!!, Card %s is not Accepted!!!!\n", idTagQuery.idToken.idToken);
  4709. }
  4710. DEBUG_INFO("offline Local Authorization Fail !!!!\n");
  4711. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "");
  4712. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4713. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Invalid]);
  4714. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4715. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4716. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4717. authorizeRetryTimes = 0;
  4718. return result;
  4719. }
  4720. else
  4721. {
  4722. DEBUG_INFO("offline Local Authorization get result !!!!\n");
  4723. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, (char*)idTagQuery.idTokenInfo.cacheExpiryDateTime);
  4724. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4725. if(isOvertNow((uint8_t*)&idTagQuery.idTokenInfo.cacheExpiryDateTime[0]))
  4726. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Expired]);
  4727. else
  4728. strcpy((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, (char*)idTagQuery.idTokenInfo.status);
  4729. DEBUG_INFO("ShmOCPP20Data->Authorize.ResponseIdTagInfo.Status: %s \n", ShmOCPP20Data->Authorize.Response_idTokenInfo.status);
  4730. result = PASS;
  4731. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4732. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  4733. authorizeRetryTimes = 0;
  4734. return result;
  4735. }
  4736. }
  4737. //initialize struct Authorize
  4738. memset(&(ShmOCPP20Data->Authorize), 0 , sizeof(struct StructAuthorize));
  4739. //get data from shared memory
  4740. strcpy((char *)ShmOCPP20Data->Authorize.idToken.idToken, (const char *)ShmSysConfigAndInfo->SysConfig.UserId);
  4741. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.idToken));
  4742. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->Authorize.idToken.type));
  4743. json_object_object_add(Authorize, "idToken", idToken);
  4744. random_uuid(guid);
  4745. sprintf(message,"[%d,\"%s\",\"Authorize\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(Authorize, JSON_C_TO_STRING_PLAIN));
  4746. json_object_put(Authorize);
  4747. LWS_Send(message);
  4748. sprintf(tempdata, "Authorize,%d", gun_index);
  4749. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4750. {
  4751. result = PASS;
  4752. }
  4753. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  4754. return result;
  4755. }
  4756. int sendBootNotificationRequest()
  4757. {
  4758. mtrace();
  4759. int result = FAIL;
  4760. char message[4096]={0};
  4761. char guid[37]={0};
  4762. char tempdata[128]={0};
  4763. json_object *BootNotification = json_object_new_object();
  4764. json_object *chargingStation = json_object_new_object();
  4765. json_object *modem = json_object_new_object();
  4766. // Fill BootNotification fields
  4767. DB_getBooType();
  4768. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.model, "%s", ShmSysConfigAndInfo->SysConfig.ModelName);
  4769. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.vendorName, "%s", ShmSysConfigAndInfo->SysConfig.chargePointVendor);
  4770. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.serialNumber, "%s", ShmSysConfigAndInfo->SysConfig.SerialNumber);
  4771. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion, "%s", ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  4772. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  4773. sprintf((char *)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi, "%s", ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  4774. if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D'))
  4775. {
  4776. json_object_object_add(modem, "iccid", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.iccid));
  4777. json_object_object_add(modem, "imsi", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.modem.imsi));
  4778. json_object_object_add(chargingStation, "modem", modem);
  4779. }
  4780. json_object_object_add(chargingStation, "model", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.model));
  4781. json_object_object_add(chargingStation, "vendorName", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.vendorName));
  4782. json_object_object_add(chargingStation, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.serialNumber));
  4783. json_object_object_add(chargingStation, "firmwareVersion", json_object_new_string((char*)ShmOCPP20Data->BootNotification.chargingStation.firmwareVersion));
  4784. json_object_object_add(BootNotification, "chargingStation", chargingStation);
  4785. json_object_object_add(BootNotification, "reason", json_object_new_string((char*)ShmOCPP20Data->BootNotification.reason));
  4786. random_uuid(guid);
  4787. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "BootNotification", json_object_to_json_string_ext(BootNotification, JSON_C_TO_STRING_PLAIN));
  4788. json_object_put(BootNotification);
  4789. LWS_Send(message);
  4790. sprintf(tempdata, "BootNotification,0");
  4791. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4792. {
  4793. result = PASS;
  4794. }
  4795. return result;
  4796. }
  4797. int sendClearedChargingLimitRequest(int gun_index)
  4798. {
  4799. mtrace();
  4800. int result = FAIL;
  4801. char message[4096]={0};
  4802. char guid[37]={0};
  4803. char tempdata[128]={0};
  4804. json_object *ClearedChargingLimit = json_object_new_object();
  4805. json_object_object_add(ClearedChargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ClearedChargingLimit[gun_index].chargingLimitSource));
  4806. json_object_object_add(ClearedChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->ClearedChargingLimit[gun_index].evseId));
  4807. random_uuid(guid);
  4808. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ClearedChargingLimit", json_object_to_json_string_ext(ClearedChargingLimit, JSON_C_TO_STRING_PLAIN));
  4809. json_object_put(ClearedChargingLimit);
  4810. LWS_Send(message);
  4811. sprintf(tempdata, "ClearedChargingLimit,%d", gun_index);
  4812. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4813. {
  4814. result = PASS;
  4815. }
  4816. return result;
  4817. }
  4818. int sendDataTransferRequest(int gun_index)
  4819. {
  4820. mtrace();
  4821. char message[1000]={0};
  4822. char guid[37]={0};
  4823. char tempdata[65]={0};
  4824. int result = FAIL;
  4825. random_uuid(guid);
  4826. sprintf(message,"[%d,\"%s\",\"DataTransfer\",{\"vendorId\":\"%s\",\"messageId\":\"%s\",\"data\":\"%s\"}]",
  4827. MESSAGE_TYPE_CALL,
  4828. guid,
  4829. ShmOCPP20Data->DataTransfer[gun_index].vendorId,
  4830. ShmOCPP20Data->DataTransfer[gun_index].messageId,
  4831. ShmOCPP20Data->DataTransfer[gun_index].data);
  4832. LWS_Send(message);
  4833. sprintf(tempdata, "DataTransfer,%d", (gun_index + 1));
  4834. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4835. {
  4836. result = PASS;
  4837. }
  4838. return result;
  4839. }
  4840. int sendFirmwareStatusNotificationRequest(char *status)
  4841. {
  4842. mtrace();
  4843. int result = FAIL;
  4844. char message[110]={0};
  4845. char guid[37]={0};
  4846. char tempdata[65]={0};
  4847. json_object *FirmwareStatusNotification = json_object_new_object();
  4848. DEBUG_INFO("sendFirmwareStatusNotificationRequest \n");
  4849. sprintf((char *)ShmOCPP20Data->FirmwareStatusNotification.status, "%s", (const char *)status);
  4850. ShmOCPP20Data->FirmwareStatusNotification.requestId = ShmOCPP20Data->UpdateFirmware.requestId;
  4851. json_object_object_add(FirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->FirmwareStatusNotification.status));
  4852. json_object_object_add(FirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->FirmwareStatusNotification.requestId));
  4853. random_uuid(guid);
  4854. sprintf(message,"[%d,\"%s\",\"FirmwareStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(FirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  4855. json_object_put(FirmwareStatusNotification);
  4856. LWS_SendNow(message);
  4857. sprintf(tempdata, "FirmwareStatusNotification,%d", 0);
  4858. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4859. {
  4860. result = PASS;
  4861. }
  4862. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  4863. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = OFF;
  4864. //record status
  4865. if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded])==0)
  4866. {
  4867. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloaded;
  4868. }
  4869. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed])==0)
  4870. {
  4871. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadFailed;
  4872. }
  4873. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading])==0)
  4874. {
  4875. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Downloading;
  4876. }
  4877. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadScheduled])==0)
  4878. {
  4879. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadScheduled;
  4880. }
  4881. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadPaused])==0)
  4882. {
  4883. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_DownloadPaused;
  4884. }
  4885. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Idle])==0)
  4886. {
  4887. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  4888. }
  4889. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallationFailed])==0)
  4890. {
  4891. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallationFailed;
  4892. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  4893. }
  4894. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installing])==0)
  4895. {
  4896. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installing;
  4897. }
  4898. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Installed])==0)
  4899. {
  4900. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Installed;
  4901. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  4902. }
  4903. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallRebooting])==0)
  4904. {
  4905. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallRebooting;
  4906. DB_updateBootType(BootReasonEnumType_FirmwareUpdate);
  4907. }
  4908. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallScheduled])==0)
  4909. {
  4910. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallScheduled;
  4911. }
  4912. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InstallVerificationFailed])==0)
  4913. {
  4914. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InstallVerificationFailed;
  4915. }
  4916. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_InvalidSignature])==0)
  4917. {
  4918. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_InvalidSignature;
  4919. }
  4920. else if(strcmp(status,FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_SignatureVerified])==0)
  4921. {
  4922. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_SignatureVerified;
  4923. }
  4924. return result;
  4925. }
  4926. int sendGet15118EVCertificateRequest()
  4927. {
  4928. mtrace();
  4929. int result = FAIL;
  4930. char message[4096]={0};
  4931. char guid[37]={0};
  4932. char tempdata[128]={0};
  4933. json_object *Get15118EVCertificate = json_object_new_object();
  4934. json_object_object_add(Get15118EVCertificate, "iso15118SchemaVersion", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.iso15118SchemaVersion));
  4935. json_object_object_add(Get15118EVCertificate, "action", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.action));
  4936. json_object_object_add(Get15118EVCertificate, "exiRequest", json_object_new_string((char*)ShmOCPP20Data->Get15118EVCertificate.exiRequest));
  4937. random_uuid(guid);
  4938. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "Get15118EVCertificate", json_object_to_json_string_ext(Get15118EVCertificate, JSON_C_TO_STRING_PLAIN));
  4939. json_object_put(Get15118EVCertificate);
  4940. LWS_Send(message);
  4941. sprintf(tempdata, "Get15118EVCertificate,0");
  4942. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4943. {
  4944. result = PASS;
  4945. }
  4946. return result;
  4947. }
  4948. int sendGetCertificateStatusRequest()
  4949. {
  4950. mtrace();
  4951. int result = FAIL;
  4952. char message[4096]={0};
  4953. char guid[37]={0};
  4954. char tempdata[128]={0};
  4955. json_object *GetCertificateStatus = json_object_new_object();
  4956. json_object *ocspRequestData = json_object_new_object();
  4957. json_object_object_add(ocspRequestData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.hashAlgorithm));
  4958. json_object_object_add(ocspRequestData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerNameHash));
  4959. json_object_object_add(ocspRequestData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.issuerKeyHash));
  4960. json_object_object_add(ocspRequestData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.serialNumber));
  4961. json_object_object_add(ocspRequestData, "responderURL", json_object_new_string((char*)ShmOCPP20Data->GetCertificateStatus.ocspRequestData.responderURL));
  4962. json_object_object_add(GetCertificateStatus, "ocspRequestData", ocspRequestData);
  4963. random_uuid(guid);
  4964. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "GetCertificateStatus", json_object_to_json_string_ext(GetCertificateStatus, JSON_C_TO_STRING_PLAIN));
  4965. json_object_put(GetCertificateStatus);
  4966. LWS_Send(message);
  4967. sprintf(tempdata, "GetCertificateStatus,0");
  4968. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4969. {
  4970. result = PASS;
  4971. }
  4972. return result;
  4973. }
  4974. int sendHeartbeatRequest()
  4975. {
  4976. mtrace();
  4977. int result = FAIL;
  4978. char message[40096]={0};
  4979. char guid[37]={0};
  4980. char tempdata[128]={0};
  4981. random_uuid(guid);
  4982. sprintf(message, "[%d,\"%s\",\"Heartbeat\",{ }]"
  4983. , MESSAGE_TYPE_CALL
  4984. , guid );
  4985. LWS_Send(message);
  4986. sprintf(tempdata, "Heartbeat,%d", 0);
  4987. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  4988. {
  4989. result = PASS;
  4990. }
  4991. return result;
  4992. }
  4993. int sendLogStatusNotificationRequest(char *status)
  4994. {
  4995. mtrace();
  4996. int result = FAIL;
  4997. char message[4096]={0};
  4998. char guid[37]={0};
  4999. char tempdata[128]={0};
  5000. json_object *LogStatusNotification = json_object_new_object();
  5001. DEBUG_INFO("sendLogStatusNotificationRequest \n");
  5002. ShmOCPP20Data->LogStatusNotification.requestId = ShmOCPP20Data->GetLog.requestId;
  5003. sprintf((char *)ShmOCPP20Data->LogStatusNotification.status,"%s",(const char *)status);
  5004. json_object_object_add(LogStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->LogStatusNotification.status));
  5005. json_object_object_add(LogStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->LogStatusNotification.requestId));
  5006. random_uuid(guid);
  5007. sprintf(message,"[%d,\"%s\",\"LogStatusNotification\",%s]",MESSAGE_TYPE_CALL, guid, json_object_to_json_string_ext(LogStatusNotification, JSON_C_TO_STRING_PLAIN));
  5008. json_object_put(LogStatusNotification);
  5009. LWS_SendNow(message);
  5010. sprintf(tempdata, "LogStatusNotification,%d", 0);
  5011. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5012. {
  5013. result = PASS;
  5014. }
  5015. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  5016. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = OFF;
  5017. //record status
  5018. if(strcmp(status,"BadMessage")==0)
  5019. {
  5020. LogStatusNotificationStatus = UploadLogStatusEnumType_BadMessage;
  5021. }
  5022. else if(strcmp(status,"Idle")==0)
  5023. {
  5024. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  5025. }
  5026. else if(strcmp(status,"NotSupportedOperation")==0)
  5027. {
  5028. LogStatusNotificationStatus = UploadLogStatusEnumType_NotSupportedOperation;
  5029. }
  5030. else if(strcmp(status,"PermissionDenied")==0)
  5031. {
  5032. LogStatusNotificationStatus = UploadLogStatusEnumType_PermissionDenied;
  5033. }
  5034. else if(strcmp(status,"Uploaded")==0)
  5035. {
  5036. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploaded;
  5037. }
  5038. else if(strcmp(status,"UploadFailure")==0)
  5039. {
  5040. LogStatusNotificationStatus = UploadLogStatusEnumType_UploadFailure;
  5041. }
  5042. else if(strcmp(status,"Uploading")==0)
  5043. {
  5044. LogStatusNotificationStatus = UploadLogStatusEnumType_Uploading;
  5045. }
  5046. return result;
  5047. }
  5048. int sendMeterValuesRequest(int gun_index, ReadingContextEnumType dataType)
  5049. {
  5050. mtrace();
  5051. int result = FAIL;
  5052. char guid[37]={0};
  5053. char tempdata[65]={0};
  5054. int tempIndex = 0;
  5055. json_object *MeterValueReq = json_object_new_object();
  5056. json_object *meterValues = json_object_new_array();
  5057. json_object *meterValue = json_object_new_object();
  5058. json_object *sampledValues = json_object_new_array();
  5059. json_object *sampledValue = json_object_new_object();
  5060. json_object *unitOfMeasure = json_object_new_object();
  5061. DEBUG_INFO("sendMeterValuesRequest ...\n");
  5062. memset(queuedata, 0, ARRAY_SIZE(queuedata));
  5063. //set value
  5064. ShmOCPP20Data->MeterValues[gun_index].evseId = gun_index + 1; // gun start from 1~
  5065. //UTC Date time
  5066. struct timeval tmnow;
  5067. struct tm *tm;
  5068. char buf[28];//, usec_buf[6];
  5069. gettimeofday(&tmnow, NULL);
  5070. time_t t;
  5071. t = time(NULL);
  5072. /*UTC time and date*/
  5073. tm = gmtime(&t);
  5074. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  5075. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].timestamp, buf);
  5076. //DEBUG_INFO("ShmSysConfigAndInfo->SysConfig.ModelName[0]=%c\n", ShmSysConfigAndInfo->SysConfig.ModelName[0]);
  5077. //idx_sample=0;
  5078. //********************************(1)Current.Import L1************************************************/
  5079. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5080. if(gunType[gun_index] == 'J')
  5081. {
  5082. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5083. {
  5084. tempIndex = ((gun_index==2) ? 1: 0);
  5085. }
  5086. else
  5087. {
  5088. tempIndex = gun_index;
  5089. }
  5090. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5091. {
  5092. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5093. {
  5094. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent;
  5095. }
  5096. }
  5097. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5098. }
  5099. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5100. {
  5101. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5102. {
  5103. tempIndex = ((gun_index==2) ? 1: 0);
  5104. }
  5105. else
  5106. {
  5107. tempIndex = gun_index;
  5108. }
  5109. for (int index = 0; index < CCS_QUANTITY; index++)
  5110. {
  5111. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5112. {
  5113. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent;
  5114. }
  5115. }
  5116. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5117. }
  5118. else if(gunType[gun_index] == 'G')
  5119. {
  5120. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5121. {
  5122. tempIndex = ((gun_index==2) ? 1: 0);
  5123. }
  5124. else
  5125. {
  5126. tempIndex = gun_index;
  5127. }
  5128. for (int index = 0; index < GB_QUANTITY; index++)
  5129. {
  5130. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5131. {
  5132. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent;
  5133. }
  5134. }
  5135. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5136. }
  5137. else if(gunType[gun_index] == 'O')
  5138. {
  5139. tempIndex = gun_index;
  5140. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5141. {
  5142. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5143. {
  5144. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent;
  5145. }
  5146. }
  5147. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5148. }
  5149. else
  5150. {
  5151. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5152. {
  5153. tempIndex = 2;
  5154. }
  5155. else
  5156. {
  5157. tempIndex = gun_index;
  5158. }
  5159. for (int index = 0; index < AC_QUANTITY; index++)
  5160. {
  5161. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5162. {
  5163. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent;
  5164. }
  5165. }
  5166. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5167. }
  5168. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].context, ReadingContextEnumTypeStr[dataType]);
  5169. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5170. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5171. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.uint , "A");
  5172. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[0].unitOfMeasure.multiplier = 0;
  5173. //idx_sample=1;
  5174. //********************************(2)Energy.Active.Import.Register ************************************************/
  5175. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5176. if(gunType[gun_index] == 'J')
  5177. {
  5178. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5179. {
  5180. tempIndex = ((gun_index==2) ? 1: 0);
  5181. }
  5182. else
  5183. {
  5184. tempIndex = gun_index;
  5185. }
  5186. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5187. {
  5188. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5189. {
  5190. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption;
  5191. }
  5192. }
  5193. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5194. }
  5195. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5196. {
  5197. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5198. {
  5199. tempIndex = ((gun_index==2) ? 1: 0);
  5200. }
  5201. else
  5202. {
  5203. tempIndex = gun_index;
  5204. }
  5205. for (int index = 0; index < CCS_QUANTITY; index++)
  5206. {
  5207. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5208. {
  5209. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption;
  5210. }
  5211. }
  5212. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5213. }
  5214. else if(gunType[gun_index] == 'G')
  5215. {
  5216. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5217. {
  5218. tempIndex = ((gun_index==2) ? 1: 0);
  5219. }
  5220. else
  5221. {
  5222. tempIndex = gun_index;
  5223. }
  5224. for (int index = 0; index < GB_QUANTITY; index++)
  5225. {
  5226. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5227. {
  5228. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption;
  5229. }
  5230. }
  5231. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5232. }
  5233. else if(gunType[gun_index] == 'O')
  5234. {
  5235. tempIndex = gun_index;
  5236. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5237. {
  5238. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5239. {
  5240. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption;
  5241. }
  5242. }
  5243. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5244. }
  5245. else
  5246. {
  5247. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5248. {
  5249. tempIndex = 2;
  5250. }
  5251. else
  5252. {
  5253. tempIndex = gun_index;
  5254. }
  5255. for (int index = 0; index < AC_QUANTITY; index++)
  5256. {
  5257. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5258. {
  5259. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption;
  5260. }
  5261. }
  5262. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5263. }
  5264. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].context, ReadingContextEnumTypeStr[dataType]);
  5265. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Register]);
  5266. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5267. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[1].unitOfMeasure.uint , "kWh");
  5268. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5269. //idx_sample=2;
  5270. //****************************************************(3)Energy.Active.Import.Interval*********************************************/
  5271. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5272. if(gunType[gun_index] == 'J')
  5273. {
  5274. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5275. {
  5276. tempIndex = ((gun_index==2) ? 1: 0);
  5277. }
  5278. else
  5279. {
  5280. tempIndex = gun_index;
  5281. }
  5282. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5283. {
  5284. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5285. {
  5286. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy;
  5287. }
  5288. } // END OF FOR CHAdeMO_QUANTITY
  5289. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5290. }
  5291. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5292. {
  5293. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5294. {
  5295. tempIndex = ((gun_index==2) ? 1: 0);
  5296. }
  5297. else
  5298. {
  5299. tempIndex = gun_index;
  5300. }
  5301. for (int index = 0; index < CCS_QUANTITY; index++)
  5302. {
  5303. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5304. {
  5305. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy;
  5306. }
  5307. } // END OF CCS_QUANTITY
  5308. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5309. }
  5310. else if(gunType[gun_index] == 'G')
  5311. {
  5312. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5313. {
  5314. tempIndex = ((gun_index==2) ? 1: 0);
  5315. }
  5316. else
  5317. {
  5318. tempIndex = gun_index;
  5319. }
  5320. for (int index = 0; index < GB_QUANTITY; index++)
  5321. {
  5322. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5323. {
  5324. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy;
  5325. }
  5326. } // END OF GB_QUANTITY
  5327. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5328. }
  5329. else if(gunType[gun_index] == 'O')
  5330. {
  5331. tempIndex = gun_index;
  5332. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5333. {
  5334. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5335. {
  5336. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy;
  5337. }
  5338. }
  5339. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5340. }
  5341. else
  5342. {
  5343. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5344. {
  5345. tempIndex = 2;
  5346. }
  5347. else
  5348. {
  5349. tempIndex = gun_index;
  5350. }
  5351. for (int index = 0; index < AC_QUANTITY; index++)
  5352. {
  5353. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5354. {
  5355. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy;
  5356. }
  5357. }
  5358. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5359. }
  5360. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].context, ReadingContextEnumTypeStr[dataType]);
  5361. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Energy_Active_Import_Interval]);
  5362. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5363. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.uint , "kWh");
  5364. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[2].unitOfMeasure.multiplier = 0;
  5365. //idx_sample=3;
  5366. //********************************(4)Power.Active.Import************************************************/
  5367. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5368. if(gunType[gun_index] == 'J')
  5369. {
  5370. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5371. {
  5372. tempIndex = ((gun_index==2) ? 1: 0);
  5373. }
  5374. else
  5375. {
  5376. tempIndex = gun_index;
  5377. }
  5378. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5379. {
  5380. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5381. {
  5382. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingPower;
  5383. }
  5384. } // END OF FOR
  5385. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5386. }
  5387. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5388. {
  5389. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5390. {
  5391. tempIndex = ((gun_index==2) ? 1: 0);
  5392. }
  5393. else
  5394. {
  5395. tempIndex = gun_index;
  5396. }
  5397. for (int index = 0; index < CCS_QUANTITY; index++)
  5398. {
  5399. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5400. {
  5401. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingPower;
  5402. }
  5403. }
  5404. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5405. }
  5406. else if(gunType[gun_index] == 'G')
  5407. {
  5408. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5409. {
  5410. tempIndex = ((gun_index==2) ? 1: 0);
  5411. }
  5412. else
  5413. {
  5414. tempIndex = gun_index;
  5415. }
  5416. for (int index = 0; index < GB_QUANTITY; index++)
  5417. {
  5418. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5419. {
  5420. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5421. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower;
  5422. }
  5423. }
  5424. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5425. }
  5426. else if(gunType[gun_index] == 'O')
  5427. {
  5428. tempIndex = gun_index;
  5429. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5430. {
  5431. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5432. {
  5433. //ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingPower = 100.0;
  5434. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingPower;
  5435. }
  5436. }
  5437. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5438. }
  5439. else
  5440. {
  5441. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5442. {
  5443. tempIndex = 2;
  5444. }
  5445. else
  5446. {
  5447. tempIndex = gun_index;
  5448. }
  5449. for (int index = 0; index < AC_QUANTITY; index++)
  5450. {
  5451. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5452. {
  5453. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingPower;
  5454. }
  5455. }
  5456. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5457. }
  5458. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].context, ReadingContextEnumTypeStr[dataType]);
  5459. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Power_Active_Import]);
  5460. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5461. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.uint , "kW");
  5462. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[3].unitOfMeasure.multiplier = 0;
  5463. //idx_sample=4;
  5464. //***********************************************(5)VOLTAGE L1******************************************************/
  5465. //J : CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  5466. if(gunType[gun_index] == 'J')
  5467. {
  5468. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5469. {
  5470. tempIndex = ((gun_index==2) ? 1: 0);
  5471. }
  5472. else
  5473. {
  5474. tempIndex = gun_index;
  5475. }
  5476. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5477. {
  5478. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5479. {
  5480. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage;
  5481. }
  5482. }
  5483. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5484. }
  5485. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5486. {
  5487. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5488. {
  5489. tempIndex = ((gun_index==2) ? 1: 0);
  5490. }
  5491. else
  5492. {
  5493. tempIndex = gun_index;
  5494. }
  5495. for (int index = 0; index < CCS_QUANTITY; index++)
  5496. {
  5497. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5498. {
  5499. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage;
  5500. }
  5501. }
  5502. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5503. }
  5504. else if(gunType[gun_index] == 'G')
  5505. {
  5506. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5507. {
  5508. tempIndex = ((gun_index==2) ? 1: 0);
  5509. }
  5510. else
  5511. {
  5512. tempIndex = gun_index;
  5513. }
  5514. for (int index = 0; index < GB_QUANTITY; index++)
  5515. {
  5516. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5517. {
  5518. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage;
  5519. }
  5520. }
  5521. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5522. }
  5523. else if(gunType[gun_index] == 'O')
  5524. {
  5525. tempIndex = gun_index;
  5526. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5527. {
  5528. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5529. {
  5530. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage;
  5531. }
  5532. }
  5533. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5534. }
  5535. else
  5536. {
  5537. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5538. {
  5539. tempIndex = 2;
  5540. }
  5541. else
  5542. {
  5543. tempIndex = gun_index;
  5544. }
  5545. for (int index = 0; index < AC_QUANTITY; index++)
  5546. {
  5547. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5548. {
  5549. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage;
  5550. }
  5551. }
  5552. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].phase, PhaseEnumTypeStr[PhaseEnumType_L1_N]);
  5553. }
  5554. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].context, ReadingContextEnumTypeStr[dataType]);
  5555. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5556. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5557. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.uint , "V");
  5558. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[4].unitOfMeasure.multiplier = 0;
  5559. //***********************************************(6)SOC******************************************************/
  5560. if((gunType[gun_index] == 'J')||(gunType[gun_index] == 'U')||(gunType[gun_index] == 'E')||(gunType[gun_index] == 'G'))
  5561. {
  5562. //idx_sample=5;
  5563. //sampledValue = NULL;
  5564. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  5565. {
  5566. tempIndex = ((gun_index==2) ? 1: 0);
  5567. }
  5568. else
  5569. {
  5570. tempIndex = gun_index;
  5571. }
  5572. if(gunType[gun_index] == 'J')
  5573. {
  5574. //tempIndex = ((gun_index==2) ? 1: 0);
  5575. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  5576. {
  5577. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  5578. {
  5579. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  5580. }
  5581. }
  5582. }
  5583. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  5584. {
  5585. //tempIndex = ((gun_index==2) ? 1: 0);
  5586. for (int index = 0; index < CCS_QUANTITY; index++)
  5587. {
  5588. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  5589. {
  5590. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  5591. }
  5592. }
  5593. }
  5594. else if(gunType[gun_index] == 'G')
  5595. {
  5596. //tempIndex = ((gun_index==2) ? 1: 0);
  5597. for (int index = 0; index < GB_QUANTITY; index++)
  5598. {
  5599. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  5600. {
  5601. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  5602. }
  5603. }
  5604. }
  5605. else if(gunType[gun_index] == 'O')
  5606. {
  5607. //tempIndex = ((gun_index==2) ? 1: 0);
  5608. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  5609. {
  5610. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  5611. {
  5612. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].value = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  5613. }
  5614. }
  5615. }
  5616. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].context, ReadingContextEnumTypeStr[dataType]);
  5617. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].measurand, MeasurandEnumTypeStr[MeasurandEnumType_SoC]);
  5618. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5619. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].location, LocationEnumTypeStr[LocationEnumType_EV]);
  5620. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.uint , "Percent");
  5621. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[5].unitOfMeasure.multiplier = 0;
  5622. }
  5623. //********************************(7)Current.Import L2************************************************/
  5624. // Only for AC 3 phase
  5625. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5626. {
  5627. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5628. {
  5629. tempIndex = 2;
  5630. }
  5631. else
  5632. {
  5633. tempIndex = gun_index;
  5634. }
  5635. for (int index = 0; index < AC_QUANTITY; index++)
  5636. {
  5637. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5638. {
  5639. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2;
  5640. }
  5641. }
  5642. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5643. }
  5644. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].context, ReadingContextEnumTypeStr[dataType]);
  5645. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5646. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5647. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.uint , "A");
  5648. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[6].unitOfMeasure.multiplier = 0;
  5649. //********************************(8)Current.Import L3************************************************/
  5650. // Only for AC 3 phase
  5651. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5652. {
  5653. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5654. {
  5655. tempIndex = 2;
  5656. }
  5657. else
  5658. {
  5659. tempIndex = gun_index;
  5660. }
  5661. for (int index = 0; index < AC_QUANTITY; index++)
  5662. {
  5663. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5664. {
  5665. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3;
  5666. }
  5667. }
  5668. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5669. }
  5670. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].context, ReadingContextEnumTypeStr[dataType]);
  5671. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Current_Import]);
  5672. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5673. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.uint , "A");
  5674. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[7].unitOfMeasure.multiplier = 0;
  5675. //***********************************************(9)VOLTAGE L2******************************************************/
  5676. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5677. {
  5678. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5679. {
  5680. tempIndex = 2;
  5681. }
  5682. else
  5683. {
  5684. tempIndex = gun_index;
  5685. }
  5686. for (int index = 0; index < AC_QUANTITY; index++)
  5687. {
  5688. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5689. {
  5690. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2;
  5691. }
  5692. }
  5693. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].phase, PhaseEnumTypeStr[PhaseEnumType_L2_N]);
  5694. }
  5695. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].context, ReadingContextEnumTypeStr[dataType]);
  5696. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5697. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5698. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.uint , "V");
  5699. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[8].unitOfMeasure.multiplier = 0;
  5700. //***********************************************(10)VOLTAGE L3******************************************************/
  5701. if(('1' <= gunType[gun_index]) && (gunType[gun_index] <= '9') && ((ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'Y') || (ShmSysConfigAndInfo->SysConfig.ModelName[2] == 'W')))
  5702. {
  5703. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  5704. {
  5705. tempIndex = 2;
  5706. }
  5707. else
  5708. {
  5709. tempIndex = gun_index;
  5710. }
  5711. for (int index = 0; index < AC_QUANTITY; index++)
  5712. {
  5713. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  5714. {
  5715. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].value = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3;
  5716. }
  5717. }
  5718. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].phase, PhaseEnumTypeStr[PhaseEnumType_L3_N]);
  5719. }
  5720. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].context, ReadingContextEnumTypeStr[dataType]);
  5721. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].measurand, MeasurandEnumTypeStr[MeasurandEnumType_Voltage]);
  5722. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].location, LocationEnumTypeStr[LocationEnumType_Outlet]);
  5723. strcpy((char *)ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.uint , "V");
  5724. ShmOCPP20Data->MeterValues[gun_index].meterValue[0].sampledValue[9].unitOfMeasure.multiplier = 0;
  5725. // Message create ====================================================================================================
  5726. random_uuid(guid);
  5727. uint8_t idxMeter = 0;
  5728. while(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp) > 0)
  5729. {
  5730. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  5731. {
  5732. if(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value > 0)
  5733. {
  5734. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  5735. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  5736. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  5737. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand) > 0)
  5738. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  5739. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase) > 0)
  5740. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  5741. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location) > 0)
  5742. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  5743. if(strlen((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint) > 0)
  5744. {
  5745. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  5746. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  5747. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  5748. }
  5749. json_object_array_add(sampledValues, sampledValue);
  5750. }
  5751. }
  5752. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->MeterValues[gun_index].meterValue[idxMeter].timestamp));
  5753. json_object_object_add(meterValue, "sampledValue", sampledValues);
  5754. json_object_array_add(meterValues, meterValue);
  5755. idxMeter++;
  5756. }
  5757. json_object_object_add(MeterValueReq, "meterValue", meterValues);
  5758. json_object_object_add(MeterValueReq, "evseId", json_object_new_int(ShmOCPP20Data->MeterValues[gun_index].evseId));
  5759. sprintf(queuedata,"%d,[%d,\"%s\",\"MeterValues\",%s]"
  5760. ,gun_index + 1
  5761. ,MESSAGE_TYPE_CALL
  5762. ,guid
  5763. ,json_object_to_json_string_ext(MeterValueReq, JSON_C_TO_STRING_PLAIN));
  5764. json_object_put(MeterValueReq);
  5765. // Put request guid to hash map
  5766. sprintf(tempdata, "MeterValues,%d", (gun_index));
  5767. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5768. {
  5769. result = PASS;
  5770. }
  5771. if((dataType != ReadingContextEnumType_Trigger) &&
  5772. (dataType != ReadingContextEnumType_Sample_Clock))
  5773. queue_operation(QUEUE_OPERATION_ADD, guid, queuedata );//addq(guid, queuedata); ---> remove temporally
  5774. else
  5775. {
  5776. if(FirstHeartBeat)
  5777. LWS_Send(queuedata +2);
  5778. }
  5779. return result;
  5780. }
  5781. int sendNotifyChargingLimitRequest(int gun_index)
  5782. {
  5783. mtrace();
  5784. int result = FAIL;
  5785. char message[4096]={0};
  5786. char guid[37]={0};
  5787. char tempdata[128]={0};
  5788. json_object *NotifyChargingLimit = json_object_new_object();
  5789. json_object *chargingLimit = json_object_new_object();
  5790. json_object_object_add(NotifyChargingLimit, "evseId", json_object_new_int(ShmOCPP20Data->NotifyChargingLimit[gun_index].evseId));
  5791. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.chargingLimitSource));
  5792. json_object_object_add(chargingLimit, "chargingLimitSource", json_object_new_boolean(ShmOCPP20Data->NotifyChargingLimit[gun_index].chargingLimit.isGridCritical));
  5793. json_object_object_add(NotifyChargingLimit, "chargingLimit", NotifyChargingLimit);
  5794. random_uuid(guid);
  5795. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyChargingLimit", json_object_to_json_string_ext(NotifyChargingLimit, JSON_C_TO_STRING_PLAIN));
  5796. json_object_put(NotifyChargingLimit);
  5797. LWS_Send(message);
  5798. sprintf(tempdata, "NotifyChargingLimit,%d", gun_index);
  5799. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5800. {
  5801. result = PASS;
  5802. }
  5803. return result;
  5804. }
  5805. int sendNotifyCustomerInformationRequest()
  5806. {
  5807. mtrace();
  5808. int result = FAIL;
  5809. char message[4096]={0};
  5810. char guid[37]={0};
  5811. char tempdata[128]={0};
  5812. json_object *NotifyCustomerInformation = json_object_new_object();
  5813. json_object_object_add(NotifyCustomerInformation, "data", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.data));
  5814. json_object_object_add(NotifyCustomerInformation, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyCustomerInformation.tbc));
  5815. json_object_object_add(NotifyCustomerInformation, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.seqNo));
  5816. json_object_object_add(NotifyCustomerInformation, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyCustomerInformation.generatedAt));
  5817. json_object_object_add(NotifyCustomerInformation, "requestId", json_object_new_int(ShmOCPP20Data->NotifyCustomerInformation.requestId));
  5818. random_uuid(guid);
  5819. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyCustomerInformation", json_object_to_json_string_ext(NotifyCustomerInformation, JSON_C_TO_STRING_PLAIN));
  5820. json_object_put(NotifyCustomerInformation);
  5821. LWS_Send(message);
  5822. sprintf(tempdata, "NotifyCustomerInformation,0");
  5823. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5824. {
  5825. result = PASS;
  5826. }
  5827. return result;
  5828. }
  5829. int sendNotifyDisplayMessagesRequest()
  5830. {
  5831. mtrace();
  5832. int result = FAIL;
  5833. char message[4096]={0};
  5834. char guid[37]={0};
  5835. char tempdata[128]={0};
  5836. json_object *NotifyDisplayMessages = json_object_new_object();
  5837. json_object *messageInfos = json_object_new_array();
  5838. json_object_object_add(NotifyDisplayMessages, "requestId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.requestId));
  5839. json_object_object_add(NotifyDisplayMessages, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyDisplayMessages.tbc));
  5840. for(int idxMsg=0;idxMsg<ARRAY_SIZE(ShmOCPP20Data->NotifyDisplayMessages.messageInfo);idxMsg++)
  5841. {
  5842. if(strlen((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content) > 0)
  5843. {
  5844. json_object *messageInfo = json_object_new_object();
  5845. json_object *message = json_object_new_object();
  5846. json_object *display = json_object_new_object();
  5847. json_object *evse = json_object_new_object();
  5848. json_object_object_add(messageInfo, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].id));
  5849. json_object_object_add(messageInfo, "priority", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].priority));
  5850. json_object_object_add(messageInfo, "state", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].state));
  5851. json_object_object_add(messageInfo, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].startDateTime));
  5852. json_object_object_add(messageInfo, "endDateTime", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].endDateTime));
  5853. json_object_object_add(messageInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].transactionId));
  5854. json_object_object_add(message, "format", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.format));
  5855. json_object_object_add(message, "language", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.language));
  5856. json_object_object_add(message, "content", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].message.content));
  5857. json_object_object_add(messageInfo, "message", message);
  5858. json_object_object_add(display, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.name));
  5859. json_object_object_add(display, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.instance));
  5860. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.id));
  5861. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyDisplayMessages.messageInfo[idxMsg].display.evse.connectorId));
  5862. json_object_object_add(display, "evse",evse);
  5863. json_object_object_add(messageInfo, "evse", display);
  5864. json_object_array_add(messageInfos, messageInfo);
  5865. }
  5866. }
  5867. json_object_object_add(NotifyDisplayMessages, "messageInfo", messageInfos);
  5868. random_uuid(guid);
  5869. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyDisplayMessages", json_object_to_json_string_ext(NotifyDisplayMessages, JSON_C_TO_STRING_PLAIN));
  5870. json_object_put(NotifyDisplayMessages);
  5871. LWS_Send(message);
  5872. sprintf(tempdata, "NotifyDisplayMessages,0");
  5873. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5874. {
  5875. result = PASS;
  5876. }
  5877. return result;
  5878. }
  5879. int sendNotifyEVChargingNeedsRequest(int gun_index)
  5880. {
  5881. mtrace();
  5882. int result = FAIL;
  5883. char message[4096]={0};
  5884. char guid[37]={0};
  5885. char tempdata[128]={0};
  5886. json_object *NotifyEVChargingNeeds = json_object_new_object();
  5887. json_object *chargingNeeds = json_object_new_object();
  5888. json_object *acChargingParameters = json_object_new_object();
  5889. json_object *dcChargingParameters = json_object_new_object();
  5890. json_object_object_add(NotifyEVChargingNeeds, "maxScheduleTuples", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].maxScheduleTuples));
  5891. json_object_object_add(NotifyEVChargingNeeds, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].evseId));
  5892. json_object_object_add(chargingNeeds, "requestedEnergyTransfer", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.requestedEnergyTransfer));
  5893. json_object_object_add(chargingNeeds, "departureTime", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.departureTime));
  5894. json_object_object_add(acChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.energyAmount));
  5895. json_object_object_add(acChargingParameters, "evMinCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMinCurrent));
  5896. json_object_object_add(acChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxCurrent));
  5897. json_object_object_add(acChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.acChargingParameters.evMaxVoltage));
  5898. json_object_object_add(chargingNeeds, "acChargingParameters", acChargingParameters);
  5899. json_object_object_add(dcChargingParameters, "evMaxCurrent", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxCurrent));
  5900. json_object_object_add(dcChargingParameters, "evMaxVoltage", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxVoltage));
  5901. json_object_object_add(dcChargingParameters, "energyAmount", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.energyAmount));
  5902. json_object_object_add(dcChargingParameters, "evMaxPower", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evMaxPower));
  5903. json_object_object_add(dcChargingParameters, "stateOfCharge", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.stateOfCharge));
  5904. json_object_object_add(dcChargingParameters, "evEnergyCapacity", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.evEnergyCapacity));
  5905. json_object_object_add(dcChargingParameters, "fullSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.fullSoC));
  5906. json_object_object_add(dcChargingParameters, "bulkSoC", json_object_new_int(ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].chargingNeeds.dcChargingParameters.bulkSoC));
  5907. json_object_object_add(chargingNeeds, "dcChargingParameters", dcChargingParameters);
  5908. json_object_object_add(NotifyEVChargingNeeds, "chargingNeeds", chargingNeeds);
  5909. random_uuid(guid);
  5910. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingNeeds", json_object_to_json_string_ext(NotifyEVChargingNeeds, JSON_C_TO_STRING_PLAIN));
  5911. json_object_put(NotifyEVChargingNeeds);
  5912. LWS_Send(message);
  5913. sprintf(tempdata, "NotifyEVChargingNeeds,%d", gun_index);
  5914. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5915. {
  5916. result = PASS;
  5917. }
  5918. return result;
  5919. }
  5920. int sendNotifyEVChargingScheduleRequest(int gun_index)
  5921. {
  5922. mtrace();
  5923. int result = FAIL;
  5924. char message[4096]={0};
  5925. char guid[37]={0};
  5926. char tempdata[128]={0};
  5927. json_object *NotifyEVChargingSchedule = json_object_new_object();
  5928. json_object *chargingSchedule = json_object_new_object();
  5929. json_object *periods = json_object_new_array();
  5930. json_object_object_add(NotifyEVChargingSchedule, "timeBase", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].timeBase));
  5931. json_object_object_add(NotifyEVChargingSchedule, "evseId", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].evseId));
  5932. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.startSchedule));
  5933. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.duration));
  5934. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingRateUnit));
  5935. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.minChargingRate));
  5936. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.id));
  5937. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  5938. {
  5939. if(((ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  5940. (ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  5941. {
  5942. json_object *Period = json_object_new_object();
  5943. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  5944. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  5945. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  5946. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  5947. if(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  5948. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  5949. json_object_array_add(periods, Period);
  5950. }
  5951. }
  5952. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", periods);
  5953. json_object_object_add(NotifyEVChargingSchedule, "chargingSchedule", chargingSchedule);
  5954. random_uuid(guid);
  5955. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEVChargingSchedule", json_object_to_json_string_ext(NotifyEVChargingSchedule, JSON_C_TO_STRING_PLAIN));
  5956. json_object_put(NotifyEVChargingSchedule);
  5957. LWS_Send(message);
  5958. sprintf(tempdata, "NotifyEVChargingSchedule,%d", gun_index);
  5959. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  5960. {
  5961. result = PASS;
  5962. }
  5963. return result;
  5964. }
  5965. int sendNotifyEventRequest()
  5966. {
  5967. mtrace();
  5968. int result = FAIL;
  5969. char message[4096]={0};
  5970. char guid[37]={0};
  5971. char tempdata[128]={0};
  5972. json_object *NotifyEvent = json_object_new_object();
  5973. json_object *eventDatas = json_object_new_array();
  5974. json_object_object_add(NotifyEvent, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.generatedAt));
  5975. json_object_object_add(NotifyEvent, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.tbc));
  5976. json_object_object_add(NotifyEvent, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyEvent.seqNo));
  5977. for(int idxEvent=0;idxEvent<ARRAY_SIZE(ShmOCPP20Data->NotifyEvent.eventData);idxEvent++)
  5978. {
  5979. if(strlen((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp) > 0)
  5980. {
  5981. json_object *eventData = json_object_new_object();
  5982. json_object *component = json_object_new_object();
  5983. json_object *evse = json_object_new_object();
  5984. json_object *variable = json_object_new_object();
  5985. json_object_object_add(eventData, "eventId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventId));
  5986. json_object_object_add(eventData, "timestamp", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].timestamp));
  5987. json_object_object_add(eventData, "trigger", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].trigger));
  5988. json_object_object_add(eventData, "cause", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cause));
  5989. json_object_object_add(eventData, "actualValue", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].actualValue));
  5990. json_object_object_add(eventData, "techCode", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techcode));
  5991. json_object_object_add(eventData, "techInfo", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].techInfo));
  5992. json_object_object_add(eventData, "cleared", json_object_new_boolean(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].cleared));
  5993. json_object_object_add(eventData, "transactionId", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].transactionId));
  5994. json_object_object_add(eventData, "variableMonitoringId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variableMonitoringId));
  5995. json_object_object_add(eventData, "eventNotificationType", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].eventNotificationType));
  5996. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.name));
  5997. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.instance));
  5998. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.id));
  5999. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyEvent.eventData[idxEvent].component.evse.connectorId));
  6000. json_object_object_add(component, "evse",evse);
  6001. json_object_object_add(eventData, "component", component);
  6002. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.name));
  6003. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyEvent.eventData[idxEvent].variable.instance));
  6004. json_object_object_add(eventData, "variable", variable);
  6005. json_object_array_add(eventDatas, eventData);
  6006. }
  6007. }
  6008. json_object_object_add(NotifyEvent, "eventData", eventDatas);
  6009. random_uuid(guid);
  6010. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyEvent", json_object_to_json_string_ext(NotifyEvent, JSON_C_TO_STRING_PLAIN));
  6011. json_object_put(NotifyEvent);
  6012. LWS_Send(message);
  6013. sprintf(tempdata, "NotifyEvent,0");
  6014. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6015. {
  6016. result = PASS;
  6017. }
  6018. return result;
  6019. }
  6020. int sendNotifyMonitoringReportRequest()
  6021. {
  6022. mtrace();
  6023. int result = FAIL;
  6024. char message[4096]={0};
  6025. char guid[37]={0};
  6026. char tempdata[128]={0};
  6027. json_object *NotifyMonitoringReport = json_object_new_object();
  6028. json_object *monitors = json_object_new_array();
  6029. json_object_object_add(NotifyMonitoringReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.requestId));
  6030. json_object_object_add(NotifyMonitoringReport, "tbc", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.tbc));
  6031. json_object_object_add(NotifyMonitoringReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.seqNo));
  6032. json_object_object_add(NotifyMonitoringReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.generatedAt));
  6033. for(int idxMonitor=0;idxMonitor<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor);idxMonitor++)
  6034. {
  6035. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name) > 0)
  6036. {
  6037. json_object *monitor = json_object_new_object();
  6038. json_object *component = json_object_new_object();
  6039. json_object *evse = json_object_new_object();
  6040. json_object *variable = json_object_new_object();
  6041. json_object *variableMonitorings = json_object_new_array();
  6042. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.name));
  6043. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.instance));
  6044. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.id));
  6045. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].component.evse.connectorId));
  6046. json_object_object_add(component, "evse",evse);
  6047. json_object_object_add(monitor, "component", component);
  6048. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.name));
  6049. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variable.instance));
  6050. json_object_object_add(monitor, "variable", variable);
  6051. for(int idxVar=0;idxVar<ARRAY_SIZE(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring);idxVar++)
  6052. {
  6053. if(strlen((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type) > 0)
  6054. {
  6055. json_object *variableMonitoring = json_object_new_object();
  6056. json_object_object_add(variableMonitoring, "id", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].id));
  6057. json_object_object_add(variableMonitoring, "value", json_object_new_double(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].value));
  6058. json_object_object_add(variableMonitoring, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].type));
  6059. json_object_object_add(variableMonitoring, "severity", json_object_new_int(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].severity));
  6060. json_object_object_add(variableMonitoring, "transaction", json_object_new_boolean(ShmOCPP20Data->NotifyMonitoringReport.monitor[idxMonitor].variableMonitoring[idxVar].transaction));
  6061. json_object_array_add(variableMonitorings, variableMonitoring);
  6062. }
  6063. }
  6064. json_object_object_add(monitor, "variableMonitoring", variableMonitorings);
  6065. json_object_array_add(monitors, monitor);
  6066. }
  6067. }
  6068. json_object_object_add(NotifyMonitoringReport, "monitor", monitors);
  6069. random_uuid(guid);
  6070. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyMonitoringReport", json_object_to_json_string_ext(NotifyMonitoringReport, JSON_C_TO_STRING_PLAIN));
  6071. json_object_put(NotifyMonitoringReport);
  6072. LWS_Send(message);
  6073. sprintf(tempdata, "NotifyMonitoringReport,0");
  6074. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6075. {
  6076. result = PASS;
  6077. }
  6078. return result;
  6079. }
  6080. int sendNotifyReportRequest()
  6081. {
  6082. mtrace();
  6083. int result = FAIL;
  6084. char message[4096]={0};
  6085. char guid[37]={0};
  6086. char tempdata[128]={0};
  6087. json_object *NotifyReport = json_object_new_object();
  6088. json_object *reportDatas = json_object_new_array();
  6089. json_object_object_add(NotifyReport, "requestId", json_object_new_int(ShmOCPP20Data->NotifyReport.requestId));
  6090. json_object_object_add(NotifyReport, "generatedAt", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.generatedAt));
  6091. json_object_object_add(NotifyReport, "tbc", json_object_new_boolean(ShmOCPP20Data->NotifyReport.tbc));
  6092. json_object_object_add(NotifyReport, "seqNo", json_object_new_int(ShmOCPP20Data->NotifyReport.seqNo));
  6093. for(int idxReport=0;idxReport<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData);idxReport++)
  6094. {
  6095. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name) > 0)
  6096. {
  6097. json_object *reportData = json_object_new_object();
  6098. json_object *component = json_object_new_object();
  6099. json_object *evse = json_object_new_object();
  6100. json_object *variable = json_object_new_object();
  6101. json_object *variableAttributes = json_object_new_array();
  6102. json_object *variableCharacteristics = json_object_new_object();
  6103. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.name));
  6104. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].component.instance));
  6105. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.id));
  6106. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->NotifyReport.reportData[idxReport].component.evse.connectorId));
  6107. json_object_object_add(component, "evse",evse);
  6108. json_object_object_add(reportData, "component", component);
  6109. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.name));
  6110. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variable.instance));
  6111. json_object_object_add(reportData, "variable",variable);
  6112. json_object_object_add(variableCharacteristics, "unit", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.unit));
  6113. json_object_object_add(variableCharacteristics, "dataType", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.dataType));
  6114. json_object_object_add(variableCharacteristics, "minLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.minLimit));
  6115. json_object_object_add(variableCharacteristics, "maxLimit", json_object_new_double(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableCharacteristics.maxLimit));
  6116. json_object_object_add(reportData, "variableCharacteristics",variableCharacteristics);
  6117. for(int idxAttr=0;idxAttr<ARRAY_SIZE(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute);idxAttr++)
  6118. {
  6119. if(strlen((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value) > 0)
  6120. {
  6121. json_object *variableAttribute = json_object_new_object();
  6122. json_object_object_add(variableAttribute, "type", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].type));
  6123. json_object_object_add(variableAttribute, "value", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].value));
  6124. json_object_object_add(variableAttribute, "mutability", json_object_new_string((char*)ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].mutability));
  6125. json_object_object_add(variableAttribute, "persistent", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].persistent));
  6126. json_object_object_add(variableAttribute, "constant", json_object_new_boolean(ShmOCPP20Data->NotifyReport.reportData[idxReport].variableAttribute[idxAttr].constant));
  6127. json_object_array_add(variableAttributes, variableAttribute);
  6128. }
  6129. }
  6130. json_object_object_add(reportData, "variableAttribute", variableAttributes);
  6131. json_object_array_add(reportDatas, reportData);
  6132. }
  6133. }
  6134. json_object_object_add(NotifyReport, "reportData", reportDatas);
  6135. random_uuid(guid);
  6136. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "NotifyReport", json_object_to_json_string_ext(NotifyReport, JSON_C_TO_STRING_PLAIN));
  6137. json_object_put(NotifyReport);
  6138. LWS_Send(message);
  6139. sprintf(tempdata, "NotifyReport,0");
  6140. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6141. {
  6142. result = PASS;
  6143. }
  6144. return result;
  6145. }
  6146. int sendPublishFirmwareStatusNotificationRequest()
  6147. {
  6148. mtrace();
  6149. int result = FAIL;
  6150. char message[4096]={0};
  6151. char guid[37]={0};
  6152. char tempdata[128]={0};
  6153. json_object *PublishFirmwareStatusNotification = json_object_new_object();
  6154. json_object *locations = json_object_new_array();
  6155. json_object_object_add(PublishFirmwareStatusNotification, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.status));
  6156. json_object_object_add(PublishFirmwareStatusNotification, "requestId", json_object_new_int(ShmOCPP20Data->PublishFirmwareStatusNotificatio.requestId));
  6157. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->PublishFirmwareStatusNotificatio.location);idx++)
  6158. {
  6159. json_object_array_add(locations, json_object_new_string((char*)ShmOCPP20Data->PublishFirmwareStatusNotificatio.location[idx]));
  6160. }
  6161. json_object_object_add(PublishFirmwareStatusNotification, "location", locations);
  6162. random_uuid(guid);
  6163. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "PublishFirmwareStatusNotification", json_object_to_json_string_ext(PublishFirmwareStatusNotification, JSON_C_TO_STRING_PLAIN));
  6164. json_object_put(PublishFirmwareStatusNotification);
  6165. LWS_Send(message);
  6166. sprintf(tempdata, "PublishFirmwareStatusNotification,0");
  6167. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6168. {
  6169. result = PASS;
  6170. }
  6171. return result;
  6172. }
  6173. int sendReportChargingProfilesRequest(int gun_index)
  6174. {
  6175. mtrace();
  6176. int result = FAIL;
  6177. char message[4096]={0};
  6178. char guid[37]={0};
  6179. char tempdata[128]={0};
  6180. json_object *ReportChargingProfiles = json_object_new_object();
  6181. json_object *chargingProfiles = json_object_new_array();
  6182. json_object_object_add(ReportChargingProfiles, "requestId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].requestId));
  6183. json_object_object_add(ReportChargingProfiles, "chargingLimitSource", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingLimitSource));
  6184. json_object_object_add(ReportChargingProfiles, "tbc", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].tbc));
  6185. json_object_object_add(ReportChargingProfiles, "evseId", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].evseId));
  6186. for(int idxProfile=0;idxProfile<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile);idxProfile++)
  6187. {
  6188. json_object *chargingProfile = json_object_new_object();
  6189. json_object *chargingSchedules = json_object_new_array();
  6190. json_object_object_add(chargingProfile, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].id));
  6191. json_object_object_add(chargingProfile, "stackLevel", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].stackLevel));
  6192. json_object_object_add(chargingProfile, "chargingProfilePurpose", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfilePurpose));
  6193. json_object_object_add(chargingProfile, "chargingProfileKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingProfileKind));
  6194. json_object_object_add(chargingProfile, "recurrencyKind", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].recurrencyKind));
  6195. json_object_object_add(chargingProfile, "validFrom", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validFrom));
  6196. json_object_object_add(chargingProfile, "validTo", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].validTo));
  6197. json_object_object_add(chargingProfile, "transactionId", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].transactionId));
  6198. for(int idxSchedule=0;idxSchedule<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule);idxSchedule++)
  6199. {
  6200. json_object *chargingSchedule = json_object_new_object();
  6201. json_object *chargingSchedulePeriods = json_object_new_array();
  6202. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].startSchedule));
  6203. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].duration));
  6204. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingRateUnit));
  6205. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].minChargingRate));
  6206. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].id));
  6207. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod);idxPeriod++)
  6208. {
  6209. json_object *chargingSchedulePeriod = json_object_new_object();
  6210. json_object_object_add(chargingSchedulePeriod, "startPeriod", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].startPeriod));
  6211. json_object_object_add(chargingSchedulePeriod, "limit", json_object_new_double(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].limit));
  6212. json_object_object_add(chargingSchedulePeriod, "numberPhases", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].numberPhases));
  6213. json_object_object_add(chargingSchedulePeriod, "phaseToUse", json_object_new_int(ShmOCPP20Data->ReportChargingProfiles[gun_index].chargingProfile[idxProfile].chargingSchedule[idxSchedule].chargingSchedulePeriod[idxPeriod].phaseToUse));
  6214. json_object_array_add(chargingSchedulePeriods, chargingSchedulePeriod);
  6215. }
  6216. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriods);
  6217. json_object_array_add(chargingSchedules, chargingSchedule);
  6218. }
  6219. json_object_object_add(chargingProfile, "chargingSchedule", chargingSchedules);
  6220. json_object_array_add(chargingProfiles, chargingProfile);
  6221. }
  6222. json_object_object_add(ReportChargingProfiles, "chargingProfile", chargingProfiles);
  6223. random_uuid(guid);
  6224. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReportChargingProfiles", json_object_to_json_string_ext(ReportChargingProfiles, JSON_C_TO_STRING_PLAIN));
  6225. json_object_put(ReportChargingProfiles);
  6226. LWS_Send(message);
  6227. sprintf(tempdata, "ReportChargingProfiles,%d", gun_index);
  6228. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6229. {
  6230. result = PASS;
  6231. }
  6232. return result;
  6233. }
  6234. int sendReservationStatusUpdateRequest(int gun_index)
  6235. {
  6236. mtrace();
  6237. int result = FAIL;
  6238. char message[4096]={0};
  6239. char guid[37]={0};
  6240. char tempdata[128]={0};
  6241. json_object *ReservationStatusUpdate = json_object_new_object();
  6242. json_object_object_add(ReservationStatusUpdate, "reservationId", json_object_new_int(ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationId));
  6243. json_object_object_add(ReservationStatusUpdate, "reservationUpdateStatus", json_object_new_string((char*)ShmOCPP20Data->ReservationStatusUpdate[gun_index].reservationUpdateStatus));
  6244. random_uuid(guid);
  6245. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "ReservationStatusUpdate", json_object_to_json_string_ext(ReservationStatusUpdate, JSON_C_TO_STRING_PLAIN));
  6246. json_object_put(ReservationStatusUpdate);
  6247. LWS_Send(message);
  6248. sprintf(tempdata, "ReservationStatusUpdate,%d", gun_index);
  6249. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6250. {
  6251. result = PASS;
  6252. }
  6253. return result;
  6254. }
  6255. int sendSecurityEventNotificationRequest()
  6256. {
  6257. mtrace();
  6258. int result = FAIL;
  6259. char message[4096]={0};
  6260. char guid[37]={0};
  6261. char tempdata[128]={0};
  6262. json_object *SecurityEventNotification = json_object_new_object();
  6263. json_object_object_add(SecurityEventNotification, "type", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.type));
  6264. json_object_object_add(SecurityEventNotification, "timestamp", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.timestamp));
  6265. json_object_object_add(SecurityEventNotification, "techInfo", json_object_new_string((char*)ShmOCPP20Data->SecurityEventNotification.techinfo));
  6266. random_uuid(guid);
  6267. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SecurityEventNotification", json_object_to_json_string_ext(SecurityEventNotification, JSON_C_TO_STRING_PLAIN));
  6268. json_object_put(SecurityEventNotification);
  6269. LWS_Send(message);
  6270. sprintf(tempdata, "SecurityEventNotification,0");
  6271. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6272. {
  6273. result = PASS;
  6274. }
  6275. return result;
  6276. }
  6277. int sendSignCertificateRequest()
  6278. {
  6279. mtrace();
  6280. int result = FAIL;
  6281. char message[4096]={0};
  6282. char guid[37]={0};
  6283. char tempdata[128]={0};
  6284. json_object *SignCertificate = json_object_new_object();
  6285. json_object_object_add(SignCertificate, "csr", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.csr));
  6286. json_object_object_add(SignCertificate, "certificateType", json_object_new_string((char*)ShmOCPP20Data->SignCertificate.certificateType));
  6287. random_uuid(guid);
  6288. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "SignCertificate", json_object_to_json_string_ext(SignCertificate, JSON_C_TO_STRING_PLAIN));
  6289. json_object_put(SignCertificate);
  6290. LWS_Send(message);
  6291. sprintf(tempdata, "SignCertificate,0");
  6292. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6293. {
  6294. result = PASS;
  6295. }
  6296. return result;
  6297. }
  6298. int sendStatusNotificationRequest(int gun_index)
  6299. {
  6300. mtrace();
  6301. int result = FAIL;
  6302. char message[600]={0};
  6303. char guid[37];
  6304. int currentStatus = 0;
  6305. struct timeval tmnow;
  6306. struct tm *tm;
  6307. char buf[28];//, usec_buf[6];
  6308. char tempdata[65]={0};
  6309. int tempIndex = 0;
  6310. gettimeofday(&tmnow, NULL);
  6311. time_t t;
  6312. t = time(NULL);
  6313. /*UTC time and date*/
  6314. tm = gmtime(&t);
  6315. strftime(buf,28,"%Y-%m-%dT%H:%M:%SZ", tm);
  6316. #if 0 // remove temporally
  6317. strftime(buf,30,"%Y-%m-%dT%H:%M:%S", tm);
  6318. strcat(buf,".");
  6319. sprintf(usec_buf,"%dZ",(int)tmnow.tv_usec);
  6320. strcat(buf,usec_buf);
  6321. #endif
  6322. printf("%s",buf);
  6323. ShmOCPP20Data->StatusNotification[gun_index].evseId = (gun_index + 1);
  6324. ShmOCPP20Data->StatusNotification[gun_index].connectorId = (gun_index + 1);
  6325. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].timestamp, buf);
  6326. //strcpy(ShmOCPP20Data->StatusNotification[gun_index].ErrorCode, "NoError"); --- CSU Setting
  6327. /*
  6328. enum _SYSTEM_STATUS
  6329. {
  6330. S_BOOTING = 0,
  6331. S_IDLE, = 1
  6332. S_AUTHORIZING, =2
  6333. S_REASSIGN_CHECK, =3
  6334. S_REASSIGN, =4
  6335. S_PRECHARGE, =5
  6336. S_PREPARING_FOR_EV, =6
  6337. S_PREPARING_FOR_EVSE, =7
  6338. S_CHARGING, =8
  6339. S_TERMINATING, =9
  6340. S_COMPLETE, =10
  6341. S_ALARM, =11
  6342. S_FAULT =12
  6343. }
  6344. */
  6345. //check Transaction active
  6346. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  6347. if(gunType[gun_index] == 'J')
  6348. {
  6349. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6350. {
  6351. tempIndex = ((gun_index==2) ? 1: 0);
  6352. }
  6353. else
  6354. {
  6355. tempIndex = gun_index;
  6356. }
  6357. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6358. {
  6359. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6360. {
  6361. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6362. {
  6363. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6364. {
  6365. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6366. }
  6367. else
  6368. {
  6369. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6370. }
  6371. }
  6372. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6373. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6374. ) //S_PRECHARGE
  6375. {
  6376. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6377. }
  6378. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6379. {
  6380. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6381. }
  6382. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6383. {
  6384. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6385. }
  6386. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6387. {
  6388. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6389. }
  6390. 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
  6391. {
  6392. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6393. }
  6394. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6395. {
  6396. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6397. }
  6398. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6399. {
  6400. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6401. }
  6402. } //end of the same index
  6403. }//end of for CHAdeMO_QUANTITY
  6404. }
  6405. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  6406. {
  6407. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6408. {
  6409. tempIndex = ((gun_index==2) ? 1: 0);
  6410. }
  6411. else
  6412. {
  6413. tempIndex = gun_index;
  6414. }
  6415. for (int index = 0; index < CCS_QUANTITY; index++)
  6416. {
  6417. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6418. {
  6419. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6420. {
  6421. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  6422. {
  6423. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6424. }
  6425. else
  6426. {
  6427. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6428. }
  6429. }
  6430. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6431. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6432. ) //S_PRECHARGE
  6433. {
  6434. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6435. }
  6436. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6437. {
  6438. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6439. }
  6440. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6441. {
  6442. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6443. }
  6444. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) //S_TERMINATING ---> SuspendedEV
  6445. {
  6446. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6447. }
  6448. 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
  6449. {
  6450. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status : Unavailable
  6451. }
  6452. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6453. {
  6454. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6455. }
  6456. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6457. {
  6458. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6459. }
  6460. } //end of the same index
  6461. } // end of for CCS_QUANTITY
  6462. }
  6463. else if(gunType[gun_index] == 'G')
  6464. {
  6465. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6466. {
  6467. tempIndex = ((gun_index==2) ? 1: 0);
  6468. }
  6469. else
  6470. {
  6471. tempIndex = gun_index;
  6472. }
  6473. for (int index = 0; index < GB_QUANTITY; index++)
  6474. {
  6475. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6476. {
  6477. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6478. {
  6479. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6480. {
  6481. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6482. }
  6483. else
  6484. {
  6485. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6486. }
  6487. }
  6488. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_AUTHORIZING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6489. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6490. ) //S_PRECHARGE
  6491. {
  6492. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6493. }
  6494. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6495. {
  6496. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6497. }
  6498. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6499. {
  6500. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6501. }
  6502. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6503. {
  6504. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6505. }
  6506. 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
  6507. {
  6508. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6509. }
  6510. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM ,S_FAULT ---> Faulted
  6511. {
  6512. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6513. }
  6514. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6515. {
  6516. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6517. }
  6518. } //end of the same index
  6519. } // end of for GB_QUANTITY
  6520. }
  6521. else if(gunType[gun_index] == 'O')
  6522. {
  6523. tempIndex = gun_index;
  6524. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6525. {
  6526. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6527. {
  6528. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6529. {
  6530. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6531. {
  6532. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6533. }
  6534. else
  6535. {
  6536. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6537. }
  6538. }
  6539. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_AUTHORIZING) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6540. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6541. ) //S_PRECHARGE
  6542. {
  6543. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6544. }
  6545. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6546. {
  6547. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6548. }
  6549. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6550. {
  6551. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6552. }
  6553. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6554. {
  6555. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6556. }
  6557. 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
  6558. {
  6559. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6560. }
  6561. 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
  6562. {
  6563. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6564. }
  6565. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6566. {
  6567. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6568. }
  6569. } //end of the same index
  6570. }
  6571. }
  6572. else
  6573. {
  6574. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  6575. {
  6576. tempIndex = 2;
  6577. }
  6578. else
  6579. {
  6580. tempIndex = gun_index;
  6581. }
  6582. for (int index = 0; index < AC_QUANTITY; index++)
  6583. {
  6584. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  6585. {
  6586. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  6587. {
  6588. 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))
  6589. {
  6590. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6591. }
  6592. else
  6593. {
  6594. currentStatus = ConnectorStatusEnumType_Available; //OCPP Status: Available
  6595. }
  6596. }
  6597. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING)) //SYS_MODE_PREPARING
  6598. {
  6599. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Preparing
  6600. }
  6601. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //SYS_MODE_CHARGING
  6602. {
  6603. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Charging
  6604. }
  6605. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //SYS_MODE_COMPLETE
  6606. {
  6607. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: Finishing
  6608. }
  6609. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6610. {
  6611. currentStatus = ConnectorStatusEnumType_Occupied; //OCPP Status: SuspendedEV
  6612. }
  6613. 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
  6614. {
  6615. currentStatus = ConnectorStatusEnumType_Unavailable; //OCPP Status: Unavailable
  6616. }
  6617. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6618. {
  6619. currentStatus = ConnectorStatusEnumType_Faulted; //OCPP Status: Faulted
  6620. }
  6621. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6622. {
  6623. currentStatus = ConnectorStatusEnumType_Reserved; //OCPP Status: Reserved
  6624. }
  6625. }//end of the same index
  6626. }//end of for AC_QUANTITY
  6627. }
  6628. strcpy((char *)ShmOCPP20Data->StatusNotification[gun_index].connectorStatus, ConnectorStatusEnumTypeStr[currentStatus]);
  6629. random_uuid(guid);
  6630. sprintf(message, "[%d,\"%s\",\"StatusNotification\",{\"connectorId\":%d,\"evseId\":%d,\"connectorStatus\":\"%s\",\"timestamp\":\"%s\"}]"
  6631. , MESSAGE_TYPE_CALL
  6632. , guid
  6633. , ShmOCPP20Data->StatusNotification[gun_index].connectorId
  6634. , ShmOCPP20Data->StatusNotification[gun_index].evseId
  6635. , ShmOCPP20Data->StatusNotification[gun_index].connectorStatus
  6636. , ShmOCPP20Data->StatusNotification[gun_index].timestamp);
  6637. if((server_sign == TRUE))
  6638. {
  6639. LWS_Send(message);
  6640. sprintf(tempdata, "StatusNotification,%d", (gun_index));
  6641. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  6642. {
  6643. result = PASS;
  6644. }
  6645. }
  6646. else
  6647. {
  6648. result = PASS;
  6649. }
  6650. return result;
  6651. }
  6652. int sendTransactionEventRequest(int gun_index)
  6653. {
  6654. mtrace();
  6655. int result = FAIL;
  6656. char message[1024*20]={0};
  6657. char guid[37]={0};
  6658. char tempdata[128]={0};
  6659. uint8_t tempIndex;
  6660. json_object *TransactionEvent = json_object_new_object();
  6661. json_object *transactionInfo = json_object_new_object();
  6662. json_object *idToken = json_object_new_object();
  6663. json_object *evse = json_object_new_object();
  6664. json_object *meterValues = json_object_new_array();
  6665. if(gunType[gun_index] == 'J')
  6666. {
  6667. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6668. {
  6669. tempIndex = ((gun_index==2) ? 1: 0);
  6670. }
  6671. else
  6672. {
  6673. tempIndex = gun_index;
  6674. }
  6675. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  6676. {
  6677. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex))
  6678. {
  6679. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  6680. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  6681. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  6682. else
  6683. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  6684. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  6685. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  6686. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  6687. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)//S_IDLE
  6688. {
  6689. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6690. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6691. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6692. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6693. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6694. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6695. {
  6696. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  6697. }
  6698. else
  6699. {
  6700. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  6701. }
  6702. }
  6703. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  6704. {
  6705. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6706. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6707. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  6708. }
  6709. else if ( ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6710. ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6711. ) //S_PRECHARGE
  6712. {
  6713. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6714. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  6715. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6716. }
  6717. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6718. {
  6719. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  6720. random_uuid(ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  6721. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId);
  6722. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6723. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6724. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6725. }
  6726. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6727. {
  6728. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  6729. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6730. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6731. }
  6732. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6733. {
  6734. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6735. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  6736. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6737. }
  6738. 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
  6739. {
  6740. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6741. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6742. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6743. }
  6744. else if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6745. {
  6746. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6747. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6748. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6749. }
  6750. else if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6751. {
  6752. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6753. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6754. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6755. }
  6756. } //end of the same index
  6757. }//end of for CHAdeMO_QUANTITY
  6758. }
  6759. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  6760. {
  6761. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6762. {
  6763. tempIndex = ((gun_index==2) ? 1: 0);
  6764. }
  6765. else
  6766. {
  6767. tempIndex = gun_index;
  6768. }
  6769. for (int index = 0; index < CCS_QUANTITY; index++)
  6770. {
  6771. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  6772. {
  6773. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  6774. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  6775. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  6776. else
  6777. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  6778. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  6779. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  6780. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  6781. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6782. {
  6783. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6784. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6785. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6786. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6787. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6788. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  6789. {
  6790. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  6791. }
  6792. else
  6793. {
  6794. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  6795. }
  6796. }
  6797. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  6798. {
  6799. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6800. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6801. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  6802. }
  6803. else if ( ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6804. ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6805. ) //S_PRECHARGE
  6806. {
  6807. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6808. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  6809. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6810. }
  6811. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6812. {
  6813. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  6814. random_uuid(ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  6815. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId);
  6816. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6817. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6818. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6819. }
  6820. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6821. {
  6822. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  6823. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6824. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6825. }
  6826. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6827. {
  6828. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6829. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  6830. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6831. }
  6832. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_MAINTAIN)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_DEBUG) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_UPDATE)) // ---> Unavailable
  6833. {
  6834. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6835. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6836. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6837. }
  6838. else if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6839. {
  6840. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6841. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6842. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6843. }
  6844. else if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6845. {
  6846. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6847. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6848. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6849. }
  6850. } //end of the same index
  6851. } // end of for CCS_QUANTITY
  6852. }
  6853. else if(gunType[gun_index] == 'G')
  6854. {
  6855. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  6856. {
  6857. tempIndex = ((gun_index==2) ? 1: 0);
  6858. }
  6859. else
  6860. {
  6861. tempIndex = gun_index;
  6862. }
  6863. for (int index = 0; index < GB_QUANTITY; index++)
  6864. {
  6865. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  6866. {
  6867. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  6868. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  6869. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  6870. else
  6871. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  6872. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  6873. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  6874. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  6875. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6876. {
  6877. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6878. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6879. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6880. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6881. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6882. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn == ON) //0: unplug, 1: Plug-in
  6883. {
  6884. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  6885. }
  6886. else
  6887. {
  6888. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  6889. }
  6890. }
  6891. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  6892. {
  6893. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6894. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6895. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  6896. }
  6897. else if ( ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6898. ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6899. ) //S_PRECHARGE
  6900. {
  6901. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6902. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  6903. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6904. }
  6905. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6906. {
  6907. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  6908. random_uuid(ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  6909. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId);
  6910. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6911. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6912. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6913. }
  6914. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  6915. {
  6916. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  6917. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6918. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6919. }
  6920. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  6921. {
  6922. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6923. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  6924. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6925. }
  6926. 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
  6927. {
  6928. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6929. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6930. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6931. }
  6932. else if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  6933. {
  6934. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6935. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6936. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6937. }
  6938. else if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  6939. {
  6940. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6941. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  6942. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  6943. }
  6944. } //end of the same index
  6945. } // end of for GB_QUANTITY
  6946. }
  6947. else if(gunType[gun_index] == 'O')
  6948. {
  6949. tempIndex = gun_index;
  6950. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  6951. {
  6952. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  6953. {
  6954. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  6955. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  6956. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  6957. else
  6958. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  6959. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  6960. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  6961. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  6962. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) //S_IDLE
  6963. {
  6964. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  6965. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  6966. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  6967. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6968. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6969. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn == ON) // //0: unplug, 1: Plug-in
  6970. {
  6971. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  6972. }
  6973. else
  6974. {
  6975. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  6976. }
  6977. }
  6978. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  6979. {
  6980. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6981. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  6982. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  6983. }
  6984. else if ( ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  6985. ((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  6986. ) //S_PRECHARGE
  6987. {
  6988. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  6989. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  6990. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  6991. }
  6992. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  6993. {
  6994. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  6995. random_uuid(ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  6996. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId);
  6997. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  6998. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  6999. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7000. }
  7001. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7002. {
  7003. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7004. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7005. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7006. }
  7007. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7008. {
  7009. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7010. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7011. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7012. }
  7013. 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
  7014. {
  7015. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7016. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7017. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7018. }
  7019. 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
  7020. {
  7021. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7022. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7023. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7024. }
  7025. else if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7026. {
  7027. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7028. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7029. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7030. }
  7031. } //end of the same index
  7032. }
  7033. }
  7034. else
  7035. {
  7036. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  7037. {
  7038. tempIndex = 2;
  7039. }
  7040. else
  7041. {
  7042. tempIndex = gun_index;
  7043. }
  7044. for (int index = 0; index < AC_QUANTITY; index++)
  7045. {
  7046. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  7047. {
  7048. getNowDatetime(ShmOCPP20Data->TransactionEvent[index].timestamp);
  7049. if((ShmOCPP20Data->TransactionEvent[index].seqNo + 1) < INT_MAX)
  7050. ShmOCPP20Data->TransactionEvent[index].seqNo++;
  7051. else
  7052. ShmOCPP20Data->TransactionEvent[index].seqNo = 0;
  7053. ShmOCPP20Data->TransactionEvent[index].offline = (!ShmOCPP20Data->OcppConnStatus?TRUE:FALSE);
  7054. ShmOCPP20Data->TransactionEvent[index].evse.id = 0;
  7055. ShmOCPP20Data->TransactionEvent[index].evse.connectorId = (gun_index + 1);
  7056. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //SYS_MODE_IDLE
  7057. {
  7058. memset(&ShmOCPP20Data->TransactionEvent[index].transactionInfo, 0x00, sizeof(struct TransactionType));
  7059. memset(&ShmOCPP20Data->TransactionEvent[index].idToken, 0x00, sizeof(struct IdTokenType));
  7060. memset(&ShmOCPP20Data->TransactionEvent[index].meterValue, 0x00, sizeof(struct MeterValueType));
  7061. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7062. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7063. 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))
  7064. {
  7065. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_CablePluggedIn]);
  7066. }
  7067. else
  7068. {
  7069. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_EVCommunicationLost]);
  7070. }
  7071. }
  7072. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING)//S_IDLE
  7073. {
  7074. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7075. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Idle]);
  7076. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_Authorized]);
  7077. }
  7078. else if ( ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_PREPARING)&&( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_PREPARE_FOR_EVSE)) ||
  7079. ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus >= SYS_MODE_CCS_PRECHARGE_STEP0) && ( ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus <= SYS_MODE_CCS_PRECHARGE_STEP1) )
  7080. ) //S_PRECHARGE
  7081. {
  7082. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7083. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_EVConnected]);
  7084. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7085. }
  7086. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) //S_CHARGING
  7087. {
  7088. if(strlen((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId) == 0)
  7089. random_uuid(ShmOCPP20Data->TransactionEvent[index].transactionInfo.transactionId);
  7090. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].idToken.idToken, "%s", ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId);
  7091. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7092. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7093. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7094. }
  7095. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE) //S_COMPLETE
  7096. {
  7097. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Ended]);
  7098. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_Charging]);
  7099. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7100. }
  7101. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) // S_TERMINATING ---> SuspendedEV
  7102. {
  7103. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7104. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEV]);
  7105. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_ChargingStateChanged]);
  7106. }
  7107. 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
  7108. {
  7109. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7110. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7111. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7112. }
  7113. else if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT)|| (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM)) //S_ALARM,S_FAULT ---> Faulted
  7114. {
  7115. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Updated]);
  7116. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7117. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7118. }
  7119. else if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // ---> Reserved
  7120. {
  7121. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].eventType, "%s", TransactionEventEnumTypeStr[TransactionEventEnumType_Started]);
  7122. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].transactionInfo.chargingState, "%s", ChargingStateEnumTypeStr[ChargingStateEnumType_SuspendedEVSE]);
  7123. sprintf((char*)ShmOCPP20Data->TransactionEvent[index].triggerReason, "%s", TriggerReasonEnumTypeStr[TriggerReasonEnumType_AbnormalCondition]);
  7124. }
  7125. }//end of the same index
  7126. }//end of for AC_QUANTITY
  7127. }
  7128. // Message
  7129. json_object_object_add(TransactionEvent, "eventType", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].eventType));
  7130. json_object_object_add(TransactionEvent, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].timestamp));
  7131. json_object_object_add(TransactionEvent, "triggerReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].triggerReason));
  7132. json_object_object_add(TransactionEvent, "seqNo", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].seqNo));
  7133. json_object_object_add(TransactionEvent, "offline", json_object_new_boolean(ShmOCPP20Data->TransactionEvent[gun_index].offline));
  7134. if(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed > 0)
  7135. json_object_object_add(TransactionEvent, "numberOfPhasesUsed", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].numberOfPhasesUsed));
  7136. if(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent > 0)
  7137. json_object_object_add(TransactionEvent, "cableMaxCurrent", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].cableMaxCurrent));
  7138. if(ShmOCPP20Data->TransactionEvent[gun_index].reservationId > 0)
  7139. json_object_object_add(TransactionEvent, "reservationId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].reservationId));
  7140. json_object_object_add(transactionInfo, "transactionId", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId));
  7141. json_object_object_add(transactionInfo, "chargingState", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.chargingState));
  7142. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging > 0)
  7143. json_object_object_add(transactionInfo, "timeSpentCharging", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.timeSpentCharging));
  7144. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason) > 0)
  7145. json_object_object_add(transactionInfo, "stoppedReason", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason));
  7146. if(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId > 0)
  7147. json_object_object_add(transactionInfo, "remoteStartId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.remoteStartId));
  7148. json_object_object_add(TransactionEvent, "transactionInfo", transactionInfo);
  7149. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken) > 0)
  7150. {
  7151. json_object_object_add(idToken, "idToken", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken));
  7152. json_object_object_add(idToken, "type", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.type));
  7153. json_object_object_add(TransactionEvent, "idToken", idToken);
  7154. }
  7155. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.id));
  7156. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].evse.connectorId));
  7157. json_object_object_add(TransactionEvent, "evse", evse);
  7158. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[0].timestamp) > 0)
  7159. {
  7160. for(int idxMeter=0;idxMeter<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue);idxMeter++)
  7161. {
  7162. json_object *meterValue = json_object_new_object();
  7163. json_object *sampledValues = json_object_new_array();
  7164. json_object_object_add(meterValue, "timestamp", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].timestamp));
  7165. for(int idxSample=0;idxSample<ARRAY_SIZE(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue);idxSample++)
  7166. {
  7167. if(strlen((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context) > 0)
  7168. {
  7169. json_object *sampledValue = json_object_new_object();
  7170. json_object *unitOfMeasure = json_object_new_object();
  7171. json_object_object_add(sampledValue, "value", json_object_new_double(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].value));
  7172. json_object_object_add(sampledValue, "context", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].context));
  7173. json_object_object_add(sampledValue, "measurand", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].measurand));
  7174. json_object_object_add(sampledValue, "phase", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].phase));
  7175. json_object_object_add(sampledValue, "location", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].location));
  7176. json_object_object_add(unitOfMeasure, "unit", json_object_new_string((char*)ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.uint));
  7177. json_object_object_add(unitOfMeasure, "multiplier", json_object_new_int(ShmOCPP20Data->TransactionEvent[gun_index].meterValue[idxMeter].sampledValue[idxSample].unitOfMeasure.multiplier));
  7178. json_object_object_add(sampledValue, "unitOfMeasure", unitOfMeasure);
  7179. json_object_array_add(sampledValues, sampledValue);
  7180. }
  7181. }
  7182. json_object_object_add(meterValue, "sampledValue", sampledValues);
  7183. json_object_array_add(meterValues, meterValue);
  7184. }
  7185. json_object_object_add(TransactionEvent, "meterValue", meterValues);
  7186. }
  7187. random_uuid(guid);
  7188. sprintf(message,"[%d,\"%s\",\"%s\",%s]",MESSAGE_TYPE_CALL, guid, "TransactionEvent", json_object_to_json_string_ext(TransactionEvent, JSON_C_TO_STRING_PLAIN));
  7189. json_object_put(TransactionEvent);
  7190. LWS_Send(message);
  7191. sprintf(tempdata, "TransactionEvent,%d", gun_index);
  7192. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == PASS)
  7193. {
  7194. result = PASS;
  7195. }
  7196. return result;
  7197. }
  7198. //==========================================
  7199. // send confirm routine
  7200. //==========================================
  7201. int sendCancelReservationConfirmation(char *uuid, unsigned char gun_index)
  7202. {
  7203. mtrace();
  7204. int result = FAIL;
  7205. char message[4096]={0};
  7206. json_object *CancelReservation = json_object_new_object();
  7207. DEBUG_INFO("sendCancelReservationConfirmation...\n");
  7208. json_object_object_add(CancelReservation, "status", json_object_new_string((char*)ShmOCPP20Data->CancelReservation[gun_index].Response_status));
  7209. sprintf(message,"[%d,\"%s\",%s]"
  7210. ,MESSAGE_TYPE_CALLRESULT
  7211. ,uuid
  7212. ,json_object_to_json_string_ext(CancelReservation, JSON_C_TO_STRING_PLAIN));
  7213. json_object_put(CancelReservation);
  7214. ShmOCPP20Data->CsMsg.bits[0].CancelReservationConf = OFF;
  7215. LWS_Send(message);
  7216. result = TRUE;
  7217. return result;
  7218. }
  7219. int sendCertificateSignedConfirmation(char *uuid)
  7220. {
  7221. mtrace();
  7222. int result = FAIL;
  7223. char message[4096]={0};
  7224. json_object *CertificateSigned = json_object_new_object();
  7225. DEBUG_INFO("sendCertificateSignedConfirmation...\n");
  7226. json_object_object_add(CertificateSigned, "status", json_object_new_string((char*)ShmOCPP20Data->CertificateSigned.Response_status));
  7227. sprintf(message,"[%d,\"%s\",%s]"
  7228. ,MESSAGE_TYPE_CALLRESULT
  7229. ,uuid
  7230. ,json_object_to_json_string_ext(CertificateSigned, JSON_C_TO_STRING_PLAIN));
  7231. json_object_put(CertificateSigned);
  7232. LWS_Send(message);
  7233. result = TRUE;
  7234. return result;
  7235. }
  7236. int sendChangeAvailabilityConfirmation(char *uuid, unsigned char gun_index)
  7237. {
  7238. mtrace();
  7239. int result = FAIL;
  7240. char message[4096]={0};
  7241. json_object *ChangeAvailability = json_object_new_object();
  7242. DEBUG_INFO("sendChangeAvailabilityConfirmation...\n");
  7243. json_object_object_add(ChangeAvailability, "status", json_object_new_string((char*)ShmOCPP20Data->ChangeAvailability[gun_index].Response_status));
  7244. sprintf(message,"[%d,\"%s\",%s]"
  7245. ,MESSAGE_TYPE_CALLRESULT
  7246. ,uuid
  7247. ,json_object_to_json_string_ext(ChangeAvailability, JSON_C_TO_STRING_PLAIN));
  7248. json_object_put(ChangeAvailability);
  7249. LWS_Send(message);
  7250. result = TRUE;
  7251. return result;
  7252. }
  7253. int sendClearCacheConfirmation(char *uuid)
  7254. {
  7255. mtrace();
  7256. int result = FAIL;
  7257. char message[4096]={0};
  7258. json_object *ClearCache = json_object_new_object();
  7259. DEBUG_INFO("sendClearCacheConfirmation...\n");
  7260. json_object_object_add(ClearCache, "status", json_object_new_string((char*)ShmOCPP20Data->ClearCache.Response_status));
  7261. sprintf(message,"[%d,\"%s\",%s]"
  7262. ,MESSAGE_TYPE_CALLRESULT
  7263. ,uuid
  7264. ,json_object_to_json_string_ext(ClearCache, JSON_C_TO_STRING_PLAIN));
  7265. json_object_put(ClearCache);
  7266. LWS_Send(message);
  7267. result = TRUE;
  7268. return result;
  7269. }
  7270. int sendClearChargingProfileConfirmation(char *uuid,char *payload)
  7271. {
  7272. mtrace();
  7273. int result = FAIL;
  7274. char message[500]={0};
  7275. DEBUG_INFO("sendClearChargingProfileConfirmation...\n");
  7276. sprintf(message,"[%d,\"%s\",{\"%s\":\"%s\"}]",MESSAGE_TYPE_CALLRESULT, uuid, "status", payload);
  7277. LWS_Send(message);
  7278. return result;
  7279. }
  7280. int sendClearDisplayMessageConfirmation(char *uuid)
  7281. {
  7282. mtrace();
  7283. int result = FAIL;
  7284. char message[4096]={0};
  7285. json_object *ClearDisplayMessage = json_object_new_object();
  7286. DEBUG_INFO("sendClearDisplayMessageConfirmation...\n");
  7287. json_object_object_add(ClearDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status));
  7288. sprintf(message,"[%d,\"%s\",%s]"
  7289. ,MESSAGE_TYPE_CALLRESULT
  7290. ,uuid
  7291. ,json_object_to_json_string_ext(ClearDisplayMessage, JSON_C_TO_STRING_PLAIN));
  7292. json_object_put(ClearDisplayMessage);
  7293. LWS_Send(message);
  7294. result = TRUE;
  7295. return result;
  7296. }
  7297. int sendClearVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  7298. {
  7299. mtrace();
  7300. int result = FAIL;
  7301. char message[4096]={0};
  7302. json_object *ClearVariableMonitoring = json_object_new_object();
  7303. json_object *clearMonitoringResults = json_object_new_array();
  7304. DEBUG_INFO("sendClearVariableMonitoringConfirmation...\n");
  7305. for(int idx=0;idx<variableQuantity;idx++)
  7306. {
  7307. json_object *clearMonitoringResult = json_object_new_object();
  7308. json_object_object_add(clearMonitoringResult, "id", json_object_new_int(ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id));
  7309. json_object_object_add(clearMonitoringResult, "status", json_object_new_string((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status));
  7310. json_object_array_add(clearMonitoringResults, clearMonitoringResult);
  7311. }
  7312. json_object_object_add(ClearVariableMonitoring, "clearMonitoringResult", clearMonitoringResults);
  7313. sprintf(message,"[%d,\"%s\",%s]"
  7314. ,MESSAGE_TYPE_CALLRESULT
  7315. ,uuid
  7316. ,json_object_to_json_string_ext(ClearVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  7317. json_object_put(ClearVariableMonitoring);
  7318. LWS_Send(message);
  7319. result = TRUE;
  7320. return result;
  7321. }
  7322. int sendCostUpdatedConfirmation(char *uuid)
  7323. {
  7324. mtrace();
  7325. int result = FAIL;
  7326. char message[4096]={0};
  7327. DEBUG_INFO("sendCostUpdatedConfirmation...\n");
  7328. sprintf(message,"[%d,\"%s\",{}]"
  7329. ,MESSAGE_TYPE_CALLRESULT
  7330. ,uuid);
  7331. LWS_Send(message);
  7332. result = TRUE;
  7333. return result;
  7334. }
  7335. int sendCustomerInformationConfirmation(char *uuid)
  7336. {
  7337. mtrace();
  7338. int result = FAIL;
  7339. char message[4096]={0};
  7340. json_object *CustomerInformation = json_object_new_object();
  7341. DEBUG_INFO("sendCustomerInformationConfirmation...\n");
  7342. json_object_object_add(CustomerInformation, "status", json_object_new_string((char*)ShmOCPP20Data->CustomerInformation.Response_status));
  7343. sprintf(message,"[%d,\"%s\",%s]"
  7344. ,MESSAGE_TYPE_CALLRESULT
  7345. ,uuid
  7346. ,json_object_to_json_string_ext(CustomerInformation, JSON_C_TO_STRING_PLAIN));
  7347. json_object_put(CustomerInformation);
  7348. LWS_Send(message);
  7349. result = TRUE;
  7350. return result;
  7351. }
  7352. int sendDataTransferConfirmation(char *uuid, unsigned char gun_index)
  7353. {
  7354. mtrace();
  7355. int result = FAIL;
  7356. char message[4096]={0};
  7357. json_object *DataTransfer = json_object_new_object();
  7358. DEBUG_INFO("sendDataTransferConfirmation...\n");
  7359. json_object_object_add(DataTransfer, "status", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status));
  7360. json_object_object_add(DataTransfer, "data", json_object_new_string((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data));
  7361. sprintf(message,"[%d,\"%s\",%s]"
  7362. ,MESSAGE_TYPE_CALLRESULT
  7363. ,uuid
  7364. ,json_object_to_json_string_ext(DataTransfer, JSON_C_TO_STRING_PLAIN));
  7365. json_object_put(DataTransfer);
  7366. LWS_Send(message);
  7367. result = TRUE;
  7368. return result;
  7369. }
  7370. int sendDeleteCertificateConfirmation(char *uuid)
  7371. {
  7372. mtrace();
  7373. int result = FAIL;
  7374. char message[4096]={0};
  7375. json_object *DeleteCertificate = json_object_new_object();
  7376. DEBUG_INFO("sendDeleteCertificateConfirmation...\n");
  7377. json_object_object_add(DeleteCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->DeleteCertificate.Response_status));
  7378. sprintf(message,"[%d,\"%s\",%s]"
  7379. ,MESSAGE_TYPE_CALLRESULT
  7380. ,uuid
  7381. ,json_object_to_json_string_ext(DeleteCertificate, JSON_C_TO_STRING_PLAIN));
  7382. json_object_put(DeleteCertificate);
  7383. LWS_Send(message);
  7384. result = TRUE;
  7385. return result;
  7386. }
  7387. int sendGetBaseReportConfirmation(char *uuid)
  7388. {
  7389. mtrace();
  7390. int result = FAIL;
  7391. char message[4096]={0};
  7392. json_object *GetBaseReport = json_object_new_object();
  7393. DEBUG_INFO("sendGetBaseReportConfirmation...\n");
  7394. json_object_object_add(GetBaseReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetBaseReport.Response_status));
  7395. sprintf(message,"[%d,\"%s\",%s]"
  7396. ,MESSAGE_TYPE_CALLRESULT
  7397. ,uuid
  7398. ,json_object_to_json_string_ext(GetBaseReport, JSON_C_TO_STRING_PLAIN));
  7399. json_object_put(GetBaseReport);
  7400. LWS_Send(message);
  7401. result = TRUE;
  7402. return result;
  7403. }
  7404. int sendGetChargingProfilesConfirmation(char *uuid, unsigned char gun_index)
  7405. {
  7406. mtrace();
  7407. int result = FAIL;
  7408. char message[4096]={0};
  7409. json_object *GetChargingProfiles = json_object_new_object();
  7410. DEBUG_INFO("sendGetChargingProfilesConfirmation...\n");
  7411. json_object_object_add(GetChargingProfiles, "status", json_object_new_string((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status));
  7412. sprintf(message,"[%d,\"%s\",%s]"
  7413. ,MESSAGE_TYPE_CALLRESULT
  7414. ,uuid
  7415. ,json_object_to_json_string_ext(GetChargingProfiles, JSON_C_TO_STRING_PLAIN));
  7416. json_object_put(GetChargingProfiles);
  7417. LWS_Send(message);
  7418. result = TRUE;
  7419. return result;
  7420. }
  7421. int sendGetCompositeScheduleConfirmation(char *uuid, char *payload, int connectorIdInt, int nPeriod)
  7422. {
  7423. mtrace();
  7424. int result = FAIL;
  7425. char message[4096]={0};
  7426. int CompositeScheduleIndex = 0;
  7427. json_object *GetCompositeSchedule = json_object_new_object();
  7428. json_object *schedule = json_object_new_object();
  7429. json_object *chargingSchedule = json_object_new_object();
  7430. json_object *chargingSchedulePeriod = json_object_new_array();
  7431. DEBUG_INFO("sendGetCompositeScheduleConfirmation...\n");
  7432. json_object_object_add(GetCompositeSchedule, "status", json_object_new_string(payload));
  7433. CompositeScheduleIndex = (connectorIdInt > 0) ?(connectorIdInt -1) : 0;
  7434. if(nPeriod == 0)
  7435. {
  7436. if(strcmp((const char *)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime,"")!=0)
  7437. {
  7438. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7439. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7440. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7441. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7442. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7443. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7444. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7445. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7446. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7447. {
  7448. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7449. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7450. {
  7451. json_object *Period = json_object_new_object();
  7452. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7453. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7454. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7455. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7456. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7457. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7458. json_object_array_add(chargingSchedulePeriod, Period);
  7459. }
  7460. }
  7461. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7462. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7463. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7464. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7465. }
  7466. }
  7467. else
  7468. {
  7469. if(strlen((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule))
  7470. json_object_object_add(chargingSchedule, "startSchedule", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.startSchedule));
  7471. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration > 0)
  7472. json_object_object_add(chargingSchedule, "duration", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.duration));
  7473. json_object_object_add(chargingSchedule, "chargingRateUnit", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingRateUnit));
  7474. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate > 0)
  7475. json_object_object_add(chargingSchedule, "minChargingRate", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.minChargingRate));
  7476. json_object_object_add(chargingSchedule, "id", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.id));
  7477. for(int idxPeriod=0;idxPeriod<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod);idxPeriod++)
  7478. {
  7479. if(((ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod == 0) && (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit>0)) ||
  7480. (ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod > 0))
  7481. {
  7482. json_object *Period = json_object_new_object();
  7483. json_object_object_add(Period, "startPeriod", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].startPeriod));
  7484. json_object_object_add(Period, "limit", json_object_new_double(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].limit));
  7485. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases > 0)
  7486. json_object_object_add(Period, "numberPhases", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].numberPhases));
  7487. if(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse > 0)
  7488. json_object_object_add(Period, "phaseToUse", json_object_new_int(ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.chargingSchedule.chargingSchedulePeriod[idxPeriod].phaseToUse));
  7489. json_object_array_add(chargingSchedulePeriod, Period);
  7490. }
  7491. }
  7492. json_object_object_add(chargingSchedule, "chargingSchedulePeriod", chargingSchedulePeriod);
  7493. json_object_object_add(schedule, "startDateTime", json_object_new_string((char*)ShmOCPP20Data->GetCompositeSchedule[CompositeScheduleIndex].Response_schedule.startDateTime));
  7494. json_object_object_add(schedule, "chargingSchedule", chargingSchedule);
  7495. json_object_object_add(GetCompositeSchedule, "schedule", schedule);
  7496. }
  7497. sprintf(message,"[%d,\"%s\",%s]"
  7498. ,MESSAGE_TYPE_CALLRESULT
  7499. ,uuid
  7500. ,json_object_to_json_string_ext(GetCompositeSchedule, JSON_C_TO_STRING_PLAIN));
  7501. json_object_put(GetCompositeSchedule);
  7502. LWS_Send(message);
  7503. result = TRUE;
  7504. return result;
  7505. }
  7506. int sendGetGetDisplayMessagesConfirmation(char *uuid)
  7507. {
  7508. mtrace();
  7509. int result = FAIL;
  7510. char message[4096]={0};
  7511. json_object *GetGetDisplayMessages = json_object_new_object();
  7512. DEBUG_INFO("sendGetGetDisplayMessagesConfirmation...\n");
  7513. json_object_object_add(GetGetDisplayMessages, "status", json_object_new_string((char*)ShmOCPP20Data->GetDisplayMessages.Response_status));
  7514. sprintf(message,"[%d,\"%s\",%s]"
  7515. ,MESSAGE_TYPE_CALLRESULT
  7516. ,uuid
  7517. ,json_object_to_json_string_ext(GetGetDisplayMessages, JSON_C_TO_STRING_PLAIN));
  7518. json_object_put(GetGetDisplayMessages);
  7519. LWS_Send(message);
  7520. result = TRUE;
  7521. return result;
  7522. }
  7523. int sendGetInstalledCertificateIdsConfirmation(char *uuid, unsigned char certQuantity)
  7524. {
  7525. mtrace();
  7526. int result = FAIL;
  7527. char message[4096]={0};
  7528. json_object *GetInstalledCertificateIds = json_object_new_object();
  7529. json_object *certificateHashDataChains = json_object_new_array();
  7530. DEBUG_INFO("sendGetInstalledCertificateIdsConfirmation...\n");
  7531. json_object_object_add(GetInstalledCertificateIds, "status", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status));
  7532. for(int idx=0;idx<certQuantity;idx++)
  7533. {
  7534. json_object *cert = json_object_new_object();
  7535. json_object *certificateHashData = json_object_new_object();
  7536. json_object_object_add(certificateHashData, "hashAlgorithm", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.hashAlgorithm));
  7537. json_object_object_add(certificateHashData, "issuerNameHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerNameHash));
  7538. json_object_object_add(certificateHashData, "issuerKeyHash", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.issuerKeyHash));
  7539. json_object_object_add(certificateHashData, "serialNumber", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateHashData.serialNumber));
  7540. json_object_object_add(cert, "certificateHashData", certificateHashData);
  7541. json_object_object_add(cert, "certificateType", json_object_new_string((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_certificateHashDataChain[idx].certificateType));
  7542. json_object_array_add(certificateHashDataChains, cert);
  7543. }
  7544. json_object_object_add(GetInstalledCertificateIds , "certificateHashDataChain", certificateHashDataChains);
  7545. sprintf(message,"[%d,\"%s\",%s]"
  7546. ,MESSAGE_TYPE_CALLRESULT
  7547. ,uuid
  7548. ,json_object_to_json_string_ext(GetInstalledCertificateIds, JSON_C_TO_STRING_PLAIN));
  7549. json_object_put(GetInstalledCertificateIds);
  7550. LWS_Send(message);
  7551. result = TRUE;
  7552. return result;
  7553. }
  7554. int sendGetLocalListVersionConfirmation(char *uuid)
  7555. {
  7556. mtrace();
  7557. int result = FAIL;
  7558. char message[4096]={0};
  7559. json_object *GetLocalListVersion = json_object_new_object();
  7560. DEBUG_INFO("sendGetLocalListVersionConfirmation...\n");
  7561. json_object_object_add(GetLocalListVersion, "versionNumber", json_object_new_int(ShmOCPP20Data->GetLocalListVersion.Response_versionNumber));
  7562. sprintf(message,"[%d,\"%s\",%s]"
  7563. ,MESSAGE_TYPE_CALLRESULT
  7564. ,uuid
  7565. ,json_object_to_json_string_ext(GetLocalListVersion, JSON_C_TO_STRING_PLAIN));
  7566. json_object_put(GetLocalListVersion);
  7567. LWS_Send(message);
  7568. result = TRUE;
  7569. return result;
  7570. }
  7571. int sendGetLogConfirmation(char *uuid)
  7572. {
  7573. mtrace();
  7574. int result = FAIL;
  7575. char message[4096]={0};
  7576. json_object *GetLog = json_object_new_object();
  7577. DEBUG_INFO("sendGetLogConfirmation...\n");
  7578. json_object_object_add(GetLog, "status", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_status));
  7579. json_object_object_add(GetLog, "filename", json_object_new_string((char*)ShmOCPP20Data->GetLog.Response_filename));
  7580. sprintf(message,"[%d,\"%s\",%s]"
  7581. ,MESSAGE_TYPE_CALLRESULT
  7582. ,uuid
  7583. ,json_object_to_json_string_ext(GetLog, JSON_C_TO_STRING_PLAIN));
  7584. json_object_put(GetLog);
  7585. LWS_Send(message);
  7586. result = TRUE;
  7587. return result;
  7588. }
  7589. int sendGetMonitoringReportConfirmation(char *uuid)
  7590. {
  7591. mtrace();
  7592. int result = FAIL;
  7593. char message[4096]={0};
  7594. json_object *GetMonitoringReport = json_object_new_object();
  7595. DEBUG_INFO("sendGetMonitoringReportConfirmation...\n");
  7596. json_object_object_add(GetMonitoringReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetMonitoringReport.Response_status));
  7597. sprintf(message,"[%d,\"%s\",%s]"
  7598. ,MESSAGE_TYPE_CALLRESULT
  7599. ,uuid
  7600. ,json_object_to_json_string_ext(GetMonitoringReport, JSON_C_TO_STRING_PLAIN));
  7601. json_object_put(GetMonitoringReport);
  7602. LWS_Send(message);
  7603. result = TRUE;
  7604. return result;
  7605. }
  7606. int sendGetReportConfirmation(char *uuid)
  7607. {
  7608. mtrace();
  7609. int result = FAIL;
  7610. char message[4096]={0};
  7611. json_object *GetReport = json_object_new_object();
  7612. DEBUG_INFO("sendGetReportConfirmation...\n");
  7613. json_object_object_add(GetReport, "status", json_object_new_string((char*)ShmOCPP20Data->GetReport.Response_status));
  7614. sprintf(message,"[%d,\"%s\",%s]"
  7615. ,MESSAGE_TYPE_CALLRESULT
  7616. ,uuid
  7617. ,json_object_to_json_string_ext(GetReport, JSON_C_TO_STRING_PLAIN));
  7618. json_object_put(GetReport);
  7619. LWS_Send(message);
  7620. result = TRUE;
  7621. return result;
  7622. }
  7623. int sendGetTransactionStatusConfirmation(char *uuid, unsigned char gun_index)
  7624. {
  7625. mtrace();
  7626. int result = FAIL;
  7627. char message[4096]={0};
  7628. json_object *GetTransactionStatus = json_object_new_object();
  7629. DEBUG_INFO("sendGetTransactionStatusConfirmation...\n");
  7630. json_object_object_add(GetTransactionStatus, "ongoingIndicator", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator));
  7631. json_object_object_add(GetTransactionStatus, "messagesInQueue", json_object_new_boolean(ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue));
  7632. sprintf(message,"[%d,\"%s\",%s]"
  7633. ,MESSAGE_TYPE_CALLRESULT
  7634. ,uuid
  7635. ,json_object_to_json_string_ext(GetTransactionStatus, JSON_C_TO_STRING_PLAIN));
  7636. json_object_put(GetTransactionStatus);
  7637. LWS_Send(message);
  7638. result = TRUE;
  7639. return result;
  7640. }
  7641. int sendGetVariablesConfirmation(char *uuid, unsigned char variableQuantity)
  7642. {
  7643. mtrace();
  7644. int result = FAIL;
  7645. char message[4096]={0};
  7646. json_object *GetVariables = json_object_new_object();
  7647. json_object *getVariableResults = json_object_new_array();
  7648. DEBUG_INFO("sendGetVariablesConfirmation...\n");
  7649. for(int idx=0;idx<variableQuantity;idx++)
  7650. {
  7651. json_object *variableResult = json_object_new_object();
  7652. json_object *component = json_object_new_object();
  7653. json_object *variable = json_object_new_object();
  7654. json_object *evse = json_object_new_object();
  7655. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  7656. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  7657. json_object_object_add(variableResult, "attributeValue", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus));
  7658. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.id));
  7659. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.evse.connectorId));
  7660. json_object_object_add(component, "component", evse);
  7661. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.name));
  7662. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component.instance));
  7663. json_object_object_add(variableResult, "component", component);
  7664. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.name));
  7665. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable.instance));
  7666. json_object_object_add(variableResult, "variable", variable);
  7667. json_object_array_add(getVariableResults, variableResult);
  7668. }
  7669. json_object_object_add(GetVariables , "setVariableResult", getVariableResults);
  7670. sprintf(message,"[%d,\"%s\",%s]"
  7671. ,MESSAGE_TYPE_CALLRESULT
  7672. ,uuid
  7673. ,json_object_to_json_string_ext(GetVariables, JSON_C_TO_STRING_PLAIN));
  7674. json_object_put(GetVariables);
  7675. LWS_Send(message);
  7676. result = TRUE;
  7677. return result;
  7678. }
  7679. int sendInstallCertificateConfirmation(char *uuid)
  7680. {
  7681. mtrace();
  7682. int result = FAIL;
  7683. char message[4096]={0};
  7684. json_object *InstallCertificate = json_object_new_object();
  7685. DEBUG_INFO("sendInstallCertificateConfirmation...\n");
  7686. json_object_object_add(InstallCertificate, "status", json_object_new_string((char*)ShmOCPP20Data->InstallCertificate.Response_status));
  7687. sprintf(message,"[%d,\"%s\",%s]"
  7688. ,MESSAGE_TYPE_CALLRESULT
  7689. ,uuid
  7690. ,json_object_to_json_string_ext(InstallCertificate, JSON_C_TO_STRING_PLAIN));
  7691. json_object_put(InstallCertificate);
  7692. LWS_Send(message);
  7693. result = TRUE;
  7694. return result;
  7695. }
  7696. int sendPublishFirmwareConfirmation(char *uuid)
  7697. {
  7698. mtrace();
  7699. int result = FAIL;
  7700. char message[4096]={0};
  7701. json_object *PublishFirmware = json_object_new_object();
  7702. json_object_object_add(PublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->PublishFirmware.Response_status));
  7703. DEBUG_INFO("sendPublishFirmwareConfirmation...\n");
  7704. sprintf(message,"[%d,\"%s\",%s]"
  7705. ,MESSAGE_TYPE_CALLRESULT
  7706. ,uuid
  7707. ,json_object_to_json_string_ext(PublishFirmware, JSON_C_TO_STRING_PLAIN));
  7708. json_object_put(PublishFirmware);
  7709. LWS_Send(message);
  7710. result = TRUE;
  7711. return result;
  7712. }
  7713. int sendRemoteStartTransactionConfirmation(char *uuid, unsigned char gun_index)
  7714. {
  7715. mtrace();
  7716. int result = FAIL;
  7717. char message[4096]={0};
  7718. json_object *RemoteStartTransaction = json_object_new_object();
  7719. json_object_object_add(RemoteStartTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_status));
  7720. json_object_object_add(RemoteStartTransaction, "transactionId", json_object_new_string((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].Response_transactionId));
  7721. DEBUG_INFO("sendRemoteStartConfirmation...\n");
  7722. sprintf(message,"[%d,\"%s\",%s]"
  7723. ,MESSAGE_TYPE_CALLRESULT
  7724. ,uuid
  7725. ,json_object_to_json_string_ext(RemoteStartTransaction, JSON_C_TO_STRING_PLAIN));
  7726. json_object_put(RemoteStartTransaction);
  7727. LWS_Send(message);
  7728. result = TRUE;
  7729. return result;
  7730. }
  7731. int sendRemoteStopTransactionConfirmation(char *uuid, unsigned char gun_index)
  7732. {
  7733. mtrace();
  7734. int result = FAIL;
  7735. char message[4096]={0};
  7736. json_object *RemoteStopTransaction = json_object_new_object();
  7737. json_object_object_add(RemoteStopTransaction, "status", json_object_new_string((char*)ShmOCPP20Data->RequestStopTransaction[gun_index].Response_status));
  7738. DEBUG_INFO("sendRemoteStopTransactionConfirmation...\n");
  7739. sprintf(message,"[%d,\"%s\",%s]"
  7740. ,MESSAGE_TYPE_CALLRESULT
  7741. ,uuid
  7742. ,json_object_to_json_string_ext(RemoteStopTransaction, JSON_C_TO_STRING_PLAIN));
  7743. json_object_put(RemoteStopTransaction);
  7744. LWS_Send(message);
  7745. result = TRUE;
  7746. return result;
  7747. }
  7748. int sendReserveNowConfirmation(char *uuid, unsigned char gun_index)
  7749. {
  7750. mtrace();
  7751. int result = FAIL;
  7752. char message[4096]={0};
  7753. json_object *ReserveNow = json_object_new_object();
  7754. json_object_object_add(ReserveNow, "status", json_object_new_string((char*)ShmOCPP20Data->ReserveNow[gun_index].Response_status));
  7755. DEBUG_INFO("sendReserveNowTransactionConfirmation...\n");
  7756. sprintf(message,"[%d,\"%s\",%s]"
  7757. ,MESSAGE_TYPE_CALLRESULT
  7758. ,uuid
  7759. ,json_object_to_json_string_ext(ReserveNow, JSON_C_TO_STRING_PLAIN));
  7760. json_object_put(ReserveNow);
  7761. LWS_Send(message);
  7762. result = TRUE;
  7763. return result;
  7764. }
  7765. int sendResetConfirmation(char *uuid)
  7766. {
  7767. mtrace();
  7768. int result = FAIL;
  7769. char message[4096]={0};
  7770. json_object *Reset = json_object_new_object();
  7771. ShmOCPP20Data->MsMsg.bits.ResetConf = OFF;
  7772. json_object_object_add(Reset, "status", json_object_new_string((char*)ShmOCPP20Data->Reset.Response_status));
  7773. sprintf(message,"[%d,\"%s\",%s]"
  7774. ,MESSAGE_TYPE_CALLRESULT
  7775. ,uuid
  7776. ,json_object_to_json_string_ext(Reset, JSON_C_TO_STRING_PLAIN));
  7777. json_object_put(Reset);
  7778. LWS_Send(message);
  7779. if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Accepted]) == 0)
  7780. {
  7781. DB_updateBootType(BootReasonEnumType_RemoteReset);
  7782. }
  7783. else if(strcmp((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Scheduled]) == 0)
  7784. {
  7785. DB_updateBootType(BootReasonEnumType_ScheduledReset);
  7786. }
  7787. result = TRUE;
  7788. return result;
  7789. }
  7790. int sendSendLocalListConfirmation(char *uuid)
  7791. {
  7792. mtrace();
  7793. int result = FAIL;
  7794. char message[4096]={0};
  7795. json_object *SendLocalList = json_object_new_object();
  7796. json_object_object_add(SendLocalList, "status", json_object_new_string((char*)ShmOCPP20Data->SendLocalList.Response_status));
  7797. sprintf(message,"[%d,\"%s\",%s]"
  7798. ,MESSAGE_TYPE_CALLRESULT
  7799. ,uuid
  7800. ,json_object_to_json_string_ext(SendLocalList, JSON_C_TO_STRING_PLAIN));
  7801. json_object_put(SendLocalList);
  7802. LWS_Send(message);
  7803. result = TRUE;
  7804. return result;
  7805. }
  7806. int sendSetChargingProfileConfirmation(char *uuid, unsigned char gun_index)
  7807. {
  7808. mtrace();
  7809. int result = FAIL;
  7810. char message[4096]={0};
  7811. json_object *SetChargingProfile = json_object_new_object();
  7812. DEBUG_INFO("sendSetChargingProfileConfirmation...\n");
  7813. json_object_object_add(SetChargingProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetChargingProfile[gun_index].Response_status));
  7814. sprintf(message,"[%d,\"%s\",%s]"
  7815. ,MESSAGE_TYPE_CALLRESULT
  7816. ,uuid
  7817. ,json_object_to_json_string_ext(SetChargingProfile, JSON_C_TO_STRING_PLAIN));
  7818. json_object_put(SetChargingProfile);
  7819. LWS_Send(message);
  7820. result = TRUE;
  7821. return result;
  7822. }
  7823. int sendSetDisplayMessageConfirmation(char *uuid)
  7824. {
  7825. mtrace();
  7826. int result = FAIL;
  7827. char message[4096]={0};
  7828. json_object *SetDisplayMessage = json_object_new_object();
  7829. DEBUG_INFO("sendSetDisplayMessageConfirmation...\n");
  7830. json_object_object_add(SetDisplayMessage, "status", json_object_new_string((char*)ShmOCPP20Data->SetDisplayMessage.Response_status));
  7831. sprintf(message,"[%d,\"%s\",%s]"
  7832. ,MESSAGE_TYPE_CALLRESULT
  7833. ,uuid
  7834. ,json_object_to_json_string_ext(SetDisplayMessage, JSON_C_TO_STRING_PLAIN));
  7835. json_object_put(SetDisplayMessage);
  7836. LWS_Send(message);
  7837. result = TRUE;
  7838. return result;
  7839. }
  7840. int sendSetMonitoringBaseConfirmation(char *uuid)
  7841. {
  7842. mtrace();
  7843. int result = FAIL;
  7844. char message[4096]={0};
  7845. json_object *SetMonitoringBase = json_object_new_object();
  7846. DEBUG_INFO("sendSetMonitoringBaseConfirmation...\n");
  7847. json_object_object_add(SetMonitoringBase, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringBase.Response_status));
  7848. sprintf(message,"[%d,\"%s\",%s]"
  7849. ,MESSAGE_TYPE_CALLRESULT
  7850. ,uuid
  7851. ,json_object_to_json_string_ext(SetMonitoringBase, JSON_C_TO_STRING_PLAIN));
  7852. json_object_put(SetMonitoringBase);
  7853. LWS_Send(message);
  7854. result = TRUE;
  7855. return result;
  7856. }
  7857. int sendSetMonitoringLevelConfirmation(char *uuid)
  7858. {
  7859. mtrace();
  7860. int result = FAIL;
  7861. char message[4096]={0};
  7862. json_object *SetMonitoringLevel = json_object_new_object();
  7863. DEBUG_INFO("sendSetMonitoringLevelConfirmation...\n");
  7864. json_object_object_add(SetMonitoringLevel, "status", json_object_new_string((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status));
  7865. sprintf(message,"[%d,\"%s\",%s]"
  7866. ,MESSAGE_TYPE_CALLRESULT
  7867. ,uuid
  7868. ,json_object_to_json_string_ext(SetMonitoringLevel, JSON_C_TO_STRING_PLAIN));
  7869. json_object_put(SetMonitoringLevel);
  7870. LWS_Send(message);
  7871. result = TRUE;
  7872. return result;
  7873. }
  7874. int sendSetNetworkProfileConfirmation(char *uuid)
  7875. {
  7876. mtrace();
  7877. int result = FAIL;
  7878. char message[4096]={0};
  7879. json_object *SetNetworkProfile = json_object_new_object();
  7880. DEBUG_INFO("sendSetNetworkProfileConfirmation...\n");
  7881. json_object_object_add(SetNetworkProfile, "status", json_object_new_string((char*)ShmOCPP20Data->SetNetworkProfile.Response_status));
  7882. sprintf(message,"[%d,\"%s\",%s]"
  7883. ,MESSAGE_TYPE_CALLRESULT
  7884. ,uuid
  7885. ,json_object_to_json_string_ext(SetNetworkProfile, JSON_C_TO_STRING_PLAIN));
  7886. json_object_put(SetNetworkProfile);
  7887. LWS_Send(message);
  7888. result = TRUE;
  7889. return result;
  7890. }
  7891. int sendSetVariableMonitoringConfirmation(char *uuid, unsigned char variableQuantity)
  7892. {
  7893. mtrace();
  7894. int result = FAIL;
  7895. char message[4096]={0};
  7896. json_object *SetVariableMonitoring = json_object_new_object();
  7897. json_object *setMonitoringResults = json_object_new_array();
  7898. DEBUG_INFO("sendSetVariableMonitoringConfirmation...\n");
  7899. for(int idx=0;idx<variableQuantity;idx++)
  7900. {
  7901. json_object *variableMonitorResult = json_object_new_object();
  7902. json_object *component = json_object_new_object();
  7903. json_object *variable = json_object_new_object();
  7904. json_object *evse = json_object_new_object();
  7905. json_object_object_add(variableMonitorResult, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id));
  7906. json_object_object_add(variableMonitorResult, "type", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type));
  7907. json_object_object_add(variableMonitorResult, "severity", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity));
  7908. json_object_object_add(variableMonitorResult, "status", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status));
  7909. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.id));
  7910. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.evse.connectorId));
  7911. json_object_object_add(component, "component", evse);
  7912. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.name));
  7913. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component.instance));
  7914. json_object_object_add(variableMonitorResult, "component", component);
  7915. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.name));
  7916. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable.instance));
  7917. json_object_object_add(variableMonitorResult, "variable", variable);
  7918. json_object_array_add(setMonitoringResults, variableMonitorResult);
  7919. }
  7920. json_object_object_add(SetVariableMonitoring , "setMonitoringResult", setMonitoringResults);
  7921. sprintf(message,"[%d,\"%s\",%s]"
  7922. ,MESSAGE_TYPE_CALLRESULT
  7923. ,uuid
  7924. ,json_object_to_json_string_ext(SetVariableMonitoring, JSON_C_TO_STRING_PLAIN));
  7925. json_object_put(SetVariableMonitoring);
  7926. LWS_Send(message);
  7927. result = TRUE;
  7928. return result;
  7929. }
  7930. int sendSetVariableConfirmation(char *uuid, unsigned char variableQuantity)
  7931. {
  7932. mtrace();
  7933. int result = FAIL;
  7934. char message[4096]={0};
  7935. json_object *SetVariable = json_object_new_object();
  7936. json_object *setVariableResults = json_object_new_array();
  7937. DEBUG_INFO("sendSetVariableConfirmation...\n");
  7938. for(int idx=0;idx<variableQuantity;idx++)
  7939. {
  7940. json_object *variableResult = json_object_new_object();
  7941. json_object *component = json_object_new_object();
  7942. json_object *variable = json_object_new_object();
  7943. json_object *evse = json_object_new_object();
  7944. json_object_object_add(variableResult, "attributeType", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType));
  7945. json_object_object_add(variableResult, "attributeStatus", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus));
  7946. json_object_object_add(evse, "id", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.id));
  7947. json_object_object_add(evse, "connectorId", json_object_new_int(ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.evse.connectorId));
  7948. json_object_object_add(component, "component", evse);
  7949. json_object_object_add(component, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.name));
  7950. json_object_object_add(component, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component.instance));
  7951. json_object_object_add(variableResult, "component", component);
  7952. json_object_object_add(variable, "name", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.name));
  7953. json_object_object_add(variable, "instance", json_object_new_string((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable.instance));
  7954. json_object_object_add(variableResult, "variable", variable);
  7955. json_object_array_add(setVariableResults, variableResult);
  7956. }
  7957. json_object_object_add(SetVariable , "setVariableResult", setVariableResults);
  7958. sprintf(message,"[%d,\"%s\",%s]"
  7959. ,MESSAGE_TYPE_CALLRESULT
  7960. ,uuid
  7961. ,json_object_to_json_string_ext(SetVariable, JSON_C_TO_STRING_PLAIN));
  7962. json_object_put(SetVariable);
  7963. LWS_Send(message);
  7964. result = TRUE;
  7965. return result;
  7966. }
  7967. int sendTriggerMessageConfirmation(char *uuid)
  7968. {
  7969. mtrace();
  7970. int result = FAIL;
  7971. char message[4096]={0};
  7972. json_object *TriggerMessage = json_object_new_object();
  7973. DEBUG_INFO("sendTriggerMessageConfirmation...\n");
  7974. json_object_object_add(TriggerMessage, "status", json_object_new_string((char*)ShmOCPP20Data->TriggerMessage.Response_status));
  7975. sprintf(message,"[%d,\"%s\",%s]",
  7976. MESSAGE_TYPE_CALLRESULT,
  7977. uuid,
  7978. json_object_to_json_string_ext(TriggerMessage, JSON_C_TO_STRING_PLAIN));
  7979. json_object_put(TriggerMessage);
  7980. LWS_Send(message);
  7981. result = TRUE;
  7982. return result;
  7983. }
  7984. int sendUnlockConnectorConfirmation(char *uuid, unsigned char gun_index)
  7985. {
  7986. mtrace();
  7987. int result = FAIL;
  7988. char message[4096]={0};
  7989. json_object *UnlockConnector = json_object_new_object();
  7990. DEBUG_INFO("sendUnlockConnectorConfirmation...\n");
  7991. json_object_object_add(UnlockConnector, "status", json_object_new_string((char*)ShmOCPP20Data->UnlockConnector[gun_index].Response_status));
  7992. sprintf(message,"[%d,\"%s\",%s]",
  7993. MESSAGE_TYPE_CALLRESULT,
  7994. uuid,
  7995. json_object_to_json_string_ext(UnlockConnector, JSON_C_TO_STRING_PLAIN));
  7996. json_object_put(UnlockConnector);
  7997. LWS_Send(message);
  7998. result = TRUE;
  7999. return result;
  8000. }
  8001. int sendUnpublishFirmwareConfirmation(char *uuid)
  8002. {
  8003. mtrace();
  8004. int result = FAIL;
  8005. char message[4096]={0};
  8006. json_object *UnpublishFirmware = json_object_new_object();
  8007. DEBUG_INFO("sendUnpublishFirmwareConfirmation...\n");
  8008. json_object_object_add(UnpublishFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UnpublishFirmware.Response_status));
  8009. sprintf(message,"[%d,\"%s\",%s]"
  8010. ,MESSAGE_TYPE_CALLRESULT
  8011. ,uuid
  8012. ,json_object_to_json_string_ext(UnpublishFirmware, JSON_C_TO_STRING_PLAIN));
  8013. json_object_put(UnpublishFirmware);
  8014. LWS_Send(message);
  8015. result = TRUE;
  8016. return result;
  8017. }
  8018. int sendUpdateFirmwareConfirmation(char *uuid)
  8019. {
  8020. mtrace();
  8021. int result = FAIL;
  8022. char message[4096]={0};
  8023. json_object *UpdateFirmware = json_object_new_object();
  8024. DEBUG_INFO("sendUpdateFirmwareConfirmation...\n");
  8025. json_object_object_add(UpdateFirmware, "status", json_object_new_string((char*)ShmOCPP20Data->UpdateFirmware.Response_status));
  8026. sprintf(message,"[%d,\"%s\",%s]"
  8027. ,MESSAGE_TYPE_CALLRESULT
  8028. ,uuid
  8029. ,json_object_to_json_string_ext(UpdateFirmware, JSON_C_TO_STRING_PLAIN));
  8030. json_object_put(UpdateFirmware);
  8031. LWS_Send(message);
  8032. result = TRUE;
  8033. return result;
  8034. }
  8035. //==========================================
  8036. // send CallError routine
  8037. //==========================================
  8038. void SendCallError(char *uniqueId, char *action, char *errorCode, char *errorDescription)
  8039. {
  8040. mtrace();
  8041. char message[220]={0};
  8042. DEBUG_INFO("An error occurred. Sending this information: uniqueId {}: action: {}, errorCore: {}, errorDescription: {}\n", uniqueId, action, errorCode, errorDescription);
  8043. sprintf(message,"[%d,\"%s\",\"%s\",\"%s\",{}]",MESSAGE_TYPE_CALLERROR, uniqueId, errorCode, errorDescription);
  8044. LWS_Send(message);
  8045. }
  8046. //==========================================
  8047. // Handle server request routine Start
  8048. //==========================================
  8049. int handleCancelReservationRequest(char *uuid, char *payload)
  8050. {
  8051. mtrace();
  8052. int result = FAIL;
  8053. int gunNO = 0;
  8054. int reservationIdInt = -1;
  8055. DEBUG_INFO("handleCancelReservationRequest...\n");
  8056. json_object *CancelReservation;
  8057. CancelReservation = json_tokener_parse(payload);
  8058. if(!is_error(CancelReservation))
  8059. {
  8060. // Required data
  8061. if(json_object_object_get(CancelReservation, "reservationId") != NULL)
  8062. reservationIdInt = json_object_get_int(json_object_object_get(CancelReservation, "reservationId"));
  8063. }
  8064. json_object_put(CancelReservation);
  8065. DEBUG_INFO("reservationIdInt = %d\n", reservationIdInt);
  8066. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->CancelReservation);idx++)
  8067. sprintf((char*)ShmOCPP20Data->CancelReservation[idx].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Rejected]);
  8068. if(reservationIdInt != -1)
  8069. {
  8070. //0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  8071. //check Transaction active
  8072. //J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DC
  8073. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8074. {
  8075. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId == reservationIdInt)
  8076. {
  8077. sprintf((char*)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8078. if(gunType[2] == 'J')
  8079. {
  8080. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index + 1;
  8081. }
  8082. else
  8083. {
  8084. gunNO = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index;
  8085. }
  8086. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8087. goto end;
  8088. }
  8089. }
  8090. for (int index = 0; index < CCS_QUANTITY; index++)
  8091. {
  8092. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId == reservationIdInt)
  8093. {
  8094. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8095. if((gunType[2] == 'U') || (gunType[2] == 'E'))
  8096. {
  8097. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index + 1;
  8098. }
  8099. else
  8100. {
  8101. gunNO = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index;
  8102. }
  8103. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8104. goto end;
  8105. }
  8106. }
  8107. for (int index = 0; index < GB_QUANTITY; index++)
  8108. {
  8109. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId == reservationIdInt)
  8110. {
  8111. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8112. if(gunType[2] == 'G')
  8113. {
  8114. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index + 1;
  8115. }
  8116. else
  8117. {
  8118. gunNO = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index;
  8119. }
  8120. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8121. goto end;
  8122. }
  8123. }
  8124. for (int index = 0; index < AC_QUANTITY; index++)
  8125. {
  8126. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId == reservationIdInt)
  8127. {
  8128. sprintf((char *)ShmOCPP20Data->CancelReservation[ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index].Response_status, "%s", CancelReservationStatusEnumTypeStr[CancelReservationStatusEnumType_Accepted]);
  8129. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  8130. {
  8131. gunNO = 1; //ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index ;
  8132. }
  8133. else
  8134. {
  8135. gunNO = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index;
  8136. }
  8137. ShmOCPP20Data->CsMsg.bits[gunNO].CancelReservationReq = ON;
  8138. goto end;
  8139. }
  8140. }
  8141. }
  8142. //The reservationId does NOT match the reservationId
  8143. sendCancelReservationConfirmation(uuid, gunNO);
  8144. end:
  8145. // Fill in ocpp packet uuid
  8146. strcpy((char *)ShmOCPP20Data->CancelReservation[gunNO].guid, uuid);
  8147. return result;
  8148. }
  8149. int handleCertificateSignedRequest(char *uuid, char *payload)
  8150. {
  8151. mtrace();
  8152. int result = FAIL;
  8153. json_object *CertificateSigned;
  8154. DEBUG_INFO("handleCertificateSignedRequest...\n");
  8155. CertificateSigned = json_tokener_parse(payload);
  8156. if(!is_error(CertificateSigned))
  8157. {
  8158. memset(&ShmOCPP20Data->CertificateSigned, 0, sizeof(struct CertificateSigned_20));
  8159. memcpy(&ShmOCPP20Data->CertificateSigned.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.guid));
  8160. // Required data
  8161. if(json_object_array_length(json_object_object_get(CertificateSigned, "certificate")) <= ARRAY_SIZE(ShmOCPP20Data->CertificateSigned.certificate))
  8162. {
  8163. for(int idx=0;idx<json_object_array_length(json_object_object_get(CertificateSigned, "certificate"));idx++)
  8164. {
  8165. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificate[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(CertificateSigned, "certificateType"), idx)));
  8166. /*
  8167. * TODO:
  8168. * 1. Certificate install response
  8169. */
  8170. }
  8171. }
  8172. // Optional data
  8173. if(json_object_object_get(CertificateSigned, "certificateType") != NULL)
  8174. {
  8175. sprintf((char*)ShmOCPP20Data->CertificateSigned.certificateType, "%s", json_object_get_string(json_object_object_get(CertificateSigned, "certificateType")));
  8176. }
  8177. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Accepted]);
  8178. }
  8179. else
  8180. strcpy((char*)ShmOCPP20Data->CertificateSigned.Response_status, CertificateSignedStatusEnumTypeStr[CertificateSignedStatusEnumType_Rejected]);
  8181. json_object_put(CertificateSigned);
  8182. sendCertificateSignedConfirmation(uuid);
  8183. return result;
  8184. }
  8185. int handleChangeAvailabilityRequest(char *uuid, char *payload)
  8186. {
  8187. mtrace();
  8188. int result = FAIL;
  8189. int evseId = 0, gunIndex = 0;
  8190. char operationalStatus[16]={0};
  8191. char comfirmstr[20];
  8192. int specificId = FALSE;
  8193. DEBUG_INFO("handleChangeAvailabilityRequest...\n");
  8194. json_object *ChangeAvailability;
  8195. ChangeAvailability = json_tokener_parse(payload);
  8196. if(!is_error(ChangeAvailability))
  8197. {
  8198. // Required data
  8199. if(json_object_object_get(ChangeAvailability, "operationalStatus") != NULL)
  8200. sprintf((char*)operationalStatus, "%s", json_object_get_string(json_object_object_get(ChangeAvailability, "operationalStatus")));
  8201. if(json_object_object_get(ChangeAvailability, "evse") != NULL)
  8202. {
  8203. evseId = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "id"));
  8204. if(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId") != NULL)
  8205. gunIndex = json_object_get_int(json_object_object_get(json_object_object_get(ChangeAvailability, "evse"), "connectorId"));
  8206. }
  8207. }
  8208. json_object_put(ChangeAvailability);
  8209. if((evseId != 0) && (evseId <= gunTotalNumber))
  8210. {
  8211. ShmOCPP20Data->ChangeAvailability[evseId - 1].evse.connectorId = evseId;
  8212. sprintf((char *)ShmOCPP20Data->ChangeAvailability[evseId - 1].operationalStatus, "%s", operationalStatus);
  8213. }
  8214. else if(evseId == 0)
  8215. {
  8216. for(int i=0; i < gunTotalNumber; i++)
  8217. {
  8218. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = evseId;
  8219. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8220. }
  8221. }
  8222. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8223. {
  8224. ShmOCPP20Data->ChangeAvailability[gunIndex - 1].evse.connectorId = gunIndex;
  8225. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].operationalStatus, "%s", operationalStatus);
  8226. }
  8227. else if(gunIndex == 0)
  8228. {
  8229. for(int i=0; i < gunTotalNumber; i++)
  8230. {
  8231. ShmOCPP20Data->ChangeAvailability[i].evse.connectorId = gunIndex;
  8232. sprintf((char *)ShmOCPP20Data->ChangeAvailability[i].operationalStatus, "%s", operationalStatus);
  8233. }
  8234. }
  8235. memset(comfirmstr, 0, ARRAY_SIZE(comfirmstr));
  8236. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8237. if((gunIndex == 0) || (gunIndex <= gunTotalNumber))
  8238. {
  8239. specificId = TRUE;
  8240. }
  8241. if(specificId == FALSE)
  8242. goto end;
  8243. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Inoperative]) == 0)
  8244. {
  8245. //----------------------gunIndex is 0 ------------------------------------------------//
  8246. if(gunIndex == 0)
  8247. {
  8248. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8249. {
  8250. for(int i=0; i < gunTotalNumber; i++)
  8251. {
  8252. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8253. {
  8254. if ((gunType[i] == 'J')&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == i))
  8255. {
  8256. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8257. {
  8258. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8259. goto end;
  8260. }
  8261. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8262. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8263. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8264. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8265. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8266. {
  8267. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8268. goto end;
  8269. }
  8270. }
  8271. }//END FOR CHAdeMO_QUANTITY
  8272. for (int index = 0; index < CCS_QUANTITY; index++)
  8273. {
  8274. if (((gunType[i] == 'U')||(gunType[i] == 'E'))&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == i))
  8275. {
  8276. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)// S_PRECHARGE
  8277. {
  8278. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8279. goto end;
  8280. }
  8281. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8282. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8283. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8284. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8285. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8286. {
  8287. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8288. goto end;
  8289. }
  8290. }
  8291. }//END FOR CCS_QUANTITY
  8292. for (int index = 0; index < GB_QUANTITY; index++)
  8293. {
  8294. if ((gunType[i] == 'G')&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == i))
  8295. {
  8296. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8297. {
  8298. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8299. goto end;
  8300. }
  8301. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8302. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8303. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8304. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8305. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8306. {
  8307. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8308. goto end;
  8309. }
  8310. }
  8311. }// END FOR GB_QUANTITY
  8312. for (int index = 0; index < AC_QUANTITY; index++)
  8313. {
  8314. if (((gunType[i] > '0')&&(gunType[i] <= '9'))&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == i))
  8315. {
  8316. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8317. {
  8318. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8319. goto end;
  8320. }
  8321. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8322. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8323. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8324. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8325. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8326. {
  8327. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8328. goto end;
  8329. }
  8330. }
  8331. }//END FOR AC_QUANTITY
  8332. }// END FOR gunTotalNumber
  8333. }
  8334. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8335. {
  8336. for(int i=0; i < gunTotalNumber; i++)
  8337. {
  8338. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_RESERVATION) // S_PRECHARGE
  8339. {
  8340. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8341. goto end;
  8342. }
  8343. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8344. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_PREPARING) ||
  8345. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_CHARGING) ||
  8346. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_TERMINATING) ||
  8347. (ShmSysConfigAndInfo->SysInfo.AcChargingData[i].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8348. {
  8349. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8350. goto end;
  8351. }
  8352. }
  8353. }
  8354. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8355. goto end;
  8356. }
  8357. //----------------------gunIndex is not 0 ------------------------------------------------//
  8358. //check Transaction active
  8359. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8360. {
  8361. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'J'))
  8362. {
  8363. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) // S_PRECHARGE
  8364. {
  8365. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8366. goto end;
  8367. }
  8368. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8369. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8370. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8371. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8372. (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8373. {
  8374. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8375. goto end;
  8376. }
  8377. else
  8378. {
  8379. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.ChademoChargingData[%d].SystemStatus = %d\n",index, ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus);
  8380. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8381. goto end;
  8382. }
  8383. }
  8384. }//END FOR CHAdeMO_QUANTITY
  8385. for (int index = 0; index < CCS_QUANTITY; index++)
  8386. {
  8387. if ((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E')))
  8388. {
  8389. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION) )// S_PRECHARGE
  8390. {
  8391. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8392. goto end;
  8393. }
  8394. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8395. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8396. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8397. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8398. (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8399. {
  8400. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8401. goto end;
  8402. }
  8403. else
  8404. {
  8405. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.CcsChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus);
  8406. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8407. goto end;
  8408. }
  8409. }
  8410. }//END FOR CCS_QUANTITY
  8411. for (int index = 0; index < GB_QUANTITY; index++)
  8412. {
  8413. if ((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))
  8414. {
  8415. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8416. {
  8417. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8418. goto end;
  8419. }
  8420. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8421. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8422. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8423. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8424. (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8425. {
  8426. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8427. goto end;
  8428. }
  8429. else
  8430. {
  8431. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.GbChargingData[%d].SystemStatus=%d\n",index,ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus);
  8432. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8433. goto end;
  8434. }
  8435. }
  8436. }// END FOR GB_QUANTITY
  8437. for (int index = 0; index < AC_QUANTITY; index++)
  8438. {
  8439. if ((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9')))
  8440. {
  8441. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) // S_PRECHARGE
  8442. {
  8443. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8444. goto end;
  8445. }
  8446. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) ||
  8447. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) ||
  8448. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
  8449. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ||
  8450. (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // S_CHARGING
  8451. {
  8452. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Scheduled] );
  8453. goto end;
  8454. }
  8455. else
  8456. {
  8457. DEBUG_INFO("ShmSysConfigAndInfo->SysInfo.AcChargingData[%d].SystemStatus=%d\n",index, ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus);
  8458. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8459. goto end;
  8460. }
  8461. }
  8462. }//END FOR AC_QUANTITY
  8463. }//END FOR AvailabilityEnumTypeStr[Inoperative]
  8464. if(strcmp((const char *)operationalStatus, OperationalStatusEnumTypeStr[OperationalStatusEnumType_Operative]) == 0)
  8465. {
  8466. //----------------------gunIndex is 0 ------------------------------------------------//
  8467. if(gunIndex == 0)
  8468. {
  8469. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  8470. {
  8471. for(int i=0; i < gunTotalNumber; i++)
  8472. {
  8473. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8474. {
  8475. 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
  8476. {
  8477. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8478. goto end;
  8479. }
  8480. }//END FOR CHAdeMO_QUANTITY
  8481. for (int index = 0; index < CCS_QUANTITY; index++)
  8482. {
  8483. 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
  8484. {
  8485. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8486. goto end;
  8487. }
  8488. }//END FOR CCS_QUANTITY
  8489. for (int index = 0; index < GB_QUANTITY; index++)
  8490. {
  8491. 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
  8492. {
  8493. //ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8494. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8495. goto end;
  8496. }
  8497. }// END FOR GB_QUANTITY
  8498. for (int index = 0; index < AC_QUANTITY; index++)
  8499. {
  8500. 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
  8501. {
  8502. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8503. goto end;
  8504. }
  8505. }//END FOR CHAdeMO_QUANTITY
  8506. }// END FOR gunTotalNumber
  8507. }
  8508. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  8509. {
  8510. for(int i=0; i < gunTotalNumber; i++)
  8511. {
  8512. for (int index = 0; index < AC_QUANTITY; index++)
  8513. {
  8514. 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
  8515. {
  8516. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected] );
  8517. goto end;
  8518. }
  8519. }//END FOR CHAdeMO_QUANTITY
  8520. } // END FOR gunTotalNumber
  8521. }
  8522. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8523. goto end;
  8524. }
  8525. //----------------------gunIndex is not 0 ------------------------------------------------//
  8526. //check Transaction active
  8527. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  8528. {
  8529. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'J') ) &&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8530. {
  8531. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8532. goto end;
  8533. }
  8534. }//END FOR CHAdeMO_QUANTITY
  8535. for (int index = 0; index < CCS_QUANTITY; index++)
  8536. {
  8537. if ((((gunIndex > 0)&&((gunType[gunIndex - 1] == 'U')||(gunType[gunIndex - 1] == 'E'))) )&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8538. {
  8539. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8540. goto end;
  8541. }
  8542. }//END FOR CCS_QUANTITY
  8543. for (int index = 0; index < GB_QUANTITY; index++)
  8544. {
  8545. if (((gunIndex > 0)&&(gunType[gunIndex-1] == 'G'))&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8546. {
  8547. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8548. goto end;
  8549. }
  8550. }// END FOR GB_QUANTITY
  8551. for (int index = 0; index < AC_QUANTITY; index++)
  8552. {
  8553. if (((gunIndex > 0)&&((gunType[gunIndex-1] > '0')&&(gunType[gunIndex-1] <= '9'))) &&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)) //S_FAULT
  8554. {
  8555. sprintf(comfirmstr, "%s", ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Accepted] );
  8556. goto end;
  8557. }
  8558. }//END FOR AC_QUANTITY
  8559. }//END FOR AvailabilityEnumTypeStr[Operative]
  8560. end:
  8561. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8562. {
  8563. sprintf((char *)ShmOCPP20Data->ChangeAvailability[gunIndex - 1].Response_status, "%s", comfirmstr );
  8564. }
  8565. else
  8566. {
  8567. sprintf((char *)ShmOCPP20Data->ChangeAvailability[0].Response_status, "%s", comfirmstr );
  8568. }
  8569. if((gunIndex != 0) && (gunIndex <= gunTotalNumber))
  8570. {
  8571. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  8572. ShmOCPP20Data->CsMsg.bits[gunIndex - 1].ChangeAvailabilityReq = ON;
  8573. }
  8574. else if(gunIndex == 0)
  8575. {
  8576. if(strstr(comfirmstr, ChangeAvailabilityStatusEnumTypeStr[ChangeAvailabilityStatusEnumType_Rejected]) == NULL)
  8577. {
  8578. for(int i=0; i < gunTotalNumber/*(CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY)*/; i++)
  8579. ShmOCPP20Data->CsMsg.bits[i].ChangeAvailabilityReq = ON;
  8580. }
  8581. }
  8582. sendChangeAvailabilityConfirmation(uuid, (gunIndex==0?gunIndex:gunIndex-1));
  8583. return result;
  8584. }
  8585. int handleClearCacheRequest(char *uuid, char *payload)
  8586. {
  8587. mtrace();
  8588. int result = FAIL;
  8589. char rmFileCmd[100]={0};
  8590. struct stat stats;
  8591. DEBUG_INFO("handleClearCacheRequest...\n");
  8592. stat("/Storage/OCPP", &stats);
  8593. // Check for directory existence
  8594. if (S_ISDIR(stats.st_mode) == 1)
  8595. {}
  8596. else
  8597. {
  8598. DEBUG_INFO("\n OCPP directory not exist, create dir \n");
  8599. sprintf(rmFileCmd,"mkdir -p %s","/Storage/OCPP");
  8600. system(rmFileCmd);
  8601. }
  8602. /*
  8603. * TODO:
  8604. * 1. Clear cache from sqlite db
  8605. */
  8606. if(1)
  8607. {
  8608. DEBUG_INFO("open AuthorizationCache file failed\n");
  8609. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Rejected] );
  8610. }
  8611. else
  8612. {
  8613. DEBUG_INFO("open AuthorizationCache file successful\n");
  8614. sprintf((char*)ShmOCPP20Data->ClearCache.Response_status, "%s", ClearCacheStatusEnumTypeStr[ClearCacheStatusEnumType_Accepted] );
  8615. }
  8616. sendClearCacheConfirmation(uuid);
  8617. return result;
  8618. }
  8619. int handleClearChargingProfileRequest(char *uuid, char *payload)
  8620. {
  8621. mtrace();
  8622. int result = FAIL;
  8623. int resultRename;
  8624. int connectorIdInt, chargingProfileIdInt, stackLevelInt;
  8625. char chargingProfilePurposeStr[26]={0};
  8626. int tempconnectorIdInt, tempchargingProfileIdInt, tempstackLevelInt;
  8627. char tempchargingProfilePurposeStr[26]={0};
  8628. char sstr[160]={0};
  8629. char str[100]={0};
  8630. int c = 0;
  8631. char *loc;
  8632. char fname[200]={0};
  8633. char comfirmstr[20]={0};
  8634. char word[1600]={0};
  8635. int clearflag = FALSE;
  8636. int chargingProfileIdIsNULL = FALSE;
  8637. int connectorIsNULL = FALSE;
  8638. int chargingProfilePurposeIsNULL = FALSE;
  8639. int stackLevelIsNULL = FALSE;
  8640. //int GotoEnd = FALSE;
  8641. FILE *fptr1, *fptr2;
  8642. char temp[] = "/Storage/OCPP/ClearChargingProfiletemp.json"; // Create temp file
  8643. int n_chargingProfile=0;
  8644. int isEmptyFile = FALSE;
  8645. char sLineWord[1600]={0};
  8646. char chargingProfiles[10][100]={0};
  8647. int ChargeProfileCount = 0;
  8648. int ch;
  8649. connectorIdInt = chargingProfileIdInt = stackLevelInt = 0;
  8650. DEBUG_INFO("handleClearChargingProfileRequest...\n");
  8651. json_object *ClearChargingProfile;
  8652. ClearChargingProfile = json_tokener_parse(payload);
  8653. if(!is_error(ClearChargingProfile))
  8654. {
  8655. // Optional data
  8656. if(json_object_object_get(ClearChargingProfile, "chargingProfileId") != NULL)
  8657. chargingProfileIdInt = json_object_get_int(json_object_object_get(ClearChargingProfile, "chargingProfileId"));
  8658. else
  8659. chargingProfileIdIsNULL = TRUE;
  8660. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId") != NULL)
  8661. connectorIdInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "evseId"));
  8662. else
  8663. connectorIsNULL = TRUE;
  8664. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose") != NULL)
  8665. sprintf((char*)chargingProfilePurposeStr, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "chargingProfilePurpose")));
  8666. else
  8667. chargingProfilePurposeIsNULL = TRUE;
  8668. if(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel") != NULL)
  8669. stackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(ClearChargingProfile, "chargingProfileCriteria"), "stackLevel"));
  8670. else
  8671. stackLevelIsNULL = TRUE;
  8672. }
  8673. json_object_put(ClearChargingProfile);
  8674. if(connectorIsNULL == FALSE)
  8675. {
  8676. switch(connectorIdInt)
  8677. {
  8678. case 0:
  8679. if(chargingProfilePurposeIsNULL == TRUE)
  8680. {
  8681. int l = 0;
  8682. strcpy(fname, ChargePointMaxProfile_JSON);
  8683. if((access(fname,F_OK))!=-1)
  8684. {
  8685. strcpy(chargingProfiles[l], fname);
  8686. l = l + 1;
  8687. }
  8688. strcpy(fname, TxDefaultProfile_0_JSON);
  8689. if((access(fname,F_OK))!=-1)
  8690. {
  8691. strcpy(chargingProfiles[l], fname);
  8692. l = l + 1;
  8693. }
  8694. ChargeProfileCount = l;
  8695. }
  8696. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"ChargePointMaxProfile")==0))
  8697. {
  8698. strcpy(fname, ChargePointMaxProfile_JSON);
  8699. if((access(fname,F_OK))!=-1)
  8700. {
  8701. strcpy(chargingProfiles[0], fname);
  8702. ChargeProfileCount = 1;
  8703. }
  8704. }
  8705. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  8706. {
  8707. strcpy(fname, TxDefaultProfile_0_JSON);
  8708. if((access(fname,F_OK))!=-1)
  8709. {
  8710. strcpy(chargingProfiles[0], fname);
  8711. ChargeProfileCount = 1;
  8712. }
  8713. }
  8714. break;
  8715. default:
  8716. if(chargingProfilePurposeIsNULL == TRUE)
  8717. {
  8718. int m = 0;
  8719. memset(fname, 0, ARRAY_SIZE(fname));
  8720. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  8721. if((access(fname,F_OK))!=-1)
  8722. {
  8723. strcpy(chargingProfiles[m], fname);
  8724. m = m + 1;
  8725. }
  8726. memset(fname, 0, ARRAY_SIZE(fname));
  8727. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  8728. if((access(fname,F_OK))!=-1)
  8729. {
  8730. strcpy(chargingProfiles[m], fname);
  8731. m = m + 1;
  8732. }
  8733. ChargeProfileCount = m;
  8734. }
  8735. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxDefaultProfile")==0))
  8736. {
  8737. //strcpy(fname, TxDefaultProfile_1_JSON);
  8738. sprintf(fname, "/Storage/OCPP/TxDefaultProfile_%d.json", connectorIdInt);
  8739. if((access(fname,F_OK))!=-1)
  8740. {
  8741. strcpy(chargingProfiles[0], fname);
  8742. ChargeProfileCount = 1;
  8743. }
  8744. }
  8745. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(chargingProfilePurposeStr,"TxProfile")==0))
  8746. {
  8747. sprintf(fname, "/Storage/OCPP/TxProfile_%d.json", connectorIdInt);
  8748. if((access(fname,F_OK))!=-1)
  8749. {
  8750. strcpy(chargingProfiles[0], fname);
  8751. ChargeProfileCount = 1;
  8752. }
  8753. }
  8754. //strcpy(fname, ChargePointMaxProfile_JSON );
  8755. break;
  8756. }
  8757. }
  8758. else // Check all Charging Profiles
  8759. {
  8760. int i = 0;
  8761. char fnametemp[200]={0};
  8762. ChargeProfileCount = 0;
  8763. //Check ChargePointMaxProfile.json exit
  8764. if((access("/Storage/OCPP/ChargePointMaxProfile.json",F_OK))!=-1)
  8765. {
  8766. strcpy(chargingProfiles[i], "/Storage/OCPP/ChargePointMaxProfile.json");
  8767. i = i + 1;
  8768. }
  8769. //Check TxDefaultProfile_0.json exit
  8770. if((access("/Storage/OCPP/TxDefaultProfile_0.json",F_OK))!=-1)
  8771. {
  8772. strcpy(chargingProfiles[i], "/Storage/OCPP/TxDefaultProfile_0.json");
  8773. i = i + 1;
  8774. }
  8775. //Check TxDefaultProfile_%d.json
  8776. for(int j=1; j <= gunTotalNumber; j++)
  8777. {
  8778. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  8779. sprintf(fnametemp, "/Storage/OCPP/TxDefaultProfile_%d.json", j);
  8780. if((access(fnametemp,F_OK))!=-1)
  8781. {
  8782. strcpy(chargingProfiles[i], fnametemp);
  8783. i = i + 1;
  8784. }
  8785. }
  8786. //Check TxProfile_%d.json
  8787. for(int j=1; j <= gunTotalNumber; j++)
  8788. {
  8789. memset(fnametemp, 0, ARRAY_SIZE(fnametemp));
  8790. sprintf(fnametemp, "/Storage/OCPP/TxProfile_%d.json", j);
  8791. if((access(fnametemp,F_OK))!=-1)
  8792. {
  8793. strcpy(chargingProfiles[i], fnametemp);
  8794. i = i + 1;
  8795. }
  8796. }
  8797. ChargeProfileCount = i;
  8798. }// End connectorIsNULL is TRUE
  8799. if(ChargeProfileCount == 0)
  8800. {
  8801. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  8802. goto end;
  8803. }
  8804. if(connectorIsNULL == FALSE && (connectorIdInt != 0) && ( (connectorIdInt-1) > gunTotalNumber) )
  8805. {
  8806. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  8807. goto end;
  8808. }
  8809. if((connectorIsNULL == FALSE) && (connectorIdInt == 0) )
  8810. {
  8811. memset(str, 0, ARRAY_SIZE(str));
  8812. // clear temp file
  8813. sprintf(str,"rm -f %s",temp);
  8814. system(str);
  8815. for(int k=0; k < ChargeProfileCount; k++)
  8816. {
  8817. memset(str, 0, ARRAY_SIZE(str));
  8818. //clear file in C
  8819. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8820. system(str);
  8821. }
  8822. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8823. goto end;
  8824. }
  8825. else if(connectorIsNULL == TRUE)
  8826. {
  8827. for(int k=0; k < ChargeProfileCount; k++)
  8828. {
  8829. fptr1 = fopen(chargingProfiles[k], "r");
  8830. fptr2 = fopen("/Storage/OCPP/ClearChargingProfiletemp.json", "w+");
  8831. //Check Charging Profile Count
  8832. while(fscanf(fptr1, "%s", word) != EOF)
  8833. {
  8834. //DEBUG_INFO("word=%s\n",word);
  8835. if(strstr(word, "chargingProfileId")!= NULL)
  8836. {
  8837. //DEBUG_INFO("test chargingProfileId \n");
  8838. n_chargingProfile = n_chargingProfile + 1;
  8839. //DEBUG_INFO("chargingProfileId Found\n");
  8840. }
  8841. }
  8842. rewind(fptr1);
  8843. //search Charging Profile Element
  8844. //int i= 0;
  8845. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  8846. {
  8847. //------------------------tempconnectorIdInt------------------------//
  8848. loc = strstr(sLineWord, "connectorId");
  8849. c = 0;
  8850. memset(sstr ,0, sizeof(sstr) );
  8851. while (loc[strlen("connectorId")+2+c] != ',')
  8852. {
  8853. sstr[c] = loc[strlen("connectorId")+2+c];
  8854. c++;
  8855. }
  8856. sstr[c] = '\0';
  8857. tempconnectorIdInt = atoi(sstr);
  8858. printf("file's gun number is %d\n", tempconnectorIdInt);
  8859. //--------------------------chargingProfileId--------------------//
  8860. c = 0;
  8861. loc = strstr(sLineWord, "chargingProfileId");
  8862. memset(sstr ,0, ARRAY_SIZE(sstr));
  8863. while (loc[strlen("chargingProfileId")+2+c] != ',')
  8864. {
  8865. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  8866. //printf("i=%d sstr=%c\n",c, sstr[c]);
  8867. c++;
  8868. }
  8869. sstr[c] = '\0';
  8870. tempchargingProfileIdInt = atoi(sstr);
  8871. //stackLevel
  8872. c = 0;
  8873. loc = strstr(sLineWord, "stackLevel");
  8874. memset(sstr ,0, ARRAY_SIZE(sstr));
  8875. while (loc[strlen("stackLevel")+2+c] != ',')
  8876. {
  8877. sstr[c] = loc[strlen("stackLevel")+2+c];
  8878. //printf("i=%d sstr=%c\n",c, sstr[c]);
  8879. c++;
  8880. }
  8881. sstr[c] = '\0';
  8882. tempstackLevelInt = atoi(sstr);
  8883. c = 0;
  8884. loc = strstr(sLineWord, "chargingProfilePurpose");
  8885. memset(sstr ,0, ARRAY_SIZE(sstr));
  8886. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  8887. {
  8888. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  8889. c++;
  8890. }
  8891. sstr[c] = '\0';
  8892. strcpy(tempchargingProfilePurposeStr, sstr);
  8893. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  8894. {
  8895. //------- not write to fptr2-------//
  8896. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8897. //clearflag = TRUE;
  8898. }
  8899. else if((chargingProfilePurposeIsNULL == FALSE)&&(strcmp(tempchargingProfilePurposeStr, chargingProfilePurposeStr) == 0))
  8900. {
  8901. //------- not write to fptr2-------//
  8902. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8903. }
  8904. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  8905. {
  8906. //------- not write to fptr2-------//
  8907. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8908. }
  8909. else if(chargingProfileIdIsNULL && chargingProfilePurposeIsNULL && stackLevelIsNULL)
  8910. {
  8911. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  8912. }
  8913. else
  8914. {
  8915. fprintf(fptr2, sLineWord);//writing data into file
  8916. }
  8917. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  8918. } //End of while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  8919. if(clearflag == TRUE)
  8920. {
  8921. fclose(fptr1);
  8922. fclose(fptr2);
  8923. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8924. system(str);
  8925. // clear temp file
  8926. sprintf(str,"rm -f %s",temp);
  8927. system(str);
  8928. }
  8929. else
  8930. {
  8931. fclose(fptr1);
  8932. fclose(fptr2);
  8933. memset(str, 0, ARRAY_SIZE(str));
  8934. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8935. system(str);
  8936. resultRename = rename(temp, chargingProfiles[k]);
  8937. if(resultRename == 0)
  8938. {
  8939. DEBUG_INFO("File ChargingProfile renamed successfully\n");
  8940. }
  8941. else
  8942. {
  8943. DEBUG_INFO("Error: unable to rename the ChargingProfile file\n");
  8944. }
  8945. if(comfirmstr[0]== 0)
  8946. {
  8947. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  8948. }
  8949. //Check chargingProfile is empty file
  8950. /*------ Read the file ----------------*/
  8951. fptr1=fopen(chargingProfiles[k],"r");
  8952. ch=fgetc(fptr1);
  8953. rewind(fptr1);
  8954. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  8955. if(ch!=EOF)
  8956. {
  8957. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  8958. {
  8959. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  8960. if(sLineWord[0]=='\0')
  8961. {
  8962. isEmptyFile = TRUE;
  8963. break;
  8964. }
  8965. else
  8966. {
  8967. isEmptyFile = FALSE;
  8968. break;
  8969. }
  8970. }
  8971. }
  8972. else
  8973. isEmptyFile = TRUE;
  8974. fclose(fptr1);
  8975. if(isEmptyFile == TRUE)
  8976. {
  8977. memset(str, 0, ARRAY_SIZE(str));
  8978. sprintf(str,"rm -f %s",chargingProfiles[k]);
  8979. system(str);
  8980. }
  8981. }
  8982. }// End of while(int k=0; k < ChargePointCount; k++)
  8983. }
  8984. else if((connectorIsNULL == FALSE) && (connectorIdInt != 0) )
  8985. {
  8986. DEBUG_INFO("ChargeProfileCount = %d\n", ChargeProfileCount);
  8987. for(int k=0; k < ChargeProfileCount; k++)
  8988. {
  8989. fptr1 = fopen(chargingProfiles[k], "r");
  8990. fptr2 = fopen(temp, "w+");
  8991. //Check Charging Profile Count
  8992. while(fscanf(fptr1, "%s", word) != EOF)
  8993. {
  8994. //DEBUG_INFO("word=%s\n",word);
  8995. if(strstr(word, "chargingProfileId")!= NULL)
  8996. {
  8997. n_chargingProfile = n_chargingProfile + 1;
  8998. }
  8999. }
  9000. rewind(fptr1);
  9001. //search Charging Profile Element
  9002. //int i= 0;
  9003. while ( fgets( sLineWord, sizeof sLineWord, fptr1 ) != NULL )
  9004. {
  9005. //*************************tempconnectorIdInt*********************************/
  9006. loc = strstr(sLineWord, "connectorId");
  9007. c = 0;
  9008. memset(sstr ,0, ARRAY_SIZE(sstr));
  9009. while (loc[strlen("connectorId")+2+c] != ',')
  9010. {
  9011. sstr[c] = loc[strlen("connectorId")+2+c];
  9012. c++;
  9013. }
  9014. sstr[c] = '\0';
  9015. tempconnectorIdInt = atoi(sstr);
  9016. //chargingProfileId
  9017. c = 0;
  9018. loc = strstr(sLineWord, "chargingProfileId");
  9019. memset(sstr ,0, ARRAY_SIZE(sstr));
  9020. while (loc[strlen("chargingProfileId")+2+c] != ',')
  9021. {
  9022. sstr[c] = loc[strlen("chargingProfileId")+2+c];
  9023. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9024. c++;
  9025. }
  9026. sstr[c] = '\0';
  9027. tempchargingProfileIdInt = atoi(sstr);
  9028. //stackLevel
  9029. c = 0;
  9030. loc = strstr(sLineWord, "stackLevel");
  9031. memset(sstr ,0, ARRAY_SIZE(sstr));
  9032. while (loc[strlen("stackLevel")+2+c] != ',')
  9033. {
  9034. sstr[c] = loc[strlen("stackLevel")+2+c];
  9035. //printf("i=%d sstr=%c\n",c, sstr[c]);
  9036. c++;
  9037. }
  9038. sstr[c] = '\0';
  9039. tempstackLevelInt = atoi(sstr);
  9040. c = 0;
  9041. loc = strstr(sLineWord, "chargingProfilePurpose");
  9042. memset(sstr ,0, ARRAY_SIZE(sstr));
  9043. while (loc[3+strlen("chargingProfilePurpose")+c] != '\"')
  9044. {
  9045. sstr[c] = loc[3+strlen("chargingProfilePurpose")+c];
  9046. c++;
  9047. }
  9048. sstr[c] = '\0';
  9049. strcpy(tempchargingProfilePurposeStr, sstr);
  9050. if((chargingProfileIdIsNULL == FALSE)&&(tempchargingProfileIdInt == chargingProfileIdInt))
  9051. {
  9052. //------- not write to fptr2-------//
  9053. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9054. //clearflag = TRUE;
  9055. }
  9056. else if((stackLevelIsNULL == FALSE) &&(tempstackLevelInt == stackLevelInt))
  9057. {
  9058. //------- not write to fptr2-------//
  9059. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9060. }
  9061. else if(stackLevelIsNULL == TRUE)
  9062. {
  9063. //Clear Whole File
  9064. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted] );
  9065. clearflag = TRUE;
  9066. break;
  9067. }
  9068. else
  9069. {
  9070. fprintf(fptr2, sLineWord);//writing data into file
  9071. }
  9072. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9073. }
  9074. if(clearflag == TRUE)
  9075. {
  9076. fclose(fptr1);
  9077. fclose(fptr2);
  9078. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9079. system(str);
  9080. // clear temp file
  9081. sprintf(str,"rm -f %s",temp);
  9082. system(str);
  9083. }
  9084. else
  9085. {
  9086. fclose(fptr1);
  9087. fclose(fptr2);
  9088. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9089. system(str);
  9090. resultRename = rename(temp, chargingProfiles[k]);
  9091. if(resultRename == 0)
  9092. {
  9093. DEBUG_INFO("File ChargingProfile renamed successfully");
  9094. }
  9095. else
  9096. {
  9097. DEBUG_INFO("Error: unable to rename the ChargingProfile file");
  9098. }
  9099. if(comfirmstr[0]== 0)
  9100. {
  9101. sprintf(comfirmstr, "%s", ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Unknown] );
  9102. }
  9103. //Check chargingProfile is empty file
  9104. /*------ Read the file ----------------*/
  9105. fptr1=fopen(chargingProfiles[k],"r");
  9106. ch=fgetc(fptr1);
  9107. rewind(fptr1);
  9108. memset(sLineWord, 0, ARRAY_SIZE(sLineWord));
  9109. if(ch!=EOF)
  9110. {
  9111. while (fgets( sLineWord, sizeof sLineWord, fptr1) != NULL)
  9112. {
  9113. str[strlen(sLineWord) - 1] = '\0'; // eat the newline fgets() stores
  9114. if(sLineWord[0]=='\0')
  9115. {
  9116. isEmptyFile = TRUE;
  9117. break;
  9118. }
  9119. else
  9120. {
  9121. isEmptyFile = FALSE;
  9122. break;
  9123. }
  9124. }
  9125. }
  9126. else
  9127. isEmptyFile = TRUE;
  9128. fclose(fptr1);
  9129. if(isEmptyFile == TRUE)
  9130. {
  9131. memset(str, 0, ARRAY_SIZE(str));
  9132. sprintf(str,"rm -f %s",chargingProfiles[k]);
  9133. system(str);
  9134. }
  9135. /*------- End of reading ---------------*/
  9136. }
  9137. } // while(int k=0; k < ChargeProfileCount; k++)
  9138. }// (connectorIsNULL == FALSE) && (connectorIdInt != 0)
  9139. end:
  9140. if(strcmp(comfirmstr, ClearChargingProfileStatusEnumTypeStr[ClearChargingProfileStatusEnumType_Accepted]) == 0)
  9141. {
  9142. if(connectorIdInt == 0)
  9143. {
  9144. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  9145. {
  9146. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  9147. }
  9148. }
  9149. else
  9150. checkCompositeSchedule(connectorIdInt, 86400, &ShmOCPP20Data->SmartChargingProfile[connectorIdInt-1]);
  9151. }
  9152. sendClearChargingProfileConfirmation(uuid, comfirmstr);
  9153. return result;
  9154. }
  9155. int handleClearDisplayMessageRequest(char *uuid, char *payload)
  9156. {
  9157. mtrace();
  9158. int result = FAIL;
  9159. json_object *ClearDisplayMessage;
  9160. DEBUG_INFO("handleClearDisplayMessageRequest...\n");
  9161. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Unknown]);
  9162. ClearDisplayMessage = json_tokener_parse(payload);
  9163. if(!is_error(ClearDisplayMessage))
  9164. {
  9165. // Required data
  9166. if(json_object_object_get(ClearDisplayMessage, "id") != NULL)
  9167. {
  9168. ShmOCPP20Data->ClearDisplayMessage.id = json_object_get_double(json_object_object_get(ClearDisplayMessage, "id"));
  9169. sprintf((char*)ShmOCPP20Data->ClearDisplayMessage.Response_status, ClearMessageStatusEnumTypeStr[ClearMessageStatusEnumType_Accepted]);
  9170. }
  9171. }
  9172. json_object_put(ClearDisplayMessage);
  9173. sendCostUpdatedConfirmation(uuid);
  9174. return result;
  9175. }
  9176. int handleClearVariableMonitoringRequest(char *uuid, char *payload)
  9177. {
  9178. mtrace();
  9179. int result = FAIL;
  9180. json_object *ClearVariableMonitorin;
  9181. DEBUG_INFO("handleClearVariableMonitoringRequest...\n");
  9182. ClearVariableMonitorin = json_tokener_parse(payload);
  9183. if(!is_error(ClearVariableMonitorin))
  9184. {
  9185. // Required data
  9186. if(json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")) <= ARRAY_SIZE(ShmOCPP20Data->ClearVariableMonitoring.id))
  9187. {
  9188. for(int idx=0;idx<json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id"));idx++)
  9189. {
  9190. ShmOCPP20Data->ClearVariableMonitoring.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(ClearVariableMonitorin, "id"), idx));
  9191. /*
  9192. * TODO:
  9193. * 1. Check response
  9194. */
  9195. ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].id = ShmOCPP20Data->ClearVariableMonitoring.id[idx];
  9196. strcpy((char*)ShmOCPP20Data->ClearVariableMonitoring.Response_clearMonitoringResult[idx].status, ClearMonitoringStatusEnumTypeStr[ClearMonitoringStatusEnumType_Accepted]);
  9197. }
  9198. sendClearVariableMonitoringConfirmation(uuid, json_object_array_length(json_object_object_get(ClearVariableMonitorin, "id")));
  9199. }
  9200. }
  9201. json_object_put(ClearVariableMonitorin);
  9202. return result;
  9203. }
  9204. int handleCostUpdatedRequest(char *uuid, char *payload)
  9205. {
  9206. mtrace();
  9207. int result = FAIL;
  9208. json_object *CostUpdate;
  9209. DEBUG_INFO("handleCostUpdatedRequest...\n");
  9210. CostUpdate = json_tokener_parse(payload);
  9211. if(!is_error(CostUpdate))
  9212. {
  9213. // Required data
  9214. if(json_object_object_get(CostUpdate, "totalCost") != NULL)
  9215. {
  9216. ShmOCPP20Data->CostUpdated.totalCost = json_object_get_double(json_object_object_get(CostUpdate, "totalCost"));
  9217. }
  9218. if(json_object_object_get(CostUpdate, "transactionId") != NULL)
  9219. {
  9220. sprintf((char*)ShmOCPP20Data->CostUpdated.transactionId, "%s", json_object_get_string(json_object_object_get(CostUpdate, "transactionId")));
  9221. }
  9222. }
  9223. json_object_put(CostUpdate);
  9224. sendCostUpdatedConfirmation(uuid);
  9225. return result;
  9226. }
  9227. int handleCustomerInformationRequest(char *uuid, char *payload)
  9228. {
  9229. mtrace();
  9230. int result = FAIL;
  9231. json_object *CustomerInformation;
  9232. DEBUG_INFO("handleCustomerInformationRequest...\n");
  9233. CustomerInformation = json_tokener_parse(payload);
  9234. if(!is_error(CustomerInformation))
  9235. {
  9236. // Required data
  9237. if(json_object_object_get(CustomerInformation, "requestId") != NULL)
  9238. {
  9239. ShmOCPP20Data->CustomerInformation.requestId = json_object_get_int(json_object_object_get(CustomerInformation, "requestId"));
  9240. }
  9241. if(json_object_object_get(CustomerInformation, "report") != NULL)
  9242. {
  9243. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "report"));
  9244. }
  9245. if(json_object_object_get(CustomerInformation, "clear") != NULL)
  9246. {
  9247. ShmOCPP20Data->CustomerInformation.report = json_object_get_boolean(json_object_object_get(CustomerInformation, "clear"));
  9248. }
  9249. // Optional data
  9250. if(json_object_object_get(CustomerInformation, "idToken") != NULL)
  9251. {
  9252. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken") != NULL)
  9253. {
  9254. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "idToken")));
  9255. }
  9256. if(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type") != NULL)
  9257. {
  9258. sprintf((char*)ShmOCPP20Data->CustomerInformation.idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "idToken"), "type")));
  9259. }
  9260. }
  9261. if(json_object_object_get(CustomerInformation, "customerCertificate") != NULL)
  9262. {
  9263. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm") != NULL)
  9264. {
  9265. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "hashAlgorithm")));
  9266. }
  9267. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash") != NULL)
  9268. {
  9269. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerNameHash")));
  9270. }
  9271. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash") != NULL)
  9272. {
  9273. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "issuerKeyHash")));
  9274. }
  9275. if(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber") != NULL)
  9276. {
  9277. sprintf((char*)ShmOCPP20Data->CustomerInformation.customerCertificate.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(CustomerInformation, "customerCertificate"), "serialNumber")));
  9278. }
  9279. }
  9280. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Accepted]);
  9281. }
  9282. else
  9283. strcpy((char*)ShmOCPP20Data->CustomerInformation.Response_status, CustomerInformationStatusEnumTypeStr[CustomerInformationStatusEnumType_Rejected]);
  9284. json_object_put(CustomerInformation);
  9285. sendCustomerInformationConfirmation(uuid);
  9286. return result;
  9287. }
  9288. void createFirmwareVersionByDataTransfer(void)
  9289. {
  9290. json_object *FirmwareDataTransfer = json_object_new_object();
  9291. // AC & DC model
  9292. json_object_object_add(FirmwareDataTransfer, "CsuBootLoadFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev));
  9293. json_object_object_add(FirmwareDataTransfer, "CsuKernelFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev));
  9294. json_object_object_add(FirmwareDataTransfer, "CsuRootFsFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev));
  9295. json_object_object_add(FirmwareDataTransfer, "CsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev));
  9296. // DC model
  9297. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'))
  9298. {
  9299. json_object_object_add(FirmwareDataTransfer, "FanModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.FanModuleFwRev));
  9300. json_object_object_add(FirmwareDataTransfer, "RelayModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev));
  9301. json_object_object_add(FirmwareDataTransfer, "LedModuleFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev));
  9302. json_object_object_add(FirmwareDataTransfer, "Connector1FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector1FwRev));
  9303. json_object_object_add(FirmwareDataTransfer, "PsuPrimFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev));
  9304. json_object_object_add(FirmwareDataTransfer, "PsuSecFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.PsuSecFwRev));
  9305. }
  9306. if((ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') &&
  9307. ((gunType[1] != '0') || (gunType[2] != '0') || (gunType[3] != '0')))
  9308. {
  9309. json_object_object_add(FirmwareDataTransfer, "Connector2FwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysInfo.Connector2FwRev));
  9310. }
  9311. // 4G model
  9312. if((ShmSysConfigAndInfo->SysConfig.ModelName[10]=='T'))
  9313. {
  9314. json_object_object_add(FirmwareDataTransfer, "TelcomModemFwRev", json_object_new_string((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
  9315. }
  9316. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "Phihong Technology");
  9317. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion");
  9318. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, json_object_to_json_string(FirmwareDataTransfer));
  9319. }
  9320. int handleDataTransferRequest(char *uuid, char *payload)
  9321. {
  9322. mtrace();
  9323. int result = PASS;
  9324. DEBUG_INFO("handleDataTransferRequest...\n");
  9325. if((uuid != NULL) && (payload != NULL))
  9326. {
  9327. json_object *DataTransfer;
  9328. DataTransfer = json_tokener_parse(payload);
  9329. if(!is_error(DataTransfer))
  9330. {
  9331. // Required data
  9332. if(json_object_object_get(DataTransfer, "vendorId") != NULL)
  9333. sprintf((char*)ShmOCPP20Data->DataTransfer[0].vendorId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "vendorId")));
  9334. // Optional data
  9335. if(json_object_object_get(DataTransfer, "messageId") != NULL)
  9336. sprintf((char*)ShmOCPP20Data->DataTransfer[0].messageId, "%s", json_object_get_string(json_object_object_get(DataTransfer, "messageId")));
  9337. if(json_object_object_get(DataTransfer, "data") != NULL)
  9338. sprintf((char*)ShmOCPP20Data->DataTransfer[0].data, "%s", json_object_get_string(json_object_object_get(DataTransfer, "data")));
  9339. result = PASS;
  9340. }
  9341. json_object_put(DataTransfer);
  9342. if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "ID_FirmwareVersion") != NULL)
  9343. {
  9344. // Send all moudle firmware version on EVSE
  9345. system("/usr/bin/run_tmate_restart.sh");
  9346. createFirmwareVersionByDataTransfer();
  9347. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9348. }
  9349. else if(strstr((char*)ShmOCPP20Data->DataTransfer[0].messageId, "SetLEDBar") != NULL)
  9350. {
  9351. json_object *data;
  9352. data = json_tokener_parse((char*)ShmOCPP20Data->DataTransfer[0].data);
  9353. if(!is_error(data))
  9354. {
  9355. ShmSysConfigAndInfo->SysConfig.LedInfo.Intensity = json_object_get_int(json_object_object_get(data, "Intensity"));
  9356. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "R"));
  9357. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[0]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "G"));
  9358. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[0] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Idle"), "B"));
  9359. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "R"));
  9360. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[1]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "G"));
  9361. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[1] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Charging"), "B"));
  9362. ShmSysConfigAndInfo->SysConfig.LedInfo.Red[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "R"));
  9363. ShmSysConfigAndInfo->SysConfig.LedInfo.Green[2]= json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "G"));
  9364. ShmSysConfigAndInfo->SysConfig.LedInfo.Blue[2] = json_object_get_int(json_object_object_get(json_object_object_get(data, "Fault"), "B"));
  9365. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Accepted]);
  9366. }
  9367. else
  9368. {
  9369. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_Rejected]);
  9370. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data, "Configuration content something wrong.");
  9371. }
  9372. json_object_put(data);
  9373. }
  9374. else
  9375. {
  9376. // Can not find valid message id
  9377. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9378. sprintf((char*)ShmOCPP20Data->DataTransfer[0].Response_data,"vendorId: %s messageId: %s data: %s"
  9379. ,ShmOCPP20Data->DataTransfer[0].vendorId
  9380. ,ShmOCPP20Data->DataTransfer[0].messageId
  9381. ,ShmOCPP20Data->DataTransfer[0].data);
  9382. }
  9383. }
  9384. else
  9385. {
  9386. strcpy((char*)ShmOCPP20Data->DataTransfer[0].Response_status, DataTransferStatusEnumTypeStr[DataTransferStatusEnumType_UnknownMessageId]);
  9387. result = FAIL;
  9388. }
  9389. sendDataTransferConfirmation(uuid, 0);
  9390. return result;
  9391. }
  9392. int handleDeleteCertificateRequest(char *uuid, char *payload)
  9393. {
  9394. mtrace();
  9395. int result = FAIL;
  9396. json_object *DeleteCertificate;
  9397. DEBUG_INFO("handleDeleteCertificateRequest...\n");
  9398. DeleteCertificate = json_tokener_parse(payload);
  9399. if(!is_error(DeleteCertificate))
  9400. {
  9401. memset(&ShmOCPP20Data->DeleteCertificate, 0, sizeof(struct DeleteCertificate_20));
  9402. memcpy(&ShmOCPP20Data->DeleteCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->DeleteCertificate.guid));
  9403. // Required data
  9404. if(json_object_object_get(DeleteCertificate, "certificateHashData") != NULL)
  9405. {
  9406. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm") != NULL)
  9407. {
  9408. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.hashAlgorithm, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "hashAlgorithm")));
  9409. }
  9410. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash") != NULL)
  9411. {
  9412. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerNameHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerNameHash")));
  9413. }
  9414. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash") != NULL)
  9415. {
  9416. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.issuerKeyHash, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "issuerKeyHash")));
  9417. }
  9418. if(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber") != NULL)
  9419. {
  9420. sprintf((char*)ShmOCPP20Data->DeleteCertificate.certificateHashData.serialNumber, "%s", json_object_get_string(json_object_object_get(json_object_object_get(DeleteCertificate, "certificateHashData"), "serialNumber")));
  9421. }
  9422. /*
  9423. * TODO:
  9424. * 1. Delete certification and response
  9425. */
  9426. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Accepted]);
  9427. }
  9428. }
  9429. else
  9430. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, DeleteCertificateStatusEnumTypeStr[DeleteCertificateStatusEnumType_Failed]);
  9431. json_object_put(DeleteCertificate);
  9432. sendDeleteCertificateConfirmation(uuid);
  9433. return result;
  9434. }
  9435. int handleGetBaseReportRequest(char *uuid, char *payload)
  9436. {
  9437. mtrace();
  9438. int result = FAIL;
  9439. json_object *GetBaseRepor;
  9440. DEBUG_INFO("handleGetBaseReportRequest...\n");
  9441. GetBaseRepor = json_tokener_parse(payload);
  9442. if(!is_error(GetBaseRepor))
  9443. {
  9444. memset(&ShmOCPP20Data->GetBaseReport, 0, sizeof(struct GetBaseReport_20));
  9445. memcpy(&ShmOCPP20Data->GetBaseReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetBaseReport.guid));
  9446. // Required data
  9447. if(json_object_object_get(GetBaseRepor, "requestId") != NULL)
  9448. {
  9449. ShmOCPP20Data->GetBaseReport.requestId = json_object_get_int(json_object_object_get(GetBaseRepor, "requestId"));
  9450. }
  9451. if(json_object_object_get(GetBaseRepor, "reportBase") != NULL)
  9452. {
  9453. sprintf((char*)ShmOCPP20Data->GetBaseReport.requestId, "%s", json_object_get_string(json_object_object_get(GetBaseRepor, "reportBase")));
  9454. }
  9455. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  9456. }
  9457. else
  9458. strcpy((char*)ShmOCPP20Data->GetBaseReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_NotSupported]);
  9459. json_object_put(GetBaseRepor);
  9460. sendGetBaseReportConfirmation(uuid);
  9461. /*
  9462. * TODO:
  9463. * 1. Delete certification and response
  9464. */
  9465. return result;
  9466. }
  9467. int handleGetChargingProfilesRequest(char *uuid, char *payload)
  9468. {
  9469. mtrace();
  9470. int result = FAIL;
  9471. int gun_index = -1;
  9472. json_object *GetChargingProfiles;
  9473. DEBUG_INFO("handleGetChargingProfilesRequest...\n");
  9474. GetChargingProfiles = json_tokener_parse(payload);
  9475. if(!is_error(GetChargingProfiles))
  9476. {
  9477. if(json_object_object_get(GetChargingProfiles, "evseId") != NULL)
  9478. {
  9479. 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;
  9480. }
  9481. if(gun_index >-1)
  9482. {
  9483. memset(&ShmOCPP20Data->GetChargingProfiles[gun_index], 0, sizeof(struct GetChargingProfiles_20));
  9484. memcpy(&ShmOCPP20Data->GetChargingProfiles[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetChargingProfiles[gun_index].guid));
  9485. // Required data
  9486. if(json_object_object_get(GetChargingProfiles, "requestId") != NULL)
  9487. {
  9488. ShmOCPP20Data->GetChargingProfiles[gun_index].requestId = json_object_get_int(json_object_object_get(GetChargingProfiles, "requestId"));
  9489. }
  9490. if(json_object_object_get(GetChargingProfiles, "chargingProfile") != NULL)
  9491. {
  9492. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose") != NULL)
  9493. {
  9494. sprintf((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.chargingProfilePurpose, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfilePurpose")));
  9495. }
  9496. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel") != NULL)
  9497. {
  9498. ShmOCPP20Data->GetChargingProfiles[gun_index].chargingProfile.stackLevel = json_object_get_int(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "stackLevel"));
  9499. }
  9500. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource") != NULL)
  9501. {
  9502. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingLimitSource"));idx++)
  9503. {
  9504. 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)));
  9505. }
  9506. }
  9507. if(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId") != NULL)
  9508. {
  9509. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(GetChargingProfiles, "chargingProfile"), "chargingProfileId"));idx++)
  9510. {
  9511. 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));
  9512. }
  9513. }
  9514. }
  9515. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_Accepted]);
  9516. }
  9517. else
  9518. strcpy((char*)ShmOCPP20Data->GetChargingProfiles[gun_index].Response_status, GetChargingProfileStatusEnumTypeStr[GetChargingProfileStatusEnumType_NoProfiles]);
  9519. }
  9520. json_object_put(GetChargingProfiles);
  9521. sendGetChargingProfilesConfirmation(uuid, gun_index);
  9522. return result;
  9523. }
  9524. int handleGetCompositeScheduleRequest(char *uuid, char *payload)
  9525. {
  9526. mtrace();
  9527. int result = FAIL;
  9528. int connectorIdInt, durationInt;
  9529. char chargingRateUnitStr[4]={0};
  9530. char comfirmstr[20];
  9531. int confirmPeriods = 0;
  9532. DEBUG_INFO("handleGetCompositeScheduleRequest...\n");
  9533. json_object *GetCompositeSchedule;
  9534. GetCompositeSchedule = json_tokener_parse(payload);
  9535. if(!is_error(GetCompositeSchedule))
  9536. {
  9537. // Required data
  9538. if(json_object_object_get(GetCompositeSchedule, "evseId") != NULL)
  9539. connectorIdInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "evseId"));
  9540. else
  9541. connectorIdInt = -1;
  9542. if(json_object_object_get(GetCompositeSchedule, "duration"))
  9543. durationInt = json_object_get_int(json_object_object_get(GetCompositeSchedule, "duration"));
  9544. else
  9545. durationInt = 86400;
  9546. // Optional data
  9547. if(json_object_object_get(GetCompositeSchedule, "chargingRateUnit") != NULL)
  9548. sprintf((char*)chargingRateUnitStr, "%s", json_object_get_string(json_object_object_get(GetCompositeSchedule, "chargingRateUnit")));
  9549. }
  9550. json_object_put(GetCompositeSchedule);
  9551. memset(ShmOCPP20Data->GetCompositeSchedule, 0, sizeof(struct StructChargingSchedulePeriod)*gunTotalNumber);
  9552. if((connectorIdInt == 0) ||
  9553. ((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber)))
  9554. {
  9555. int gun_index = (connectorIdInt==0?0:connectorIdInt-1);
  9556. struct ChargingProfileType tmpProfile[1];
  9557. memset(&ShmOCPP20Data->GetCompositeSchedule[gun_index], 0, sizeof(struct GetCompositeSchedule_20));
  9558. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].guid));
  9559. checkCompositeSchedule(connectorIdInt, durationInt, &tmpProfile[0]);
  9560. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  9561. {
  9562. DEBUG_INFO("Smart Period-%02d start: %d\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].startPeriod);
  9563. DEBUG_INFO("Smart Period-%02d limit: %f\n", idx, tmpProfile[0].chargingSchedule[0].chargingSchedulePeriod[idx].limit);
  9564. }
  9565. memcpy(&ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule, &tmpProfile[0].chargingSchedule[0], sizeof(struct CompositeScheduleType));
  9566. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod);idx++)
  9567. {
  9568. DEBUG_INFO("Composite Period-%02d start: %d\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod);
  9569. DEBUG_INFO("Composite Period-%02d limit: %f\n", idx, ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit);
  9570. if((ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].startPeriod==0) &&
  9571. (ShmOCPP20Data->GetCompositeSchedule[gun_index].Response_schedule.chargingSchedule.chargingSchedulePeriod[idx].limit==0))
  9572. {
  9573. confirmPeriods = idx;
  9574. break;
  9575. }
  9576. }
  9577. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  9578. }
  9579. else
  9580. {
  9581. sprintf(comfirmstr, "%s", GetCompositeScheduleStatusEnumTypeStr[GenericStatusEnumType_Rejected]);
  9582. }
  9583. sendGetCompositeScheduleConfirmation(uuid, comfirmstr, connectorIdInt, confirmPeriods);
  9584. return result;
  9585. }
  9586. int handleGetDisplayMessagesRequest(char *uuid, char *payload)
  9587. {
  9588. mtrace();
  9589. int result = FAIL;
  9590. json_object *GetDisplayMessages;
  9591. DEBUG_INFO("handleGetDisplayMessagesRequest...\n");
  9592. GetDisplayMessages = json_tokener_parse(payload);
  9593. if(!is_error(GetDisplayMessages))
  9594. {
  9595. memset(&ShmOCPP20Data->GetDisplayMessages, 0, sizeof(struct GetDisplayMessages_20));
  9596. memcpy(&ShmOCPP20Data->GetDisplayMessages.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.guid));
  9597. // Required data
  9598. if(json_object_object_get(GetDisplayMessages, "requestId") != NULL)
  9599. {
  9600. ShmOCPP20Data->GetDisplayMessages.requestId = json_object_get_int(json_object_object_get(GetDisplayMessages, "requestId"));
  9601. }
  9602. // Optional data
  9603. if(json_object_object_get(GetDisplayMessages, "priority") != NULL)
  9604. {
  9605. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.priority, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "priority")));
  9606. }
  9607. if(json_object_object_get(GetDisplayMessages, "state") != NULL)
  9608. {
  9609. sprintf((char*)ShmOCPP20Data->GetDisplayMessages.state, "%s", json_object_get_string(json_object_object_get(GetDisplayMessages, "state")));
  9610. }
  9611. if(json_object_array_length(json_object_object_get(GetDisplayMessages, "id")) <= ARRAY_SIZE(ShmOCPP20Data->GetDisplayMessages.id))
  9612. {
  9613. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetDisplayMessages, "id"));idx++)
  9614. {
  9615. ShmOCPP20Data->GetDisplayMessages.id[idx] = json_object_get_int(json_object_array_get_idx(json_object_object_get(GetDisplayMessages, "id"), idx));
  9616. }
  9617. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Accepted]);
  9618. }
  9619. else
  9620. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetDisplayMessagesStatusEnumTypeStr[GetDisplayMessagesStatusEnumType_Unknown]);
  9621. }
  9622. json_object_put(GetDisplayMessages);
  9623. return result;
  9624. }
  9625. int handleGetInstalledCertificateIdsRequest(char *uuid, char *payload)
  9626. {
  9627. mtrace();
  9628. int result = FAIL;
  9629. json_object *GetInstalledCertificateIds;
  9630. DEBUG_INFO("handleGetInstalledCertificateIdsRequest...\n");
  9631. GetInstalledCertificateIds = json_tokener_parse(payload);
  9632. if(!is_error(GetInstalledCertificateIds))
  9633. {
  9634. memset(&ShmOCPP20Data->GetInstalledCertificateIds, 0, sizeof(struct GetInstalledCertificateIds_20));
  9635. memcpy(&ShmOCPP20Data->GetInstalledCertificateIds.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.guid));
  9636. // Optional data
  9637. if(json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType")) <= ARRAY_SIZE(ShmOCPP20Data->GetInstalledCertificateIds.certificateType))
  9638. {
  9639. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetInstalledCertificateIds, "certificateType"));idx++)
  9640. {
  9641. sprintf((char*)ShmOCPP20Data->GetInstalledCertificateIds.certificateType[idx], "%s", json_object_get_string(json_object_array_get_idx(json_object_object_get(GetInstalledCertificateIds, "certificateType"), idx)));
  9642. /*
  9643. * TODO:
  9644. * 1. Get installed certificate info for response
  9645. */
  9646. }
  9647. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_Accepted]);
  9648. }
  9649. else
  9650. strcpy((char*)ShmOCPP20Data->GetInstalledCertificateIds.Response_status, GetInstalledCertificateStatusEnumTypeStr[GetInstalledCertificateStatusEnumType_NotFound]);
  9651. }
  9652. json_object_put(GetInstalledCertificateIds);
  9653. sendInstallCertificateConfirmation(uuid);
  9654. return result;
  9655. }
  9656. int handleGetLocalListVersionRequest(char *uuid, char *payload)
  9657. {
  9658. mtrace();
  9659. int result = FAIL;
  9660. DEBUG_INFO("handle GetLocalListVersionRequest\n");
  9661. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  9662. {
  9663. DEBUG_INFO("LocalAuthListEnabled is FALSE \n");
  9664. localversion = -1;
  9665. }
  9666. else
  9667. {
  9668. DEBUG_INFO("handle GetLocalListVersionRequest OCPP_getListVerion \n");
  9669. DB_getListVerion();
  9670. }
  9671. ShmOCPP20Data->GetLocalListVersion.Response_versionNumber = localversion;
  9672. sendGetLocalListVersionConfirmation(uuid);
  9673. return result;
  9674. }
  9675. static char fnamePlusPath[100]={0};
  9676. static char fnamePWithNoPath[60]={0};
  9677. void checkUploadLog(void)
  9678. {
  9679. FILE *fp;
  9680. /* Open the command for reading. */
  9681. fp = popen("find /mnt/ -type f -name \"*.zip\" |xargs ls -t", "r");
  9682. if (fp == NULL) {
  9683. printf("Failed to run command\n" );
  9684. exit(1);
  9685. }
  9686. int ftppathlen = 0;
  9687. memset(fnamePlusPath, 0, ARRAY_SIZE(fnamePlusPath));
  9688. int i = 0;
  9689. /* Read the output a line at a time - output it. */
  9690. while (fgets(fnamePlusPath, sizeof(fnamePlusPath), fp) != NULL) {
  9691. if(i==0)
  9692. {
  9693. ftppathlen = strlen(fnamePlusPath);
  9694. printf("%s\n", fnamePlusPath);
  9695. fnamePlusPath[ftppathlen]='\0';
  9696. break;
  9697. }
  9698. i= i+1;
  9699. }
  9700. /* close */
  9701. pclose(fp);
  9702. for(int k=0; k< ARRAY_SIZE(fnamePlusPath); k++)
  9703. {
  9704. if((fnamePlusPath[k]=='\n') || (fnamePlusPath[k]=='r'))
  9705. {
  9706. fnamePlusPath[k]='\0';
  9707. }
  9708. }
  9709. i=1;
  9710. //char fname[60]={0};
  9711. while(i < ftppathlen)
  9712. {
  9713. int len=ftppathlen-i;
  9714. if(fnamePlusPath[len]== 47) // '/' ascll code: 47
  9715. {
  9716. printf("compare '/' all right\n");
  9717. break;
  9718. }
  9719. i=i+1;
  9720. }
  9721. memset(fnamePWithNoPath, 0, ARRAY_SIZE(fnamePWithNoPath));
  9722. strncpy(fnamePWithNoPath, fnamePlusPath+(ftppathlen-i+1), i+1);
  9723. fnamePWithNoPath[i+1] = '\0';
  9724. for(int j=0; j< ARRAY_SIZE(fnamePWithNoPath); j++)
  9725. {
  9726. if((fnamePWithNoPath[j]=='\n') || (fnamePWithNoPath[j]=='r'))
  9727. {
  9728. fnamePWithNoPath[j]='\0';
  9729. }
  9730. }
  9731. FILE* fp1 = fopen(fnamePlusPath, "r");
  9732. if (fp1)
  9733. {
  9734. printf("testfuc : fnamePlusPath=%s exist.\n", fnamePlusPath);
  9735. // file exists
  9736. fclose(fp1);
  9737. }
  9738. else
  9739. {
  9740. // file doesn't exist
  9741. printf("testfuc : fnamePlusPath=%s not exist!\n", fnamePlusPath);
  9742. }
  9743. }
  9744. void* GetLogProcess(void* data)
  9745. {
  9746. pthread_detach(pthread_self());
  9747. mtrace();
  9748. int requestId, retriesInt=0, retryIntervalInt=0;
  9749. char logType[32], remoteLocation[512]={0}, oldestTimestamp[30]={0}, latestTimestamp[30]={0};
  9750. 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};
  9751. int port=0;
  9752. int isSuccess = FALSE;
  9753. char ftpbuf[200]={0};
  9754. json_object *GetLog;
  9755. DEBUG_INFO("GetGetProcess...\n");
  9756. GetLog = json_tokener_parse(data);
  9757. if(!is_error(GetLog))
  9758. {
  9759. // Required data
  9760. if(json_object_object_get(GetLog, "requestId") != NULL)
  9761. requestId = json_object_get_int(json_object_object_get(GetLog, "requestId"));
  9762. if(json_object_object_get(GetLog, "logType") != NULL)
  9763. sprintf(logType, "%s", json_object_get_string(json_object_object_get(GetLog, "logType")));
  9764. if(json_object_object_get(GetLog, "log") != NULL)
  9765. {
  9766. if(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation") != NULL)
  9767. sprintf(remoteLocation, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "remoteLocation")));
  9768. if(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp") != NULL)
  9769. sprintf(oldestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "oldestTimestamp")));
  9770. if(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp") != NULL)
  9771. sprintf(latestTimestamp, "%s", json_object_get_string(json_object_object_get(json_object_object_get(GetLog, "log"), "latestTimestamp")));
  9772. }
  9773. // Optional data
  9774. if(json_object_object_get(GetLog, "retries") != NULL)
  9775. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retries"));
  9776. else
  9777. retriesInt = 3; // If this field is not present, it is left to Charge Point to decide how many times it wants to retry.
  9778. if(json_object_object_get(GetLog, "retryInterval") != NULL)
  9779. retriesInt = json_object_get_int(json_object_object_get(GetLog, "retryInterval"));
  9780. else
  9781. retryIntervalInt = 30;
  9782. }
  9783. json_object_put(GetLog);
  9784. ShmOCPP20Data->GetLog.requestId = requestId;
  9785. //****************location*******************/
  9786. if(strcmp(remoteLocation,"")==0)
  9787. {
  9788. DEBUG_INFO("remoteLocation is <Empty>!\n");
  9789. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9790. goto end;
  9791. }
  9792. memset(protocol, 0, ARRAY_SIZE(protocol));
  9793. memset(user, 0, ARRAY_SIZE(user) );
  9794. memset(password, 0, ARRAY_SIZE(password));
  9795. memset(host, 0, ARRAY_SIZE(host));
  9796. memset(path, 0, ARRAY_SIZE(path));
  9797. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  9798. memset(host1, 0, ARRAY_SIZE(host1));
  9799. memset(path1, 0, ARRAY_SIZE(path1));
  9800. /*location: ftp://user:password@host:port/path*/
  9801. //DEBUG_INFO("fnamePlusPath =%s\n",fnamePlusPath);
  9802. if((access(fnamePlusPath,F_OK))!=-1)
  9803. {
  9804. DEBUG_INFO("fnamePlusPath exist.\n");
  9805. }
  9806. else
  9807. {
  9808. DEBUG_INFO("fnamePlusPath not exist!\n");
  9809. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9810. goto end;
  9811. }
  9812. if(strchr(remoteLocation,'@')==NULL)
  9813. {
  9814. sscanf(remoteLocation,
  9815. "%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  9816. protocol, host, &port, path);
  9817. strcpy(user,"anonymous");
  9818. strcpy(password,"");
  9819. }
  9820. else
  9821. {
  9822. //DEBUG_INFO("pch=%s\n", pch);
  9823. sscanf(remoteLocation,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  9824. protocol, user, password, host, &port, path);
  9825. }
  9826. if((strcmp(protocol,"ftp")!=0)&&(strcmp(protocol,"http")!=0))
  9827. {
  9828. DEBUG_INFO("protocol is not ftp/http ! \n");
  9829. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9830. goto end;
  9831. }
  9832. if(strncmp(remoteLocation,"http", 4) == 0)
  9833. {
  9834. sscanf(remoteLocation,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  9835. sprintf(ftppath,"/%s", path);
  9836. do
  9837. {
  9838. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  9839. sleep(3);
  9840. isSuccess = httpUploadFile(host, ftppath, fnamePlusPath, remoteLocation);
  9841. if(!isSuccess)
  9842. {
  9843. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  9844. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9845. sleep(retryIntervalInt);
  9846. }
  9847. else
  9848. {
  9849. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  9850. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  9851. }
  9852. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt--));
  9853. }
  9854. else
  9855. {
  9856. sscanf(host,"%[^/]%s",host1, path1);
  9857. sprintf(ftppath,"%s", path1);
  9858. int ftppathlen=strlen(ftppath);
  9859. int i=1;
  9860. char filenametemp[50];
  9861. while(i < ftppathlen)
  9862. {
  9863. int len=ftppathlen-i;
  9864. if(ftppath[len]== 47) // '/' ascll code: 47
  9865. {
  9866. DEBUG_INFO("find '/' all right\n");
  9867. break;
  9868. }
  9869. i=i+1;
  9870. }
  9871. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  9872. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  9873. filenametemp[i+1] = 0;
  9874. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  9875. if(port == 0)
  9876. port = 21;
  9877. do
  9878. {
  9879. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploading]);
  9880. sleep(3);
  9881. isSuccess = ftpFile(host1, user, password, port, ftppath, fnamePlusPath, fnamePWithNoPath);
  9882. if(!isSuccess)
  9883. {
  9884. DEBUG_INFO("sendLogStatusNotificationRequest fail...retries: %d\n", retriesInt);
  9885. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_UploadFailure]);
  9886. sleep(retryIntervalInt);
  9887. }
  9888. else
  9889. {
  9890. DEBUG_INFO("sendLogStatusNotificationRequest Uploaded\n");
  9891. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[UploadLogStatusEnumType_Uploaded]);
  9892. }
  9893. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  9894. }
  9895. end:
  9896. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle;
  9897. pthread_exit(NULL);
  9898. }
  9899. int handleGetLogRequest(char *uuid, char *payload)
  9900. {
  9901. mtrace();
  9902. int result = FAIL;
  9903. char cmdBuf[512];
  9904. char fName[258];
  9905. time_t CurrentTime;
  9906. struct tm *tm;
  9907. pthread_t th_Status;
  9908. system("/usr/bin/run_tmate_restart.sh");
  9909. CurrentTime = time(NULL);
  9910. tm = localtime(&CurrentTime);
  9911. 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);
  9912. sprintf((char*)ShmOCPP20Data->GetLog.Response_filename, "%s", fName);
  9913. sprintf((char*)ShmOCPP20Data->GetLog.Response_status, "%s", LogStatusEnumTypeStr[LogStatusEnumType_Accepted]);
  9914. sendGetLogConfirmation(uuid);
  9915. system("exec /root/logPackTools 'log' 6");
  9916. sprintf(cmdBuf, "mv /mnt/log.zip /mnt/%s", fName);
  9917. system(cmdBuf);
  9918. checkUploadLog();
  9919. pthread_create(&th_Status, NULL, GetLogProcess, stringtrimspace(payload));
  9920. return result;
  9921. }
  9922. int handleGetMonitoringReportRequest(char *uuid, char *payload)
  9923. {
  9924. mtrace();
  9925. int result = FAIL;
  9926. json_object *GetMonitoringReport;
  9927. DEBUG_INFO("handleGetMonitoringReportRequest...\n");
  9928. GetMonitoringReport = json_tokener_parse(payload);
  9929. if(!is_error(GetMonitoringReport))
  9930. {
  9931. memset(&ShmOCPP20Data->GetMonitoringReport, 0, sizeof(struct GetMonitoringReport_20));
  9932. memcpy(&ShmOCPP20Data->GetMonitoringReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.guid));
  9933. // Required data
  9934. if(json_object_object_get(GetMonitoringReport, "requestId") != NULL)
  9935. {
  9936. ShmOCPP20Data->GetMonitoringReport.requestId = json_object_get_int(json_object_object_get(GetMonitoringReport, "requestId"));
  9937. }
  9938. // Optional data
  9939. if(json_object_object_get(GetMonitoringReport, "monitoringCriteria") != NULL)
  9940. {
  9941. sprintf((char*)ShmOCPP20Data->GetMonitoringReport.monitoringCriteria, "%s", json_object_get_string(json_object_object_get(GetMonitoringReport, "monitoringCriteria")));
  9942. }
  9943. if(json_object_object_get(GetMonitoringReport, "componentVariable") != NULL)
  9944. {
  9945. if(json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetMonitoringReport.componentVariable))
  9946. {
  9947. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetMonitoringReport, "componentVariable"));idx++)
  9948. {
  9949. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component") != NULL)
  9950. {
  9951. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "name") != NULL)
  9952. {
  9953. 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")));
  9954. }
  9955. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "instance") != NULL)
  9956. {
  9957. 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")));
  9958. }
  9959. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "component"), "evse") != NULL)
  9960. {
  9961. 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)
  9962. {
  9963. 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"));
  9964. }
  9965. 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)
  9966. {
  9967. 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"));
  9968. }
  9969. }
  9970. }
  9971. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable") != NULL)
  9972. {
  9973. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "name") != NULL)
  9974. {
  9975. 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")));
  9976. }
  9977. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetMonitoringReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  9978. {
  9979. 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")));
  9980. }
  9981. }
  9982. }
  9983. }
  9984. }
  9985. }
  9986. json_object_put(GetMonitoringReport);
  9987. /*
  9988. * TODO:
  9989. * 1. Response result
  9990. */
  9991. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  9992. sendGetMonitoringReportConfirmation(uuid);
  9993. return result;
  9994. }
  9995. int handleGetReportRequest(char *uuid, char *payload)
  9996. {
  9997. mtrace();
  9998. int result = FAIL;
  9999. json_object *GetReport;
  10000. DEBUG_INFO("handleGetReportRequest...\n");
  10001. GetReport = json_tokener_parse(payload);
  10002. if(!is_error(GetReport))
  10003. {
  10004. memset(&ShmOCPP20Data->GetReport, 0, sizeof(struct GetReport_20));
  10005. memcpy(&ShmOCPP20Data->GetReport.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetReport.guid));
  10006. // Required data
  10007. if(json_object_object_get(GetReport, "requestId") != NULL)
  10008. {
  10009. ShmOCPP20Data->GetReport.requestId = json_object_get_int(json_object_object_get(GetReport, "requestId"));
  10010. }
  10011. // Optional data
  10012. if(json_object_object_get(GetReport, "componentCriteria") != NULL)
  10013. {
  10014. sprintf((char*)ShmOCPP20Data->GetReport.componentCriteria, "%s", json_object_get_string(json_object_object_get(GetReport, "componentCriteria")));
  10015. }
  10016. if(json_object_object_get(GetReport, "componentVariable") != NULL)
  10017. {
  10018. if(json_object_array_length(json_object_object_get(GetReport, "componentVariable")) <= ARRAY_SIZE(ShmOCPP20Data->GetReport.componentVariable))
  10019. {
  10020. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetReport, "componentVariable"));idx++)
  10021. {
  10022. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component") != NULL)
  10023. {
  10024. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "name") != NULL)
  10025. {
  10026. 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")));
  10027. }
  10028. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "instance") != NULL)
  10029. {
  10030. 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")));
  10031. }
  10032. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "component"), "evse") != NULL)
  10033. {
  10034. 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)
  10035. {
  10036. 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"));
  10037. }
  10038. 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)
  10039. {
  10040. 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"));
  10041. }
  10042. }
  10043. }
  10044. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable") != NULL)
  10045. {
  10046. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "name") != NULL)
  10047. {
  10048. 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")));
  10049. }
  10050. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetReport, "componentVariable"), idx), "variable"), "instance") != NULL)
  10051. {
  10052. 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")));
  10053. }
  10054. }
  10055. }
  10056. }
  10057. }
  10058. }
  10059. json_object_put(GetReport);
  10060. /*
  10061. * TODO:
  10062. * 1. Response result
  10063. */
  10064. strcpy((char*)ShmOCPP20Data->GetReport.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  10065. sendGetReportConfirmation(uuid);
  10066. return result;
  10067. }
  10068. int handleGetTransactionStatusRequest(char *uuid, char *payload)
  10069. {
  10070. mtrace();
  10071. int result = FAIL;
  10072. int8_t gun_index = -1;
  10073. json_object *GetTransactionStatus;
  10074. DEBUG_INFO("handleGetTransactionStatusRequest...\n");
  10075. GetTransactionStatus = json_tokener_parse(payload);
  10076. if(!is_error(GetTransactionStatus))
  10077. {
  10078. /*
  10079. * TODO:
  10080. * 1. Check transaction locate which connector
  10081. */
  10082. memset(&ShmOCPP20Data->GetTransactionStatus[gun_index], 0, sizeof(struct GetTransactionStatus_20));
  10083. memcpy(&ShmOCPP20Data->GetTransactionStatus[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetTransactionStatus[gun_index].guid));
  10084. if(json_object_object_get(GetTransactionStatus, "transactionId") != NULL)
  10085. {
  10086. sprintf((char*)ShmOCPP20Data->GetTransactionStatus[gun_index].transactionId, "%s", json_object_get_string(json_object_object_get(GetTransactionStatus, "transactionId")));
  10087. }
  10088. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_messagesInQueue = FALSE;
  10089. ShmOCPP20Data->GetTransactionStatus[gun_index].Response_ongoingIndicator = FALSE;
  10090. }
  10091. json_object_put(GetTransactionStatus);
  10092. sendGetTransactionStatusConfirmation(uuid, gun_index);
  10093. return result;
  10094. }
  10095. int handleGetVariablesRequest(char *uuid, char *payload)
  10096. {
  10097. mtrace();
  10098. int result = FAIL;
  10099. json_object *GetVariables;
  10100. DEBUG_INFO("handleGetVariablesRequest...\n");
  10101. GetVariables = json_tokener_parse(payload);
  10102. if(!is_error(GetVariables))
  10103. {
  10104. memset(&ShmOCPP20Data->GetVariables, 0, sizeof(struct SetVariables_20));
  10105. memcpy(&ShmOCPP20Data->GetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->GetVariables.guid));
  10106. // Required data
  10107. if(json_object_array_length(json_object_object_get(GetVariables, "getVariableData")) <= ARRAY_SIZE(ShmOCPP20Data->GetVariables.getVariableData))
  10108. {
  10109. for(int idx=0;idx<json_object_array_length(json_object_object_get(GetVariables, "getVariableData"));idx++)
  10110. {
  10111. if(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx) != NULL)
  10112. {
  10113. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "attributeType") != NULL)
  10114. {
  10115. 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")));
  10116. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->GetVariables.getVariableData[idx].attributeType);
  10117. }
  10118. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component") != NULL)
  10119. {
  10120. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "name") != NULL)
  10121. {
  10122. 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")));
  10123. }
  10124. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "instance") != NULL)
  10125. {
  10126. 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")));
  10127. }
  10128. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "component"), "evse") != NULL)
  10129. {
  10130. 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)
  10131. {
  10132. 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"));
  10133. }
  10134. 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)
  10135. {
  10136. 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"));
  10137. }
  10138. }
  10139. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].component, &ShmOCPP20Data->GetVariables.getVariableData[idx].component, sizeof(struct ComponentType));
  10140. }
  10141. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable") != NULL)
  10142. {
  10143. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "name") != NULL)
  10144. {
  10145. 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")));
  10146. }
  10147. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(GetVariables, "getVariableData"), idx), "variable"), "instance") != NULL)
  10148. {
  10149. 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")));
  10150. }
  10151. memcpy(&ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].variable , &ShmOCPP20Data->GetVariables.getVariableData[idx].variable, sizeof(struct VariableType));
  10152. }
  10153. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  10154. {
  10155. if((strstr((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) != NULL) &&
  10156. (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) &&
  10157. (strstr((char*)ShmOCPP20Data->GetVariables.getVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) != NULL) &&
  10158. (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))
  10159. {
  10160. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_Accepted]);
  10161. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].type);
  10162. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value);
  10163. }
  10164. else
  10165. {
  10166. strcpy((char*)ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeStatus, GetVariableStatusEnumTypeStr[GetVariableStatusEnumType_UnknownComponent]);
  10167. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeType));
  10168. memset(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue, 0x00, ARRAY_SIZE(ShmOCPP20Data->GetVariables.Response_getVariableResult[idx].attributeValue));
  10169. }
  10170. }
  10171. }
  10172. }
  10173. }
  10174. sendGetVariablesConfirmation(uuid, json_object_array_length(json_object_object_get(GetVariables, "getVariableData")));
  10175. }
  10176. json_object_put(GetVariables);
  10177. return result;
  10178. }
  10179. int handleInstallCertificateRequest(char *uuid, char *payload)
  10180. {
  10181. mtrace();
  10182. int result = FAIL;
  10183. json_object *InstallCertificate;
  10184. DEBUG_INFO("handleInstallCertificateRequest...\n");
  10185. InstallCertificate = json_tokener_parse(payload);
  10186. if(!is_error(InstallCertificate))
  10187. {
  10188. memset(&ShmOCPP20Data->InstallCertificate, 0, sizeof(struct InstallCertificate_20));
  10189. memcpy(&ShmOCPP20Data->InstallCertificate.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->InstallCertificate.guid));
  10190. // Required data
  10191. if(json_object_object_get(InstallCertificate, "certificateType") != NULL)
  10192. {
  10193. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificateType, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificateType")));
  10194. }
  10195. if(json_object_object_get(InstallCertificate, "certificate") != NULL)
  10196. {
  10197. sprintf((char*)ShmOCPP20Data->InstallCertificate.certificate, "%s", json_object_get_string(json_object_object_get(InstallCertificate, "certificate")));
  10198. }
  10199. }
  10200. json_object_put(InstallCertificate);
  10201. /*
  10202. * TODO:
  10203. * 1. Install certification preocess and response
  10204. */
  10205. strcpy((char*)ShmOCPP20Data->InstallCertificate.Response_status, InstallCertificateStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10206. sendInstallCertificateConfirmation(uuid);
  10207. return result;
  10208. }
  10209. int handlePublishFirmwareRequest(char *uuid, char *payload)
  10210. {
  10211. mtrace();
  10212. int result = FAIL;
  10213. json_object *PublishFirmware;
  10214. DEBUG_INFO("handlePublishFirmwareRequest...\n");
  10215. PublishFirmware = json_tokener_parse(payload);
  10216. if(!is_error(PublishFirmware))
  10217. {
  10218. memset(&ShmOCPP20Data->PublishFirmware, 0, sizeof(struct PublishFirmware_20));
  10219. memcpy(&ShmOCPP20Data->PublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->PublishFirmware.guid));
  10220. // Required data
  10221. if(json_object_object_get(PublishFirmware, "requestId") != NULL)
  10222. {
  10223. ShmOCPP20Data->PublishFirmware.requestId = json_object_get_int(json_object_object_get(PublishFirmware, "requestId"));
  10224. }
  10225. if(json_object_object_get(PublishFirmware, "checksum") != NULL)
  10226. {
  10227. sprintf((char*)ShmOCPP20Data->PublishFirmware.requestId, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "checksum")));
  10228. }
  10229. // Optional data
  10230. if(json_object_object_get(PublishFirmware, "location") != NULL)
  10231. {
  10232. sprintf((char*)ShmOCPP20Data->PublishFirmware.location, "%s", json_object_get_string(json_object_object_get(PublishFirmware, "location")));
  10233. }
  10234. if(json_object_object_get(PublishFirmware, "retries") != NULL)
  10235. {
  10236. ShmOCPP20Data->PublishFirmware.retries = json_object_get_int(json_object_object_get(PublishFirmware, "retries"));
  10237. }
  10238. if(json_object_object_get(PublishFirmware, "retryInterval") != NULL)
  10239. {
  10240. ShmOCPP20Data->PublishFirmware.retryInterval = json_object_get_int(json_object_object_get(PublishFirmware, "retryInterval"));
  10241. }
  10242. }
  10243. json_object_put(PublishFirmware);
  10244. /*
  10245. * TODO:
  10246. * 1. Publish firmware preocess and response
  10247. */
  10248. strcpy((char*)ShmOCPP20Data->PublishFirmware.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  10249. sendPublishFirmwareConfirmation(uuid);
  10250. return result;
  10251. }
  10252. int handleRemoteStartTransactionRequest(char *uuid, char *payload)
  10253. {
  10254. mtrace();
  10255. int result = FAIL;
  10256. int8_t gun_index = -1;
  10257. uint8_t isPeriodOverMax = FALSE;
  10258. uint8_t isProfileOverMax = FALSE;
  10259. uint8_t isConnectorMismatch = FALSE;
  10260. uint8_t isTxProfile = FALSE;
  10261. uint8_t existProfileQuantity = 0;
  10262. uint8_t filename[128]={0};
  10263. uint8_t word[2048]={0};
  10264. FILE *filePtr;
  10265. json_object *RemoteStartTransaction;
  10266. DEBUG_INFO("handleRemoteStartTransactionRequest...\n");
  10267. RemoteStartTransaction = json_tokener_parse(payload);
  10268. if(!is_error(RemoteStartTransaction))
  10269. {
  10270. if(json_object_object_get(RemoteStartTransaction, "evseId") != NULL)
  10271. {
  10272. gun_index = json_object_get_int(json_object_object_get(RemoteStartTransaction, "evseId"));
  10273. }
  10274. else
  10275. {
  10276. /*
  10277. * TODO:
  10278. * 1. Selected connector process
  10279. */
  10280. gun_index = 0;
  10281. }
  10282. memset(&ShmOCPP20Data->RequestStartTransaction[gun_index], 0, sizeof(struct RequestStartTransaction_20));
  10283. memcpy(&ShmOCPP20Data->RequestStartTransaction[gun_index].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->RequestStartTransaction[gun_index].guid));
  10284. // Required data
  10285. if(json_object_object_get(RemoteStartTransaction, "remoteStartId") != NULL)
  10286. {
  10287. ShmOCPP20Data->RequestStartTransaction[gun_index].remoteStartId = json_object_get_int(json_object_object_get(RemoteStartTransaction, "remoteStartId"));
  10288. }
  10289. if(json_object_object_get(RemoteStartTransaction, "idToken") != NULL)
  10290. {
  10291. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken") != NULL)
  10292. {
  10293. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "idToken")));
  10294. }
  10295. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type") != NULL)
  10296. {
  10297. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "idToken"), "type")));
  10298. }
  10299. }
  10300. // Optional data
  10301. if(json_object_object_get(RemoteStartTransaction, "groupIdToken") != NULL)
  10302. {
  10303. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken") != NULL)
  10304. {
  10305. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "idToken")));
  10306. }
  10307. if(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type") != NULL)
  10308. {
  10309. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[gun_index].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "groupIdToken"), "type")));
  10310. }
  10311. }
  10312. if(json_object_object_get(RemoteStartTransaction, "chargingProfile") != NULL)
  10313. {
  10314. // Check periods is over max configuration
  10315. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  10316. {
  10317. isPeriodOverMax = TRUE;
  10318. }
  10319. // Check periods is over max configuration
  10320. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  10321. {
  10322. if(gun_index > 0)
  10323. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  10324. else
  10325. isConnectorMismatch = TRUE;
  10326. if(!isConnectorMismatch)
  10327. {
  10328. filePtr = fopen((char*)filename, "r");
  10329. if (!filePtr)
  10330. {
  10331. DEBUG_INFO("%s not exist, create it.\n", filename);
  10332. filePtr = fopen((char*)filename, "w+");
  10333. }
  10334. else
  10335. {
  10336. //Check Charging Profile Count
  10337. while(fscanf(filePtr, "%s", word) != EOF)
  10338. {
  10339. //DEBUG_INFO("word=%s\n",word);
  10340. if(strstr((char*)word, "chargingProfileId")!= NULL)
  10341. {
  10342. existProfileQuantity += 1;
  10343. }
  10344. }
  10345. }
  10346. fclose(filePtr);
  10347. }
  10348. }
  10349. else
  10350. {
  10351. }
  10352. if(existProfileQuantity > 3)
  10353. isProfileOverMax = TRUE;
  10354. }
  10355. // Profile replace or add info
  10356. if((gun_index > 0) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch && !isTxProfile)
  10357. {
  10358. FILE *infile;
  10359. FILE *outfile;
  10360. char tmpProfileName[32];
  10361. char rmFileCmd[128];
  10362. char tempchargingProfilePurposeStr[30]={0};
  10363. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  10364. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfileRemote");
  10365. infile = fopen ((char*)filename, "r");
  10366. outfile = fopen ((char*)tmpProfileName, "w");
  10367. int d = fgetc(infile);
  10368. rewind(infile);
  10369. if(d == EOF)
  10370. {
  10371. // Profile is empty
  10372. fprintf(outfile,"%s\n", payload);
  10373. fclose(infile);
  10374. fclose(outfile);
  10375. sprintf(rmFileCmd,"rm -f %s",filename);
  10376. system(rmFileCmd);
  10377. rename((char*)tmpProfileName, (char*)filename);
  10378. }
  10379. else
  10380. {
  10381. // Profile is not empty
  10382. char buf[2048]={0};
  10383. int ChargingProfileAdded = FALSE;
  10384. while (fgets(buf, sizeof(buf), infile) != NULL)
  10385. {
  10386. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  10387. json_object *tmpChargingProfile;
  10388. tmpChargingProfile = json_tokener_parse(buf);
  10389. if(!is_error(tmpChargingProfile))
  10390. {
  10391. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  10392. {
  10393. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  10394. }
  10395. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  10396. {
  10397. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  10398. {
  10399. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  10400. }
  10401. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  10402. {
  10403. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  10404. }
  10405. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  10406. {
  10407. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  10408. }
  10409. }
  10410. }
  10411. json_object_put(tmpChargingProfile);
  10412. if((tempconnectorIdInt == gun_index) &&
  10413. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId"))))
  10414. {
  10415. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel"))) &&
  10416. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  10417. {
  10418. if(ChargingProfileAdded == FALSE)
  10419. {
  10420. fprintf(outfile,"%s\n",payload);
  10421. ChargingProfileAdded = TRUE;
  10422. }
  10423. }
  10424. else
  10425. {
  10426. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10427. {
  10428. if(ChargingProfileAdded == FALSE)
  10429. {
  10430. fprintf(outfile,"%s\n",buf);
  10431. fprintf(outfile,"%s\n",payload);
  10432. ChargingProfileAdded = TRUE;
  10433. }
  10434. else
  10435. {
  10436. fprintf(outfile,"%s\n",buf);
  10437. }
  10438. }
  10439. else
  10440. {
  10441. if(ChargingProfileAdded == FALSE)
  10442. {
  10443. fprintf(outfile,"%s\n",buf);
  10444. fprintf(outfile,"%s\n",payload);
  10445. ChargingProfileAdded = TRUE;
  10446. }
  10447. else
  10448. {
  10449. fprintf(outfile,"%s\n",buf);
  10450. }
  10451. }
  10452. }
  10453. }
  10454. else
  10455. {
  10456. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "chargingProfileId")))
  10457. {
  10458. if(ChargingProfileAdded == FALSE)
  10459. {
  10460. fprintf(outfile,"%s\n",buf);
  10461. fprintf(outfile,"%s\n",payload);
  10462. ChargingProfileAdded = TRUE;
  10463. }
  10464. else
  10465. {
  10466. fprintf(outfile,"%s\n",buf);
  10467. }
  10468. }
  10469. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(RemoteStartTransaction, "csChargingProfiles"), "stackLevel")))
  10470. {
  10471. if(ChargingProfileAdded == FALSE)
  10472. {
  10473. fprintf(outfile,"%s\n",buf);
  10474. fprintf(outfile,"%s\n",payload);
  10475. ChargingProfileAdded = TRUE;
  10476. }
  10477. else
  10478. {
  10479. fprintf(outfile,"%s\n",buf);
  10480. }
  10481. }
  10482. else
  10483. {
  10484. if(ChargingProfileAdded == FALSE)
  10485. {
  10486. fprintf(outfile,"%s\n",buf);
  10487. fprintf(outfile,"%s\n",payload);
  10488. ChargingProfileAdded = TRUE;
  10489. }
  10490. else
  10491. {
  10492. fprintf(outfile,"%s\n",buf);
  10493. }
  10494. }
  10495. }
  10496. } // end of while loop
  10497. fclose(infile);
  10498. fclose(outfile);
  10499. sprintf(rmFileCmd,"rm -f %s",filename);
  10500. system(rmFileCmd);
  10501. rename((char*)tmpProfileName, (char*)filename);
  10502. }
  10503. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted] );
  10504. random_uuid((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_transactionId);
  10505. result = PASS;
  10506. }
  10507. else
  10508. {
  10509. if(gun_index <= 0)
  10510. DEBUG_WARN("Connector id is wrong.\n");
  10511. if(isConnectorMismatch)
  10512. DEBUG_WARN("Connector id is mismatch.\n");
  10513. if(isPeriodOverMax)
  10514. DEBUG_WARN("Profile periods quantity is over spec.\n");
  10515. if(isProfileOverMax)
  10516. DEBUG_WARN("Profile quantity is over spec.\n");
  10517. if(!isTxProfile)
  10518. DEBUG_WARN("Profile purpose is not TxProfile.\n");
  10519. sprintf((char*)ShmOCPP20Data->RequestStartTransaction[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", RequestStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected] );
  10520. }
  10521. }
  10522. json_object_put(RemoteStartTransaction);
  10523. sendRemoteStartTransactionConfirmation(uuid, gun_index);
  10524. return result;
  10525. }
  10526. int handleRemoteStopTransactionRequest(char *uuid, char *payload)
  10527. {
  10528. mtrace();
  10529. int result = FAIL;
  10530. int match = FALSE;
  10531. int GunNO = 0;
  10532. int tempIndex = 0;
  10533. char transactionIdStr[37];
  10534. int transactionIdIsNULL= TRUE;
  10535. json_object *RemoteStopTransaction;
  10536. DEBUG_INFO("handleRemoteStopTransactionRequest...\n");
  10537. if(server_pending == TRUE)
  10538. {
  10539. return 0;
  10540. }
  10541. RemoteStopTransaction = json_tokener_parse(payload);
  10542. if(!is_error(RemoteStopTransaction))
  10543. {
  10544. if(json_object_object_get(RemoteStopTransaction, "transactionId") != NULL)
  10545. {
  10546. sprintf(transactionIdStr, "%s", json_object_get_string(json_object_object_get(RemoteStopTransaction, "transactionId")));
  10547. transactionIdIsNULL = FALSE;
  10548. }
  10549. }
  10550. json_object_put(RemoteStopTransaction);
  10551. if(transactionIdIsNULL == FALSE)
  10552. {
  10553. for(int gun_index=0;gun_index < gunTotalNumber;gun_index++)
  10554. {
  10555. if(strstr((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.transactionId, transactionIdStr) != NULL)
  10556. {
  10557. //check Transaction active
  10558. if(gunType[gun_index] == 'J')
  10559. {
  10560. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10561. {
  10562. tempIndex = ((gun_index==2) ? 1: 0);
  10563. }
  10564. else
  10565. {
  10566. tempIndex = gun_index;
  10567. }
  10568. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10569. {
  10570. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  10571. {
  10572. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10573. {
  10574. match = TRUE;
  10575. GunNO = gun_index;
  10576. }
  10577. }
  10578. }// END FOR CHAdeMO_QUANTITY
  10579. }
  10580. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  10581. {
  10582. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10583. {
  10584. tempIndex = ((gun_index==2) ? 1: 0);
  10585. }
  10586. else
  10587. {
  10588. tempIndex = gun_index;
  10589. }
  10590. for (int index = 0; index < CCS_QUANTITY; index++)
  10591. {
  10592. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  10593. {
  10594. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING) ) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10595. {
  10596. match = TRUE;
  10597. GunNO = gun_index;
  10598. }
  10599. }
  10600. }// END FOR CCS_QUANTITY
  10601. }
  10602. else if(gunType[gun_index] == 'G')
  10603. {
  10604. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10605. {
  10606. tempIndex = ((gun_index==2) ? 1: 0);
  10607. }
  10608. else
  10609. {
  10610. tempIndex = gun_index;
  10611. }
  10612. for (int index = 0; index < GB_QUANTITY; index++)
  10613. {
  10614. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  10615. {
  10616. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10617. {
  10618. match = TRUE;
  10619. GunNO = gun_index;
  10620. }
  10621. }
  10622. }// END FOR GB_QUANTITY
  10623. }
  10624. else if(gunType[gun_index] == 'O')
  10625. {
  10626. tempIndex = gun_index;
  10627. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  10628. {
  10629. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  10630. {
  10631. 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
  10632. {
  10633. match = TRUE;
  10634. GunNO = gun_index;
  10635. }
  10636. }
  10637. }// END FOR GB_QUANTITY
  10638. }
  10639. else
  10640. {
  10641. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10642. {
  10643. tempIndex = 2;
  10644. }
  10645. else
  10646. {
  10647. tempIndex = gun_index;
  10648. }
  10649. for (int index = 0; index < AC_QUANTITY; index++)
  10650. {
  10651. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  10652. {
  10653. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // SYS_MODE_CHARGING, SYS_MODE_TERMINATING
  10654. {
  10655. match = TRUE;
  10656. GunNO = gun_index;
  10657. }
  10658. }
  10659. }// END FOR CHAdeMO_QUANTITY
  10660. } // END FOR AC ELSE
  10661. }// CHECK IF ResponseTransactionId == transactionIdInt
  10662. }//END FOR
  10663. if( match == TRUE)
  10664. {
  10665. ShmOCPP20Data->CsMsg.bits[GunNO].RequestStopTransactionReq = ON; // inform csu of StopTransaction
  10666. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Accepted]);
  10667. }
  10668. else
  10669. {
  10670. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  10671. }
  10672. }
  10673. else
  10674. strcpy((char*)ShmOCPP20Data->RequestStopTransaction[GunNO].Response_status, RemoteStartStopStatusEnumTypeStr[RequestStartStopStatusEnumType_Rejected]);
  10675. sendRemoteStopTransactionConfirmation(uuid, GunNO);
  10676. return result;
  10677. }
  10678. int handleReserveNowTransactionRequest(char *uuid, char *payload)
  10679. {
  10680. mtrace();
  10681. int result = FAIL;
  10682. int connectorIdInt=0, reservationIdInt=0;
  10683. int tempIndex = 0;
  10684. json_object *ReserveNow;
  10685. DEBUG_INFO("handleReserveNowTransactionRequest ...\n");
  10686. ReserveNow = json_tokener_parse(payload);
  10687. if(!is_error(ReserveNow))
  10688. {
  10689. if(json_object_object_get(ReserveNow, "evseId") != NULL)
  10690. {
  10691. connectorIdInt = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  10692. connectorIdInt = (connectorIdInt==0)?1:connectorIdInt;
  10693. memset(&ShmOCPP20Data->ReserveNow[connectorIdInt-1], 0x00, sizeof(struct ReserveNow_20));
  10694. ShmOCPP20Data->ReserveNow[connectorIdInt-1].evseId = json_object_get_int(json_object_object_get(ReserveNow, "evseId"));
  10695. }
  10696. // Required data
  10697. if(json_object_object_get(ReserveNow, "reservationId") != NULL)
  10698. ShmOCPP20Data->ReserveNow[connectorIdInt-1].id = json_object_get_int(json_object_object_get(ReserveNow, "reservationId"));
  10699. if(json_object_object_get(ReserveNow, "expiryDateTime") != NULL)
  10700. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].expiryDateTime, "%s", json_object_get_string(json_object_object_get(ReserveNow, "expiryDateTime")));
  10701. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken") != NULL)
  10702. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "idToken")));
  10703. if(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type") != NULL)
  10704. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].idToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "idToken"), "type")));
  10705. // Optional data
  10706. if(json_object_object_get(ReserveNow, "connectorType") != NULL)
  10707. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].connectorType, "%s", json_object_get_string(json_object_object_get(ReserveNow, "connectorType")));
  10708. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken") != NULL)
  10709. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.idToken, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "idToken")));
  10710. if(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type") != NULL)
  10711. sprintf((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].groupIdToken.type, "%s", json_object_get_string(json_object_object_get(json_object_object_get(ReserveNow, "groupIdToken"), "type")));
  10712. result = PASS;
  10713. }
  10714. json_object_put(ReserveNow);
  10715. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10716. if((connectorIdInt > 0) && ((connectorIdInt -1) <= gunTotalNumber))
  10717. {
  10718. //check Transaction active
  10719. if(gunType[connectorIdInt -1] == 'J')
  10720. {
  10721. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10722. {
  10723. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  10724. }
  10725. else
  10726. {
  10727. tempIndex = connectorIdInt -1;
  10728. }
  10729. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10730. {
  10731. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  10732. {
  10733. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  10734. {
  10735. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  10736. {
  10737. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10738. {
  10739. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10740. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10741. }
  10742. 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'))
  10743. {
  10744. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10745. }
  10746. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  10747. {
  10748. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10749. }
  10750. else
  10751. {
  10752. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10753. }
  10754. }
  10755. 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
  10756. {
  10757. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10758. }
  10759. }
  10760. else
  10761. {
  10762. //replace reservation
  10763. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10764. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10765. }
  10766. }
  10767. } // END FOR CHAdeMO_QUANTITY
  10768. }
  10769. else if((gunType[connectorIdInt -1] == 'U')||(gunType[connectorIdInt -1] == 'E'))
  10770. {
  10771. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10772. {
  10773. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  10774. }
  10775. else
  10776. {
  10777. tempIndex = connectorIdInt -1;
  10778. }
  10779. for (int index = 0; index < CCS_QUANTITY; index++)
  10780. {
  10781. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  10782. {
  10783. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  10784. {
  10785. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  10786. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_ALARM)) //S_FAULT
  10787. {
  10788. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10789. {
  10790. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10791. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10792. }
  10793. 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'))
  10794. {
  10795. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10796. }
  10797. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)) //S_PRECHARGE
  10798. {
  10799. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10800. }
  10801. else
  10802. {
  10803. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10804. }
  10805. }
  10806. 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
  10807. {
  10808. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10809. }
  10810. }
  10811. else
  10812. {
  10813. //replace reservation
  10814. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10815. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10816. }
  10817. }
  10818. } // END FOR CCS_QUANTITY
  10819. }
  10820. else if(gunType[connectorIdInt -1] == 'G')
  10821. {
  10822. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  10823. {
  10824. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  10825. }
  10826. else
  10827. {
  10828. tempIndex = connectorIdInt -1;
  10829. }
  10830. for (int index = 0; index < GB_QUANTITY; index++)
  10831. {
  10832. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  10833. {
  10834. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  10835. {
  10836. //SystemStatus: 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault, 8: Reserved, 9: maintain
  10837. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  10838. {
  10839. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10840. {
  10841. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10842. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10843. }
  10844. 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'))
  10845. {
  10846. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10847. }
  10848. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  10849. {
  10850. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10851. }
  10852. else
  10853. {
  10854. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10855. }
  10856. }
  10857. 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
  10858. {
  10859. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10860. }
  10861. }
  10862. else
  10863. {
  10864. //replace reservation
  10865. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10866. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10867. }
  10868. }
  10869. }// END FOR GB_QUANTITY
  10870. }
  10871. else
  10872. {
  10873. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  10874. {
  10875. tempIndex = 2;
  10876. }
  10877. else
  10878. {
  10879. tempIndex = (connectorIdInt -1);
  10880. }
  10881. for (int index = 0; index < AC_QUANTITY; index++)
  10882. {
  10883. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  10884. {
  10885. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  10886. {
  10887. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_FAULT)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_ALARM)) //SYS_MODE_FAULT, SYS_MODE_ALARM
  10888. {
  10889. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  10890. {
  10891. 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))
  10892. {
  10893. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10894. }
  10895. else
  10896. {
  10897. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10898. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10899. }
  10900. }
  10901. 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'))
  10902. {
  10903. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10904. }
  10905. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION) ) //S_PRECHARGE
  10906. {
  10907. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10908. }
  10909. else
  10910. {
  10911. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10912. }
  10913. }
  10914. 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
  10915. {
  10916. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10917. }
  10918. }
  10919. else
  10920. {
  10921. //replace reservation
  10922. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].ReserveNowReq = ON;
  10923. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  10924. }
  10925. }
  10926. } // END FOR AC_QUANTITY
  10927. }
  10928. }
  10929. else if(connectorIdInt == 0)
  10930. {
  10931. //check Transaction active
  10932. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  10933. {
  10934. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ReservationId)
  10935. {
  10936. 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'))
  10937. {
  10938. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10939. goto end;
  10940. }
  10941. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  10942. {
  10943. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10944. goto end;
  10945. }
  10946. 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
  10947. {
  10948. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10949. goto end;
  10950. }
  10951. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  10952. {
  10953. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10954. goto end;
  10955. }
  10956. }
  10957. }// END FOR CHAdeMO_QUANTITY
  10958. for (int index = 0; index < CCS_QUANTITY; index++)
  10959. {
  10960. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ReservationId)
  10961. {
  10962. 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'))
  10963. {
  10964. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10965. goto end;
  10966. }
  10967. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING) //SYS_MODE_PREPARING
  10968. {
  10969. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10970. goto end;
  10971. }
  10972. 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
  10973. {
  10974. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  10975. goto end;
  10976. }
  10977. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  10978. {
  10979. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  10980. goto end;
  10981. }
  10982. }
  10983. } // END FOR CCS_QUANTITY
  10984. for (int index = 0; index < GB_QUANTITY; index++)
  10985. {
  10986. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ReservationId)
  10987. {
  10988. 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'))
  10989. {
  10990. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  10991. goto end;
  10992. }
  10993. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  10994. {
  10995. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  10996. goto end;
  10997. }
  10998. 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
  10999. {
  11000. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11001. goto end;
  11002. }
  11003. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11004. {
  11005. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11006. goto end;
  11007. }
  11008. }
  11009. } // END FOR GB_QUANTITY
  11010. for (int index = 0; index < AC_QUANTITY; index++)
  11011. {
  11012. if(reservationIdInt != ShmSysConfigAndInfo->SysInfo.AcChargingData[index].ReservationId)
  11013. {
  11014. 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'))
  11015. {
  11016. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Unavailable]);
  11017. goto end;
  11018. }
  11019. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING) //S_PRECHARGE
  11020. {
  11021. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11022. goto end;
  11023. }
  11024. 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
  11025. {
  11026. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Faulted]);
  11027. goto end;
  11028. }
  11029. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) //S_IDLE
  11030. {
  11031. 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))
  11032. {
  11033. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Occupied]);
  11034. goto end;
  11035. }
  11036. }
  11037. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_IDLE) //S_IDLE
  11038. {
  11039. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11040. goto end;
  11041. }
  11042. }
  11043. }// END FOR AC_QUANTITY
  11044. //The connectorId is 0
  11045. ShmOCPP20Data->CsMsg.bits[0].ReserveNowReq = ON;
  11046. strcpy((char*)ShmOCPP20Data->ReserveNow[0].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]);
  11047. strcpy((char *)ShmOCPP20Data->ReserveNow[0].guid, uuid);
  11048. result = TRUE;
  11049. return result;
  11050. }
  11051. else
  11052. {
  11053. strcpy((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status, ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Rejected]);
  11054. }
  11055. if(strcmp((char*)ShmOCPP20Data->ReserveNow[connectorIdInt-1].Response_status,ReservationStatusEnumTypeStr[ReserveNowStatusEnumType_Accepted]) == 0)
  11056. {
  11057. strcpy((char *)ShmOCPP20Data->ReserveNow[connectorIdInt-1].guid, uuid);
  11058. result = TRUE;
  11059. return result;
  11060. }
  11061. end:
  11062. sendReserveNowConfirmation(uuid, (connectorIdInt==0?connectorIdInt:connectorIdInt-1));
  11063. return result;
  11064. }
  11065. int handleResetRequest(char *uuid, char *payload)
  11066. {
  11067. mtrace();
  11068. int result = FAIL;
  11069. json_object *Reset = json_object_new_object();
  11070. DEBUG_INFO("handleResetRequest...\n");
  11071. Reset = json_tokener_parse(payload);
  11072. if(!is_error(Reset))
  11073. {
  11074. // Required data
  11075. if(json_object_object_get(Reset, "type") != NULL)
  11076. {
  11077. sprintf((char*)ShmOCPP20Data->Reset.type, "%s", json_object_get_string(json_object_object_get(Reset, "type")));
  11078. }
  11079. if(json_object_object_get(Reset, "evseId") != NULL)
  11080. {
  11081. ShmOCPP20Data->Reset.evseId = json_object_get_int(json_object_object_get(Reset, "evseId"));
  11082. }
  11083. }
  11084. json_object_put(Reset);
  11085. if((strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_Immediate])==0) || (strcmp((char*)ShmOCPP20Data->Reset.type, ResetEnumTypeStr[ResetEnumType_OnIdle])==0))
  11086. {
  11087. ShmOCPP20Data->MsMsg.bits.ResetReq = ON;
  11088. strcpy((char *)ShmOCPP20Data->Reset.guid, uuid);
  11089. result = TRUE;
  11090. return result;
  11091. }
  11092. else
  11093. {
  11094. strcpy((char*)ShmOCPP20Data->Reset.Response_status, ResetStatusEnumTypeStr[ResetStatusEnumType_Rejected]);
  11095. goto errorend;
  11096. }
  11097. errorend:
  11098. sendResetConfirmation(uuid);
  11099. return result;
  11100. }
  11101. int handleSendLocalListRequest(char *uuid, char *payload)
  11102. {
  11103. mtrace();
  11104. int result = FAIL;
  11105. char updateTypestr[15]={0};
  11106. int checkState_Faulted = FALSE;
  11107. json_object *SendLocalList;
  11108. DEBUG_INFO("handleSendLocalListRequest...\n");
  11109. if(strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[LocalAuthListCtrlr_Enabled].variableAttribute[0].value, "FALSE") == 0)
  11110. {
  11111. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11112. goto end;
  11113. }
  11114. SendLocalList = json_tokener_parse(payload);
  11115. if(!is_error(SendLocalList))
  11116. {
  11117. memset(&ShmOCPP20Data->SendLocalList, 0x00, sizeof(struct SendLocalList_20));
  11118. // Required data
  11119. if(json_object_object_get(SendLocalList, "versionNumber") != NULL)
  11120. {
  11121. ShmOCPP20Data->SendLocalList.versionNumber = json_object_get_int(json_object_object_get(SendLocalList, "versionNumber"));
  11122. }
  11123. if(json_object_object_get(SendLocalList, "updateType") != NULL)
  11124. sprintf((char*)ShmOCPP20Data->SendLocalList.updateType, "%s", json_object_get_string(json_object_object_get(SendLocalList, "updateType")));
  11125. // Optional data
  11126. if(json_object_object_get(SendLocalList, "localAuthorizationList") != NULL)
  11127. {
  11128. for(int idx=0;idx<json_object_array_length(json_object_object_get(SendLocalList, "localAuthorizationList"));idx++)
  11129. {
  11130. // Required data
  11131. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idToken") != NULL)
  11132. {
  11133. 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")));
  11134. 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")));
  11135. }
  11136. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo") != NULL)
  11137. {
  11138. 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")));
  11139. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "cacheExpiryDateTime") != NULL)
  11140. 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")));
  11141. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "chargingPriority") != NULL)
  11142. 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"));
  11143. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SendLocalList, "localAuthorizationList"), idx), "idTagInfo"), "groupIdToken") != NULL)
  11144. {
  11145. 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")));
  11146. 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")));
  11147. }
  11148. }
  11149. }
  11150. }
  11151. }
  11152. json_object_put(SendLocalList);
  11153. //check Charge Point state
  11154. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  11155. {
  11156. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11157. {
  11158. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11159. }
  11160. }
  11161. for (int index = 0; index < CCS_QUANTITY; index++)
  11162. {
  11163. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11164. {
  11165. checkState_Faulted = TRUE; //OCPP Status
  11166. }
  11167. }
  11168. for (int index = 0; index < GB_QUANTITY; index++)
  11169. {
  11170. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11171. {
  11172. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11173. }
  11174. }
  11175. for (int index = 0; index < AC_QUANTITY; index++)
  11176. {
  11177. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT) //S_FAULT ---> Faulted
  11178. {
  11179. checkState_Faulted = TRUE; //OCPP Status: Faulted
  11180. }
  11181. }
  11182. if(checkState_Faulted == TRUE)
  11183. {
  11184. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11185. goto end;
  11186. }
  11187. // Check update type
  11188. if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Full]) == 0)
  11189. {
  11190. //Local list full update
  11191. DEBUG_INFO("Local list full update.\n");
  11192. DB_getListVerion();
  11193. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11194. {
  11195. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11196. goto end;
  11197. }
  11198. DB_cleanLocalList();
  11199. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11200. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11201. }
  11202. else if(strcmp(updateTypestr, UpdateEnumTypeStr[UpdateEnumType_Differential]) == 0)
  11203. {
  11204. //Local list different update
  11205. DEBUG_INFO("Local list different update.\n");
  11206. DB_getListVerion();
  11207. if(ShmOCPP20Data->SendLocalList.versionNumber < localversion )//if(listVersionInt <= localversion ) for OCTT Case ---remove temporally
  11208. {
  11209. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_VersionMismatch]);
  11210. goto end;
  11211. }
  11212. for(int idx=0;idx<ARRAY_SIZE(ShmOCPP20Data->SendLocalList.localAuthorizationList);idx++)
  11213. DB_addLocalList(ShmOCPP20Data->SendLocalList.versionNumber, &ShmOCPP20Data->SendLocalList.localAuthorizationList[idx]);
  11214. }
  11215. else
  11216. {
  11217. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Failed]);
  11218. goto end;
  11219. }
  11220. strcpy((char*)ShmOCPP20Data->SendLocalList.Response_status, UpdateStatusEnumTypeStr[UpdateStatusEnumType_Accepted]);
  11221. end:
  11222. sendSendLocalListConfirmation(uuid);
  11223. return result;
  11224. }
  11225. int handleSetChargingProfileRequest(char *uuid, char *payload)
  11226. {
  11227. mtrace();
  11228. int result = FAIL;
  11229. int8_t gun_index = -1;
  11230. uint8_t isPeriodOverMax = FALSE;
  11231. uint8_t isProfileOverMax = FALSE;
  11232. uint8_t isConnectorMismatch = FALSE;
  11233. uint8_t existProfileQuantity = 0;
  11234. uint8_t filename[128]={0};
  11235. uint8_t word[2048]={0};
  11236. FILE *filePtr;
  11237. json_object *SetChargingProfile;
  11238. DEBUG_INFO("handleSetChargingProfileRequest...\n");
  11239. SetChargingProfile = json_tokener_parse(payload);
  11240. if(!is_error(SetChargingProfile))
  11241. {
  11242. // Required data
  11243. if(json_object_object_get(SetChargingProfile, "evseId") != NULL)
  11244. {
  11245. gun_index = json_object_get_int(json_object_object_get(SetChargingProfile, "evseId"));
  11246. }
  11247. if(json_object_object_get(SetChargingProfile, "chargingProfile") != NULL)
  11248. {
  11249. // Check periods is over max configuration
  11250. if(json_object_array_length(json_object_object_get(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingSchedule"), "chargingSchedulePeriod")) > 10)
  11251. {
  11252. isPeriodOverMax = TRUE;
  11253. }
  11254. // Check periods is over max configuration
  11255. if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationMaxProfile]) != NULL)
  11256. {
  11257. if(gun_index == 0)
  11258. {
  11259. sprintf((char*)filename, ChargePointMaxProfile_JSON);
  11260. filePtr = fopen((char*)filename, "r");
  11261. if (!filePtr)
  11262. {
  11263. DEBUG_INFO("%s not exist, create it.\n", ChargePointMaxProfile_JSON);
  11264. filePtr = fopen((char*)filename, "w+");
  11265. }
  11266. else
  11267. {
  11268. //Check Charging Profile Count
  11269. while(fscanf(filePtr, "%s", word) != EOF)
  11270. {
  11271. //DEBUG_INFO("word=%s\n",word);
  11272. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11273. {
  11274. existProfileQuantity += 1;
  11275. }
  11276. }
  11277. }
  11278. fclose(filePtr);
  11279. }
  11280. else
  11281. isConnectorMismatch = TRUE;
  11282. }
  11283. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxDefaultProfile]) != NULL)
  11284. {
  11285. if(gun_index < 5)
  11286. sprintf((char*)filename, "/Storage/OCPP/TxDefaultProfile_%d_OCPP20.json", gun_index);
  11287. else
  11288. isConnectorMismatch = TRUE;
  11289. if(!isConnectorMismatch)
  11290. {
  11291. filePtr = fopen((char*)filename, "r");
  11292. if (!filePtr)
  11293. {
  11294. DEBUG_INFO("%s not exist, create it.\n", filename);
  11295. filePtr = fopen((char*)filename, "w+");
  11296. }
  11297. else
  11298. {
  11299. //Check Charging Profile Count
  11300. while(fscanf(filePtr, "%s", word) != EOF)
  11301. {
  11302. //DEBUG_INFO("word=%s\n",word);
  11303. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11304. {
  11305. existProfileQuantity += 1;
  11306. }
  11307. }
  11308. }
  11309. fclose(filePtr);
  11310. }
  11311. }
  11312. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_TxProfile]) != NULL)
  11313. {
  11314. if(gun_index>0)
  11315. sprintf((char*)filename, "/Storage/OCPP/TxProfile_%d_OCPP20.json", gun_index);
  11316. else
  11317. isConnectorMismatch = TRUE;
  11318. if(!isConnectorMismatch)
  11319. {
  11320. filePtr = fopen((char*)filename, "r");
  11321. if (!filePtr)
  11322. {
  11323. DEBUG_INFO("%s not exist, create it.\n", filename);
  11324. filePtr = fopen((char*)filename, "w+");
  11325. }
  11326. else
  11327. {
  11328. //Check Charging Profile Count
  11329. while(fscanf(filePtr, "%s", word) != EOF)
  11330. {
  11331. //DEBUG_INFO("word=%s\n",word);
  11332. if(strstr((char*)word, "chargingProfileId")!= NULL)
  11333. {
  11334. existProfileQuantity += 1;
  11335. }
  11336. }
  11337. }
  11338. fclose(filePtr);
  11339. }
  11340. }
  11341. else if(strstr(json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "chargingProfile"), "chargingProfilePurpose")), ChargingProfilePurposeEnumTypeStr[ChargingProfilePurposeEnumType_ChargingStationExternalConstraints]) != NULL)
  11342. {
  11343. }
  11344. else
  11345. {
  11346. }
  11347. if(existProfileQuantity > 3)
  11348. isProfileOverMax = TRUE;
  11349. }
  11350. // Profile replace or add info
  11351. if((gun_index > -1) && !isPeriodOverMax && !isProfileOverMax && !isConnectorMismatch)
  11352. {
  11353. FILE *infile;
  11354. FILE *outfile;
  11355. char tmpProfileName[32];
  11356. char rmFileCmd[128];
  11357. char tempchargingProfilePurposeStr[30]={0};
  11358. int tempconnectorIdInt=0, tempchargingProfileIdInt=0, tempstackLevelInt=0;
  11359. sprintf((char*)tmpProfileName, "/Storage/OCPP/tmpProfile");
  11360. infile = fopen ((char*)filename, "r");
  11361. outfile = fopen ((char*)tmpProfileName, "w");
  11362. int d = fgetc(infile);
  11363. rewind(infile);
  11364. if(d == EOF)
  11365. {
  11366. // Profile is empty
  11367. fprintf(outfile,"%s\n", payload);
  11368. fclose(infile);
  11369. fclose(outfile);
  11370. sprintf(rmFileCmd,"rm -f %s",filename);
  11371. system(rmFileCmd);
  11372. rename((char*)tmpProfileName, (char*)filename);
  11373. }
  11374. else
  11375. {
  11376. // Profile is not empty
  11377. char buf[2048]={0};
  11378. int ChargingProfileAdded = FALSE;
  11379. while (fgets(buf, sizeof(buf), infile) != NULL)
  11380. {
  11381. buf[strlen(buf) - 1] = '\0'; // eat the newline fgets() stores
  11382. json_object *tmpChargingProfile;
  11383. tmpChargingProfile = json_tokener_parse(buf);
  11384. if(!is_error(tmpChargingProfile))
  11385. {
  11386. if(json_object_object_get(tmpChargingProfile, "evseId") != NULL)
  11387. {
  11388. tempconnectorIdInt = json_object_get_int(json_object_object_get(tmpChargingProfile, "evseId") );
  11389. }
  11390. if(json_object_object_get(tmpChargingProfile, "csChargingProfiles") != NULL)
  11391. {
  11392. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId") != NULL)
  11393. {
  11394. tempchargingProfileIdInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfileId"));
  11395. }
  11396. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel") != NULL)
  11397. {
  11398. tempstackLevelInt = json_object_get_int(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "stackLevel"));
  11399. }
  11400. if(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose") != NULL)
  11401. {
  11402. strcpy(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(tmpChargingProfile, "csChargingProfiles"), "chargingProfilePurpose")));
  11403. }
  11404. }
  11405. }
  11406. json_object_put(tmpChargingProfile);
  11407. if((tempconnectorIdInt == gun_index) &&
  11408. (tempchargingProfileIdInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId"))))
  11409. {
  11410. if((tempstackLevelInt == json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel"))) &&
  11411. (strcmp(tempchargingProfilePurposeStr, json_object_get_string(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfilePurpose"))) == 0))
  11412. {
  11413. //DEBUG_INFO("update set chargingProfile to file -0\n");
  11414. if(ChargingProfileAdded == FALSE)
  11415. {
  11416. fprintf(outfile,"%s\n",payload);
  11417. ChargingProfileAdded = TRUE;
  11418. }
  11419. }
  11420. else
  11421. {
  11422. if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11423. {
  11424. if(ChargingProfileAdded == FALSE)
  11425. {
  11426. fprintf(outfile,"%s\n",buf);
  11427. fprintf(outfile,"%s\n",payload);
  11428. ChargingProfileAdded = TRUE;
  11429. }
  11430. else
  11431. {
  11432. fprintf(outfile,"%s\n",buf);
  11433. }
  11434. }
  11435. else
  11436. {
  11437. if(ChargingProfileAdded == FALSE)
  11438. {
  11439. fprintf(outfile,"%s\n",buf);
  11440. fprintf(outfile,"%s\n",payload);
  11441. ChargingProfileAdded = TRUE;
  11442. }
  11443. else
  11444. {
  11445. fprintf(outfile,"%s\n",buf);
  11446. }
  11447. }
  11448. }
  11449. }
  11450. else
  11451. {
  11452. if(tempchargingProfileIdInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "chargingProfileId")))
  11453. {
  11454. if(ChargingProfileAdded == FALSE)
  11455. {
  11456. fprintf(outfile,"%s\n",buf);
  11457. fprintf(outfile,"%s\n",payload);
  11458. ChargingProfileAdded = TRUE;
  11459. }
  11460. else
  11461. {
  11462. fprintf(outfile,"%s\n",buf);
  11463. }
  11464. }
  11465. else if(tempstackLevelInt < json_object_get_int(json_object_object_get(json_object_object_get(SetChargingProfile, "csChargingProfiles"), "stackLevel")))
  11466. {
  11467. if(ChargingProfileAdded == FALSE)
  11468. {
  11469. fprintf(outfile,"%s\n",buf);
  11470. fprintf(outfile,"%s\n",payload);
  11471. ChargingProfileAdded = TRUE;
  11472. }
  11473. else
  11474. {
  11475. fprintf(outfile,"%s\n",buf);
  11476. }
  11477. }
  11478. else
  11479. {
  11480. if(ChargingProfileAdded == FALSE)
  11481. {
  11482. fprintf(outfile,"%s\n",buf);
  11483. fprintf(outfile,"%s\n",payload);
  11484. ChargingProfileAdded = TRUE;
  11485. }
  11486. else
  11487. {
  11488. fprintf(outfile,"%s\n",buf);
  11489. }
  11490. }
  11491. }
  11492. } // end of while loop
  11493. fclose(infile);
  11494. fclose(outfile);
  11495. sprintf(rmFileCmd,"rm -f %s",filename);
  11496. system(rmFileCmd);
  11497. rename((char*)tmpProfileName, (char*)filename);
  11498. }
  11499. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted] );
  11500. result = PASS;
  11501. }
  11502. else
  11503. {
  11504. if(gun_index == -1)
  11505. DEBUG_WARN("Connector id is wrong.\n");
  11506. if(isConnectorMismatch)
  11507. DEBUG_WARN("Connector id is mismatch.\n");
  11508. if(isPeriodOverMax)
  11509. DEBUG_WARN("Profile periods quantity is over spec.\n");
  11510. if(isProfileOverMax)
  11511. DEBUG_WARN("Profile quantity is over spec.\n");
  11512. sprintf((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, "%s", ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Rejected] );
  11513. }
  11514. }
  11515. json_object_put(SetChargingProfile);
  11516. if(strcmp((char*)ShmOCPP20Data->SetChargingProfile[(gun_index==0?gun_index:gun_index-1)].Response_status, ChargingProfileStatusEnumTypeStr[ChargingProfileStatusEnumType_Accepted]) == 0)
  11517. {
  11518. if(gun_index == 0)
  11519. {
  11520. for(uint8_t idx=0;idx<gunTotalNumber;idx++)
  11521. {
  11522. checkCompositeSchedule((idx+1), 86400, &ShmOCPP20Data->SmartChargingProfile[idx]);
  11523. }
  11524. }
  11525. else
  11526. checkCompositeSchedule(gun_index, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index-1]);
  11527. }
  11528. sendSetChargingProfileConfirmation(uuid, (gun_index==0?gun_index:gun_index-1));
  11529. return result;
  11530. }
  11531. int handleSetDisplayMessageRequest(char *uuid, char *payload)
  11532. {
  11533. mtrace();
  11534. int result = FAIL;
  11535. json_object *SetDisplayMessage;
  11536. DEBUG_INFO("handleSetDisplayMessageRequest...\n");
  11537. SetDisplayMessage = json_tokener_parse(payload);
  11538. if(!is_error(SetDisplayMessage))
  11539. {
  11540. memset(&ShmOCPP20Data->SetDisplayMessage, 0, sizeof(struct SetDisplayMessage_20));
  11541. memcpy(&ShmOCPP20Data->SetDisplayMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetDisplayMessage.guid));
  11542. // Required data
  11543. if(json_object_object_get(SetDisplayMessage, "message") != NULL)
  11544. {
  11545. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id") != NULL)
  11546. ShmOCPP20Data->SetDisplayMessage.message.id = json_object_get_int(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "id"));
  11547. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority") != NULL)
  11548. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.priority, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "priority")));
  11549. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state") != NULL)
  11550. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.state, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "state")));
  11551. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime") != NULL)
  11552. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.startDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "startDateTime")));
  11553. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime") != NULL)
  11554. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.endDateTime, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "endDateTime")));
  11555. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId") != NULL)
  11556. sprintf((char*)ShmOCPP20Data->SetDisplayMessage.message.transactionId, "%s",json_object_get_string(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "transactionId")));
  11557. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message") != NULL)
  11558. {
  11559. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "format") != NULL)
  11560. 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")));
  11561. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "language") != NULL)
  11562. 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")));
  11563. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "message"), "content") != NULL)
  11564. 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")));
  11565. }
  11566. if(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display") != NULL)
  11567. {
  11568. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "name") != NULL)
  11569. 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")));
  11570. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "instance") != NULL)
  11571. 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")));
  11572. if(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse") != NULL)
  11573. {
  11574. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "id") != NULL)
  11575. 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"));
  11576. if(json_object_object_get(json_object_object_get(json_object_object_get(json_object_object_get(SetDisplayMessage, "message"), "display"), "evse"), "connectorId") != NULL)
  11577. 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"));
  11578. }
  11579. }
  11580. }
  11581. }
  11582. json_object_put(SetDisplayMessage);
  11583. /*
  11584. * TODO:
  11585. * 1. Configure display message and response
  11586. */
  11587. strcpy((char*)ShmOCPP20Data->SetDisplayMessage.Response_status, DisplayMessageStatusEnumTypeStr[DisplayMessageStatusEnumType_Accepted]);
  11588. sendSetMonitoringBaseConfirmation(uuid);
  11589. return result;
  11590. }
  11591. int handleSetMonitoringBaseRequest(char *uuid, char *payload)
  11592. {
  11593. mtrace();
  11594. int result = FAIL;
  11595. json_object *SetMonitoringBase;
  11596. DEBUG_INFO("handleSetMonitoringBaseRequest...\n");
  11597. SetMonitoringBase = json_tokener_parse(payload);
  11598. if(!is_error(SetMonitoringBase))
  11599. {
  11600. memset(&ShmOCPP20Data->SetMonitoringBase, 0, sizeof(struct SetMonitoringBase_20));
  11601. memcpy(&ShmOCPP20Data->SetMonitoringBase.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringBase.guid));
  11602. // Required data
  11603. if(json_object_object_get(SetMonitoringBase, "monitoringBase") != NULL)
  11604. sprintf((char*)ShmOCPP20Data->SetMonitoringBase.monitoringBase, "%s",json_object_get_string(json_object_object_get(SetMonitoringBase, "monitoringBase")));
  11605. }
  11606. json_object_put(SetMonitoringBase);
  11607. /*
  11608. * TODO:
  11609. * 1. Configure monitor base and response
  11610. */
  11611. strcpy((char*)ShmOCPP20Data->SetMonitoringBase.Response_status, GenericDeviceModelStatusEnumTypeStr[GenericDeviceModelStatusEnumType_Accepted]);
  11612. sendSetMonitoringBaseConfirmation(uuid);
  11613. return result;
  11614. }
  11615. int handleSetMonitoringLevelRequest(char *uuid, char *payload)
  11616. {
  11617. mtrace();
  11618. int result = FAIL;
  11619. json_object *SetMonitoringLevel;
  11620. DEBUG_INFO("handleSetMonitoringLevelRequest...\n");
  11621. SetMonitoringLevel = json_tokener_parse(payload);
  11622. if(!is_error(SetMonitoringLevel))
  11623. {
  11624. memset(&ShmOCPP20Data->SetMonitoringLevel, 0, sizeof(struct SetMonitoringLevel_20));
  11625. memcpy(&ShmOCPP20Data->SetMonitoringLevel.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetMonitoringLevel.guid));
  11626. // Required data
  11627. if(json_object_object_get(SetMonitoringLevel, "severity") != NULL)
  11628. ShmOCPP20Data->SetMonitoringLevel.severity = json_object_get_int(json_object_object_get(SetMonitoringLevel, "severity"));
  11629. }
  11630. json_object_put(SetMonitoringLevel);
  11631. /*
  11632. * TODO:
  11633. * Configure monitor status and response
  11634. */
  11635. strcpy((char*)ShmOCPP20Data->SetMonitoringLevel.Response_status, GenericStatusEnumTypeStr[GenericStatusEnumType_Accepted]);
  11636. sendSetMonitoringLevelConfirmation(uuid);
  11637. return result;
  11638. }
  11639. int handleSetNetworkProfileRequest(char *uuid, char *payload)
  11640. {
  11641. mtrace();
  11642. int result = FAIL;
  11643. json_object *SetNetworkProfile;
  11644. DEBUG_INFO("handleSetNetworkProfileRequest...\n");
  11645. SetNetworkProfile = json_tokener_parse(payload);
  11646. if(!is_error(SetNetworkProfile))
  11647. {
  11648. memset(&ShmOCPP20Data->SetNetworkProfile, 0, sizeof(struct SetNetworkProfile_20));
  11649. memcpy(&ShmOCPP20Data->SetNetworkProfile.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.guid));
  11650. // Required data
  11651. if(json_object_object_get(SetNetworkProfile, "configurationSlot") != NULL)
  11652. ShmOCPP20Data->SetNetworkProfile.configurationSlot = json_object_get_int(json_object_object_get(SetNetworkProfile, "configurationSlot"));
  11653. if(json_object_object_get(SetNetworkProfile, "connectionData") != NULL)
  11654. {
  11655. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion") != NULL)
  11656. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppVersion")));
  11657. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport") != NULL)
  11658. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppTransport")));
  11659. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl") != NULL)
  11660. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppCsmsUrl, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppCsmsUrl")));
  11661. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout") != NULL)
  11662. ShmOCPP20Data->SetNetworkProfile.connectionData.messageTimeout = json_object_get_int(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "messageTimeout"));
  11663. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface") != NULL)
  11664. sprintf((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppInterface, "%s", json_object_get_string(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "ocppInterface")));
  11665. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn") != NULL)
  11666. {
  11667. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "server") != NULL)
  11668. 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")));
  11669. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "user") != NULL)
  11670. 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")));
  11671. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "group") != NULL)
  11672. 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")));
  11673. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "password") != NULL)
  11674. 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")));
  11675. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "key") != NULL)
  11676. 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")));
  11677. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "vpn"), "type") != NULL)
  11678. 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")));
  11679. }
  11680. if(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn") != NULL)
  11681. {
  11682. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apn") != NULL)
  11683. {
  11684. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn));
  11685. 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")));
  11686. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apn);
  11687. }
  11688. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnUserName") != NULL)
  11689. {
  11690. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName));
  11691. 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")));
  11692. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnUserName);
  11693. }
  11694. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnPassword") != NULL)
  11695. {
  11696. memset(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword, 0x00, ARRAY_SIZE(ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword));
  11697. 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")));
  11698. strcpy((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd, (char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnPassword);
  11699. }
  11700. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "simPin") != NULL)
  11701. 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"));
  11702. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "preferredNetwork") != NULL)
  11703. 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")));
  11704. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "useOnlyPreferredNetwork") != NULL)
  11705. 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"));
  11706. if(json_object_object_get(json_object_object_get(json_object_object_get(SetNetworkProfile, "connectionData"), "apn"), "apnAuthentication") != NULL)
  11707. 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")));
  11708. }
  11709. }
  11710. }
  11711. json_object_put(SetNetworkProfile);
  11712. /*
  11713. * TODO:
  11714. * 1. Process network configuration and response
  11715. */
  11716. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP12]) == 0)
  11717. {
  11718. }
  11719. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP15]) == 0)
  11720. {
  11721. }
  11722. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP16]) == 0)
  11723. {
  11724. }
  11725. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppVersion, OCPPVersionEnumTypeStr[OCPPVersionEnumType_OCPP20]) == 0)
  11726. {
  11727. }
  11728. else
  11729. {
  11730. }
  11731. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_JSON]) == 0)
  11732. {
  11733. }
  11734. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.ocppTransport, OCPPTransportEnumTypeStr[OCPPTransportEnumType_SOAP]) == 0)
  11735. {
  11736. }
  11737. else
  11738. {
  11739. }
  11740. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired0]) == 0)
  11741. {
  11742. }
  11743. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired1]) == 0)
  11744. {
  11745. }
  11746. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired2]) == 0)
  11747. {
  11748. }
  11749. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wired3]) == 0)
  11750. {
  11751. }
  11752. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless0]) == 0)
  11753. {
  11754. }
  11755. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless1]) == 0)
  11756. {
  11757. }
  11758. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless2]) == 0)
  11759. {
  11760. }
  11761. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, OCPPInterfaceEnumTypeStr[OCPPInterfaceEnumType_Wireless3]) == 0)
  11762. {
  11763. }
  11764. else
  11765. {
  11766. }
  11767. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IKEv2]) == 0)
  11768. {
  11769. }
  11770. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_IPSec]) == 0)
  11771. {
  11772. }
  11773. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_L2TP]) == 0)
  11774. {
  11775. }
  11776. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.vpn.type, VPNEnumTypeStr[VPNEnumType_PPTP]) == 0)
  11777. {
  11778. }
  11779. else
  11780. {
  11781. }
  11782. if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_CHAP]) == 0)
  11783. {
  11784. }
  11785. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_NONE]) == 0)
  11786. {
  11787. }
  11788. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_PAP]) == 0)
  11789. {
  11790. }
  11791. else if(strcmp((char*)ShmOCPP20Data->SetNetworkProfile.connectionData.apn.apnAuthentication, APNAuthenticationEnumTypeStr[APNAuthenticationEnumType_AUTO]) == 0)
  11792. {
  11793. }
  11794. else
  11795. {
  11796. }
  11797. strcpy((char*)ShmOCPP20Data->SetNetworkProfile.Response_status, SetNetworkProfileStatusEnumTypeStr[SetNetworkProfileStatusEnumType_Accepted]);
  11798. sendSetNetworkProfileConfirmation(uuid);
  11799. return result;
  11800. }
  11801. int handleSetVariableMonitoringRequest(char *uuid, char *payload)
  11802. {
  11803. mtrace();
  11804. int result = FAIL;
  11805. json_object *SetVariableMonitoring;
  11806. DEBUG_INFO("handleSetVariableMonitoringRequest...\n");
  11807. SetVariableMonitoring = json_tokener_parse(payload);
  11808. if(!is_error(SetVariableMonitoring))
  11809. {
  11810. memset(&ShmOCPP20Data->SetVariableMonitoring, 0, sizeof(struct SetVariableMonitoring_20));
  11811. memcpy(&ShmOCPP20Data->SetVariableMonitoring.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariableMonitoring.guid));
  11812. // Required data
  11813. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariableMonitoring, "setMonitoringData"));idx++)
  11814. {
  11815. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "id") != NULL)
  11816. {
  11817. 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"));
  11818. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].id = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].id;
  11819. }
  11820. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "value") != NULL)
  11821. {
  11822. 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"));
  11823. /*
  11824. * TODO:
  11825. * 1. Check monitor value status
  11826. */
  11827. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].status, MonitorEnumTypeStr[MonitorEnumType_Delta]);
  11828. }
  11829. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "type") != NULL)
  11830. {
  11831. 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")));
  11832. strcpy((char*)ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].type, (char*)ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].type);
  11833. }
  11834. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "severity") != NULL)
  11835. {
  11836. 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"));
  11837. ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].severity = ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].severity;
  11838. }
  11839. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "setMonitoringData"), idx), "transaction") != NULL)
  11840. {
  11841. 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"));
  11842. }
  11843. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "component") != NULL)
  11844. {
  11845. 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)
  11846. {
  11847. 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")));
  11848. }
  11849. 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)
  11850. {
  11851. 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")));
  11852. }
  11853. 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)
  11854. {
  11855. 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)
  11856. {
  11857. 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"));
  11858. }
  11859. 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)
  11860. {
  11861. 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"));
  11862. }
  11863. }
  11864. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].component, &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].component, sizeof(struct ComponentType));
  11865. }
  11866. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariableMonitoring, "json_object_array_get_idx"), idx), "variable") != NULL)
  11867. {
  11868. 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)
  11869. {
  11870. 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")));
  11871. }
  11872. 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)
  11873. {
  11874. 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")));
  11875. }
  11876. memcpy(&ShmOCPP20Data->SetVariableMonitoring.Response_setMonitoringResult[idx].variable , &ShmOCPP20Data->SetVariableMonitoring.setMonitoringData[idx].variable, sizeof(struct VariableType));
  11877. }
  11878. }
  11879. }
  11880. json_object_put(SetVariableMonitoring);
  11881. return result;
  11882. }
  11883. int handleSetVariablesRequest(char *uuid, char *payload)
  11884. {
  11885. mtrace();
  11886. int result = FAIL;
  11887. json_object *SetVariables;
  11888. DEBUG_INFO("handleSetVariablesRequest...\n");
  11889. SetVariables = json_tokener_parse(payload);
  11890. if(!is_error(SetVariables))
  11891. {
  11892. memset(&ShmOCPP20Data->SetVariables, 0, sizeof(struct SetVariables_20));
  11893. memcpy(&ShmOCPP20Data->SetVariables.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->SetVariables.guid));
  11894. // Required data
  11895. for(int idx=0;idx<json_object_array_length(json_object_object_get(SetVariables, "setVariableData"));idx++)
  11896. {
  11897. if(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx) != NULL)
  11898. {
  11899. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component") != NULL)
  11900. {
  11901. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "name") != NULL)
  11902. {
  11903. 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")));
  11904. }
  11905. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "instance") != NULL)
  11906. {
  11907. 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")));
  11908. }
  11909. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "component"), "evse") != NULL)
  11910. {
  11911. 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)
  11912. {
  11913. 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"));
  11914. }
  11915. 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)
  11916. {
  11917. 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"));
  11918. }
  11919. }
  11920. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].component, &ShmOCPP20Data->SetVariables.setVariableData[idx].component, sizeof(struct ComponentType));
  11921. }
  11922. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable") != NULL)
  11923. {
  11924. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "name") != NULL)
  11925. {
  11926. 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")));
  11927. }
  11928. if(json_object_object_get(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "variable"), "instance") != NULL)
  11929. {
  11930. 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")));
  11931. }
  11932. memcpy(&ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].variable , &ShmOCPP20Data->SetVariables.setVariableData[idx].variable, sizeof(struct VariableType));
  11933. }
  11934. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeType") != NULL)
  11935. {
  11936. 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")));
  11937. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeType, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeType);
  11938. }
  11939. if(json_object_object_get(json_object_array_get_idx(json_object_object_get(SetVariables, "setVariableData"), idx), "attributeValue") != NULL)
  11940. {
  11941. 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")));
  11942. for(uint8_t idx_var=0;idx_var<CtrlrVariable_CNT;idx_var++)
  11943. {
  11944. if((strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].component.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].component.name) != NULL) &&
  11945. (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) &&
  11946. (strstr((char*)ShmOCPP20Data->SetVariables.setVariableData[idx].variable.name, (char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variable.name) != NULL) &&
  11947. (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))
  11948. {
  11949. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_Accepted]);
  11950. strcpy((char*)ShmOCPP20Data->ControllerComponentVariable[idx_var].variableAttribute[0].value, (char*)ShmOCPP20Data->SetVariables.setVariableData[idx].attributeValue);
  11951. DB_variableSaveToDb(&ShmOCPP20Data->ControllerComponentVariable[idx_var]);
  11952. }
  11953. else
  11954. {
  11955. strcpy((char*)ShmOCPP20Data->SetVariables.Response_setVariableResult[idx].attributeStatus, SetVariableStatusEnumTypeStr[SetVariableStatusEnumType_UnknownComponent]);
  11956. }
  11957. }
  11958. }
  11959. }
  11960. }
  11961. sendSetVariableConfirmation(uuid, json_object_array_length(json_object_object_get(SetVariables, "setVariableData")));
  11962. }
  11963. json_object_put(SetVariables);
  11964. return result;
  11965. }
  11966. int handleTriggerMessageRequest(char *uuid, char *payload)
  11967. {
  11968. mtrace();
  11969. int result = FAIL;
  11970. int connectorIdIsNULL = FALSE;
  11971. int connectorIdInt =0;
  11972. char requestedMessagestr[40]={0};
  11973. json_object *TriggerMessage;
  11974. DEBUG_INFO("handleTriggerMessageRequest\n");
  11975. TriggerMessage = json_tokener_parse(payload);
  11976. if(!is_error(TriggerMessage))
  11977. {
  11978. memset(&ShmOCPP20Data->TriggerMessage, 0, sizeof(struct TriggerMessage_20));
  11979. memcpy(&ShmOCPP20Data->TriggerMessage.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->TriggerMessage.guid));
  11980. // Required data
  11981. if(json_object_object_get(TriggerMessage, "requestedMessage") != NULL)
  11982. sprintf((char*)ShmOCPP20Data->TriggerMessage.requestedMessage, "%s", json_object_get_string(json_object_object_get(TriggerMessage, "requestedMessage")));
  11983. // Optional data
  11984. if(json_object_object_get(TriggerMessage, "evse") != NULL)
  11985. {
  11986. // Required data
  11987. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id") != NULL)
  11988. ShmOCPP20Data->TriggerMessage.evse.id = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "id"));
  11989. // Optional data
  11990. if(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId") != NULL)
  11991. {
  11992. ShmOCPP20Data->TriggerMessage.evse.connectorId = json_object_get_int(json_object_object_get(json_object_object_get(TriggerMessage, "evse"), "connectorId"));
  11993. connectorIdInt = ShmOCPP20Data->TriggerMessage.evse.connectorId;
  11994. }
  11995. else
  11996. connectorIdIsNULL = TRUE;
  11997. }
  11998. }
  11999. json_object_put(TriggerMessage);
  12000. if((connectorIdIsNULL == TRUE) || ((connectorIdIsNULL == FALSE) && ((connectorIdInt > 0) && (connectorIdInt <= gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/ ))) )
  12001. {
  12002. if((strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) != 0) &&
  12003. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) != 0) &&
  12004. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) != 0 ) &&
  12005. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) != 0) &&
  12006. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) != 0) &&
  12007. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignChargingStationCertificate]) != 0 ) &&
  12008. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignV2GCertificate]) != 0 ) &&
  12009. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) != 0 ) &&
  12010. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_TransactionEvent]) != 0 ) &&
  12011. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_SignCombinedCertificate]) != 0 ) &&
  12012. (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_PublishFirmwareStatusNotification]) != 0 ))
  12013. {
  12014. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_NotImplemented] );
  12015. sendTriggerMessageConfirmation(uuid);
  12016. return TRUE;
  12017. }
  12018. else
  12019. {
  12020. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Accepted] );
  12021. sendTriggerMessageConfirmation(uuid);
  12022. }
  12023. }
  12024. else if(connectorIdIsNULL == FALSE && ((connectorIdInt <= 0) || (connectorIdInt > gunTotalNumber /*(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)*/) ))
  12025. {
  12026. sprintf((char*)ShmOCPP20Data->TriggerMessage.Response_status, "%s",TriggerMessageStatusEnumTypeStr[TriggerMessageStatusEnumType_Rejected] );
  12027. sendTriggerMessageConfirmation(uuid);
  12028. return TRUE;
  12029. }
  12030. //==========================
  12031. // Trigger message
  12032. //==========================
  12033. if( strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_FirmwareStatusNotification]) == 0)
  12034. {
  12035. if((FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloading) &&
  12036. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Downloaded) &&
  12037. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Idle) &&
  12038. (FirmwareStatusNotificationStatus != FirmwareStatusEnumType_Installing) )
  12039. {
  12040. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle;
  12041. }
  12042. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusNotificationStatus]);
  12043. }
  12044. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_LogStatusNotification]) == 0 )
  12045. {
  12046. sendLogStatusNotificationRequest(UploadLogStatusEnumTypeStr[LogStatusNotificationStatus]);
  12047. }
  12048. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_BootNotification]) == 0 )
  12049. {
  12050. if(DB_updateBootType(BootReasonEnumType_Triggered))
  12051. server_sign = FALSE;
  12052. }
  12053. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_Heartbeat]) == 0 )
  12054. {
  12055. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval);
  12056. }
  12057. else if (strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_MeterValues]) == 0 )
  12058. {
  12059. if(connectorIdIsNULL == FALSE)
  12060. {
  12061. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12062. {
  12063. //sendMeterValuesRequest((connectorIdInt -1), ReadingContext_Trigger);
  12064. cpinitateMsg.bits[connectorIdInt -1].TriggerMeterValueReq = ON;
  12065. }
  12066. }
  12067. else
  12068. {
  12069. for(int idx=0;idx< gunTotalNumber;idx++)
  12070. {
  12071. //sendMeterValuesRequest(idx, ReadingContext_Trigger);
  12072. cpinitateMsg.bits[idx].TriggerMeterValueReq = ON;
  12073. }
  12074. }
  12075. }
  12076. else if(strcmp(requestedMessagestr, MessageTriggerEnumTypeStr[MessageTriggerEnumType_StatusNotification]) == 0 )
  12077. {
  12078. if(connectorIdIsNULL == FALSE)
  12079. {
  12080. if((connectorIdInt > 0) && ((connectorIdInt -1) < gunTotalNumber))
  12081. {
  12082. cpinitateMsg.bits[connectorIdInt -1].StatusNotificationReq = ON;
  12083. }
  12084. }
  12085. else
  12086. {
  12087. for(int idx=0;idx< gunTotalNumber;idx++)
  12088. cpinitateMsg.bits[idx].StatusNotificationReq = ON;
  12089. }
  12090. }
  12091. return result;
  12092. }
  12093. int handleUnlockConnectorRequest(char *uuid, char *payload)
  12094. {
  12095. mtrace();
  12096. int result = FAIL;
  12097. int connectorIdInt =0;
  12098. int tempIndex = 0;
  12099. json_object *UnlockConnector;
  12100. DEBUG_INFO("handleUnlockConnectorRequest ...\n");
  12101. UnlockConnector = json_tokener_parse(payload);
  12102. if(!is_error(UnlockConnector))
  12103. {
  12104. if(json_object_object_get(UnlockConnector, "connectorId") != NULL)
  12105. {
  12106. connectorIdInt = json_object_get_int(json_object_object_get(UnlockConnector, "connectorId"));
  12107. }
  12108. if(json_object_object_get(UnlockConnector, "evseId") != NULL)
  12109. {
  12110. ShmOCPP20Data->UnlockConnector[(connectorIdInt>0?connectorIdInt-1:0)].evseId = json_object_get_int(json_object_object_get(UnlockConnector, "evseId"));
  12111. }
  12112. }
  12113. json_object_put(UnlockConnector);
  12114. DEBUG_INFO("Unlock connectorIdInt = %d\n",connectorIdInt);
  12115. if(gunTotalNumber == 0)
  12116. {
  12117. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12118. goto end;
  12119. }
  12120. else if((connectorIdInt > gunTotalNumber/*CHAdeMO_QUANTITY+ CCS_QUANTITY + GB_QUANTITY*/) || (connectorIdInt <= 0))
  12121. {
  12122. sprintf((char*)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].Response_status, "%s", UnlockStatusEnumTypeStr[UnlockStatusEnumType_UnknownConnector] );
  12123. goto end;
  12124. }
  12125. else
  12126. {
  12127. memset(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1], 0, sizeof(struct UnlockConnector_20));
  12128. memcpy(&ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid));
  12129. //check Transaction active
  12130. if(gunType[connectorIdInt-1] == 'J')
  12131. {
  12132. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12133. {
  12134. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12135. }
  12136. else
  12137. {
  12138. tempIndex = connectorIdInt -1;
  12139. }
  12140. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  12141. {
  12142. if ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12143. {
  12144. //stop Transaction
  12145. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12146. }
  12147. }
  12148. }
  12149. else if((gunType[connectorIdInt-1] == 'U')||(gunType[connectorIdInt-1] == 'E'))
  12150. {
  12151. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12152. {
  12153. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12154. }
  12155. else
  12156. {
  12157. tempIndex = connectorIdInt -1;
  12158. }
  12159. for (int index = 0; index < CCS_QUANTITY; index++)
  12160. {
  12161. if ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12162. {
  12163. //stop Transaction
  12164. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12165. }
  12166. }
  12167. }
  12168. else if(gunType[connectorIdInt-1] == 'G')
  12169. {
  12170. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  12171. {
  12172. tempIndex = (((connectorIdInt -1)==2) ? 1: 0);
  12173. }
  12174. else
  12175. {
  12176. tempIndex = connectorIdInt -1;
  12177. }
  12178. for (int index = 0; index < GB_QUANTITY; index++)
  12179. {
  12180. if ((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex ) &&((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)||(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)))
  12181. {
  12182. //stop Transaction
  12183. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12184. }
  12185. }
  12186. }
  12187. else
  12188. {
  12189. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  12190. {
  12191. tempIndex = 2;
  12192. }
  12193. else
  12194. {
  12195. tempIndex = connectorIdInt-1;
  12196. }
  12197. for (int index = 0; index < AC_QUANTITY; index++)
  12198. {
  12199. if ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex ) && ((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) ))
  12200. {
  12201. ShmOCPP20Data->CsMsg.bits[connectorIdInt-1].UnlockConnectorReq = ON;
  12202. }
  12203. }
  12204. }
  12205. ShmOCPP20Data->UnlockConnector[connectorIdInt-1].connectorId = connectorIdInt;
  12206. strcpy((char *)ShmOCPP20Data->UnlockConnector[connectorIdInt-1].guid, uuid);
  12207. result = TRUE;
  12208. return result;
  12209. }
  12210. end:
  12211. //json_object_put(obj); --- remove temporally
  12212. sendUnlockConnectorConfirmation(uuid, connectorIdInt-1);
  12213. return result;
  12214. }
  12215. int handleUnpublishFirmwareRequest(char *uuid, char *payload)
  12216. {
  12217. mtrace();
  12218. int result = FAIL;
  12219. json_object *UnpublishFirmware;
  12220. DEBUG_INFO("handleUnpublishFirmwareRequest...\n");
  12221. UnpublishFirmware = json_tokener_parse(payload);
  12222. if(!is_error(UnpublishFirmware))
  12223. {
  12224. memset(&ShmOCPP20Data->UnpublishFirmware, 0, sizeof(struct UnpublishFirmware_20));
  12225. memcpy(&ShmOCPP20Data->UnpublishFirmware.guid, uuid, ARRAY_SIZE(ShmOCPP20Data->UnpublishFirmware.guid));
  12226. // Required data
  12227. if(json_object_object_get(UnpublishFirmware, "checksum") != NULL)
  12228. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.checksum, json_object_get_string(json_object_object_get(UnpublishFirmware, "checksum")));
  12229. }
  12230. json_object_put(UnpublishFirmware);
  12231. ShmOCPP20Data->MsMsg.bits.UnpublishFirmwareReq = ON;
  12232. /*
  12233. * TODO:
  12234. * 1. Check unpublished status
  12235. */
  12236. sprintf((char*)ShmOCPP20Data->UnpublishFirmware.Response_status, UnpublishFirmwareStatusEnumTypeStr[Unpublished_NoFirmware]);
  12237. sendUnpublishFirmwareConfirmation(uuid);
  12238. return result;
  12239. }
  12240. static char UpdateFirmwarepayloadData[512]={0};
  12241. void *UpdateFirmwareProcess(void *data)
  12242. {
  12243. pthread_detach(pthread_self());
  12244. mtrace();
  12245. int retriesInt =0, retryIntervalInt=0;
  12246. char protocol[10], user[50],password[50],host[50], path[50], ftppath[60],host1[50],path1[20];
  12247. int port=0;
  12248. char locationstr[160]={0}, retrieveDatestr[30]={0};
  12249. int isSuccess = 0;
  12250. char ftpbuf[200];
  12251. char temp[100];
  12252. char * pch;
  12253. DEBUG_INFO("handleUpdateFirmwareRequest ...\n");
  12254. json_object *UpdateFirmware;
  12255. UpdateFirmware = json_tokener_parse(UpdateFirmwarepayloadData);
  12256. if(!is_error(UpdateFirmware))
  12257. {
  12258. // Required data
  12259. if(json_object_object_get(UpdateFirmware, "location") != NULL)
  12260. sprintf((char*)locationstr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "location")));
  12261. if(json_object_object_get(UpdateFirmware, "retrieveDate") != NULL)
  12262. sprintf((char*)retrieveDatestr, "%s", json_object_get_string(json_object_object_get(UpdateFirmware, "retrieveDate")));
  12263. // Optional data
  12264. if(json_object_object_get(UpdateFirmware, "retries"))
  12265. {
  12266. retriesInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retries"));
  12267. }
  12268. if(json_object_object_get(UpdateFirmware, "retryInterval"))
  12269. {
  12270. retryIntervalInt = json_object_get_int(json_object_object_get(UpdateFirmware, "retryInterval"));
  12271. }
  12272. }
  12273. json_object_put(UpdateFirmware);
  12274. memset(ftppath, 0, ARRAY_SIZE(ftppath));
  12275. memset(path, 0, ARRAY_SIZE(path));
  12276. system("rm -f /mnt/*");
  12277. if(strncmp(locationstr,"http", 4) == 0)
  12278. {
  12279. sscanf(locationstr,"%[^:]:%*2[/]%[^/]/%199[^\n]", protocol, host, path);
  12280. //sscanf(locationstr,"%[^:]:%*2[/]%[^:]:%[^@]@%[^/]%199[^\n]",
  12281. // protocol, user, password, host, path);
  12282. sprintf(ftppath,"/%s", path);
  12283. DEBUG_INFO("locationstr: %s\n", locationstr);
  12284. DEBUG_INFO("protocol: %s\n",protocol);
  12285. DEBUG_INFO("host: %s\n",host);
  12286. DEBUG_INFO("path: %s\n",path);
  12287. DEBUG_INFO("ftppath: %s\n",ftppath);
  12288. int ftppathlen=strlen(ftppath);
  12289. int i=1;
  12290. char filenametemp[50];
  12291. while(i < ftppathlen)
  12292. {
  12293. int len=ftppathlen-i;
  12294. if(ftppath[len]== 47) // '/' ascll code: 47
  12295. {
  12296. DEBUG_INFO("compare '/' all right\n");
  12297. break;
  12298. }
  12299. i=i+1;
  12300. }
  12301. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12302. strncpy(filenametemp, ftppath+(ftppathlen-i+1), i+1);
  12303. filenametemp[i+1] = 0;
  12304. do
  12305. {
  12306. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12307. sleep(3);
  12308. isSuccess = httpDownLoadFile(host, ftppath, filenametemp, locationstr);
  12309. if(!isSuccess)
  12310. {
  12311. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12312. sleep(retryIntervalInt);
  12313. }
  12314. else
  12315. {
  12316. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12317. }
  12318. }while((isSuccess == 0)&&(retriesInt > 0 && retriesInt --));
  12319. }
  12320. else if(strncmp(locationstr,"ftp", 3) == 0) // ftp
  12321. {
  12322. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12323. memset(temp, 0, ARRAY_SIZE(temp));
  12324. //DEBUG_INFO("locationstr=%s\n",locationstr);
  12325. strcpy(ftpbuf, locationstr/*"ftp://ipc_ui:pht2016@ftp.phihong.com.tw/DC/log/DemoDC1_2018-07-13_185011_PSULog.zip"*/ );
  12326. int ftppathlen=strlen(ftpbuf);
  12327. int i=1;
  12328. char filenametemp[50];
  12329. while(i < ftppathlen)
  12330. {
  12331. int len=ftppathlen-i;
  12332. if(ftpbuf[len]== 47) // '/' ascll code: 47
  12333. {
  12334. DEBUG_INFO(" compare '/' all right\n");
  12335. break;
  12336. }
  12337. i=i+1;
  12338. }
  12339. memset(filenametemp, 0, ARRAY_SIZE(filenametemp));
  12340. strncpy(filenametemp, ftpbuf+(ftppathlen-i+1), i+1);
  12341. filenametemp[i+1] = 0;
  12342. strncpy(temp, ftpbuf, ftppathlen-i+1);
  12343. pch=strchr(temp,'@');
  12344. if(pch==NULL)
  12345. {
  12346. sscanf(temp,"%[^:]:%*2[/]%[^:]:%i/%[a-zA-Z0-9._/-]",
  12347. protocol, host, &port, path);
  12348. strcpy(user,"anonymous");
  12349. strcpy(password,"");
  12350. }
  12351. else
  12352. {
  12353. sscanf(temp,"%[^:]:%*2[/]%[^:]:%[^@]@%[^:]:%i/%199[^\n]",
  12354. protocol, user, password, host, &port, path);
  12355. }
  12356. sscanf(host,"%[^/]%s",host1, path1);
  12357. sprintf(ftppath,"%s", path1);
  12358. //DEBUG_INFO("protocol =%s\n",protocol);
  12359. //DEBUG_INFO("user =%s\n",user);
  12360. //DEBUG_INFO("password =%s\n",password);
  12361. //DEBUG_INFO("host1 =%s\n",host1);
  12362. //DEBUG_INFO("port =%d\n",port);
  12363. //DEBUG_INFO("path1 =%s\n",path1);
  12364. //DEBUG_INFO("ftppath=%s\n",ftppath);
  12365. //ftpFile(host, user, password, port, ftppath, fname);
  12366. //download firmware pthred
  12367. if(port == 0)
  12368. {
  12369. port = 21;
  12370. }
  12371. do
  12372. {
  12373. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloading]);
  12374. sleep(3);
  12375. isSuccess = ftpDownLoadFile(host1, user, password, port, ftppath, filenametemp, locationstr);
  12376. if(!isSuccess)
  12377. {
  12378. //BulldogUtil.sleepMs(interval*1000);
  12379. DEBUG_INFO("Update firmware request and download file fail.\n");
  12380. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12381. sleep(retryIntervalInt);
  12382. }
  12383. else
  12384. {
  12385. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_Downloaded]);
  12386. }
  12387. }while((!isSuccess)&&(retriesInt > 0 && retriesInt --));
  12388. }
  12389. else
  12390. {
  12391. sendFirmwareStatusNotificationRequest(FirmwareStatusEnumTypeStr[FirmwareStatusEnumType_DownloadFailed]);
  12392. }
  12393. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareReq = ON;
  12394. pthread_exit(NULL);
  12395. }
  12396. int handleUpdateFirmwareRequest(char *uuid, char *payload)
  12397. {
  12398. mtrace();
  12399. int result = FAIL;
  12400. pthread_t t;
  12401. sendUpdateFirmwareConfirmation(uuid);
  12402. memset(UpdateFirmwarepayloadData, 0, ARRAY_SIZE(UpdateFirmwarepayloadData));
  12403. strcpy(UpdateFirmwarepayloadData, stringtrimspace(payload));
  12404. memset(&ShmOCPP20Data->UpdateFirmware, 0, sizeof(struct UpdateFirmware_20));
  12405. pthread_create(&t, NULL, UpdateFirmwareProcess, stringtrimspace(payload));
  12406. ////pthread_join(t, NULL); //
  12407. //pthread_detach(t);
  12408. //sendUpdateFirmwareConfirmation(uuid);
  12409. ShmOCPP20Data->MsMsg.bits.UpdateFirmwareConf = ON;
  12410. return result;
  12411. }
  12412. //==========================================
  12413. // Handle server response routine
  12414. //==========================================
  12415. void handleAuthorizeResponse(char *payload, int gun_index)
  12416. {
  12417. mtrace();
  12418. DEBUG_INFO("handleAuthorizeResponse...\n");
  12419. json_object *Authorize;
  12420. Authorize = json_tokener_parse(payload);
  12421. if(!is_error(Authorize))
  12422. {
  12423. if(json_object_object_get(Authorize, "idTokenInfo") != NULL)
  12424. {
  12425. // Required data
  12426. sprintf((char *)(char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "status")));
  12427. // Optional data
  12428. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "cacheExpiryDateTime") != NULL)
  12429. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "cacheExpiryDateTime")));
  12430. else
  12431. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime));
  12432. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "chargingPriority") != NULL)
  12433. ShmOCPP20Data->Authorize.Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "chargingPriority"));
  12434. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language1") != NULL)
  12435. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language1, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language1")));
  12436. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "evseId") != NULL)
  12437. {
  12438. for(int idx=0;idx<json_object_array_length(json_object_object_get(json_object_object_get(Authorize, "idTagInfo"), "evseId"));idx++)
  12439. {
  12440. 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));
  12441. }
  12442. }
  12443. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "language2") != NULL)
  12444. sprintf((char *)ShmOCPP20Data->Authorize.Response_idTokenInfo.language2, "%s", json_object_get_string(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "language2")));
  12445. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "groupIdToken") != NULL)
  12446. {
  12447. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  12448. 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")));
  12449. else
  12450. memset(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken, 0x00, ARRAY_SIZE(ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken));
  12451. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  12452. 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")));
  12453. }
  12454. if(json_object_object_get(json_object_object_get(Authorize,"idTagInfo"), "personalMessage") != NULL)
  12455. {
  12456. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "format") != NULL)
  12457. 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")));
  12458. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "language") != NULL)
  12459. 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")));
  12460. if(json_object_object_get(json_object_object_get(json_object_object_get(Authorize,"idTokenInfo"), "personalMessage"), "content") != NULL)
  12461. 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")));
  12462. }
  12463. }
  12464. if(json_object_object_get(Authorize, "certificateStatus") != NULL)
  12465. {
  12466. strcpy((char *)ShmOCPP20Data->Authorize.Response_certificateStatus, json_object_get_string(json_object_object_get(Authorize, "certificateStatus")));
  12467. }
  12468. }
  12469. json_object_put(Authorize);
  12470. //Update idTag information to authorization cache if supported
  12471. if((strcmp((const char *)ShmOCPP20Data->ControllerComponentVariable[AuthCacheCtrlr_Enabled].variableAttribute[0].value, "TRUE") == 0) &&
  12472. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.groupIdToken.idToken) > 0) &&
  12473. (strlen((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.cacheExpiryDateTime) >0) &&
  12474. strstr((char*)ShmOCPP20Data->Authorize.Response_idTokenInfo.status, AuthorizationStatusEnumTypeStr[AuthorizationStatusEnumType_Accepted]) != NULL)
  12475. {
  12476. DB_addLocalCache(&ShmOCPP20Data->Authorize.idToken, &ShmOCPP20Data->Authorize.Response_idTokenInfo);
  12477. }
  12478. ShmOCPP20Data->SpMsg.bits.AuthorizeReq = OFF;
  12479. ShmOCPP20Data->SpMsg.bits.AuthorizeConf = ON; // inform csu
  12480. authorizeRetryTimes = 0;
  12481. }
  12482. void handleBootNotificationResponse(char *payload, int gun_index)
  12483. {
  12484. mtrace();
  12485. char statusStr[12]={0};
  12486. char currentTimeStr[30]={0};
  12487. int intervalInt = 0;
  12488. struct tm tp;
  12489. char buf[28]={0};
  12490. char timebuf[50]={0};
  12491. DEBUG_INFO("handleBootNotificationResponse...\n");
  12492. json_object *BootNotification;
  12493. BootNotification = json_tokener_parse(payload);
  12494. if(!is_error(BootNotification))
  12495. {
  12496. // Required data
  12497. sprintf((char *)currentTimeStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"currentTime")));
  12498. intervalInt = json_object_get_int(json_object_object_get(BootNotification,"interval"));
  12499. sprintf((char *)statusStr, "%s", json_object_get_string(json_object_object_get(BootNotification,"status")));
  12500. }
  12501. json_object_put(BootNotification);
  12502. DEBUG_INFO("statusStr: %s\n", statusStr);
  12503. ShmOCPP20Data->BootNotification.Response_interval = intervalInt;
  12504. BootNotificationInterval = intervalInt;
  12505. HeartBeatWaitTime = intervalInt;
  12506. //write back to ShmOCPP20Data->BootNotification
  12507. strcpy((char *)ShmOCPP20Data->BootNotification.Response_currentTime, currentTimeStr);
  12508. strcpy((char *)ShmOCPP20Data->BootNotification.Response_status, statusStr);
  12509. if((strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Accepted]) == 0 ))
  12510. {
  12511. server_sign = TRUE;
  12512. server_pending =FALSE;
  12513. DB_updateBootType(BootReasonEnumType_PowerUp);
  12514. }
  12515. else if(strcmp(statusStr, RegistrationStatusEnumTypeStr[RegistrationStatusEnumType_Pending]) == 0)
  12516. {
  12517. server_pending = TRUE;
  12518. }
  12519. strptime((const char *)ShmOCPP20Data->BootNotification.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  12520. tp.tm_isdst = -1;
  12521. //time_t utc = mktime(&tp);
  12522. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  12523. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  12524. sprintf(timebuf,"date -s '%s'",buf);
  12525. system(timebuf);
  12526. srand(time(NULL));
  12527. clientTime.Heartbeat = time((time_t*)NULL) - (ShmOCPP20Data->BootNotification.Response_interval-((rand()%8)+3));
  12528. //==============================================
  12529. // RTC sync
  12530. //==============================================
  12531. system("/sbin/hwclock -w --systohc");
  12532. ShmOCPP20Data->OcppConnStatus = ON; ////0: disconnected, 1: connected
  12533. ShmOCPP20Data->SpMsg.bits.BootNotificationConf = ON;
  12534. }
  12535. void handleClearedChargingLimitResponse(char *payload, int gun_index)
  12536. {
  12537. mtrace();
  12538. json_object *ClearedChargingLimit;
  12539. DEBUG_INFO("handleClearedChargingLimitResponse...\n");
  12540. ClearedChargingLimit = json_tokener_parse(payload);
  12541. if(!is_error(ClearedChargingLimit))
  12542. {
  12543. // Required data
  12544. if(json_object_object_get(ClearedChargingLimit,"status") != NULL)
  12545. sprintf((char*)ShmOCPP20Data->ClearChargingProfile[gun_index].Response_status, json_object_get_string(json_object_object_get(ClearedChargingLimit,"status")));
  12546. }
  12547. json_object_put(ClearedChargingLimit);
  12548. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitReq = OFF;
  12549. ShmOCPP20Data->MsMsg.bits.ClearedChargingLimitConf = ON;
  12550. }
  12551. void handleDataTransferResponse(char *payload, int gun_index)
  12552. {
  12553. mtrace();
  12554. json_object *DataTrans;
  12555. DEBUG_INFO("handleDataTransferResponse...\n");
  12556. DataTrans = json_tokener_parse(payload);
  12557. if(!is_error(DataTrans))
  12558. {
  12559. // Required data
  12560. if(json_object_object_get(DataTrans,"status") != NULL)
  12561. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_status, json_object_get_string(json_object_object_get(DataTrans,"status")));
  12562. // Optional data
  12563. if(json_object_object_get(DataTrans,"data") != NULL)
  12564. sprintf((char*)ShmOCPP20Data->DataTransfer[gun_index].Response_data, json_object_get_string(json_object_object_get(DataTrans,"data")));
  12565. }
  12566. json_object_put(DataTrans);
  12567. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferReq = OFF;
  12568. ShmOCPP20Data->CpMsg.bits[gun_index].DataTransferConf = ON;
  12569. }
  12570. void handleFirmwareStatusNotificationResponse(char *payload, int gun_index)
  12571. {
  12572. mtrace();
  12573. DEBUG_INFO("handleFirmwareStatusNotificationResponse ...\n");
  12574. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq = OFF;
  12575. ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationConf = ON;
  12576. }
  12577. void handleGet15118EVCertificateResponse(char *payload, int gun_index)
  12578. {
  12579. mtrace();
  12580. json_object *Get15118EVCertificate;
  12581. DEBUG_INFO("handleGet15118EVCertificateResponse...\n");
  12582. Get15118EVCertificate = json_tokener_parse(payload);
  12583. if(!is_error(Get15118EVCertificate))
  12584. {
  12585. // Required data
  12586. if(json_object_object_get(Get15118EVCertificate,"status") != NULL)
  12587. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_status, json_object_get_string(json_object_object_get(Get15118EVCertificate,"status")));
  12588. // Optional data
  12589. if(json_object_object_get(Get15118EVCertificate,"exiResponse") != NULL)
  12590. sprintf((char*)ShmOCPP20Data->Get15118EVCertificate.Response_exiResponse, json_object_get_string(json_object_object_get(Get15118EVCertificate,"exiResponse")));
  12591. }
  12592. json_object_put(Get15118EVCertificate);
  12593. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateReq = OFF;
  12594. ShmOCPP20Data->SpMsg.bits.Get15118EVCertificateConf = ON;
  12595. }
  12596. void hanldeGetCertificateStatusResponse(char *payload, int gun_index)
  12597. {
  12598. mtrace();
  12599. json_object *GetCertificateStatus;
  12600. DEBUG_INFO("hanldeGetCertificateStatusResponse...\n");
  12601. GetCertificateStatus = json_tokener_parse(payload);
  12602. if(!is_error(GetCertificateStatus))
  12603. {
  12604. // Required data
  12605. if(json_object_object_get(GetCertificateStatus,"status") != NULL)
  12606. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_status, json_object_get_string(json_object_object_get(GetCertificateStatus,"status")));
  12607. // Optional data
  12608. if(json_object_object_get(GetCertificateStatus,"ocspResult") != NULL)
  12609. sprintf((char*)ShmOCPP20Data->GetCertificateStatus.Response_ocspResult, json_object_get_string(json_object_object_get(GetCertificateStatus,"ocspResult")));
  12610. }
  12611. json_object_put(GetCertificateStatus);
  12612. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusReq = OFF;
  12613. ShmOCPP20Data->SpMsg.bits.GetCertificateStatusConf = ON;
  12614. }
  12615. void handleHeartbeatResponse(char *payload, int gun_index)
  12616. {
  12617. mtrace();
  12618. struct tm tp;
  12619. char buf[28]={0};
  12620. char timebuf[128]={0};
  12621. DEBUG_INFO("handleHeartbeatResponse...\n");
  12622. json_object *Heartbeat;
  12623. Heartbeat = json_tokener_parse(payload);
  12624. if(!is_error(Heartbeat))
  12625. {
  12626. // Required data
  12627. if(json_object_object_get(Heartbeat,"currentTime") != NULL)
  12628. sprintf((char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%s", json_object_get_string(json_object_object_get(Heartbeat,"currentTime")));
  12629. }
  12630. json_object_put(Heartbeat);
  12631. if(FirstHeartBeat == OFF)
  12632. {
  12633. FirstHeartBeat = ON;
  12634. DEBUG_INFO("FirstHeartBeat \n");
  12635. }
  12636. HeartBeatWithNOResponse = 0;
  12637. clientTime.Heartbeat=time((time_t*)NULL);
  12638. strptime((const char *)ShmOCPP20Data->Heartbeat.Response_currentTime, "%Y-%m-%dT%H:%M:%S", &tp);
  12639. tp.tm_isdst = -1;
  12640. strftime(buf, 28, "%Y-%m-%d %H:%M:%S", &tp);
  12641. memset(timebuf, 0, ARRAY_SIZE(timebuf));
  12642. sprintf(timebuf,"date -s '%s'",buf);
  12643. system(timebuf);
  12644. //==============================================
  12645. // RTC sync
  12646. //==============================================
  12647. system("/sbin/hwclock -w --systohc");
  12648. }
  12649. void hanldeLogStatusNotificationResponse(char *payload, int gun_index)
  12650. {
  12651. mtrace();
  12652. DEBUG_INFO("hanldeLogStatusNotificationResponse...\n");
  12653. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationReq = OFF;
  12654. ShmOCPP20Data->SpMsg.bits.LogStatusNotificationConf = ON;
  12655. }
  12656. void handleMeterValuesResponse(char *payload, int gun_index)
  12657. {
  12658. mtrace();
  12659. DEBUG_INFO("handleMeterValuesResponse...\n");
  12660. }
  12661. void handleNotifyChargingLimitResponse(char *payload, int gun_index)
  12662. {
  12663. mtrace();
  12664. DEBUG_INFO("handleNotifyChargingLimitResponse...\n");
  12665. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  12666. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  12667. }
  12668. void hanldeNotifyCustomerInformationResponse(char *payload, int gun_index)
  12669. {
  12670. mtrace();
  12671. DEBUG_INFO("hanldeNotifyCustomerInformationResponse...\n");
  12672. }
  12673. void hanldeNotifyDisplayMessagesResponse(char *payload, int gun_index)
  12674. {
  12675. mtrace();
  12676. DEBUG_INFO("hanldeNotifyDisplayMessagesResponse...\n");
  12677. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesReq = OFF;
  12678. ShmOCPP20Data->SpMsg.bits.NotifyDisplayMessagesConf = ON;
  12679. }
  12680. void hanldeNotifyEVChargingNeedsResponse(char *payload, int gun_index)
  12681. {
  12682. mtrace();
  12683. json_object *NotifyEVChargingNeeds;
  12684. DEBUG_INFO("hanldeNotifyEVChargingNeedsResponse...\n");
  12685. NotifyEVChargingNeeds = json_tokener_parse(payload);
  12686. if(!is_error(NotifyEVChargingNeeds))
  12687. {
  12688. // Required data
  12689. if(json_object_object_get(NotifyEVChargingNeeds,"status") != NULL)
  12690. sprintf((char*)ShmOCPP20Data->NotifyEVChargingNeeds[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingNeeds,"status")));
  12691. }
  12692. json_object_put(NotifyEVChargingNeeds);
  12693. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitReq = OFF;
  12694. ShmOCPP20Data->SpMsg.bits.NotifyChargingLimitConf = ON;
  12695. }
  12696. void hanldeNotifyEVChargingScheduleResponse(char *payload, int gun_index)
  12697. {
  12698. mtrace();
  12699. json_object *NotifyEVChargingSchedule;
  12700. DEBUG_INFO("hanldeNotifyEVChargingScheduleResponse...\n");
  12701. NotifyEVChargingSchedule = json_tokener_parse(payload);
  12702. if(!is_error(NotifyEVChargingSchedule))
  12703. {
  12704. // Required data
  12705. if(json_object_object_get(NotifyEVChargingSchedule,"status") != NULL)
  12706. sprintf((char*)ShmOCPP20Data->NotifyEVChargingSchedule[gun_index].Response_status, json_object_get_string(json_object_object_get(NotifyEVChargingSchedule,"status")));
  12707. }
  12708. json_object_put(NotifyEVChargingSchedule);
  12709. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleReq = OFF;
  12710. ShmOCPP20Data->SpMsg.bits.NotifyEVChargingScheduleConf = ON;
  12711. }
  12712. void hanldeNotifyEventResponse(char *payload, int gun_index)
  12713. {
  12714. mtrace();
  12715. DEBUG_INFO("hanldeNotifyEventResponse...\n");
  12716. ShmOCPP20Data->SpMsg.bits.NotifyEventReq = OFF;
  12717. ShmOCPP20Data->SpMsg.bits.NotifyEventConf = ON;
  12718. }
  12719. void hanldeNotifyMonitoringReportResponse(char *payload, int gun_index)
  12720. {
  12721. mtrace();
  12722. DEBUG_INFO("hanldeNotifyMonitoringReportResponse...\n");
  12723. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportReq = OFF;
  12724. ShmOCPP20Data->SpMsg.bits.NotifyMonitoringReportConf = ON;
  12725. }
  12726. void hanldeNotifyReportResponse(char *payload, int gun_index)
  12727. {
  12728. mtrace();
  12729. DEBUG_INFO("hanldeNotifyReportResponse...\n");
  12730. ShmOCPP20Data->SpMsg.bits.NotifyReportReq = OFF;
  12731. ShmOCPP20Data->SpMsg.bits.NotifyReportConf = ON;
  12732. }
  12733. void hanldePublishFirmwareStatusNotificationResponse(char *payload, int gun_index)
  12734. {
  12735. mtrace();
  12736. DEBUG_INFO("hanldePublishFirmwareStatusNotificationResponse...\n");
  12737. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationReq = OFF;
  12738. ShmOCPP20Data->CsMsg.bits[gun_index].PublishFirmwareStatusNotificationConf = ON;
  12739. }
  12740. void hanldeReportChargingProfilesResponse(char *payload, int gun_index)
  12741. {
  12742. mtrace();
  12743. DEBUG_INFO("hanldeReportChargingProfilesResponse...gun_index: %d\n", gun_index);
  12744. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesReq = OFF;
  12745. ShmOCPP20Data->SpMsg.bits.ReportChargingProfilesConf = ON;
  12746. }
  12747. void hanldeReservationStatusUpdateResponse(char *payload, int gun_index)
  12748. {
  12749. mtrace();
  12750. DEBUG_INFO("hanldeReservationStatusUpdateResponse...gun_index: %d\n", gun_index);
  12751. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateReq = OFF;
  12752. ShmOCPP20Data->CpMsg.bits[gun_index].ReservationStatusUpdateConf = ON;
  12753. }
  12754. void hanldeSecurityEventNotificationResponse(char *payload, int gun_index)
  12755. {
  12756. mtrace();
  12757. DEBUG_INFO("hanldeSecurityEventNotificationResponse...\n");
  12758. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationReq = OFF;
  12759. ShmOCPP20Data->SpMsg.bits.SecurityEventNotificationConf = ON;
  12760. }
  12761. void hanldeSignCertificateResponse(char *payload, int gun_index)
  12762. {
  12763. mtrace();
  12764. json_object *SignCertificate;
  12765. DEBUG_INFO("hanldeSignCertificateResponse...\n");
  12766. SignCertificate = json_tokener_parse(payload);
  12767. if(!is_error(SignCertificate))
  12768. {
  12769. // Required data
  12770. if(json_object_object_get(SignCertificate,"status") != NULL)
  12771. sprintf((char*)ShmOCPP20Data->SignCertificate.Response_status, json_object_get_string(json_object_object_get(SignCertificate,"status")));
  12772. }
  12773. json_object_put(SignCertificate);
  12774. ShmOCPP20Data->SpMsg.bits.SignCertificateReq = OFF;
  12775. ShmOCPP20Data->SpMsg.bits.SignCertificateConf = ON;
  12776. }
  12777. void handleStatusNotificationResponse(char *payload, int gun_index)
  12778. {
  12779. mtrace();
  12780. DEBUG_INFO("handleStatusNotificationResponse...gun_index: %d\n", gun_index);
  12781. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  12782. cpinitateMsg.bits[gun_index].StatusNotificationConf = ON;
  12783. }
  12784. void hanldeTransactionEvenResponse(char *payload, int gun_index)
  12785. {
  12786. mtrace();
  12787. json_object *TransactionEven;
  12788. DEBUG_INFO("hanldeTransactionEvenResponse...\n");
  12789. TransactionEven = json_tokener_parse(payload);
  12790. if(!is_error(TransactionEven))
  12791. {
  12792. // Required data
  12793. // Optional data
  12794. if(json_object_object_get(TransactionEven,"totalCost") != NULL)
  12795. ShmOCPP20Data->TransactionEvent[gun_index].Response_totalCost = json_object_get_double(json_object_object_get(TransactionEven,"totalCost"));
  12796. if(json_object_object_get(TransactionEven,"chargingPriority") != NULL)
  12797. ShmOCPP20Data->TransactionEvent[gun_index].Response_chargingPriority = json_object_get_int(json_object_object_get(TransactionEven,"chargingPriority"));
  12798. if(json_object_object_get(TransactionEven,"idTokenInfo") != NULL)
  12799. {
  12800. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status") != NULL)
  12801. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.status, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "status")));
  12802. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime") != NULL)
  12803. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.cacheExpiryDateTime, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "cacheExpiryDateTime")));
  12804. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority") != NULL)
  12805. ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.chargingPriority = json_object_get_int(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "chargingPriority"));
  12806. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1") != NULL)
  12807. sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].Response_idTokenInfo.language1, json_object_get_string(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "language1")));
  12808. if(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken") != NULL)
  12809. {
  12810. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "idToken") != NULL)
  12811. 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")));
  12812. if(json_object_object_get(json_object_object_get(json_object_object_get(TransactionEven,"idTokenInfo"), "groupIdToken"), "type") != NULL)
  12813. 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")));
  12814. }
  12815. }
  12816. }
  12817. json_object_put(TransactionEven);
  12818. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq = OFF;
  12819. ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventConf = ON;
  12820. }
  12821. //==========================================
  12822. // Handle Error routine
  12823. //==========================================
  12824. void handleError(char *id, char *errorCode, char *errorDescription,char *payload)
  12825. {
  12826. mtrace();
  12827. #ifdef SystemLogMessage
  12828. DEBUG_INFO("errorCode: %s\n", errorCode);
  12829. DEBUG_INFO("errorDescription: %s\n", errorDescription);
  12830. DEBUG_INFO("errorDetails: %s\n", payload);
  12831. #endif
  12832. }
  12833. //===============================================
  12834. // Common routine
  12835. //===============================================
  12836. int initialConfigurationTable(void)
  12837. {
  12838. DEBUG_INFO("initialConfigurationTable...\n");
  12839. memset(&ShmOCPP20Data->ControllerComponentVariable[0], 0, ARRAY_SIZE(ShmOCPP20Data->ControllerComponentVariable));
  12840. DB_variableIsCreate();
  12841. DB_variableLoadFromDb();
  12842. return 0;
  12843. }
  12844. int TransactionMessageAttemptsGet(void)
  12845. {
  12846. return TransactionMessageAttemptsValue;
  12847. }
  12848. int FirstHeartBeatResponse(void)
  12849. {
  12850. return FirstHeartBeat;
  12851. }
  12852. int TransactionMessageRetryIntervalGet(void)
  12853. {
  12854. return TransactionMessageRetryIntervalValue;//atoi((const char *)ShmOCPP20Data->ConfigurationTable.CoreProfile[TransactionMessageRetryInterval].ItemData);
  12855. }
  12856. int ReadHttpStatus(int sock)
  12857. {
  12858. //char c;
  12859. char buff[1024]="",*ptr=buff+1;
  12860. int bytes_received, status;
  12861. DEBUG_INFO("Begin Response ..\n");
  12862. while((bytes_received = recv(sock, ptr, 1, 0))){
  12863. if(bytes_received==-1){
  12864. perror("ReadHttpStatus");
  12865. exit(1);
  12866. }
  12867. if((ptr[-1]=='\r') && (*ptr=='\n' )) break;
  12868. ptr++;
  12869. }
  12870. *ptr=0;
  12871. ptr=buff+1;
  12872. sscanf(ptr,"%*s %d ", &status);
  12873. DEBUG_INFO("%s\n",ptr);
  12874. DEBUG_INFO("status=%d\n",status);
  12875. DEBUG_INFO("End Response ..\n");
  12876. return (bytes_received>0)?status:0;
  12877. }
  12878. //the only filed that it parsed is 'Content-Length'
  12879. int ParseHeader(int sock)
  12880. {
  12881. //char c;
  12882. char buff[1024]="",*ptr=buff+4;
  12883. int bytes_received;
  12884. DEBUG_INFO("Begin HEADER ..\n");
  12885. while((bytes_received = recv(sock, ptr, 1, 0))){
  12886. if(bytes_received==-1){
  12887. perror("Parse Header");
  12888. exit(1);
  12889. }
  12890. if(
  12891. (ptr[-3]=='\r') && (ptr[-2]=='\n' ) &&
  12892. (ptr[-1]=='\r') && (*ptr=='\n' )
  12893. ) break;
  12894. ptr++;
  12895. }
  12896. *ptr=0;
  12897. ptr=buff+4;
  12898. //printf("%s",ptr);
  12899. if(bytes_received){
  12900. ptr=strstr(ptr,"Content-Length:");
  12901. if(ptr){
  12902. sscanf(ptr,"%*s %d",&bytes_received);
  12903. }else
  12904. bytes_received=-1; //unknown size
  12905. DEBUG_INFO("Content-Length: %d\n",bytes_received);
  12906. }
  12907. DEBUG_INFO("End HEADER ..\n");
  12908. return bytes_received ;
  12909. }
  12910. int httpDownLoadFile(char *location, char *path, char *filename,char *url)
  12911. {
  12912. char rmFileCmd[100]={0};
  12913. char FilePath[100]={0};
  12914. char ftpbuf[200];
  12915. int systemresult;
  12916. //DEBUG_INFO("filename=%s\n",filename);
  12917. //DEBUG_INFO("url=%s\n",url);
  12918. sprintf(FilePath,"/mnt/%s",filename);
  12919. system("ping 8.8.8.8 &");
  12920. if((access(FilePath,F_OK))!=-1)
  12921. {
  12922. DEBUG_INFO("filename=%s exist.\n",FilePath);
  12923. sprintf(rmFileCmd,"rm -f %s",FilePath);
  12924. system(rmFileCmd);
  12925. }
  12926. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12927. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  12928. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  12929. systemresult = system(ftpbuf);
  12930. //DEBUG_INFO("systemresult=%d\n",systemresult);
  12931. if(systemresult != 0)
  12932. {
  12933. DEBUG_INFO("http DownLoad error!\n");
  12934. return FALSE;
  12935. }
  12936. system("pkill ping");
  12937. return TRUE;
  12938. }
  12939. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  12940. {
  12941. char rmFileCmd[100]={0};
  12942. char FilePath[100]={0};
  12943. char ftpbuf[200];
  12944. int systemresult;
  12945. //char temp[100];
  12946. sprintf(FilePath,"/mnt/%s",filename);
  12947. system("ping 8.8.8.8 &");
  12948. if((access(FilePath,F_OK))!=-1)
  12949. {
  12950. DEBUG_INFO("filename=%s exist.\n",FilePath);
  12951. sprintf(rmFileCmd,"rm -f %s",FilePath);
  12952. system(rmFileCmd);
  12953. }
  12954. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12955. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  12956. //sprintf(ftpbuf, "ftpget -u %s -p %s %s -P %d %s %s%s",user,password,IPbuffer,port/*21*/,filename,path,filename); --- remove temporally
  12957. //DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  12958. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  12959. systemresult = system(ftpbuf);
  12960. //DEBUG_INFO("systemresult=%d\n",systemresult);
  12961. if(systemresult != 0)
  12962. {
  12963. printf("wget error!\n");
  12964. return FALSE;
  12965. }
  12966. system("pkill ping");
  12967. return TRUE;
  12968. }
  12969. int httpUploadFile(char *location, char *path, char *filename,char *url)
  12970. {
  12971. char rmFileCmd[100]={0};
  12972. char FilePath[100]={0};
  12973. char ftpbuf[200];
  12974. int systemresult;
  12975. //DEBUG_INFO("filename=%s\n",filename);
  12976. //DEBUG_INFO("url=%s\n",url);
  12977. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  12978. if((access(FilePath,F_OK))!=-1)
  12979. {
  12980. DEBUG_INFO("filename=%s exist.\n",FilePath);
  12981. sprintf(rmFileCmd,"rm -f %s",FilePath);
  12982. system(rmFileCmd);
  12983. }
  12984. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  12985. if(fp == NULL)
  12986. {
  12987. DEBUG_INFO("log is NULL\n");
  12988. return FALSE;
  12989. }
  12990. else
  12991. {
  12992. fprintf(fp, "%s\n", url);
  12993. fprintf(fp, "%s\n", filename);
  12994. fclose(fp);
  12995. }
  12996. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12997. sprintf(ftpbuf, "%s","/bin/php-cgi /var/www/ocpp_upload.php");
  12998. systemresult = system(ftpbuf);
  12999. DEBUG_INFO("systemresult = %d\n",systemresult);
  13000. if(systemresult != 0)
  13001. {
  13002. DEBUG_INFO("http upload error!\n");
  13003. return FALSE;
  13004. }
  13005. return TRUE;
  13006. }
  13007. int ftpFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  13008. {
  13009. struct hostent* server;
  13010. char *IPbuffer;
  13011. char ftpbuf[200];
  13012. int systemresult;
  13013. // To retrieve host information
  13014. server = gethostbyname(location);
  13015. // To convert an Internet network
  13016. // address into ASCII string
  13017. IPbuffer = inet_ntoa(*((struct in_addr*)
  13018. server->h_addr_list[0]));
  13019. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13020. /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
  13021. /* format : ftpput -u username -p passwd IP target source*/
  13022. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
  13023. DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13024. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13025. systemresult = system(ftpbuf);
  13026. DEBUG_INFO("systemresult=%d\n",systemresult);
  13027. if(systemresult != 0)
  13028. {
  13029. DEBUG_INFO("ftpput error!\n");
  13030. return FALSE;
  13031. }
  13032. return TRUE;
  13033. }
  13034. //=========================================
  13035. // Routine
  13036. //=========================================
  13037. int GetOcppServerURL()
  13038. {
  13039. int result = FALSE;
  13040. struct yuarel url;
  13041. char urlStr[512];
  13042. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  13043. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  13044. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  13045. if((ShmSysConfigAndInfo->SysConfig.OcppServerURL != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0) )
  13046. {
  13047. memcpy(urlStr, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  13048. #ifdef TEST_OCPP20
  13049. sprintf(urlStr, "ws://172.17.20.19:8080/"); // For test
  13050. #endif
  13051. if(yuarel_parse(&url, urlStr) != -1)
  13052. {
  13053. sprintf(OcppProtocol, "%s", url.scheme);
  13054. sprintf(OcppHost, "%s", url.host);
  13055. if(url.path == NULL)
  13056. OcppTempPath[0] = '\0';
  13057. else
  13058. {
  13059. if((url.path[strlen(url.path)-1] != '/') && (strlen(url.path) > 0))
  13060. {
  13061. sprintf(OcppTempPath, "%s/", url.path);
  13062. }
  13063. else
  13064. {
  13065. sprintf(OcppTempPath, "%s", url.path);
  13066. }
  13067. }
  13068. if(url.port == 0)
  13069. {
  13070. if(strcmp(OcppProtocol, "wss") == 0)
  13071. OcppPort = 443;
  13072. else
  13073. OcppPort = 80;
  13074. }
  13075. else
  13076. OcppPort = url.port;
  13077. result = TRUE;
  13078. }
  13079. }
  13080. else if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  13081. {
  13082. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  13083. if(yuarel_parse(&url, urlStr) != -1)
  13084. {
  13085. sprintf(OcppProtocol, "%s", url.scheme);
  13086. sprintf(OcppHost, "%s", url.host);
  13087. if(url.path == NULL)
  13088. OcppTempPath[0] = '\0';
  13089. else
  13090. sprintf(OcppTempPath, "%s", url.path);
  13091. if(url.port == 0)
  13092. {
  13093. if(strcmp(OcppProtocol, "wss") == 0)
  13094. OcppPort = 443;
  13095. else
  13096. OcppPort = 80;
  13097. }
  13098. else
  13099. OcppPort = url.port;
  13100. result = TRUE;
  13101. }
  13102. }
  13103. else
  13104. {
  13105. strcpy(OcppHost,"");
  13106. }
  13107. return result;
  13108. }
  13109. int GetOcppPath()
  13110. {
  13111. int result = FALSE;
  13112. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  13113. {
  13114. if(OcppTempPath == NULL)
  13115. {
  13116. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13117. }
  13118. else
  13119. {
  13120. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13121. }
  13122. result = TRUE;
  13123. }
  13124. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  13125. {
  13126. if(OcppTempPath == NULL)
  13127. {
  13128. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  13129. }
  13130. else
  13131. {
  13132. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  13133. }
  13134. result = TRUE;
  13135. }
  13136. else
  13137. {
  13138. strcpy(OcppPath,"");
  13139. }
  13140. #ifdef TEST_OCPP20
  13141. sprintf(OcppPath,"/AWLU770001D1P0D19520001A0"); // For test
  13142. #endif
  13143. return result;
  13144. }
  13145. int GetOcppPort()
  13146. {
  13147. return OcppPort;
  13148. }
  13149. int GetOcppConnStatus(void)
  13150. {
  13151. return ShmOCPP20Data->OcppConnStatus;
  13152. }
  13153. void SetOcppConnStatus(uint8_t status)
  13154. {
  13155. ShmOCPP20Data->OcppConnStatus = status;
  13156. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  13157. }
  13158. int GetHeartBeatWithNOResponse(void)
  13159. {
  13160. return HeartBeatWithNOResponse;
  13161. }
  13162. void SetHeartBeatWithNOResponse(void)
  13163. {
  13164. HeartBeatWithNOResponse = 0;
  13165. }
  13166. void GetStartTransactionIdTag(int gun_index)
  13167. {
  13168. memset(StartTransactionIdTagTemp, 0 ,ARRAY_SIZE(StartTransactionIdTagTemp));
  13169. strcpy((char *)StartTransactionIdTagTemp, (const char *)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken);
  13170. }
  13171. int GetTransactionId(int gunindex, unsigned char idTag[], uint8_t isStopTransaction)
  13172. {
  13173. char ch;
  13174. FILE *fptr1;
  13175. int temptransactionId;
  13176. char str[100]={0};
  13177. temptransactionId = 0;
  13178. if((strcmp((const char*)idTag, "")==0)||(idTag[0]=='\0'))
  13179. {
  13180. DEBUG_INFO("IdTag is empty.\n");
  13181. return temptransactionId;
  13182. }
  13183. /*------ Read the file ----------------*/
  13184. fptr1=fopen("/Storage/OCPP/QueueTransactionId","r");
  13185. if (!fptr1)
  13186. {
  13187. DEBUG_INFO("QueueTransactionId file open error.\n");
  13188. //printf(" File not found or unable to open the input file!!\n");
  13189. return temptransactionId;
  13190. }
  13191. ch=fgetc(fptr1);
  13192. //printf(" Now the content of the file %s is : \n","/Storage/OCPP/QueueTransactionId");
  13193. rewind(fptr1);
  13194. if(ch!=EOF)
  13195. {
  13196. // printf("%c",ch);
  13197. while (fgets(str, 100, fptr1) != NULL)
  13198. {
  13199. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13200. if(str[0]=='\0')
  13201. {
  13202. break;
  13203. }
  13204. char *revbuf[8] = {0}; // Variable store string split
  13205. int num = 0;// Quantity after string split
  13206. DEBUG_INFO("Transaction queue data= %s\n", str);
  13207. splitstring(str,",",revbuf,&num); // String split
  13208. DEBUG_INFO(" revbuf[0]= %s\n", revbuf[0]);
  13209. DEBUG_INFO(" revbuf[1]= %s\n", revbuf[1]);
  13210. DEBUG_INFO(" revbuf[2]= %s\n", revbuf[2]);
  13211. if((revbuf[1][0] != '\0')&&(revbuf[2][0] != '\0'))
  13212. {
  13213. if(isStopTransaction)
  13214. {
  13215. if((atoi(revbuf[0])==gunindex) && (strcmp(revbuf[1],(const char *)idTag)==0))
  13216. {
  13217. temptransactionId = atoi(revbuf[2]);
  13218. break;
  13219. }
  13220. }
  13221. else
  13222. {
  13223. if((atoi(revbuf[0])==gunindex) || (strcmp(revbuf[1],(const char *)idTag)==0))
  13224. {
  13225. temptransactionId = atoi(revbuf[2]);
  13226. break;
  13227. }
  13228. }
  13229. }
  13230. }
  13231. }
  13232. else
  13233. DEBUG_INFO("EOF\n");
  13234. fclose(fptr1);
  13235. /*------- End of reading ---------------*/
  13236. return temptransactionId;
  13237. }
  13238. void SetTransactionIdZero(int transactionId)
  13239. {
  13240. char ch;
  13241. FILE *fptr1, *fptr2;
  13242. int temptransactionId = 0;
  13243. char str[100]={0}, strtemp[100]={0}, temp[] = "/Storage/OCPP/QueueTransactionIdtemp.json";
  13244. fptr1 = fopen("/Storage/OCPP/QueueTransactionId", "r");
  13245. if (!fptr1)
  13246. {
  13247. //printf(" File not found or unable to open the input file!!\n");
  13248. return ;
  13249. }
  13250. fptr2 = fopen(temp, "w"); // open the temporary file in write mode
  13251. if (!fptr2)
  13252. {
  13253. DEBUG_INFO("Unable to open a temporary file to write!!\n");
  13254. fclose(fptr1);
  13255. return ;
  13256. }
  13257. ch=fgetc(fptr1);
  13258. rewind(fptr1);
  13259. if(ch!=EOF)
  13260. {
  13261. // copy all contents to the temporary file except the specific line
  13262. while (fgets(str, 100, fptr1) != NULL)
  13263. {
  13264. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13265. if(str[0]=='\0')
  13266. {
  13267. break;
  13268. }
  13269. char *revbuf[8] = {0};
  13270. int num = 0;
  13271. strcpy(strtemp, str);
  13272. splitstring(str,",",revbuf,&num);
  13273. if(revbuf[2][0] != '\0')
  13274. {
  13275. temptransactionId = atoi(revbuf[2]);
  13276. if(transactionId != temptransactionId)
  13277. {
  13278. fprintf(fptr2, "%s\n", strtemp);
  13279. }
  13280. }
  13281. }
  13282. }
  13283. fclose(fptr1);
  13284. fclose(fptr2);
  13285. remove("/Storage/OCPP/QueueTransactionId"); // remove the original file
  13286. rename(temp, "/Storage/OCPP/QueueTransactionId"); // rename the temporary file to original name
  13287. /*------ Read the file ----------------*/
  13288. }
  13289. int InternetDisconnect(void)
  13290. {
  13291. return (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi && ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet && ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi );
  13292. }
  13293. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  13294. void storeTempStopTransaction(int gun_index)
  13295. {
  13296. }
  13297. void checkTempStopTransaction(int gun_index)
  13298. {
  13299. FILE *fptr1;
  13300. char ch;
  13301. char str[QUEUE_MESSAGE_LENGTH]={0};
  13302. char guid[37]={0};
  13303. char tempdata[65]={0};
  13304. char connectorStr[2]={0};
  13305. char TempStopTransaction[256];
  13306. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  13307. fptr1 = fopen(TempStopTransaction, "r");
  13308. //TempStopTransaction格式: 槍號,StopTransaction封包
  13309. if (!fptr1)
  13310. {
  13311. //printf(" File not found or unable to open the input file!!\n");
  13312. return ;
  13313. }
  13314. ch=fgetc(fptr1);
  13315. //printf(" Now the content of the file %s is : \n",fname);
  13316. rewind(fptr1);
  13317. if(ch!=EOF)
  13318. {
  13319. // copy all contents to the temporary file except the specific line
  13320. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  13321. {
  13322. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13323. if(str[0]=='\0')
  13324. {
  13325. break;
  13326. }
  13327. //TempStopTransaction格式: 槍號,StopTransaction封包
  13328. strncpy(connectorStr, str, 1);
  13329. if(atoi(connectorStr) != (gun_index+1))
  13330. {
  13331. DEBUG_INFO("atoi(connectorStr) = %d, gun_index = %d\n", atoi(connectorStr), gun_index);
  13332. fclose(fptr1);
  13333. return ;
  13334. }
  13335. //random_uuid(guid);
  13336. strncpy(guid, str+6, 36); //copy guid
  13337. sprintf(tempdata, "StopTransaction,%d", (gun_index));
  13338. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  13339. {
  13340. //DEBUG_INFO("StopTransaction mapitem pass\n");
  13341. }
  13342. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  13343. memset(str,0,ARRAY_SIZE(str));
  13344. }
  13345. }
  13346. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  13347. fclose(fptr1);
  13348. remove(TempStopTransaction); // remove the original file
  13349. }
  13350. void FillStartTransaction(int ConnectorId, unsigned char IdTag[], int MeterStart,int ReservationId,unsigned char Timestamp[])
  13351. {
  13352. ShmOCPP20Data->TransactionEvent[ConnectorId-1].evse.connectorId = ConnectorId;
  13353. ShmOCPP20Data->TransactionEvent[ConnectorId-1].reservationId = ReservationId;
  13354. //ShmOCPP20Data->TransactionEvent[ConnectorId-1].MeterStart = MeterStart;
  13355. strcpy((char *)ShmOCPP20Data->TransactionEvent[ConnectorId-1].idToken.idToken, (char *)IdTag);
  13356. strcpy((char *)ShmOCPP20Data->TransactionEvent[ConnectorId-1].timestamp,(char *) Timestamp);
  13357. }
  13358. int GetWebSocketPingInterval(void)
  13359. {
  13360. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  13361. }
  13362. int GetServerSign(void)
  13363. {
  13364. return server_sign;
  13365. }
  13366. uint8_t GetOcppSecurityProfile()
  13367. {
  13368. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  13369. }
  13370. void GetOcppChargerBoxId(uint8_t *data)
  13371. {
  13372. sprintf((char*)data, "%s", ShmOCPP20Data->ChargeBoxId);
  13373. }
  13374. void GetOcppSecurityPassword(uint8_t *data)
  13375. {
  13376. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  13377. }
  13378. void SetServerSign(int value)
  13379. {
  13380. server_sign = value;
  13381. }
  13382. int GetBootNotificationInterval(void)
  13383. {
  13384. return BootNotificationInterval;
  13385. }
  13386. int GetInternetConn(void)
  13387. {
  13388. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  13389. }
  13390. void InitialSystemValue(void)
  13391. {
  13392. int connectorIndex = 0;
  13393. gunTotalNumber=0;
  13394. SystemInitial = 0;
  13395. localversion=0;
  13396. BootNotificationInterval = 0;
  13397. authorizeRetryTimes = 0;
  13398. GunStatusInterval = 10;
  13399. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  13400. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  13401. //Hear Beat
  13402. HeartBeatWithNOResponse = 0;
  13403. HeartBeatCountPerHour = 0;
  13404. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  13405. FirstHeartBeat = 0;
  13406. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  13407. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  13408. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  13409. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  13410. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  13411. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  13412. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  13413. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  13414. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  13415. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  13416. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  13417. memset(gunType, 0, ARRAY_SIZE(gunType));
  13418. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13419. {
  13420. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O')
  13421. {
  13422. // DO series
  13423. for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
  13424. {
  13425. SystemInitial = SystemInitial + 1;
  13426. gunTotalNumber = gunTotalNumber + 1;
  13427. gunType[connectorIndex] = 'O';
  13428. connectorIndex = connectorIndex + 1;
  13429. }
  13430. }
  13431. else
  13432. {
  13433. // DM, DW, DS series
  13434. //check connector / socket type (index: 8, 9, 10)
  13435. for(int index=7; index <10 ; index++)
  13436. {
  13437. if(index != 8)
  13438. {
  13439. // DC Connector
  13440. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] >= 'A') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= 'Z'))
  13441. {
  13442. SystemInitial = SystemInitial + 1;
  13443. gunTotalNumber = gunTotalNumber + 1;
  13444. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13445. connectorIndex = connectorIndex + 1;
  13446. }
  13447. }
  13448. else
  13449. {
  13450. // AC Connector
  13451. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13452. {
  13453. SystemInitial = SystemInitial + 1;
  13454. gunTotalNumber = gunTotalNumber + 1;
  13455. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13456. connectorIndex = connectorIndex + 1;
  13457. }
  13458. }
  13459. }
  13460. }
  13461. //DEBUG_INFO("DC ...\n");
  13462. }
  13463. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  13464. {
  13465. //check connector / socket type (index: 8, 9, 10)
  13466. for(int index=7; index <10 ; index++)
  13467. {
  13468. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13469. {
  13470. SystemInitial = SystemInitial + 1;
  13471. gunTotalNumber = gunTotalNumber + 1;
  13472. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13473. connectorIndex = connectorIndex + 1;
  13474. //DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
  13475. }
  13476. }
  13477. }
  13478. //Status && ConnectorPlugIn Setting
  13479. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13480. {
  13481. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  13482. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  13483. }
  13484. for (int index = 0; index < CCS_QUANTITY; index++)
  13485. {
  13486. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  13487. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  13488. }
  13489. for (int index = 0; index < GB_QUANTITY; index++)
  13490. {
  13491. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  13492. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  13493. }
  13494. for (int index = 0; index < AC_QUANTITY; index++)
  13495. {
  13496. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  13497. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  13498. }
  13499. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13500. {
  13501. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  13502. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  13503. }
  13504. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  13505. {
  13506. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13507. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  13508. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  13509. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  13510. }
  13511. clientTime.Heartbeat=time((time_t*)NULL);
  13512. sleep(1);
  13513. }
  13514. void LWS_Send(char * str)
  13515. {
  13516. //=====================================================
  13517. // Check InternetConn 0: disconnected, 1: connected
  13518. //====================================================
  13519. if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
  13520. {
  13521. DEBUG_INFO("offline now !!!\n");
  13522. return;
  13523. }
  13524. pthread_mutex_lock(&lock_send);
  13525. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13526. sprintf((char *)SendBuffer, "%s", str);
  13527. SendBufLen = strlen(str);
  13528. pthread_mutex_unlock(&lock_send);
  13529. lws_callback_on_writable(wsi_client);
  13530. //lws_service(context, 0);
  13531. //sleep(1);
  13532. }
  13533. void LWS_SendNow(char * str)
  13534. {
  13535. //=====================================================
  13536. // Check InternetConn 0: disconnected, 1: connected
  13537. //====================================================
  13538. if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
  13539. {
  13540. DEBUG_INFO("offline now !!!\n");
  13541. return;
  13542. }
  13543. pthread_mutex_lock(&lock_send);
  13544. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13545. sprintf((char *)SendBuffer, "%s", str);
  13546. SendBufLen = strlen(str);
  13547. pthread_mutex_unlock(&lock_send);
  13548. lws_callback_on_writable(wsi_client);
  13549. lws_service(context, 0);
  13550. //sleep(1);
  13551. }