MessageHandler.c 782 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712
  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 Smart Charging Profilw
  4116. //===============================
  4117. if(ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq == ON)
  4118. {
  4119. checkCompositeSchedule(gun_index+1, 86400, &ShmOCPP20Data->SmartChargingProfile[gun_index]);
  4120. ShmOCPP20Data->CSUMsg.bits[gun_index].ChargingProfileReq = OFF;
  4121. }
  4122. //==============================================
  4123. // Charger start transaction
  4124. //==============================================
  4125. /*
  4126. if((ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq == ON))
  4127. {
  4128. ShmOCPP20Data->CpMsg.bits[gun_index].StartTransactionReq = OFF;
  4129. sendStartTransactionRequest(gun_index);
  4130. clientTime.StartTransaction = time((time_t*)NULL);
  4131. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4132. }*/
  4133. //==============================================
  4134. // Charger stop transaction
  4135. //==============================================
  4136. /*
  4137. if(((ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq == ON)))
  4138. {
  4139. ShmOCPP20Data->CpMsg.bits[gun_index].StopTransactionReq =OFF;
  4140. sendStopTransactionRequest(gun_index);
  4141. clientTime.StopTransaction = time((time_t*)NULL);
  4142. }*/
  4143. //==============================================
  4144. // Charger status notification & Transaction event report
  4145. //==============================================
  4146. //--- Check Mode Change ---//
  4147. // J: CHAdeMO U: CCS1 combo E: CCS2 combo G: GBT DCcc
  4148. if(gunType[gun_index] == 'J')
  4149. {
  4150. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4151. {
  4152. tempIndex = ((gun_index==2) ? 1: 0);
  4153. }
  4154. else
  4155. {
  4156. tempIndex = gun_index;
  4157. }
  4158. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4159. {
  4160. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4161. {
  4162. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != ChademoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != ChademoPreviousConnectorPlugIn[index]) )
  4163. {
  4164. ChademoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  4165. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  4166. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4167. if(SystemInitial == 0)
  4168. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4169. }
  4170. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4171. {
  4172. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4173. if((access(filenmae,F_OK))!=-1)
  4174. {
  4175. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4176. sprintf(str,"rm -f %s",filenmae);
  4177. system(str);
  4178. }
  4179. }
  4180. #if 1 // for TempStopTransaction
  4181. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4182. {
  4183. checkTempStopTransaction(gun_index);
  4184. }
  4185. #endif
  4186. }
  4187. }
  4188. }
  4189. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4190. {
  4191. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4192. {
  4193. tempIndex = ((gun_index==2) ? 1: 0);
  4194. }
  4195. else
  4196. {
  4197. tempIndex = gun_index;
  4198. }
  4199. for (int index = 0; index < CCS_QUANTITY; index++)
  4200. {
  4201. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4202. {
  4203. 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]*/ )
  4204. {
  4205. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  4206. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  4207. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4208. if(SystemInitial == 0)
  4209. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4210. }
  4211. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4212. {
  4213. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4214. if((access(filenmae,F_OK))!=-1)
  4215. {
  4216. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4217. sprintf(str,"rm -f %s",filenmae);
  4218. system(str);
  4219. }
  4220. }
  4221. #if 1 // for TempStopTransaction
  4222. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4223. {
  4224. checkTempStopTransaction(gun_index);
  4225. }
  4226. #endif
  4227. }
  4228. }
  4229. }
  4230. else if(gunType[gun_index] == 'G')
  4231. {
  4232. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4233. {
  4234. tempIndex = ((gun_index==2) ? 1: 0);
  4235. }
  4236. else
  4237. {
  4238. tempIndex = gun_index;
  4239. }
  4240. for (int index = 0; index < GB_QUANTITY; index++)
  4241. {
  4242. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4243. {
  4244. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != GbPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != GbPreviousConnectorPlugIn[index]) )
  4245. {
  4246. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  4247. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  4248. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4249. if(SystemInitial == 0)
  4250. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4251. }
  4252. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4253. {
  4254. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4255. if((access(filenmae,F_OK))!=-1)
  4256. {
  4257. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4258. sprintf(str,"rm -f %s",filenmae);
  4259. system(str);
  4260. }
  4261. }
  4262. #if 1 // for TempStopTransaction
  4263. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4264. {
  4265. checkTempStopTransaction(gun_index);
  4266. }
  4267. #endif
  4268. }
  4269. }
  4270. }
  4271. else if(gunType[gun_index] == 'O')
  4272. {
  4273. tempIndex = gun_index;
  4274. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4275. {
  4276. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4277. {
  4278. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != DoPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != DoPreviousConnectorPlugIn[index]) )
  4279. {
  4280. DoPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  4281. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  4282. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4283. if(SystemInitial == 0)
  4284. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4285. }
  4286. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)) // complete
  4287. {
  4288. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4289. if((access(filenmae,F_OK))!=-1)
  4290. {
  4291. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4292. sprintf(str,"rm -f %s",filenmae);
  4293. system(str);
  4294. }
  4295. }
  4296. #if 1 // for TempStopTransaction
  4297. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4298. {
  4299. checkTempStopTransaction(gun_index);
  4300. }
  4301. #endif
  4302. }
  4303. }
  4304. }
  4305. else
  4306. {
  4307. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4308. {
  4309. tempIndex = 2;
  4310. }
  4311. else
  4312. {
  4313. tempIndex = gun_index;
  4314. }
  4315. for (int index = 0; index < AC_QUANTITY; index++)
  4316. {
  4317. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4318. {
  4319. if((SystemInitial > 0) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != AcPreviousSystemStatus[index]) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != AcPreviousConnectorPlugIn[index]) )
  4320. {
  4321. AcPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  4322. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  4323. cpinitateMsg.bits[gun_index].StatusNotificationReq = ON;
  4324. if(SystemInitial == 0)
  4325. cpinitateMsg.bits[gun_index].TransactionEventReq = ON;
  4326. }
  4327. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)) // complete
  4328. {
  4329. sprintf(filenmae,"/Storage/OCPP/TxProfile_%d.json",(gun_index+1));
  4330. if((access(filenmae,F_OK))!=-1)
  4331. {
  4332. DEBUG_INFO("TxProfile exist. OCPP will delete TX Charging Profile\n");
  4333. sprintf(str,"rm -f %s",filenmae);
  4334. system(str);
  4335. }
  4336. }
  4337. #if 1 // for TempStopTransaction
  4338. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE) && (ShmOCPP20Data->CpMsg.bits[gun_index].TransactionEventReq == OFF))
  4339. {
  4340. checkTempStopTransaction(gun_index);
  4341. }
  4342. #endif
  4343. }
  4344. }// END
  4345. }
  4346. if(isWebsocketSendable &&
  4347. (cpinitateMsg.bits[gun_index].StatusNotificationReq == ON) &&
  4348. ((time((time_t*)NULL)-clientTime.StatusNotification[gun_index]) > 10) )
  4349. {
  4350. if(SystemInitial > 0)
  4351. SystemInitial -= 1;
  4352. sendStatusNotificationRequest(gun_index);
  4353. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  4354. }
  4355. if(isWebsocketSendable && (server_sign == TRUE) && (cpinitateMsg.bits[gun_index].TransactionEventReq == ON))
  4356. {
  4357. sendTransactionEventRequest(gun_index);
  4358. cpinitateMsg.bits[gun_index].TransactionEventReq = OFF;
  4359. }
  4360. //==============================================
  4361. // Meter report
  4362. //==============================================
  4363. if(isWebsocketSendable && (server_sign == TRUE) && cpinitateMsg.bits[gun_index].TriggerMeterValueReq)
  4364. {
  4365. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Trigger);
  4366. cpinitateMsg.bits[gun_index].TriggerMeterValueReq = OFF;
  4367. }
  4368. // ClockAlign MeterValue
  4369. 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))
  4370. {
  4371. //check Transaction active
  4372. if(gunType[gun_index] == 'J')
  4373. {
  4374. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4375. {
  4376. tempIndex = ((gun_index==2) ? 1: 0);
  4377. }
  4378. else
  4379. {
  4380. tempIndex = gun_index;
  4381. }
  4382. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4383. {
  4384. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4385. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4386. {
  4387. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4388. {
  4389. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4390. }
  4391. }
  4392. }// End for CHAdeMO
  4393. }
  4394. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4395. {
  4396. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4397. {
  4398. tempIndex = ((gun_index==2) ? 1: 0);
  4399. }
  4400. else
  4401. {
  4402. tempIndex = gun_index;
  4403. }
  4404. for (int index = 0; index < CCS_QUANTITY; index++)
  4405. {
  4406. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4407. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4408. {
  4409. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4410. {
  4411. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4412. }
  4413. }
  4414. } // End for CCS
  4415. }
  4416. else if(gunType[gun_index] == 'G')
  4417. {
  4418. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4419. {
  4420. tempIndex = ((gun_index==2) ? 1: 0);
  4421. }
  4422. else
  4423. {
  4424. tempIndex = gun_index;
  4425. }
  4426. for (int index = 0; index < GB_QUANTITY; index++)
  4427. {
  4428. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4429. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4430. {
  4431. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4432. {
  4433. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4434. }
  4435. }
  4436. }// End for GB
  4437. }
  4438. else if(gunType[gun_index] == 'O')
  4439. {
  4440. tempIndex = gun_index;
  4441. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4442. {
  4443. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4444. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4445. {
  4446. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != SYS_MODE_CHARGING)
  4447. {
  4448. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4449. }
  4450. }
  4451. }
  4452. }
  4453. else
  4454. {
  4455. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4456. {
  4457. tempIndex = 2;
  4458. }
  4459. else
  4460. {
  4461. tempIndex = gun_index;
  4462. }
  4463. for (int index = 0; index < AC_QUANTITY; index++)
  4464. {
  4465. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4466. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4467. {
  4468. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != SYS_MODE_CHARGING)
  4469. {
  4470. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = ON;
  4471. }
  4472. }
  4473. }//End for AC
  4474. }
  4475. if(cpinitateMsg.bits[gun_index].ClockAlignMeterReq == ON)
  4476. {
  4477. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Clock);
  4478. cpinitateMsg.bits[gun_index].ClockAlignMeterReq = OFF;
  4479. }
  4480. }
  4481. // Sample period MeterValue
  4482. if(((time((time_t*)NULL) - clientTime.MeterValues[gun_index]) > (atoi((const char *)ShmOCPP20Data->ControllerComponentVariable[SampledDataCtrlr_TxUpdatedInterval].variableAttribute[0].value)- 1)))
  4483. {
  4484. //check Transaction active
  4485. if(gunType[gun_index] == 'J')
  4486. {
  4487. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4488. {
  4489. tempIndex = ((gun_index==2) ? 1: 0);
  4490. }
  4491. else
  4492. {
  4493. tempIndex = gun_index;
  4494. }
  4495. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  4496. {
  4497. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4498. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  4499. {
  4500. if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4501. {
  4502. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4503. }
  4504. }
  4505. }// End for CHAdeMO
  4506. }
  4507. else if((gunType[gun_index] == 'U')||(gunType[gun_index] == 'E'))
  4508. {
  4509. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4510. {
  4511. tempIndex = ((gun_index==2) ? 1: 0);
  4512. }
  4513. else
  4514. {
  4515. tempIndex = gun_index;
  4516. }
  4517. for (int index = 0; index < CCS_QUANTITY; index++)
  4518. {
  4519. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4520. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  4521. {
  4522. if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4523. {
  4524. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4525. }
  4526. }
  4527. } // End for CCS
  4528. }
  4529. else if(gunType[gun_index] == 'G')
  4530. {
  4531. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  4532. {
  4533. tempIndex = ((gun_index==2) ? 1: 0);
  4534. }
  4535. else
  4536. {
  4537. tempIndex = gun_index;
  4538. }
  4539. for (int index = 0; index < GB_QUANTITY; index++)
  4540. {
  4541. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4542. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  4543. {
  4544. if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4545. {
  4546. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4547. }
  4548. }
  4549. }// End for GB
  4550. }
  4551. else if(gunType[gun_index] == 'O')
  4552. {
  4553. tempIndex = gun_index;
  4554. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  4555. {
  4556. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4557. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  4558. {
  4559. if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING)
  4560. {
  4561. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4562. }
  4563. }
  4564. }
  4565. }
  4566. else
  4567. {
  4568. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  4569. {
  4570. tempIndex = 2;
  4571. }
  4572. else
  4573. {
  4574. tempIndex = gun_index;
  4575. }
  4576. for (int index = 0; index < AC_QUANTITY; index++)
  4577. {
  4578. // 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
  4579. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  4580. {
  4581. if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING)
  4582. {
  4583. cpinitateMsg.bits[gun_index].SampleMeterReq = ON;
  4584. }
  4585. }
  4586. }//End for AC
  4587. }
  4588. if(cpinitateMsg.bits[gun_index].SampleMeterReq == ON)
  4589. {
  4590. sendMeterValuesRequest(gun_index, ReadingContextEnumType_Sample_Periodic);
  4591. storeTempStopTransaction(gun_index);
  4592. cpinitateMsg.bits[gun_index].SampleMeterReq = OFF;
  4593. }
  4594. clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  4595. }
  4596. //==============================================
  4597. // Check Connector reserved
  4598. //==============================================
  4599. //===============================
  4600. // Check if Reserve is expired
  4601. //===============================
  4602. if((server_sign == TRUE) && (ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime[0] != 0) )
  4603. {
  4604. double diff_t;
  4605. struct tm tp;
  4606. // current time
  4607. time_t t = time(NULL);
  4608. strptime((char *)ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime, "%Y-%m-%dT%H:%M:%S", &tp);
  4609. tp.tm_isdst = -1;
  4610. time_t utc = mktime(&tp);
  4611. diff_t = difftime(utc, t);
  4612. if(diff_t <= 0)
  4613. {
  4614. DEBUG_INFO("reserve expired.\n");
  4615. memset(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime,0,ARRAY_SIZE(ShmOCPP20Data->ReserveNow[gun_index].expiryDateTime));
  4616. }
  4617. }//END OF Check if Reserve is expired
  4618. //==========================================
  4619. // csu trigger FirmwareStatusNotificationReq
  4620. //==========================================
  4621. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->SpMsg.bits.FirmwareStatusNotificationReq == ON))
  4622. {
  4623. sendFirmwareStatusNotificationRequest((char *)ShmOCPP20Data->FirmwareStatusNotification.status);
  4624. }
  4625. //==========================================
  4626. // csu trigger CancelReservationConf
  4627. //==========================================
  4628. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].CancelReservationConf == ON))
  4629. {
  4630. sendCancelReservationConfirmation((char *)ShmOCPP20Data->CancelReservation[gun_index].guid, gun_index);
  4631. }
  4632. //==========================================
  4633. // csu trigger ChangeAvailabilityConf
  4634. //==========================================
  4635. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ChangeAvailabilityConf == ON))
  4636. {
  4637. //sendChangeAvailabilityConfirmation(,(char *)ShmOCPP20Data->ChangeAvailability[gun_index].ResponseStatus);
  4638. }
  4639. //==========================================
  4640. // csu trigger UnlockConnectorConf
  4641. //==========================================
  4642. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf == ON))
  4643. {
  4644. sendUnlockConnectorConfirmation((char *)ShmOCPP20Data->UnlockConnector[gun_index].guid, gun_index);
  4645. ShmOCPP20Data->CsMsg.bits[gun_index].UnlockConnectorConf = OFF;
  4646. }
  4647. //==========================================
  4648. // csu trigger ReserveNowConf
  4649. //==========================================
  4650. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf == ON))
  4651. {
  4652. sendReserveNowConfirmation((char *)ShmOCPP20Data->ReserveNow[gun_index].guid, gun_index);
  4653. ShmOCPP20Data->CsMsg.bits[gun_index].ReserveNowConf = OFF;
  4654. }
  4655. //==========================================
  4656. // csu trigger DataTransferReq
  4657. //==========================================
  4658. if(isWebsocketSendable && (server_sign == TRUE) && (ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq == ON))
  4659. {
  4660. sendDataTransferRequest(gun_index);
  4661. ShmOCPP20Data->CsMsg.bits[gun_index].DataTransferReq = 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_PREPARING)&&( 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_PREPARING)&&( 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_PREPARING)&&( 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_PREPARING) && (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. if((access(FilePath,F_OK))!=-1)
  12920. {
  12921. DEBUG_INFO("filename=%s exist.\n",FilePath);
  12922. sprintf(rmFileCmd,"rm -f %s",FilePath);
  12923. system(rmFileCmd);
  12924. }
  12925. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12926. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  12927. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  12928. systemresult = system(ftpbuf);
  12929. //DEBUG_INFO("systemresult=%d\n",systemresult);
  12930. if(systemresult != 0)
  12931. {
  12932. DEBUG_INFO("http DownLoad error!\n");
  12933. return FALSE;
  12934. }
  12935. return TRUE;
  12936. }
  12937. int ftpDownLoadFile(char *location, char *user, char *password, int port, char *path, char *filename,char *url)
  12938. {
  12939. char rmFileCmd[100]={0};
  12940. char FilePath[100]={0};
  12941. char ftpbuf[200];
  12942. int systemresult;
  12943. //char temp[100];
  12944. sprintf(FilePath,"/mnt/%s",filename);
  12945. if((access(FilePath,F_OK))!=-1)
  12946. {
  12947. DEBUG_INFO("filename=%s exist.\n",FilePath);
  12948. sprintf(rmFileCmd,"rm -f %s",FilePath);
  12949. system(rmFileCmd);
  12950. }
  12951. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12952. sprintf(ftpbuf, "wget --tries=3 -O /mnt/%s -c %s -T 120",filename, url);
  12953. //sprintf(ftpbuf, "ftpget -u %s -p %s %s -P %d %s %s%s",user,password,IPbuffer,port/*21*/,filename,path,filename); --- remove temporally
  12954. //DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  12955. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  12956. systemresult = system(ftpbuf);
  12957. //DEBUG_INFO("systemresult=%d\n",systemresult);
  12958. if(systemresult != 0)
  12959. {
  12960. printf("wget error!\n");
  12961. return FALSE;
  12962. }
  12963. return TRUE;
  12964. }
  12965. int httpUploadFile(char *location, char *path, char *filename,char *url)
  12966. {
  12967. char rmFileCmd[100]={0};
  12968. char FilePath[100]={0};
  12969. char ftpbuf[200];
  12970. int systemresult;
  12971. //DEBUG_INFO("filename=%s\n",filename);
  12972. //DEBUG_INFO("url=%s\n",url);
  12973. sprintf(FilePath,"%s","/mnt/upload_file.txt");
  12974. if((access(FilePath,F_OK))!=-1)
  12975. {
  12976. DEBUG_INFO("filename=%s exist.\n",FilePath);
  12977. sprintf(rmFileCmd,"rm -f %s",FilePath);
  12978. system(rmFileCmd);
  12979. }
  12980. FILE *fp = fopen("/mnt/upload_file.txt", "w+");
  12981. if(fp == NULL)
  12982. {
  12983. DEBUG_INFO("log is NULL\n");
  12984. return FALSE;
  12985. }
  12986. else
  12987. {
  12988. fprintf(fp, "%s\n", url);
  12989. fprintf(fp, "%s\n", filename);
  12990. fclose(fp);
  12991. }
  12992. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  12993. sprintf(ftpbuf, "%s","/bin/php-cgi /var/www/ocpp_upload.php");
  12994. systemresult = system(ftpbuf);
  12995. DEBUG_INFO("systemresult = %d\n",systemresult);
  12996. if(systemresult != 0)
  12997. {
  12998. DEBUG_INFO("http upload error!\n");
  12999. return FALSE;
  13000. }
  13001. return TRUE;
  13002. }
  13003. int ftpFile(char *location, char *user, char *password, int port, char *path, char *fnamePlusPath,char *filename)
  13004. {
  13005. struct hostent* server;
  13006. char *IPbuffer;
  13007. char ftpbuf[200];
  13008. int systemresult;
  13009. // To retrieve host information
  13010. server = gethostbyname(location);
  13011. // To convert an Internet network
  13012. // address into ASCII string
  13013. IPbuffer = inet_ntoa(*((struct in_addr*)
  13014. server->h_addr_list[0]));
  13015. memset(ftpbuf, 0, ARRAY_SIZE(ftpbuf));
  13016. /* format : ftpput -u phihong -p y42j%2f4cj84 112.91.88.35 -P 21 /2020-02.zip ../mnt/2020-02.zip*/
  13017. /* format : ftpput -u username -p passwd IP target source*/
  13018. sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,port/*21*/,path,filename,fnamePlusPath);
  13019. DEBUG_INFO("ftpbuf=%s\n",ftpbuf);
  13020. //sprintf(ftpbuf, "ftpput -u %s -p %s %s -P %d %s%s %s",user,password,IPbuffer,21,filename,filename,path);
  13021. systemresult = system(ftpbuf);
  13022. DEBUG_INFO("systemresult=%d\n",systemresult);
  13023. if(systemresult != 0)
  13024. {
  13025. DEBUG_INFO("ftpput error!\n");
  13026. return FALSE;
  13027. }
  13028. return TRUE;
  13029. }
  13030. //=========================================
  13031. // Routine
  13032. //=========================================
  13033. int GetOcppServerURL()
  13034. {
  13035. int result = FALSE;
  13036. struct yuarel url;
  13037. char urlStr[512];
  13038. memset(OcppProtocol, 0, ARRAY_SIZE(OcppProtocol));
  13039. memset(OcppHost, 0, ARRAY_SIZE(OcppHost));
  13040. memset(OcppTempPath, 0, ARRAY_SIZE(OcppTempPath));
  13041. if((ShmSysConfigAndInfo->SysConfig.OcppServerURL != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL,"") != 0) )
  13042. {
  13043. memcpy(urlStr, ShmSysConfigAndInfo->SysConfig.OcppServerURL, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.OcppServerURL));
  13044. #ifdef TEST_OCPP20
  13045. sprintf(urlStr, "ws://172.17.20.19:8080/"); // For test
  13046. #endif
  13047. if(yuarel_parse(&url, urlStr) != -1)
  13048. {
  13049. sprintf(OcppProtocol, "%s", url.scheme);
  13050. sprintf(OcppHost, "%s", url.host);
  13051. if(url.path == NULL)
  13052. OcppTempPath[0] = '\0';
  13053. else
  13054. {
  13055. if(url.path[strlen(url.path)-1] != '/')
  13056. {
  13057. sprintf(OcppTempPath, "%s/", url.path);
  13058. }
  13059. else
  13060. {
  13061. sprintf(OcppTempPath, "%s", url.path);
  13062. }
  13063. }
  13064. if(url.port == 0)
  13065. {
  13066. if(strcmp(OcppProtocol, "wss") == 0)
  13067. OcppPort = 443;
  13068. else
  13069. OcppPort = 80;
  13070. }
  13071. else
  13072. OcppPort = url.port;
  13073. result = TRUE;
  13074. }
  13075. }
  13076. else if((ShmOCPP20Data->OcppServerURL != NULL) && (strcmp((const char *)ShmOCPP20Data->OcppServerURL,"") != 0))
  13077. {
  13078. memcpy(urlStr, ShmOCPP20Data->OcppServerURL, ARRAY_SIZE(ShmOCPP20Data->OcppServerURL));
  13079. if(yuarel_parse(&url, urlStr) != -1)
  13080. {
  13081. sprintf(OcppProtocol, "%s", url.scheme);
  13082. sprintf(OcppHost, "%s", url.host);
  13083. if(url.path == NULL)
  13084. OcppTempPath[0] = '\0';
  13085. else
  13086. sprintf(OcppTempPath, "%s", url.path);
  13087. if(url.port == 0)
  13088. {
  13089. if(strcmp(OcppProtocol, "wss") == 0)
  13090. OcppPort = 443;
  13091. else
  13092. OcppPort = 80;
  13093. }
  13094. else
  13095. OcppPort = url.port;
  13096. result = TRUE;
  13097. }
  13098. }
  13099. else
  13100. {
  13101. strcpy(OcppHost,"");
  13102. }
  13103. return result;
  13104. }
  13105. int GetOcppPath()
  13106. {
  13107. int result = FALSE;
  13108. if((ShmSysConfigAndInfo->SysConfig.ChargeBoxId != NULL) && (strcmp((const char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"") != 0) )
  13109. {
  13110. if(OcppTempPath == NULL)
  13111. {
  13112. sprintf(OcppPath,"/%s",ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13113. }
  13114. else
  13115. {
  13116. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  13117. }
  13118. result = TRUE;
  13119. }
  13120. else if((ShmOCPP20Data->ChargeBoxId != NULL) && (strcmp((const char *)ShmOCPP20Data->ChargeBoxId,"") != 0))
  13121. {
  13122. if(OcppTempPath == NULL)
  13123. {
  13124. sprintf(OcppPath,"/%s",ShmOCPP20Data->ChargeBoxId);
  13125. }
  13126. else
  13127. {
  13128. sprintf(OcppPath,"/%s%s",OcppTempPath,ShmOCPP20Data->ChargeBoxId);
  13129. }
  13130. result = TRUE;
  13131. }
  13132. else
  13133. {
  13134. strcpy(OcppPath,"");
  13135. }
  13136. #ifdef TEST_OCPP20
  13137. sprintf(OcppPath,"/AWLU770001D1P0D19520001A0"); // For test
  13138. #endif
  13139. return result;
  13140. }
  13141. int GetOcppPort()
  13142. {
  13143. return OcppPort;
  13144. }
  13145. int GetOcppConnStatus(void)
  13146. {
  13147. return ShmOCPP20Data->OcppConnStatus;
  13148. }
  13149. void SetOcppConnStatus(uint8_t status)
  13150. {
  13151. ShmOCPP20Data->OcppConnStatus = status;
  13152. ShmSysConfigAndInfo->SysInfo.OcppConnStatus = status;
  13153. }
  13154. int GetHeartBeatWithNOResponse(void)
  13155. {
  13156. return HeartBeatWithNOResponse;
  13157. }
  13158. void SetHeartBeatWithNOResponse(void)
  13159. {
  13160. HeartBeatWithNOResponse = 0;
  13161. }
  13162. void GetStartTransactionIdTag(int gun_index)
  13163. {
  13164. memset(StartTransactionIdTagTemp, 0 ,ARRAY_SIZE(StartTransactionIdTagTemp));
  13165. strcpy((char *)StartTransactionIdTagTemp, (const char *)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken);
  13166. }
  13167. int GetTransactionId(int gunindex, unsigned char idTag[], uint8_t isStopTransaction)
  13168. {
  13169. char ch;
  13170. FILE *fptr1;
  13171. int temptransactionId;
  13172. char str[100]={0};
  13173. temptransactionId = 0;
  13174. if((strcmp((const char*)idTag, "")==0)||(idTag[0]=='\0'))
  13175. {
  13176. DEBUG_INFO("IdTag is empty.\n");
  13177. return temptransactionId;
  13178. }
  13179. /*------ Read the file ----------------*/
  13180. fptr1=fopen("/Storage/OCPP/QueueTransactionId","r");
  13181. if (!fptr1)
  13182. {
  13183. DEBUG_INFO("QueueTransactionId file open error.\n");
  13184. //printf(" File not found or unable to open the input file!!\n");
  13185. return temptransactionId;
  13186. }
  13187. ch=fgetc(fptr1);
  13188. //printf(" Now the content of the file %s is : \n","/Storage/OCPP/QueueTransactionId");
  13189. rewind(fptr1);
  13190. if(ch!=EOF)
  13191. {
  13192. // printf("%c",ch);
  13193. while (fgets(str, 100, fptr1) != NULL)
  13194. {
  13195. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13196. if(str[0]=='\0')
  13197. {
  13198. break;
  13199. }
  13200. char *revbuf[8] = {0}; // Variable store string split
  13201. int num = 0;// Quantity after string split
  13202. DEBUG_INFO("Transaction queue data= %s\n", str);
  13203. splitstring(str,",",revbuf,&num); // String split
  13204. DEBUG_INFO(" revbuf[0]= %s\n", revbuf[0]);
  13205. DEBUG_INFO(" revbuf[1]= %s\n", revbuf[1]);
  13206. DEBUG_INFO(" revbuf[2]= %s\n", revbuf[2]);
  13207. if((revbuf[1][0] != '\0')&&(revbuf[2][0] != '\0'))
  13208. {
  13209. if(isStopTransaction)
  13210. {
  13211. if((atoi(revbuf[0])==gunindex) && (strcmp(revbuf[1],(const char *)idTag)==0))
  13212. {
  13213. temptransactionId = atoi(revbuf[2]);
  13214. break;
  13215. }
  13216. }
  13217. else
  13218. {
  13219. if((atoi(revbuf[0])==gunindex) || (strcmp(revbuf[1],(const char *)idTag)==0))
  13220. {
  13221. temptransactionId = atoi(revbuf[2]);
  13222. break;
  13223. }
  13224. }
  13225. }
  13226. }
  13227. }
  13228. else
  13229. DEBUG_INFO("EOF\n");
  13230. fclose(fptr1);
  13231. /*------- End of reading ---------------*/
  13232. return temptransactionId;
  13233. }
  13234. void SetTransactionIdZero(int transactionId)
  13235. {
  13236. char ch;
  13237. FILE *fptr1, *fptr2;
  13238. int temptransactionId = 0;
  13239. char str[100]={0}, strtemp[100]={0}, temp[] = "/Storage/OCPP/QueueTransactionIdtemp.json";
  13240. fptr1 = fopen("/Storage/OCPP/QueueTransactionId", "r");
  13241. if (!fptr1)
  13242. {
  13243. //printf(" File not found or unable to open the input file!!\n");
  13244. return ;
  13245. }
  13246. fptr2 = fopen(temp, "w"); // open the temporary file in write mode
  13247. if (!fptr2)
  13248. {
  13249. DEBUG_INFO("Unable to open a temporary file to write!!\n");
  13250. fclose(fptr1);
  13251. return ;
  13252. }
  13253. ch=fgetc(fptr1);
  13254. rewind(fptr1);
  13255. if(ch!=EOF)
  13256. {
  13257. // copy all contents to the temporary file except the specific line
  13258. while (fgets(str, 100, fptr1) != NULL)
  13259. {
  13260. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13261. if(str[0]=='\0')
  13262. {
  13263. break;
  13264. }
  13265. char *revbuf[8] = {0};
  13266. int num = 0;
  13267. strcpy(strtemp, str);
  13268. splitstring(str,",",revbuf,&num);
  13269. if(revbuf[2][0] != '\0')
  13270. {
  13271. temptransactionId = atoi(revbuf[2]);
  13272. if(transactionId != temptransactionId)
  13273. {
  13274. fprintf(fptr2, "%s\n", strtemp);
  13275. }
  13276. }
  13277. }
  13278. }
  13279. fclose(fptr1);
  13280. fclose(fptr2);
  13281. remove("/Storage/OCPP/QueueTransactionId"); // remove the original file
  13282. rename(temp, "/Storage/OCPP/QueueTransactionId"); // rename the temporary file to original name
  13283. /*------ Read the file ----------------*/
  13284. }
  13285. int InternetDisconnect(void)
  13286. {
  13287. return (ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi && ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaEthernet && ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi );
  13288. }
  13289. //Note: It is not real StopTransaction. It is temporary StopTransaction.
  13290. void storeTempStopTransaction(int gun_index)
  13291. {
  13292. }
  13293. void checkTempStopTransaction(int gun_index)
  13294. {
  13295. FILE *fptr1;
  13296. char ch;
  13297. char str[QUEUE_MESSAGE_LENGTH]={0};
  13298. char guid[37]={0};
  13299. char tempdata[65]={0};
  13300. char connectorStr[2]={0};
  13301. char TempStopTransaction[256];
  13302. sprintf(TempStopTransaction, "/Storage/OCPP/TempStopTransaction_%d", (gun_index+1));
  13303. fptr1 = fopen(TempStopTransaction, "r");
  13304. //TempStopTransaction格式: 槍號,StopTransaction封包
  13305. if (!fptr1)
  13306. {
  13307. //printf(" File not found or unable to open the input file!!\n");
  13308. return ;
  13309. }
  13310. ch=fgetc(fptr1);
  13311. //printf(" Now the content of the file %s is : \n",fname);
  13312. rewind(fptr1);
  13313. if(ch!=EOF)
  13314. {
  13315. // copy all contents to the temporary file except the specific line
  13316. while (fgets(str, QUEUE_MESSAGE_LENGTH, fptr1) != NULL)
  13317. {
  13318. str[strlen(str) - 1] = '\0'; // eat the newline fgets() stores
  13319. if(str[0]=='\0')
  13320. {
  13321. break;
  13322. }
  13323. //TempStopTransaction格式: 槍號,StopTransaction封包
  13324. strncpy(connectorStr, str, 1);
  13325. if(atoi(connectorStr) != (gun_index+1))
  13326. {
  13327. DEBUG_INFO("atoi(connectorStr) = %d, gun_index = %d\n", atoi(connectorStr), gun_index);
  13328. fclose(fptr1);
  13329. return ;
  13330. }
  13331. //random_uuid(guid);
  13332. strncpy(guid, str+6, 36); //copy guid
  13333. sprintf(tempdata, "StopTransaction,%d", (gun_index));
  13334. if(hashmap_operation(HASH_OP_ADD, guid, tempdata) == 1)
  13335. {
  13336. //DEBUG_INFO("StopTransaction mapitem pass\n");
  13337. }
  13338. queue_operation(QUEUE_OPERATION_ADD, guid, str);//addq(guid, queuedata); ---> remove temporally
  13339. memset(str,0,ARRAY_SIZE(str));
  13340. }
  13341. }
  13342. // fptr1=freopen(NULL,"w",fptr1); // reset the fptr1 again
  13343. fclose(fptr1);
  13344. remove(TempStopTransaction); // remove the original file
  13345. }
  13346. void FillStartTransaction(int ConnectorId, unsigned char IdTag[], int MeterStart,int ReservationId,unsigned char Timestamp[])
  13347. {
  13348. ShmOCPP20Data->TransactionEvent[ConnectorId-1].evse.connectorId = ConnectorId;
  13349. ShmOCPP20Data->TransactionEvent[ConnectorId-1].reservationId = ReservationId;
  13350. //ShmOCPP20Data->TransactionEvent[ConnectorId-1].MeterStart = MeterStart;
  13351. strcpy((char *)ShmOCPP20Data->TransactionEvent[ConnectorId-1].idToken.idToken, (char *)IdTag);
  13352. strcpy((char *)ShmOCPP20Data->TransactionEvent[ConnectorId-1].timestamp,(char *) Timestamp);
  13353. }
  13354. int GetWebSocketPingInterval(void)
  13355. {
  13356. return atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_WebSocketPingInterval].variableAttribute[0].value);
  13357. }
  13358. int GetServerSign(void)
  13359. {
  13360. return server_sign;
  13361. }
  13362. uint8_t GetOcppSecurityProfile()
  13363. {
  13364. return atoi((char*)ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_SecurityProfile].variableAttribute[0].value);
  13365. }
  13366. void GetOcppChargerBoxId(uint8_t *data)
  13367. {
  13368. sprintf((char*)data, "%s", ShmOCPP20Data->ChargeBoxId);
  13369. }
  13370. void GetOcppSecurityPassword(uint8_t *data)
  13371. {
  13372. sprintf((char*)data, "%s", ShmOCPP20Data->ControllerComponentVariable[SecurityCtrlr_BasicAuthPassword].variableAttribute[0].value);
  13373. }
  13374. void SetServerSign(int value)
  13375. {
  13376. server_sign = value;
  13377. }
  13378. int GetBootNotificationInterval(void)
  13379. {
  13380. return BootNotificationInterval;
  13381. }
  13382. int GetInternetConn(void)
  13383. {
  13384. return ShmSysConfigAndInfo->SysInfo.InternetConn;
  13385. }
  13386. void InitialSystemValue(void)
  13387. {
  13388. int connectorIndex = 0;
  13389. gunTotalNumber=0;
  13390. SystemInitial = 0;
  13391. localversion=0;
  13392. BootNotificationInterval = 0;
  13393. authorizeRetryTimes = 0;
  13394. GunStatusInterval = 10;
  13395. TransactionMessageAttemptsValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttempts].variableAttribute[0].value);
  13396. TransactionMessageRetryIntervalValue = atoi((char *)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_MessageAttemptInterval].variableAttribute[0].value);
  13397. //Hear Beat
  13398. HeartBeatWithNOResponse = 0;
  13399. HeartBeatCountPerHour = 0;
  13400. HeartBeatWaitTime = atoi((char*)ShmOCPP20Data->ControllerComponentVariable[OCPPCommCtrlr_HeartbeatInterval].variableAttribute[0].value);;
  13401. FirstHeartBeat = 0;
  13402. FirmwareStatusNotificationStatus = FirmwareStatusEnumType_Idle; // Idle
  13403. LogStatusNotificationStatus = UploadLogStatusEnumType_Idle; // Idle
  13404. memset(CurrentChargingProfileScheduleStr, 0, ARRAY_SIZE(CurrentChargingProfileScheduleStr));
  13405. memset(ChademoPreviousSystemStatus, 0, ARRAY_SIZE(ChademoPreviousSystemStatus));
  13406. memset(CcsPreviousSystemStatus, 0, ARRAY_SIZE(CcsPreviousSystemStatus));
  13407. memset(GbPreviousSystemStatus, 0, ARRAY_SIZE(GbPreviousSystemStatus));
  13408. memset(AcPreviousSystemStatus, 0, ARRAY_SIZE(AcPreviousSystemStatus));
  13409. memset(ChademoPreviousConnectorPlugIn, 0, ARRAY_SIZE(ChademoPreviousConnectorPlugIn));
  13410. memset(CcsPreviousConnectorPlugIn, 0, ARRAY_SIZE(CcsPreviousConnectorPlugIn));
  13411. memset(GbPreviousConnectorPlugIn, 0, ARRAY_SIZE(GbPreviousConnectorPlugIn));
  13412. memset(AcPreviousConnectorPlugIn, 0, ARRAY_SIZE(AcPreviousConnectorPlugIn));
  13413. memset(gunType, 0, ARRAY_SIZE(gunType));
  13414. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D') // 'D' means DC
  13415. {
  13416. if(ShmSysConfigAndInfo->SysConfig.ModelName[1]=='O')
  13417. {
  13418. // DO series
  13419. for(int index=0; index<GENERAL_GUN_QUANTITY ; index++)
  13420. {
  13421. SystemInitial = SystemInitial + 1;
  13422. gunTotalNumber = gunTotalNumber + 1;
  13423. gunType[connectorIndex] = 'O';
  13424. connectorIndex = connectorIndex + 1;
  13425. }
  13426. }
  13427. else
  13428. {
  13429. // DM, DW, DS series
  13430. //check connector / socket type (index: 8, 9, 10)
  13431. for(int index=7; index <10 ; index++)
  13432. {
  13433. if(index != 8)
  13434. {
  13435. // DC Connector
  13436. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] >= 'A') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= 'Z'))
  13437. {
  13438. SystemInitial = SystemInitial + 1;
  13439. gunTotalNumber = gunTotalNumber + 1;
  13440. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13441. connectorIndex = connectorIndex + 1;
  13442. }
  13443. }
  13444. else
  13445. {
  13446. // AC Connector
  13447. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13448. {
  13449. SystemInitial = SystemInitial + 1;
  13450. gunTotalNumber = gunTotalNumber + 1;
  13451. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13452. connectorIndex = connectorIndex + 1;
  13453. }
  13454. }
  13455. }
  13456. }
  13457. //DEBUG_INFO("DC ...\n");
  13458. }
  13459. else if (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='A') //'A' means AC
  13460. {
  13461. //check connector / socket type (index: 8, 9, 10)
  13462. for(int index=7; index <10 ; index++)
  13463. {
  13464. if ((ShmSysConfigAndInfo->SysConfig.ModelName[index] > '0') && (ShmSysConfigAndInfo->SysConfig.ModelName[index] <= '9'))
  13465. {
  13466. SystemInitial = SystemInitial + 1;
  13467. gunTotalNumber = gunTotalNumber + 1;
  13468. gunType[connectorIndex] = ShmSysConfigAndInfo->SysConfig.ModelName[index];
  13469. connectorIndex = connectorIndex + 1;
  13470. //DEBUG_INFO("AC: %d, %c\n", index, ShmSysConfigAndInfo->SysConfig.ModelName[index]);
  13471. }
  13472. }
  13473. }
  13474. //Status && ConnectorPlugIn Setting
  13475. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  13476. {
  13477. ChademoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PreviousSystemStatus;
  13478. ChademoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  13479. }
  13480. for (int index = 0; index < CCS_QUANTITY; index++)
  13481. {
  13482. CcsPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PreviousSystemStatus;
  13483. CcsPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  13484. }
  13485. for (int index = 0; index < GB_QUANTITY; index++)
  13486. {
  13487. GbPreviousSystemStatus[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PreviousSystemStatus;
  13488. GbPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  13489. }
  13490. for (int index = 0; index < AC_QUANTITY; index++)
  13491. {
  13492. AcPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PreviousSystemStatus;
  13493. AcPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  13494. }
  13495. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  13496. {
  13497. DoPreviousSystemStatus[index]= ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PreviousSystemStatus;
  13498. DoPreviousConnectorPlugIn[index] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PilotState;
  13499. }
  13500. for(int gun_index=0; gun_index < gunTotalNumber; gun_index++ )
  13501. {
  13502. cpinitateMsg.bits[gun_index].StatusNotificationReq = OFF;
  13503. cpinitateMsg.bits[gun_index].StatusNotificationConf = OFF;
  13504. //clientTime.MeterValues[gun_index] = time((time_t*)NULL);
  13505. clientTime.StatusNotification[gun_index] = time((time_t*)NULL);
  13506. }
  13507. clientTime.Heartbeat=time((time_t*)NULL);
  13508. sleep(1);
  13509. }
  13510. void LWS_Send(char * str)
  13511. {
  13512. //=====================================================
  13513. // Check InternetConn 0: disconnected, 1: connected
  13514. //====================================================
  13515. if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
  13516. {
  13517. DEBUG_INFO("offline now !!!\n");
  13518. return;
  13519. }
  13520. pthread_mutex_lock(&lock_send);
  13521. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13522. sprintf((char *)SendBuffer, "%s", str);
  13523. SendBufLen = strlen(str);
  13524. pthread_mutex_unlock(&lock_send);
  13525. lws_callback_on_writable(wsi_client);
  13526. //lws_service(context, 0);
  13527. //sleep(1);
  13528. }
  13529. void LWS_SendNow(char * str)
  13530. {
  13531. //=====================================================
  13532. // Check InternetConn 0: disconnected, 1: connected
  13533. //====================================================
  13534. if(ShmSysConfigAndInfo->SysInfo.InternetConn == 0)
  13535. {
  13536. DEBUG_INFO("offline now !!!\n");
  13537. return;
  13538. }
  13539. pthread_mutex_lock(&lock_send);
  13540. memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
  13541. sprintf((char *)SendBuffer, "%s", str);
  13542. SendBufLen = strlen(str);
  13543. pthread_mutex_unlock(&lock_send);
  13544. lws_callback_on_writable(wsi_client);
  13545. lws_service(context, 0);
  13546. //sleep(1);
  13547. }